Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building Clang with OpenMP offload support #2229

Merged
merged 3 commits into from
Nov 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions easybuild/easyblocks/c/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def extra_options():
'skip_all_tests': [False, "Skip running of tests", CUSTOM],
# The sanitizer tests often fail on HPC systems due to the 'weird' environment.
'skip_sanitizer_tests': [True, "Do not run the sanitizer tests", CUSTOM],
'default_cuda_capability': [None, "Default CUDA capability specified for clang, e.g. '7.5'", CUSTOM],
'cuda_compute_capabilities': [[], "List of CUDA compute capabilities to build with", CUSTOM],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a general easyconfig parameter (since easybuilders/easybuild-framework#3382), so adding cuda_compute_capabilities here too shouldn't be needed...

@nordmoen Do you have a Clang easyconfig file that requires the enhancement you implemented here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boegel The default parameter is quite nice if a user has specified more than one compute compatibility and doesn't want to use the minimum.

I added the cuda_compute_capabilities based on feedback from @Flamefire on Slack. In this way it resembles other similar easyconfig files like TensorFlow. I have used the built-in --cuda-compute-capabilites flag in EB and for me it should not be needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two different things here:

  1. The cuda_compute_capabilities easyconfig parameter, which is a general easyconfig parameter (so you don't need to define it in extra_options for it to be defined & picked up), see "eb -a | grep cuda".

  2. The --cuda-compute-capabilities EasyBuild configuration option, which is what you're picking up via build_option('cuda_compute_capabilities') (I know it can be confusing...).

I was merely pointing out that add cuda_compute_capabilities as a knwon easyconfig parameter is not needed at all, since it's already a known general easyconfig parameter. There's no real downside though (except for adding to the confusion, maybe).

})
# disable regular out-of-source build, too simplistic for Clang to work
extra_vars['separate_build_dir'][0] = False
Expand Down Expand Up @@ -282,9 +284,28 @@ def configure_step(self):
if self.cfg['parallel']:
self.make_parallel_opts = "-j %s" % self.cfg['parallel']

# If we don't want to build with CUDA (not in dependencies) trick CMakes FindCUDA module into
# not finding it by using the environment variable which is used as-is and later checked
# for a falsy value when determining wether CUDA was found
# If 'NVPTX' is in the build targets we assume the user would like OpenMP offload support as well
if 'NVPTX' in build_targets:
# list of CUDA compute capabilities to use can be specifed in two ways (where (2) overrules (1)):
# (1) in the easyconfig file, via the custom cuda_compute_capabilities;
# (2) in the EasyBuild configuration, via --cuda-compute-capabilities configuration option;
ec_cuda_cc = self.cfg['cuda_compute_capabilities']
cfg_cuda_cc = build_option('cuda_compute_capabilities')
cuda_cc = cfg_cuda_cc or ec_cuda_cc or []
if not cuda_cc:
raise EasyBuildError("Can't build Clang with CUDA support "
"without specifying 'cuda-compute-capabilities'")
default_cc = self.cfg['default_cuda_capability'] or min(cuda_cc)
if not self.cfg['default_cuda_capability']:
print_warning("No default CUDA capability defined! "
"Using '%s' taken as minimum from 'cuda_compute_capabilities'" % default_cc)
cuda_cc = [cc.replace('.', '') for cc in cuda_cc]
default_cc = default_cc.replace('.', '')
self.cfg.update('configopts', '-DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_%s' % default_cc)
self.cfg.update('configopts', '-DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=%s' % ','.join(cuda_cc))
# If we don't want to build with CUDA (not in dependencies) trick CMakes FindCUDA module into not finding it by
# using the environment variable which is used as-is and later checked for a falsy value when determining
# whether CUDA was found
if not get_software_root('CUDA'):
setvar('CUDA_NVCC_EXECUTABLE', 'IGNORE')

Expand Down