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?

// 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

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"

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