Skip to content

[SYCL][Graph] Allow capturing restricted host tasks in native recording mode#22143

Merged
sarnex merged 21 commits into
intel:syclfrom
adamfidel:adam/host-task-native-recording
Jul 9, 2026
Merged

[SYCL][Graph] Allow capturing restricted host tasks in native recording mode#22143
sarnex merged 21 commits into
intel:syclfrom
adamfidel:adam/host-task-native-recording

Conversation

@adamfidel

@adamfidel adamfidel commented May 27, 2026

Copy link
Copy Markdown
Member

This PR allows SYCL Graph native recording mode to capture the new restricted host task defined in the sycl_ext_oneapi_enqueue_functions extension.

@adamfidel adamfidel force-pushed the adam/host-task-native-recording branch from 25ba6de to 1e41cd9 Compare May 28, 2026 16:39
@adamfidel adamfidel marked this pull request as ready for review May 28, 2026 19:10
@adamfidel adamfidel requested review from a team as code owners May 28, 2026 19:10
@adamfidel adamfidel requested review from mmichel11 and slawekptak May 28, 2026 19:10
Comment thread sycl/source/handler.cpp Outdated
Comment thread sycl/source/detail/host_task.hpp Outdated
Comment thread sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc
Comment thread sycl/source/handler.cpp Outdated
@adamfidel adamfidel requested a review from a team as a code owner May 29, 2026 22:40
@adamfidel adamfidel marked this pull request as draft May 29, 2026 22:42
adamfidel and others added 11 commits June 4, 2026 13:57
…d commands

Move EnqueueHostTaskData and NativeHostTask from the anonymous namespace in
commands.cpp into host_task.hpp so both the native recording path in handler.cpp
and the scheduler path in commands.cpp use the same type and callback rather
than duplicating the pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@adamfidel adamfidel force-pushed the adam/host-task-native-recording branch from 5cfa113 to e1b75fd Compare June 4, 2026 20:59
@adamfidel adamfidel marked this pull request as ready for review June 4, 2026 21:23
Comment thread sycl/test-e2e/Graph/RecordReplay/NativeRecording/enqueue_func_host_task.cpp Outdated
Comment thread unified-runtime/source/adapters/level_zero/v2/command_list_manager.cpp Outdated
Comment thread sycl/source/detail/graph/graph_impl.cpp
Comment thread sycl/source/detail/host_task.hpp Outdated

@mmichel11 mmichel11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small feedback about proper handling with older driver versions.

Comment thread sycl/test-e2e/Graph/RecordReplay/NativeRecording/enqueue_func_host_task.cpp Outdated
Comment thread sycl/source/handler.cpp

@mmichel11 mmichel11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Graph changes LGTM

@slawekptak slawekptak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please note this PR: #22518 . It changes the implementation of native host tasks (new command type). I think it is not an issue, and depending on which PR is merged first, the other one just needs to be updated, but I'm sharing it just in case. It would be great if you could take a look at that one and make sure there are no issues. Thanks.

Comment thread sycl/source/handler.cpp Outdated
Comment thread sycl/source/handler.cpp
@slawekptak

Copy link
Copy Markdown
Contributor

One more question - is recording of restricted host tasks (enqueue_functions) supported today, but for a non-native graph recording mode?

@adamfidel

Copy link
Copy Markdown
Member Author

One more question - is recording of restricted host tasks (enqueue_functions) supported today, but for a non-native graph recording mode?

Yes, this PR introduces two tests for restricted host tasks: one for native recording mode and one for the original command buffer mode.

@adamfidel

Copy link
Copy Markdown
Member Author

Please note this PR: #22518 . It changes the implementation of native host tasks (new command type). I think it is not an issue, and depending on which PR is merged first, the other one just needs to be updated, but I'm sharing it just in case. It would be great if you could take a look at that one and make sure there are no issues. Thanks.

Thanks for sharing this. I took a look and your PR is a nice cleanup and I agree that making a native host task its own node type is a nice way to organize it. It looks like our PRs touch a lot of the same things and while don't think it will be a problem to incorporate these two PRs conceptually, I anticipate that it would be a problem in terms of actually reconciling the text diffs.

But overall I think your PR is a good rework of the native host task feature.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enables SYCL Graph native recording mode to capture restricted host tasks submitted via the sycl_ext_oneapi_enqueue_functions extension, aligning native recording behavior with the newer enqueue-functions host task API. It does so by bypassing the scheduler for eligible host tasks during recording and directly enqueueing the backend host-task callback into the native graph capture.

Changes:

  • Allow restricted host tasks to be recorded in native recording mode by enqueueing urEnqueueHostTaskExp from handler::finalize() and retaining callback lifetime via graph_impl.
  • Centralize native host-task callback plumbing (EnqueueHostTaskData, NativeHostTask<>, and host-task functor extraction) in detail/host_task.hpp, and update scheduler host-task dispatch to use it.
  • Add E2E coverage for both command-buffer and native-recording record/replay paths, and update the Graph extension documentation to reflect the new support.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sycl/test-e2e/Graph/RecordReplay/NativeRecording/enqueue_func_host_task.cpp Adds a native-recording-specific E2E test wrapper enabling native recording for the shared test logic.
sycl/test-e2e/Graph/RecordReplay/Inputs/enqueue_func_host_task.cpp Shared E2E test logic validating restricted host task recording/replay semantics across two replays.
sycl/test-e2e/Graph/RecordReplay/enqueue_func_host_task.cpp Adds command-buffer-path E2E coverage for restricted host task recording via the Record & Replay path.
sycl/source/handler.cpp Implements native-recording host-task capture path: validates restricted host task + backend support, stores callback data in the graph, enqueues UR host task, and returns a completed host event during recording.
sycl/source/detail/scheduler/commands.cpp Removes local native-host-task callback helpers and switches to the shared detail/host_task.hpp implementation.
sycl/source/detail/host_task.hpp Introduces shared native-host-task callback data + callback function template, and exposes host-task functor extraction via HandlerAccess.
sycl/source/detail/graph/graph_impl.hpp Adds API and storage to own callback data for host tasks recorded in native recording mode.
sycl/source/detail/graph/graph_impl.cpp Implements graph_impl::addNativeHostTaskCallback() to retain native host-task callback payloads for UR.
sycl/include/sycl/handler.hpp Declares HandlerAccess::getHostTaskFunc() to support internal extraction of host-task functors.
sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc Documents the native-recording limitation for handler::host_task and the supported restricted host-task path via enqueue-functions.

Comment thread sycl/source/handler.cpp Outdated
Comment thread sycl/source/handler.cpp Outdated
Comment thread sycl/source/handler.cpp Outdated
Comment thread sycl/source/detail/scheduler/commands.cpp
Comment thread sycl/source/detail/graph/graph_impl.hpp Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@adamfidel

Copy link
Copy Markdown
Member Author

@intel/llvm-gatekeepers Please consider merging :)

@sarnex sarnex merged commit b32d8e4 into intel:sycl Jul 9, 2026
31 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.

6 participants