-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL][clang-linker-wrapper] Update --bitcode-library option for SYCL #20331
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
Changes from 3 commits
ccd561d
83ad0d5
e14ec16
b565678
fe223ca
b5dcfbb
a7ffcdf
2e79f56
2bd11b1
9476a7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /// Test that SYCL bitcode device libraries are properly separated for NVIDIA and AMD targets | ||
jzc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// Check devicelib and libspirv are linked for nvptx | ||
jzc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang -### -fsycl --offload-new-driver \ | ||
jzc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // RUN: -fsycl-targets=nvptx64-nvidia-cuda \ | ||
| // RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ | ||
| // RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-NVPTX-BC %s | ||
|
|
||
| // CHECK-NVPTX-BC: clang-linker-wrapper | ||
| // CHECK-NVPTX-BC-SAME: "--bitcode-library=nvptx64-nvidia-cuda={{.*}}devicelib-nvptx64-nvidia-cuda.bc" "--bitcode-library=nvptx64-nvidia-cuda={{.*}}libspirv-nvptx64-nvidia-cuda.bc" | ||
|
|
||
| /// Check devicelib is linked for amdgcn | ||
jzc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang -### -fsycl --offload-new-driver \ | ||
| // RUN: -fsycl-targets=amdgcn-amd-amdhsa \ | ||
| // RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \ | ||
| // RUN: --rocm-path=%S/Inputs/rocm \ | ||
| // RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-AMD-BC %s | ||
|
|
||
| // CHECK-AMD-BC: clang-linker-wrapper | ||
| // CHECK-AMD-BC-SAME: "--bitcode-library=amdgcn-amd-amdhsa={{.*}}devicelib-amdgcn-amd-amdhsa.bc" | ||
jzc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Check linking with multiple targets | ||
jzc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang -### -fsycl --offload-new-driver \ | ||
| // RUN: -fsycl-targets=amdgcn-amd-amdhsa,nvptx64-nvidia-cuda \ | ||
| // RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \ | ||
| // RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \ | ||
| // RUN: --rocm-path=%S/Inputs/rocm \ | ||
| // RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-MULTI-TARGET %s | ||
|
|
||
| // CHECK-MULTI-TARGET: clang-linker-wrapper | ||
| // CHECK-MULTI-TARGET-SAME: "--bitcode-library=amdgcn-amd-amdhsa={{.*}}devicelib-amdgcn-amd-amdhsa.bc" "--bitcode-library=nvptx64-nvidia-cuda={{.*}}devicelib-nvptx64-nvidia-cuda.bc" "--bitcode-library=nvptx64-nvidia-cuda={{.*}}libspirv-nvptx64-nvidia-cuda.bc" | ||
|
|
||
| /// Test --bitcode-library with nvptx dummy libraries | ||
jzc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.devicelib.bc | ||
| // RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.libspirv.bc | ||
| // RUN: %clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda --offload-new-driver -c %s -o %t.nvptx.o -nocudalib | ||
| // RUN: clang-linker-wrapper --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.libspirv.bc \ | ||
| // RUN: --host-triple=x86_64-unknown-linux-gnu --dry-run \ | ||
| // RUN: --linker-path=/usr/bin/ld %t.nvptx.o -o a.out 2>&1 | FileCheck -check-prefix=CHECK-WRAPPER-NVPTX %s | ||
|
|
||
| // CHECK-WRAPPER-NVPTX: llvm-link{{.*}} {{.*}}.nvptx.devicelib.bc {{.*}}.nvptx.libspirv.bc | ||
|
|
||
| /// Test --bitcode-library with amdgcn dummy library | ||
jzc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -o %t.amd.devicelib.bc | ||
| // RUN: %clang++ -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 --offload-new-driver -c %s -o %t.amd.o -nogpulib | ||
| // RUN: clang-linker-wrapper --bitcode-library=amdgcn-amd-amdhsa=%t.amd.devicelib.bc \ | ||
| // RUN: --host-triple=x86_64-unknown-linux-gnu --dry-run \ | ||
| // RUN: --linker-path=/usr/bin/ld %t.amd.o -o a.out 2>&1 | FileCheck -check-prefix=CHECK-WRAPPER-AMD %s | ||
|
|
||
| // CHECK-WRAPPER-AMD: llvm-link{{.*}} {{.*}}.amd.devicelib.bc | ||
maarquitos14 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// Test --bitcode-library with multi-target bc libraries | ||
jzc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // RUN: %clang++ -fsycl -fsycl-targets=amdgcn-amd-amdhsa,nvptx64-nvidia-cuda \ | ||
| // RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \ | ||
| // RUN: --offload-new-driver -c %s -o %t.multi.o -nocudalib -nogpulib | ||
| // RUN: clang-linker-wrapper --bitcode-library=amdgcn-amd-amdhsa=%t.amd.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.libspirv.bc \ | ||
| // RUN: --host-triple=x86_64-unknown-linux-gnu --dry-run \ | ||
| // RUN: --linker-path=/usr/bin/ld %t.multi.o -o a.out 2>&1 | FileCheck -check-prefix=CHECK-WRAPPER-MULTI %s | ||
|
|
||
| // CHECK-WRAPPER-MULTI: llvm-link{{.*}} {{.*}}.amd.devicelib.bc | ||
| // CHECK-WRAPPER-MULTI: llvm-link{{.*}} {{.*}}.nvptx.devicelib.bc {{.*}}.nvptx.libspirv.bc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1432,24 +1432,17 @@ static Expected<StringRef> linkDevice(ArrayRef<StringRef> InputFiles, | |
| << "Compatible SYCL device library binary not found\n"; | ||
| } | ||
|
|
||
| // For NVPTX backend we need to also link libclc and CUDA libdevice. | ||
| if (Triple.isNVPTX()) { | ||
| if (Arg *A = Args.getLastArg(OPT_sycl_nvptx_device_lib_EQ)) { | ||
| if (A->getValues().size() == 0) | ||
| return createStringError( | ||
| inconvertibleErrorCode(), | ||
| "Number of device library files cannot be zero."); | ||
| for (StringRef Val : A->getValues()) { | ||
| SmallString<128> LibName(Val); | ||
| if (llvm::sys::fs::exists(LibName)) | ||
| ExtractedDeviceLibFiles.emplace_back(std::string(LibName)); | ||
| else | ||
| return createStringError( | ||
| inconvertibleErrorCode(), | ||
| std::string(LibName) + | ||
| " SYCL device library file for NVPTX is not found."); | ||
| } | ||
| } | ||
| for (StringRef Library : Args.getAllArgValues(OPT_bitcode_library_EQ)) { | ||
| auto [LibraryTriple, LibraryPath] = Library.split('='); | ||
| if (llvm::Triple(LibraryTriple) != Triple) | ||
| continue; | ||
|
|
||
| if (!llvm::sys::fs::exists(LibraryPath)) | ||
| return createStringError(inconvertibleErrorCode(), | ||
| "The specified device library " + LibraryPath + | ||
| " does not exist."); | ||
|
|
||
| ExtractedDeviceLibFiles.emplace_back(LibraryPath.str()); | ||
| } | ||
|
|
||
| // Make sure that SYCL device library files are available. | ||
|
|
@@ -2515,13 +2508,6 @@ getDeviceInput(const ArgList &Args) { | |
| } | ||
| } | ||
|
|
||
| for (StringRef Library : Args.getAllArgValues(OPT_bitcode_library_EQ)) { | ||
| auto FileOrErr = getInputBitcodeLibrary(Library); | ||
| if (!FileOrErr) | ||
| return FileOrErr.takeError(); | ||
| InputFiles[*FileOrErr].push_back(std::move(*FileOrErr)); | ||
| } | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This functionality is not used nor tested - searching for |
||
| SmallVector<SmallVector<OffloadFile>> InputsForTarget; | ||
| for (auto &[ID, Input] : InputFiles) | ||
| InputsForTarget.emplace_back(std::move(Input)); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.