Skip to content

[SYCL] Fix image selection for AOT on intel_cpu_{spr, gnr} #15208

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 5 commits into from
Sep 11, 2024

Conversation

jzc
Copy link
Contributor

@jzc jzc commented Aug 27, 2024

When AOT compiling for cpu, the generic spir64_x86_64 target is used with -fsycl-targets. In #14909, functionality was added to select device images based on their compile_target property in the image. The selection mechanism had to consider CPU as a special case due to not having explicit targets. However, the mechanism only considered x86_64 and not intel_cpu_spr or intel_cpu_gnr; therefore on a intel_cpu_spr or intel_cpu_gnr device, trying to launch a program compiled with -fsycl-targets=spir64_x86_64, device image selection would fail to find an image (and thus fail to launch any kernels).

This PR updates the logic to include intel_cpu_spr and intel_cpu_gnr. Note: for tests, this functionality is checked by any test that AOT compiled for CPU and launches a kernel (includes AOT/cpu.cpp, AOT/double.cpp, AOT/half.cpp).

@jzc jzc requested a review from a team as a code owner August 27, 2024 20:47
@jzc jzc requested a review from maarquitos14 August 27, 2024 20:47
@jzc jzc temporarily deployed to WindowsCILock August 27, 2024 20:47 — with GitHub Actions Inactive
@jzc jzc temporarily deployed to WindowsCILock August 27, 2024 21:15 — with GitHub Actions Inactive
Comment on lines 1318 to 1320
((ArchName == "x86_64" || ArchName == "intel_cpu_spr" ||
ArchName == "intel_cpu_gnr") &&
CompileTarget == "spir64_x86_64")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not safe, we easily can forget to update this if with more CPU architectures.
This API should be used here:

bool ext_oneapi_architecture_is(                       (2)
    ext::oneapi::experimental::arch_category category);

https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/experimental/sycl_ext_oneapi_device_architecture.asciidoc#new-member-function-of-device-class

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, we don't have intel_cpu category yet.
@gmlueck, is it ok to update the device_architecture spec and impl by extending arch_category with intel_cpu?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want a generic test for "Intel CPU" here? For example, if the device image is compiled for "intel_cpu_spr", we can only use it if the CPU really is Sapphire Rapids. Therefore, it seems like we might want a series of "if" statements here. Is there some other place in the code where we check more precisely whether the ArchName matches the CPU model? Should that logic be pushed down into the unified runtime?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not safe, we easily can forget to update this if with more CPU architectures.

I would say this special handling in this if statement is mainly temporary, as we currently have no dedicated targets for cpu targets in the compiler, i.e. there is no -fsycl-targets=intel_cpu_spr and -fsycl-targets=intel_cpu_gnr (nor -fsycl-targets=x86_64).

For example, if the device image is compiled for "intel_cpu_spr", we can only use it if the CPU really is Sapphire Rapids

Once again, this is what we want, however, as far as I am aware, there is no way to compile for specifically for intel_cpu_spr; the generic spir64_x86_64 target is used, and there is no -fsycl-targets=intel_cpu_spr.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jzc can you please update the comment to highlight that this is a temporary change until XXX is implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dm-vodopyanov Added a TODO comment 7e5fa32

@dm-vodopyanov dm-vodopyanov dismissed their stale review September 5, 2024 14:12

Dismissing my "Changes requested" label, but there is a question above.

@AlexeySachkov AlexeySachkov merged commit 098416a into intel:sycl Sep 11, 2024
12 checks passed
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.

5 participants