diff --git a/var/spack/repos/builtin/packages/kokkos/package.py b/var/spack/repos/builtin/packages/kokkos/package.py index 7f61270327..51d90ffc06 100644 --- a/var/spack/repos/builtin/packages/kokkos/package.py +++ b/var/spack/repos/builtin/packages/kokkos/package.py @@ -46,7 +46,43 @@ class Kokkos(Package): variant('qthreads', default=False, description="enable Qthreads backend") variant('cuda', default=False, description="enable Cuda backend") - variant('openmp', default=True, description="enable OpenMP backend") + variant('openmp', default=False, description="enable OpenMP backend") + + gpu_values = ('Kepler30', 'Kepler32', 'Kepler35', 'Kepler37', + 'Maxwell50', 'Maxwell52', 'Maxwell53', + 'Pascal60', 'Pascal61') + + # Host architecture variant + variant( + 'host_arch', + default=None, + values=('AMDAVX', 'ARMv80', 'ARMv81', 'ARMv8-ThunderX', + 'Power7', 'Power8', 'Power9', + 'WSM', 'SNB', 'HSW', 'BDW', 'SKX', 'KNC', 'KNL'), + description='Set the host architecture to use' + ) + + # GPU architecture variant + variant( + 'gpu_arch', + default=None, + values=gpu_values, + description='Set the GPU architecture to use' + ) + + # Check that we haven't specified a gpu architecture + # without specifying CUDA + for p in gpu_values: + conflicts('gpu_arch={0}'.format(p), when='~cuda', + msg='Must specify CUDA backend to use a GPU architecture.') + + # conflicts on kokkos version and cuda enabled + # see kokkos issue #1296 + # https://github.com/kokkos/kokkos/issues/1296 + conflicts('+cuda', when='@2.5.00:develop', + msg='Kokkos build system has issue when CUDA enabled' + ' in version 2.5.00, and develop until ' + 'issue #1296 is resolved.') # Specify that v1.x is required as v2.x has API changes depends_on('hwloc@:1') @@ -62,12 +98,24 @@ def install(self, spec, prefix): '--with-hwloc=%s' % spec['hwloc'].prefix, '--with-serial' ] + arch_args = [] + # Backends if '+openmp' in spec: g_args.append('--with-openmp') if 'qthreads' in spec: g_args.append('--with-qthreads=%s' % spec['qthreads'].prefix) if 'cuda' in spec: g_args.append('--with-cuda=%s' % spec['cuda'].prefix) + # Host architectures + host_arch = spec.variants['host_arch'].value + # GPU architectures + gpu_arch = spec.variants['gpu_arch'].value + if host_arch: + arch_args.append(host_arch) + if gpu_arch: + arch_args.append(gpu_arch) + if arch_args: + g_args.append('--arch={0}'.format(','.join(arch_args))) generate(*g_args) make()