-
Notifications
You must be signed in to change notification settings - Fork 791
[SYCL] Fix handling of comma separated arch value when calling clang-offload-packager #20130
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
base: sycl
Are you sure you want to change the base?
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -10314,9 +10314,21 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA, | |
| File = C.getArgs().MakeArgString("@" + File); | ||
|
|
||
| StringRef Arch; | ||
| std::string TransformedArch; | ||
| if (OffloadAction->getOffloadingArch()) { | ||
| if (TC->getTripleString() == "spir64_gen-unknown-unknown") { | ||
| Arch = mapIntelGPUArchName(OffloadAction->getOffloadingArch()); | ||
| // When compiling like -fsycl-targets=spir64_gen -Xsycl-target-backend | ||
| // "-device pvc,bdw", the offloading arch will be "pvc,bdw", which | ||
| // contains a comma. We need to transform it to "arch=pvc,arch=bdw" when | ||
| // passing to clang-offload-packager. | ||
| Arch = OffloadAction->getOffloadingArch(); | ||
| SmallVector<StringRef> Archs; | ||
| Arch.split(Archs, ','); | ||
| for (StringRef &A : Archs) { | ||
| A = mapIntelGPUArchName(A); | ||
| } | ||
| TransformedArch = llvm::join(Archs, ",arch="); | ||
| Arch = TransformedArch; | ||
| } else { | ||
| Arch = OffloadAction->getOffloadingArch(); | ||
| } | ||
|
|
@@ -10366,7 +10378,9 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA, | |
| AL += " "; | ||
| AL += A; | ||
| } | ||
| Parts.emplace_back(C.getArgs().MakeArgString(Twine(Opt) + AL)); | ||
| for (StringRef Split : llvm::split(AL, ',')) { | ||
|
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. Could you please add a comment describing what this newly added code does or update the above existing comment. |
||
| Parts.emplace_back(C.getArgs().MakeArgString(Twine(Opt) + Split)); | ||
| } | ||
| }; | ||
| const ArgList &Args = | ||
| C.getArgsForToolChain(nullptr, StringRef(), Action::OFK_SYCL); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -187,7 +187,7 @@ | |
| // RUN: %clangxx -fsycl -### -fsycl-targets=spir64_gen --offload-new-driver \ | ||
| // RUN: -Xsycl-target-backend=spir64_gen "-device pvc,bdw" %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix COMMA_FILE %s | ||
| // COMMA_FILE: clang-offload-packager{{.*}} "--image=file={{.*}}pvc@bdw{{.*}},triple=spir64_gen-unknown-unknown,arch=pvc,bdw,kind=sycl,compile-opts=-device_options pvc -ze-intel-enable-auto-large-GRF-mode" | ||
| // COMMA_FILE: clang-offload-packager{{.*}} "--image=file={{.*}}pvc@bdw{{.*}},triple=spir64_gen-unknown-unknown,arch=pvc,arch=bdw,kind=sycl,compile-opts=-device_options pvc -ze-intel-enable-auto-large-GRF-mode" | ||
|
|
||
| /// Verify the arch value for the packager is populated with different | ||
| /// scenarios for spir64_gen | ||
|
|
@@ -211,6 +211,21 @@ | |
| // RUN: | FileCheck -check-prefix ARCH_CHECK %s | ||
| // ARCH_CHECK: clang-offload-packager{{.*}} "--image=file={{.*}}triple=spir64_gen-unknown-unknown,arch=bdw,kind=sycl{{.*}}" | ||
|
|
||
| // Verify when a comma-separated list of architectures is provided in -device, they are | ||
|
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. What is the behavior if we pass a non-comma separated list, say a space or semi-colon separated list? 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. Is this question addressed? |
||
| // passed to clang-offload-packager correctly | ||
|
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.
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. AFAIK, |
||
| // RUN: %clangxx -fsycl -### -fsycl-targets=spir64_gen --offload-new-driver \ | ||
|
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. Also, a bit more complex test case such as: |
||
| // RUN: -Xsycl-target-backend "-device pvc,bdw" %s 2>&1 \ | ||
|
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. Another suggestion is to document this behavior in the help text or documentation instead of adding diagnostic in the code. |
||
| // RUN: | FileCheck -check-prefix MULTI_ARCH %s | ||
| // MULTI_ARCH: clang-offload-packager{{.*}} "--image=file={{.*}}triple=spir64_gen-unknown-unknown,arch=pvc,arch=bdw,kind=sycl | ||
| // MULTI_ARCH-SAME: compile-opts=-device_options pvc -ze-intel-enable-auto-large-GRF-mode -device pvc,compile-opts=bdw" | ||
|
|
||
| // Verify that the driver correctly handles link-opt and compile-opt values with commas | ||
| // RUN: %clangxx -fsycl -### -fsycl-targets=spir64_gen --offload-new-driver \ | ||
| // RUN: -Xsycl-target-backend "-device bdw -FOO a,b" \ | ||
| // RUN: -Xsycl-target-linker "-BAR x,y" %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix COMMA_OPTS %s | ||
| // COMMA_OPTS: clang-offload-packager{{.*}} "--image=file={{.*}}triple=spir64_gen-unknown-unknown,arch=bdw,kind=sycl,compile-opts=-device bdw -FOO a,compile-opts=b,link-opts=-BAR x,link-opts=y" | ||
|
|
||
| /// Verify that --cuda-path is passed to clang-linker-wrapper for SYCL offload | ||
| // RUN: %clangxx -fsycl -### -fsycl-targets=nvptx64-nvidia-cuda -fno-sycl-libspirv \ | ||
| // RUN: --cuda-gpu-arch=sm_20 --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s \ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add a comment with the requirement for
TransformedArchto outliveArch. It's not obvious from the variable declaration.