Skip to content

[CI] Provide libclc targets to build and test #5091

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

Merged
merged 3 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
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
47 changes: 28 additions & 19 deletions buildbot/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def do_configure(args):

llvm_external_projects = 'sycl;llvm-spirv;opencl;libdevice;xpti;xptifw'

libclc_amd_target_names = ';amdgcn--;amdgcn--amdhsa'
libclc_nvidia_target_names = 'nvptx64--;nvptx64--nvidiacl'

if args.llvm_external_projects:
llvm_external_projects += ";" + args.llvm_external_projects.replace(",", ";")

Expand Down Expand Up @@ -43,18 +46,6 @@ def do_configure(args):
sycl_enable_xpti_tracing = 'ON'
xpti_enable_werror = 'ON'

build_libclc = False

if args.ci_defaults:
print("#############################################")
print("# Default CI configuration will be applied. #")
print("#############################################")

# For clang-format and clang-tidy
llvm_enable_projects += ";clang-tools-extra"
# libclc is required for CI validation
build_libclc = True

# replace not append, so ARM ^ X86
if args.arm:
llvm_targets_to_build = 'ARM;AArch64'
Expand All @@ -63,26 +54,26 @@ def do_configure(args):
sycl_build_pi_esimd_emulator = 'ON'

if args.cuda or args.hip:
build_libclc = True
llvm_enable_projects += ';libclc'

if args.cuda:
llvm_targets_to_build += ';NVPTX'
libclc_targets_to_build = 'nvptx64--;nvptx64--nvidiacl'
libclc_targets_to_build = libclc_nvidia_target_names
libclc_gen_remangled_variants = 'ON'
sycl_build_pi_cuda = 'ON'

if args.hip:
if args.hip_platform == 'AMD':
llvm_targets_to_build += ';AMDGPU'
libclc_targets_to_build += ';amdgcn--;amdgcn--amdhsa'
libclc_targets_to_build += libclc_amd_target_names
if args.hip_amd_arch:
sycl_clang_extra_flags += "-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch="+args.hip_amd_arch

# The HIP plugin for AMD uses lld for linking
llvm_enable_projects += ';lld'
elif args.hip_platform == 'NVIDIA' and not args.cuda:
llvm_targets_to_build += ';NVPTX'
libclc_targets_to_build += ';nvptx64--;nvptx64--nvidiacl'
libclc_targets_to_build += libclc_nvidia_target_names
libclc_gen_remangled_variants = 'ON'

sycl_build_pi_hip_platform = args.hip_platform
Expand All @@ -103,10 +94,28 @@ def do_configure(args):
llvm_build_shared_libs = 'ON'

if args.use_lld:
llvm_enable_lld = 'ON'
llvm_enable_lld = 'ON'

if build_libclc:
llvm_enable_projects += ';libclc'
# CI Default conditionally appends to options, keep it at the bottom of
# args handling
Copy link
Contributor

Choose a reason for hiding this comment

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

@alexbatashev, @vladimirlaz, FYI.
When we originally discussed --ci-defaults option, I thought that these defaults can be overridden by additional options. E.g. --ci-defaults --option-X=val, so that if --ci-defaults sets --option-X, users can replace the default value.
Unfortunately, I don't see this requirement to be documented in the code and it seems to be not true for options modified inside this if-statement.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bader it’s a good point, we shall fix it in the future

if args.ci_defaults:
print("#############################################")
print("# Default CI configuration will be applied. #")
print("#############################################")

# For clang-format and clang-tidy
llvm_enable_projects += ";clang-tools-extra"
# libclc is required for CI validation
if 'libclc' not in llvm_enable_projects:
llvm_enable_projects += ';libclc'
# libclc passes `--nvvm-reflect-enable=false`, build NVPTX to enable it
if 'NVPTX' not in llvm_targets_to_build:
llvm_targets_to_build += ';NVPTX'
# Add both NVIDIA and AMD libclc targets
if libclc_amd_target_names not in libclc_targets_to_build:
libclc_targets_to_build += libclc_amd_target_names
Comment on lines +115 to +116
Copy link
Contributor

@bader bader Mar 3, 2023

Choose a reason for hiding this comment

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

I think to build libclc for AMD target, LLVM's AMDGPU target back-end must be built. @jchlanda, am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my guess as well, but I've just tried and LIBCLC_TARGETS_TO_BUILD:STRING=;amdgcn--;amdgcn--amdhsa builds fine with only LLVM_TARGETS_TO_BUILD:STRING=X86. Saying that I'm worried that if in future libclc uses more AMD specific code (for example builtins) it will not be possible. Enforcing AMDGPU backend seems like a wise thing to do moving forward.

if libclc_nvidia_target_names not in libclc_targets_to_build:
libclc_targets_to_build += libclc_nvidia_target_names

install_dir = os.path.join(abs_obj_dir, "install")

Expand Down
1 change: 1 addition & 0 deletions libclc/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(LIBCLC_TEST_DEPS
llvm-dis
not
clang
count
)

add_custom_target(check-libclc)
Expand Down
3 changes: 2 additions & 1 deletion libclc/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"-target", target,
"-Xclang", "-fdeclare-spirv-builtins",
"-Xclang", "-mlink-builtin-bitcode",
"-Xclang", os.path.join(config.llvm_libs_dir, "clc", builtins)
"-Xclang", os.path.join(config.llvm_libs_dir, "clc", builtins),
"-nogpulib"
]

if target == 'amdgcn--amdhsa':
Expand Down