Skip to content

Conversation

jzc
Copy link
Contributor

@jzc jzc commented Sep 18, 2025

Because clang-offload-packager uses commas to separate the key-values pairs when specifying an image, we cannot specify a value that contains a comma without some special handling. However, if you specify the same key multiple times when calling clang-offload-packager, the keys will be concatenated together with commas in between. So if we want, for example, the image to have an arch of pvc,bdw, we can call clang-offload-packager with arch=pvc,arch=bdw to achieve this.

@jzc jzc requested a review from a team as a code owner September 18, 2025 14:57
File = C.getArgs().MakeArgString("@" + File);

StringRef Arch;
std::string TransformedArch;
Copy link
Contributor

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 TransformedArch to outlive Arch. It's not obvious from the variable declaration.

// 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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?
Do we get an error/warning?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this question addressed?

// 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
// passed to clang-offload-packager correctly
Copy link
Contributor

@srividya-sundaram srividya-sundaram Sep 18, 2025

Choose a reason for hiding this comment

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

--offload-arch also supports comma-separated list of arch values.
Could you please add a test case covering that scenario as well?
Example: -Xsycl-target-backend --offload-arch=sm_80,sm_90

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, -Xsycl-target-backend and -Xsycl-target-backend= are handled individually in Driver code.
Is there a test case added for this case?

AL += A;
}
Parts.emplace_back(C.getArgs().MakeArgString(Twine(Opt) + AL));
for (StringRef Split : llvm::split(AL, ',')) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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.


// Verify when a comma-separated list of architectures is provided in -device, they are
// passed to clang-offload-packager correctly
// RUN: %clangxx -fsycl -### -fsycl-targets=spir64_gen --offload-new-driver \
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, a bit more complex test case such as:
-fsycl-targets=nvptx64-nvidia-cuda,amdgcn-amd-amdhsa,spir64_gen -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx908,gfx1010 -Xsycl-target-backend=nvptx64-nvidia-cuda --offload-arch=sm_87,sm_88,sm_89 -Xsycl-target-backend=spir64_gen "-ze-intel-enable-auto-large-GRF-mode -device pvc,bdw"

@jzc jzc temporarily deployed to WindowsCILock October 2, 2025 17:43 — with GitHub Actions Inactive
createArgString("compile-opts=");
BuildArgs.clear();
SYCLTC.TranslateLinkerTargetArgs(TC->getTriple(), Args, BuildArgs, Arch);
SYCLTC.TranslateLinkerTargetArgs(TC->getTriple(), Args, BuildArgs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the Arch arg here because it does not add the arguments when using -Xsycl-target-backend=spir64_gen '-device pvc -FOO' -Xsycl-target-linker=spir64_gen -LFOO correctly; it would only add them in a case where the =spir64_gen was removed or it was using the intel_gpu_pvc syntax.

Copy link
Contributor

Choose a reason for hiding this comment

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

By arguments, are you referring to the values '-device pvc -FOO' and -LFOO, getting passed to the target backend and linker, respectively?

@jzc jzc temporarily deployed to WindowsCILock October 2, 2025 18:14 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to WindowsCILock October 2, 2025 18:14 — with GitHub Actions Inactive
@jzc jzc requested a review from srividya-sundaram October 6, 2025 17:33
@srividya-sundaram
Copy link
Contributor

It would be helpful if you can respond to individual comments if they have been addressed or not, OR use the resolve button to resolve the conversation. Thanks!

// Verify when a comma-separated list of architectures is provided in -device, they are
// passed to clang-offload-packager correctly
// RUN: %clangxx -fsycl -### -fsycl-targets=spir64_gen --offload-new-driver \
// RUN: -Xsycl-target-backend "-device pvc,bdw" %s 2>&1 \
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants