Added HIP support to VTK-m package (#19523)
This commit is contained in:
parent
c2b943c209
commit
823a3fa646
@ -40,32 +40,52 @@ class VtkM(CMakePackage, CudaPackage):
|
||||
variant('build_type', default='Release', description='CMake build type',
|
||||
values=('Debug', 'Release', 'RelWithDebInfo', 'MinSizeRel'))
|
||||
variant("shared", default=False, description="build shared libs")
|
||||
variant("cuda", default=False, description="build cuda support")
|
||||
|
||||
variant("doubleprecision", default=True,
|
||||
description='enable double precision')
|
||||
variant("logging", default=False, description="build logging support")
|
||||
variant("mpi", default=False, description="build mpi support")
|
||||
variant("openmp", default=(sys.platform != 'darwin'), description="build openmp support")
|
||||
variant("rendering", default=True, description="build rendering support")
|
||||
variant("tbb", default=(sys.platform == 'darwin'), description="build TBB support")
|
||||
variant("64bitids", default=False,
|
||||
description="enable 64 bits ids")
|
||||
|
||||
# Device variants
|
||||
variant("cuda", default=False, description="build cuda support")
|
||||
variant("openmp", default=(sys.platform != 'darwin'), description="build openmp support")
|
||||
variant("tbb", default=(sys.platform == 'darwin'), description="build TBB support")
|
||||
variant("hip", default=False, description="build hip support")
|
||||
|
||||
# it doesn't look like spack has a amd gpu abstraction
|
||||
amdgpu_targets = (
|
||||
'gfx701', 'gfx801', 'gfx802', 'gfx803',
|
||||
'gfx900', 'gfx906', 'gfx908', 'gfx1010',
|
||||
'gfx1011', 'gfx1012'
|
||||
)
|
||||
variant('amdgpu_target', default='none', multi=True, values=amdgpu_targets)
|
||||
conflicts("+hip", when="amdgpu_target=none")
|
||||
|
||||
depends_on("cmake@3.12:", type="build") # CMake >= 3.12
|
||||
depends_on("cmake@3.18:", when="+hip") # CMake >= 3.18
|
||||
|
||||
depends_on('cuda@10.2.0:', when='+cuda')
|
||||
depends_on("tbb", when="+tbb")
|
||||
depends_on("cuda", when="+cuda")
|
||||
depends_on("mpi", when="+mpi")
|
||||
|
||||
depends_on("kokkos@3.1:+hip", when="+hip")
|
||||
depends_on("rocm-cmake@3.7:", when="+hip")
|
||||
depends_on("hip@3.7:", when="+hip")
|
||||
|
||||
conflicts("+hip", when="+cuda")
|
||||
conflicts("~shared", when="~pic")
|
||||
|
||||
def cmake_args(self):
|
||||
spec = self.spec
|
||||
options = []
|
||||
gpu_name_table = {'20': 'fermi',
|
||||
'30': 'kepler', '32': 'kepler', '35': 'kepler',
|
||||
gpu_name_table = {'30': 'kepler', '32': 'kepler', '35': 'kepler',
|
||||
'50': 'maxwell', '52': 'maxwell', '53': 'maxwell',
|
||||
'60': 'pascal', '61': 'pascal', '62': 'pascal',
|
||||
'70': 'volta', '72': 'turing', '75': 'turing'}
|
||||
'70': 'volta', '72': 'turing', '75': 'turing',
|
||||
'80': 'ampere', '86': 'ampere'}
|
||||
with working_dir('spack-build', create=True):
|
||||
options = ["-DVTKm_ENABLE_TESTING:BOOL=OFF"]
|
||||
# shared vs static libs logic
|
||||
@ -77,26 +97,6 @@ def cmake_args(self):
|
||||
options.append('-DBUILD_SHARED_LIBS=ON')
|
||||
else:
|
||||
options.append('-DBUILD_SHARED_LIBS=OFF')
|
||||
# cuda support
|
||||
if "+cuda" in spec:
|
||||
options.append("-DVTKm_ENABLE_CUDA:BOOL=ON")
|
||||
options.append("-DCMAKE_CUDA_HOST_COMPILER={0}".format(
|
||||
env["SPACK_CXX"]))
|
||||
if 'cuda_arch' in spec.variants:
|
||||
cuda_value = spec.variants['cuda_arch'].value
|
||||
cuda_arch = cuda_value[0]
|
||||
if cuda_arch in gpu_name_table:
|
||||
vtkm_cuda_arch = gpu_name_table[cuda_arch]
|
||||
options.append('-DVTKm_CUDA_Architecture={0}'.format(
|
||||
vtkm_cuda_arch))
|
||||
else:
|
||||
# this fix is necessary if compiling platform has cuda, but
|
||||
# no devices (this's common for front end nodes on hpc clus
|
||||
# ters)
|
||||
# we choose kepler as a lowest common denominator
|
||||
options.append("-DVTKm_CUDA_Architecture=kepler")
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_CUDA:BOOL=OFF")
|
||||
|
||||
# double precision
|
||||
if "+doubleprecision" in spec:
|
||||
@ -122,30 +122,12 @@ def cmake_args(self):
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_MPI:BOOL=OFF")
|
||||
|
||||
# openmp support
|
||||
if "+openmp" in spec:
|
||||
# openmp is added since version 1.3.0
|
||||
if not spec.satisfies('@1.3.0:,ascent_ver'):
|
||||
raise InstallError('OpenMP is not supported for\
|
||||
vtkm version lower than 1.3')
|
||||
options.append("-DVTKm_ENABLE_OPENMP:BOOL=ON")
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_OPENMP:BOOL=OFF")
|
||||
|
||||
# rendering support
|
||||
if "+rendering" in spec:
|
||||
options.append("-DVTKm_ENABLE_RENDERING:BOOL=ON")
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_RENDERING:BOOL=OFF")
|
||||
|
||||
# tbb support
|
||||
if "+tbb" in spec:
|
||||
# vtk-m detectes tbb via TBB_ROOT env var
|
||||
os.environ["TBB_ROOT"] = spec["tbb"].prefix
|
||||
options.append("-DVTKm_ENABLE_TBB:BOOL=ON")
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_TBB:BOOL=OFF")
|
||||
|
||||
# 64 bit ids
|
||||
if "+64bitids" in spec:
|
||||
options.append("-DVTKm_USE_64BIT_IDS:BOOL=ON")
|
||||
@ -156,4 +138,52 @@ def cmake_args(self):
|
||||
if spec.variants["build_type"].value != 'Release':
|
||||
options.append("-DVTKm_NO_ASSERT:BOOL=ON")
|
||||
|
||||
# cuda support
|
||||
if "+cuda" in spec:
|
||||
options.append("-DVTKm_ENABLE_CUDA:BOOL=ON")
|
||||
options.append("-DCMAKE_CUDA_HOST_COMPILER={0}".format(
|
||||
env["SPACK_CXX"]))
|
||||
if 'cuda_arch' in spec.variants:
|
||||
cuda_value = spec.variants['cuda_arch'].value
|
||||
cuda_arch = cuda_value[0]
|
||||
if cuda_arch in gpu_name_table:
|
||||
vtkm_cuda_arch = gpu_name_table[cuda_arch]
|
||||
options.append('-DVTKm_CUDA_Architecture={0}'.format(
|
||||
vtkm_cuda_arch))
|
||||
else:
|
||||
# this fix is necessary if compiling platform has cuda, but
|
||||
# no devices (this is common for front end nodes on hpc
|
||||
# clusters). We choose volta as a lowest common denominator
|
||||
options.append("-DVTKm_CUDA_Architecture=volta")
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_CUDA:BOOL=OFF")
|
||||
|
||||
# hip support
|
||||
if "+hip" in spec:
|
||||
options.append("-DVTKm_ENABLE_HIP:BOOL=ON")
|
||||
|
||||
archs = ",".join(self.spec.variants['amdgpu_target'].value)
|
||||
options.append(
|
||||
"-DCMAKE_HIP_ARCHITECTURES:STRING={0}".format(archs))
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_HIP:BOOL=OFF")
|
||||
|
||||
# openmp support
|
||||
if "+openmp" in spec:
|
||||
# openmp is added since version 1.3.0
|
||||
if not spec.satisfies('@1.3.0:,ascent_ver'):
|
||||
raise InstallError('OpenMP is not supported for\
|
||||
vtkm version lower than 1.3')
|
||||
options.append("-DVTKm_ENABLE_OPENMP:BOOL=ON")
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_OPENMP:BOOL=OFF")
|
||||
|
||||
# tbb support
|
||||
if "+tbb" in spec:
|
||||
# vtk-m detectes tbb via TBB_ROOT env var
|
||||
os.environ["TBB_ROOT"] = spec["tbb"].prefix
|
||||
options.append("-DVTKm_ENABLE_TBB:BOOL=ON")
|
||||
else:
|
||||
options.append("-DVTKm_ENABLE_TBB:BOOL=OFF")
|
||||
|
||||
return options
|
||||
|
Loading…
Reference in New Issue
Block a user