Skip to content

[SYCL] add an e2e test that passes for liboffload with L0#21584

Open
EuphoricThinking wants to merge 1 commit intointel:syclfrom
EuphoricThinking:liboffload_lit_tests_pr
Open

[SYCL] add an e2e test that passes for liboffload with L0#21584
EuphoricThinking wants to merge 1 commit intointel:syclfrom
EuphoricThinking:liboffload_lit_tests_pr

Conversation

@EuphoricThinking
Copy link
Contributor

@EuphoricThinking EuphoricThinking commented Mar 20, 2026

The liboffload phase 0 program is added as one of SYCL e2e tests. Moreover, lit configuration files are modified so that the liboffload backend is determined according to sycl-ls output, while the backend specified by the user preserves its precedence. When choosing between devices listed by sycl-ls, the Level Zero backend is preferred.

@EuphoricThinking EuphoricThinking requested review from a team as code owners March 20, 2026 19:03
@EuphoricThinking EuphoricThinking force-pushed the liboffload_lit_tests_pr branch from 2ac3b22 to 187486d Compare March 20, 2026 19:22
@EuphoricThinking EuphoricThinking marked this pull request as draft March 20, 2026 19:24
@EuphoricThinking EuphoricThinking force-pushed the liboffload_lit_tests_pr branch 9 times, most recently from abfe1b4 to 3c7b065 Compare March 23, 2026 14:43
@EuphoricThinking EuphoricThinking marked this pull request as ready for review March 23, 2026 14:58
Comment on lines +1061 to +1066
if re.match(r"\[offload:.*", line) and not is_offload_preferred_backend_set:
if re.match(".*Level[ _]Zero.*", line, re.IGNORECASE):
offload_assigned_backend = config.backend_to_target["level_zero"]
is_offload_preferred_backend_set = True
elif re.match(".*nvidia.*", line, re.IGNORECASE):
offload_assigned_backend = config.backend_to_target["cuda"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just assign to config.backend_to_target["offload"] directly and get rid of offload_assigned_backend.

Does the logic here depends on the order of devices/backends in sycl-ls output? I.e. if CUDA comes after L0 in the sycl-ls output, then it will be picked as offload backend. Is this the desired behavior?

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've been afraid I might have overcomplicated, so I'm glad that you point this out.

L0 backend is preferred, but the outcome is not dependent on the order of the devices listed by sycl-ls.

config.backend_to_target["offload"] might be set to target-nvidia if NVIDIA's device is the first one encountered, but is_offload_preferred_backend_set is not set, therefore the condition is still entered in the next iterations. However, when L0 is found, is_offload_preferred_backend_set is set to true, which prevents from entering the condition in the following iterations. If we start with L0 instead, is_offload_preferred_backend_set would be set before we could find NVIDIA - we would not reassign the preferred backend.

I wanted to prevent setting config.backend_to_target["offload"] to "", which was the case with using only OFFLOAD_BUILD_TARGET, but I am not sure whether preferring L0 over other devices is a strategy which is aligned with our goals. On the other hand, we focus on supporting L0 devices. One thing that concerns me is missing backends - for example, HIP is not supported by offload at this moment. Can we encounter only AMD device in our tests?

Comment on lines +18 to +20
// Allocate shared memory bound to the device and context associated to the
// queue Replacing malloc_shared with malloc_host would yield a correct
// program that allocated device-visible memory on the host.
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Comment about malloc_host seems excessive and can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed c:

@EuphoricThinking EuphoricThinking force-pushed the liboffload_lit_tests_pr branch from 3c7b065 to 0d2d8dc Compare March 25, 2026 10:33
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.

2 participants