summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--var/spack/repos/builtin/packages/cp2k/package.py26
-rw-r--r--var/spack/repos/builtin/packages/dbcsr/package.py26
2 files changed, 35 insertions, 17 deletions
diff --git a/var/spack/repos/builtin/packages/cp2k/package.py b/var/spack/repos/builtin/packages/cp2k/package.py
index f86f02c1f4..cfb58cbd3c 100644
--- a/var/spack/repos/builtin/packages/cp2k/package.py
+++ b/var/spack/repos/builtin/packages/cp2k/package.py
@@ -52,14 +52,6 @@ class Cp2k(MakefilePackage, CudaPackage):
' and BQB compression'))
variant('spglib', default=False, description='Enable support for spglib')
- # override cuda_arch from CudaPackage since we only support one arch
- # at a time and only specific ones for which we have parameter files
- # for optimal kernels
- variant('cuda_arch',
- description='CUDA architecture',
- default='none',
- values=('none', '35', '37', '60', '70'),
- multi=False)
variant('cuda_arch_35_k20x', default=False,
description=('CP2K (resp. DBCSR) has specific parameter sets for'
' different GPU models. Enable this when building'
@@ -169,6 +161,19 @@ class Cp2k(MakefilePackage, CudaPackage):
conflicts('~openmp', when='@8:', msg='Building without OpenMP is not supported in CP2K 8+')
+ # We only support specific cuda_archs for which we have parameter files
+ # for optimal kernels. Note that we don't override the cuda_archs property
+ # from the parent class, since the parent class defines constraints for all
+ # versions. Instead just mark all unsupported cuda archs as conflicting.
+ dbcsr_cuda_archs = ('35', '37', '60', '70')
+ cuda_msg = 'cp2k only supports cuda_arch {0}'.format(dbcsr_cuda_archs)
+
+ for arch in CudaPackage.cuda_arch_values:
+ if arch not in dbcsr_cuda_archs:
+ conflicts('+cuda', when='cuda_arch={0}'.format(arch), msg=cuda_msg)
+
+ conflicts('+cuda', when='cuda_arch=none', msg=cuda_msg)
+
@property
def makefile_architecture(self):
return '{0.architecture}-{0.compiler.name}'.format(self.spec)
@@ -448,7 +453,7 @@ class Cp2k(MakefilePackage, CudaPackage):
cppflags += ['-D__PW_CUDA']
libs += ['-lcufft', '-lcublas']
- cuda_arch = spec.variants['cuda_arch'].value
+ cuda_arch = spec.variants['cuda_arch'].value[0]
if cuda_arch:
gpuver = {
'35': 'K40',
@@ -581,6 +586,9 @@ class Cp2k(MakefilePackage, CudaPackage):
]
def build(self, spec, prefix):
+ if len(spec.variants['cuda_arch'].value) > 1:
+ raise InstallError("cp2k supports only one cuda_arch at a time")
+
# Apparently the Makefile bases its paths on PWD
# so we need to set PWD = self.build_directory
with spack.util.environment.set_env(PWD=self.build_directory):
diff --git a/var/spack/repos/builtin/packages/dbcsr/package.py b/var/spack/repos/builtin/packages/dbcsr/package.py
index c1b610ffb2..8aee6147d5 100644
--- a/var/spack/repos/builtin/packages/dbcsr/package.py
+++ b/var/spack/repos/builtin/packages/dbcsr/package.py
@@ -21,11 +21,6 @@ class Dbcsr(CMakePackage, CudaPackage):
variant('shared', default=True, description='Build shared library')
variant('smm', default='libxsmm', values=('libxsmm', 'blas'),
description='Library for small matrix multiplications')
- variant('cuda_arch',
- description='CUDA architecture',
- default='none',
- values=('none', '35', '37', '60', '70'),
- multi=False)
variant('cuda_arch_35_k20x', default=False,
description=('CP2K (resp. DBCSR) has specific parameter sets for'
' different GPU models. Enable this when building'
@@ -41,19 +36,34 @@ class Dbcsr(CMakePackage, CudaPackage):
depends_on('pkgconfig', type='build')
depends_on('python@3.6:', type='build', when='+cuda')
- conflicts('+cuda', when='cuda_arch=none')
+ # We only support specific cuda_archs for which we have parameter files
+ # for optimal kernels. Note that we don't override the cuda_archs property
+ # from the parent class, since the parent class defines constraints for all
+ # versions. Instead just mark all unsupported cuda archs as conflicting.
+ dbcsr_cuda_archs = ('35', '37', '60', '70')
+ cuda_msg = 'dbcsr only supports cuda_arch {0}'.format(dbcsr_cuda_archs)
+
+ for arch in CudaPackage.cuda_arch_values:
+ if arch not in dbcsr_cuda_archs:
+ conflicts('+cuda', when='cuda_arch={0}'.format(arch), msg=cuda_msg)
+
+ conflicts('+cuda', when='cuda_arch=none', msg=cuda_msg)
generator = 'Ninja'
depends_on('ninja@1.10:', type='build')
def cmake_args(self):
+ spec = self.spec
+
+ if len(spec.variants['cuda_arch'].value) > 1:
+ raise InstallError("dbcsr supports only one cuda_arch at a time")
+
if ('+openmp' in self.spec
and '^openblas' in self.spec
and '^openblas threads=openmp' not in self.spec):
raise InstallError(
'^openblas threads=openmp required for dbcsr+openmp')
- spec = self.spec
args = [
'-DUSE_SMM=%s' % ('libxsmm' if 'smm=libxsmm' in spec else 'blas'),
'-DUSE_MPI=%s' % ('ON' if '+mpi' in spec else 'OFF'),
@@ -70,7 +80,7 @@ class Dbcsr(CMakePackage, CudaPackage):
]
if '+cuda' in self.spec:
- cuda_arch = self.spec.variants['cuda_arch'].value
+ cuda_arch = self.spec.variants['cuda_arch'].value[0]
gpuver = {
'35': 'K40',