Ghost as cuda package (#7501)

* add headers  property to netlib-lapack and intel-mkl

* ghost: fix finding cblas header and libs (at least for mkl and netlib-lapack, which provide headers())

* fix flake8 errors

* ghost: remove unnecessary query parameter

* fix flake8 errors

* ghost: make it a CudaPackage (as suggested by @davydden, thanks!)

* ghost: missing whitespace
This commit is contained in:
jthies 2018-03-20 09:23:45 -07:00 committed by Adam J. Stewart
parent ed4640c75b
commit 35e7b9ac44
3 changed files with 30 additions and 12 deletions

View file

@ -26,7 +26,7 @@
from spack import * from spack import *
class Ghost(CMakePackage): class Ghost(CMakePackage, CudaPackage):
"""GHOST: a General, Hybrid and Optimized Sparse Toolkit. """GHOST: a General, Hybrid and Optimized Sparse Toolkit.
This library provides highly optimized building blocks for implementing This library provides highly optimized building blocks for implementing
sparse iterative eigenvalue and linear solvers multi- and manycore sparse iterative eigenvalue and linear solvers multi- and manycore
@ -44,8 +44,6 @@ class Ghost(CMakePackage):
description='Enables the build of shared libraries') description='Enables the build of shared libraries')
variant('mpi', default=True, variant('mpi', default=True,
description='enable/disable MPI') description='enable/disable MPI')
variant('cuda', default=False,
description='enable/disable CUDA')
variant('scotch', default=False, variant('scotch', default=False,
description='enable/disable matrix reordering with PT-SCOTCH') description='enable/disable matrix reordering with PT-SCOTCH')
variant('zoltan', default=False, variant('zoltan', default=False,
@ -58,17 +56,14 @@ class Ghost(CMakePackage):
depends_on('hwloc') depends_on('hwloc')
depends_on('blas') depends_on('blas')
depends_on('mpi', when='+mpi') depends_on('mpi', when='+mpi')
depends_on('cuda@8:', when='+cuda')
depends_on('scotch', when='+scotch') depends_on('scotch', when='+scotch')
depends_on('zoltan', when='+zoltan') depends_on('zoltan', when='+zoltan')
def cmake_args(self): def cmake_args(self):
spec = self.spec spec = self.spec
cblas_include_dir = '' # note: we require the cblas_include_dir property from the blas
if '^mkl' not in spec: # provider, this is implemented at least for intel-mkl and
cblas_include_dir = '-DCBLAS_INCLUDE_DIR=' + \ # netlib-lapack
spec['blas'].prefix.include
args = ['-DGHOST_ENABLE_MPI:BOOL=%s' args = ['-DGHOST_ENABLE_MPI:BOOL=%s'
% ('ON' if '+mpi' in spec else 'OFF'), % ('ON' if '+mpi' in spec else 'OFF'),
'-DGHOST_USE_CUDA:BOOL=%s' '-DGHOST_USE_CUDA:BOOL=%s'
@ -78,9 +73,12 @@ def cmake_args(self):
'-DGHOST_USE_ZOLTAN:BOOL=%s' '-DGHOST_USE_ZOLTAN:BOOL=%s'
% ('ON' if '+zoltan' in spec else 'OFF'), % ('ON' if '+zoltan' in spec else 'OFF'),
'-DBUILD_SHARED_LIBS:BOOL=%s' '-DBUILD_SHARED_LIBS:BOOL=%s'
% ('ON' if '+shared' in spec else 'OFF'), cblas_include_dir % ('ON' if '+shared' in spec else 'OFF'),
'-DCBLAS_INCLUDE_DIR:STRING=%s'
% format(spec['blas'].headers.directories[0]),
'-DBLAS_LIBRARIES=%s'
% spec['blas:c'].libs.joined(';')
] ]
return args return args
def check(self): def check(self):

View file

@ -182,6 +182,18 @@ def scalapack_libs(self):
return libs return libs
@property
def headers(self):
prefix = self.spec.prefix
if sys.platform != 'darwin':
include_dir = prefix.compilers_and_libraries.linux.mkl.include
else:
include_dir = prefix.include
cblas_h = join_path(include_dir, 'mkl_cblas.h')
lapacke_h = join_path(include_dir, 'mkl_lapacke.h')
return HeaderList([cblas_h, lapacke_h])
def setup_dependent_environment(self, spack_env, run_env, dependent_spec): def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
# set up MKLROOT for everyone using MKL package # set up MKLROOT for everyone using MKL package
if sys.platform == 'darwin': if sys.platform == 'darwin':

View file

@ -48,7 +48,8 @@ class NetlibLapack(Package):
version('3.4.0', '02d5706ec03ba885fc246e5fa10d8c70') version('3.4.0', '02d5706ec03ba885fc246e5fa10d8c70')
version('3.3.1', 'd0d533ec9a5b74933c2a1e84eedc58b4') version('3.3.1', 'd0d533ec9a5b74933c2a1e84eedc58b4')
variant('debug', default=False, description='Activates the Debug build type') variant('debug', default=False,
description='Activates the Debug build type')
variant('shared', default=True, description="Build shared library version") variant('shared', default=True, description="Build shared library version")
variant('external-blas', default=False, variant('external-blas', default=False,
description='Build lapack with an external blas') description='Build lapack with an external blas')
@ -123,6 +124,13 @@ def lapack_libs(self):
libraries, root=self.prefix, shared=shared, recursive=True libraries, root=self.prefix, shared=shared, recursive=True
) )
@property
def headers(self):
include_dir = self.spec.prefix.include
cblas_h = join_path(include_dir, 'cblas.h')
lapacke_h = join_path(include_dir, 'lapacke.h')
return HeaderList([cblas_h, lapacke_h])
def install_one(self, spec, prefix, shared): def install_one(self, spec, prefix, shared):
cmake_args = [ cmake_args = [
'-DBUILD_SHARED_LIBS:BOOL=%s' % ('ON' if shared else 'OFF'), '-DBUILD_SHARED_LIBS:BOOL=%s' % ('ON' if shared else 'OFF'),