dbcsr: add opencl as a third backend (#21468)
This commit is contained in:
parent
694d633a2c
commit
39a429b2a3
1 changed files with 23 additions and 6 deletions
|
@ -26,6 +26,8 @@ class Dbcsr(CMakePackage, CudaPackage, ROCmPackage):
|
||||||
' different GPU models. Enable this when building'
|
' different GPU models. Enable this when building'
|
||||||
' with cuda_arch=35 for a K20x instead of a K40'))
|
' with cuda_arch=35 for a K20x instead of a K40'))
|
||||||
|
|
||||||
|
variant('opencl', default=False, description='Enable OpenCL backend')
|
||||||
|
|
||||||
depends_on('blas')
|
depends_on('blas')
|
||||||
depends_on('lapack')
|
depends_on('lapack')
|
||||||
depends_on('mpi', when='+mpi')
|
depends_on('mpi', when='+mpi')
|
||||||
|
@ -38,6 +40,8 @@ class Dbcsr(CMakePackage, CudaPackage, ROCmPackage):
|
||||||
|
|
||||||
depends_on('hipblas', when='+rocm')
|
depends_on('hipblas', when='+rocm')
|
||||||
|
|
||||||
|
depends_on('opencl', when='+opencl')
|
||||||
|
|
||||||
# We only support specific gpu archs for which we have parameter files
|
# We only support specific gpu archs for which we have parameter files
|
||||||
# for optimal kernels. Note that we don't override the parent class arch
|
# for optimal kernels. Note that we don't override the parent class arch
|
||||||
# properties, since the parent class defines constraints for different archs
|
# properties, since the parent class defines constraints for different archs
|
||||||
|
@ -58,13 +62,17 @@ class Dbcsr(CMakePackage, CudaPackage, ROCmPackage):
|
||||||
if arch not in dbcsr_amdgpu_targets:
|
if arch not in dbcsr_amdgpu_targets:
|
||||||
conflicts('+rocm', when='amdgpu_target={0}'.format(arch), msg=amd_msg)
|
conflicts('+rocm', when='amdgpu_target={0}'.format(arch), msg=amd_msg)
|
||||||
|
|
||||||
conflicts('+cuda', when='+rocm', msg="CUDA and ROCm are mutually exclusive")
|
accel_msg = "CUDA, ROCm and OpenCL support are mutually exlusive"
|
||||||
conflicts('+rocm', when='@:2.0', msg="ROCm support is available in DBCSR v2.1 and later")
|
conflicts('+cuda', when='+rocm', msg=accel_msg)
|
||||||
|
conflicts('+cuda', when='+opencl', msg=accel_msg)
|
||||||
|
conflicts('+rocm', when='+opencl', msg=accel_msg)
|
||||||
|
|
||||||
# Require openmp threading for OpenBLAS by making other options conflict
|
# Require openmp threading for OpenBLAS by making other options conflict
|
||||||
conflicts('^openblas threads=pthreads', when='+openmp')
|
conflicts('^openblas threads=pthreads', when='+openmp')
|
||||||
conflicts('^openblas threads=none', when='+openmp')
|
conflicts('^openblas threads=none', when='+openmp')
|
||||||
|
|
||||||
|
conflicts('smm=blas', when='+opencl')
|
||||||
|
|
||||||
generator = 'Ninja'
|
generator = 'Ninja'
|
||||||
depends_on('ninja@1.10:', type='build')
|
depends_on('ninja@1.10:', type='build')
|
||||||
|
|
||||||
|
@ -89,8 +97,6 @@ def cmake_args(self):
|
||||||
'-DLAPACK_LIBRARIES=%s' % (spec['lapack'].libs.joined(';')),
|
'-DLAPACK_LIBRARIES=%s' % (spec['lapack'].libs.joined(';')),
|
||||||
'-DWITH_EXAMPLES=ON',
|
'-DWITH_EXAMPLES=ON',
|
||||||
self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
|
self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
|
||||||
self.define_from_variant('USE_HIP', 'rocm'),
|
|
||||||
self.define_from_variant('USE_CUDA', 'cuda'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.spec.satisfies('+cuda'):
|
if self.spec.satisfies('+cuda'):
|
||||||
|
@ -107,7 +113,10 @@ def cmake_args(self):
|
||||||
and self.spec.satisfies('+cuda_arch_35_k20x')):
|
and self.spec.satisfies('+cuda_arch_35_k20x')):
|
||||||
gpuver = 'K20X'
|
gpuver = 'K20X'
|
||||||
|
|
||||||
args += ['-DWITH_GPU=%s' % gpuver]
|
args += [
|
||||||
|
'-DWITH_GPU=%s' % gpuver,
|
||||||
|
'-DUSE_ACCEL=cuda'
|
||||||
|
]
|
||||||
|
|
||||||
if self.spec.satisfies('+rocm'):
|
if self.spec.satisfies('+rocm'):
|
||||||
amd_arch = self.spec.variants['amdgpu_target'].value[0]
|
amd_arch = self.spec.variants['amdgpu_target'].value[0]
|
||||||
|
@ -116,7 +125,15 @@ def cmake_args(self):
|
||||||
'gfx906': 'Mi50'
|
'gfx906': 'Mi50'
|
||||||
}[amd_arch]
|
}[amd_arch]
|
||||||
|
|
||||||
args += ['-DWITH_GPU={0}'.format(gpuver)]
|
args += [
|
||||||
|
'-DWITH_GPU={0}'.format(gpuver),
|
||||||
|
'-DUSE_ACCEL=hip'
|
||||||
|
]
|
||||||
|
|
||||||
|
if self.spec.satisfies('+opencl'):
|
||||||
|
args += [
|
||||||
|
'-DUSE_ACCEL=opencl'
|
||||||
|
]
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue