@@ -267,6 +267,34 @@ def __init__(self, *args, **kwargs):
267267
268268 self .build_targets = build_targets or []
269269
270+ self .nvptx_cond = 'NVPTX' in self .build_targets
271+ self .amd_cond = 'AMDGPU' in self .build_targets
272+ self .all_cond = 'all' in self .build_targets
273+ self .cuda_cc = []
274+ if self .nvptx_cond or self .all_cond :
275+ # list of CUDA compute capabilities to use can be specifed in two ways (where (2) overrules (1)):
276+ # (1) in the easyconfig file, via the custom cuda_compute_capabilities;
277+ # (2) in the EasyBuild configuration, via --cuda-compute-capabilities configuration option;
278+ ec_cuda_cc = self .cfg ['cuda_compute_capabilities' ]
279+ cfg_cuda_cc = build_option ('cuda_compute_capabilities' )
280+ cuda_cc = cfg_cuda_cc or ec_cuda_cc or []
281+ if not cuda_cc and self .nvptx_cond :
282+ raise EasyBuildError (
283+ "Can't build Clang with CUDA support without specifying 'cuda-compute-capabilities'"
284+ )
285+ else :
286+ self .cuda_cc = [cc .replace ('.' , '' ) for cc in cuda_cc ]
287+
288+ self .amd_gfx = []
289+ if self .amd_cond or self .all_cond :
290+ self .amd_gfx = self .cfg ['amd_gfx_list' ] or []
291+ if not self .amd_gfx and self .amd_cond :
292+ raise EasyBuildError (
293+ "Can't build Clang with AMDGPU support without specifying 'amd_gfx_list'"
294+ )
295+ else :
296+ self .log .info ("Using AMDGPU targets: %s" , ', ' .join (self .amd_gfx ))
297+
270298 general_opts ['CMAKE_BUILD_TYPE' ] = self .build_type
271299 general_opts ['CMAKE_INSTALL_PREFIX' ] = self .installdir
272300 if self .toolchain .options ['pic' ]:
@@ -404,32 +432,10 @@ def configure_step(self):
404432
405433 if 'openmp' in self .final_projects :
406434 gpu_archs = []
407- # If 'NVPTX' is in the build targets we assume the user would like OpenMP offload support as well
408- if 'NVPTX' in self .build_targets or 'all' in self .build_targets :
409- # list of CUDA compute capabilities to use can be specifed in two ways (where (2) overrules (1)):
410- # (1) in the easyconfig file, via the custom cuda_compute_capabilities;
411- # (2) in the EasyBuild configuration, via --cuda-compute-capabilities configuration option;
412- ec_cuda_cc = self .cfg ['cuda_compute_capabilities' ]
413- cfg_cuda_cc = build_option ('cuda_compute_capabilities' )
414- cuda_cc = cfg_cuda_cc or ec_cuda_cc or []
415- if not cuda_cc :
416- raise EasyBuildError ("Can't build Clang with CUDA support "
417- "without specifying 'cuda-compute-capabilities'" )
418- self .cuda_cc = [cc .replace ('.' , '' ) for cc in cuda_cc ]
419- gpu_archs += ['sm_%s' % cc for cc in self .cuda_cc ]
420- self .log .info ("Using CUDA compute capabilities: %s" , ', ' .join (self .cuda_cc ))
421- # If 'AMDGPU' is in the build targets we assume the user would like OpenMP offload support for AMD
422- if 'AMDGPU' in self .build_targets or 'all' in self .build_targets :
423- if not get_software_root ('ROCR-Runtime' ):
424- raise EasyBuildError ("Can't build Clang with AMDGPU support "
425- "without dependency 'ROCR-Runtime'" )
426- self .amd_gfx = self .cfg ['amd_gfx_list' ]
427- if not self .amd_gfx :
428- raise EasyBuildError ("Can't build Clang with AMDGPU support "
429- "without specifying 'amd_gfx_list'" )
430- gpu_archs += self .amd_gfx
431- self .log .info ("Using AMDGPU targets: %s" , ', ' .join (self .amd_gfx ))
432- general_opts ['LIBOMPTARGET_DEVICE_ARCHITECTURES' ] = '"%s"' % ';' .join (gpu_archs )
435+ gpu_archs += ['sm_%s' % cc for cc in self .cuda_cc or []]
436+ gpu_archs += self .amd_gfx or []
437+ if gpu_archs :
438+ general_opts ['LIBOMPTARGET_DEVICE_ARCHITECTURES' ] = '"%s"' % ';' .join (gpu_archs )
433439
434440 self ._configure_general_build ()
435441
0 commit comments