Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ template <> device queue_impl::get_info<info::queue::device>() const {
return get_device();
}

ext::oneapi::experimental::queue_state
queue_impl::ext_oneapi_get_state_impl() const {
// A graph may either be recording at the SYCL level or recording at a lower
// level API (e.g. L0)
if (hasCommandGraph()) {
return ext::oneapi::experimental::queue_state::recording;
}

bool IsGraphCaptureEnabled = false;
ur_result_t Result =
getAdapter().call_nocheck<UrApiKind::urQueueIsGraphCaptureEnabledExp>(
MQueue, &IsGraphCaptureEnabled);
if (Result == UR_RESULT_SUCCESS && IsGraphCaptureEnabled) {
return ext::oneapi::experimental::queue_state::recording;
}
return ext::oneapi::experimental::queue_state::executing;
}

static event
prepareSYCLEventAssociatedWithQueue(detail::queue_impl &QueueImpl) {
auto EventImpl = detail::event_impl::create_device_event(QueueImpl);
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {

bool hasCommandGraph() const { return !MGraph.expired(); }

ext::oneapi::experimental::queue_state ext_oneapi_get_state_impl() const;

EventImplPtr submit_command_to_graph(
ext::oneapi::experimental::detail::graph_impl &GraphImpl,
std::unique_ptr<detail::CG> CommandGroup, sycl::detail::CGType CGType,
Expand Down
4 changes: 1 addition & 3 deletions sycl/source/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ context queue::get_context() const { return impl->get_context(); }
device queue::get_device() const { return impl->get_device(); }

ext::oneapi::experimental::queue_state queue::ext_oneapi_get_state() const {
return impl->hasCommandGraph()
? ext::oneapi::experimental::queue_state::recording
: ext::oneapi::experimental::queue_state::executing;
return impl->ext_oneapi_get_state_impl();
}

ext::oneapi::experimental::command_graph<
Expand Down
14 changes: 14 additions & 0 deletions sycl/test-e2e/Graph/RecordReplay/native_recording_multi_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ int main() {
{property::queue::in_order{},
ext::intel::property::queue::immediate_command_list{}}};

const exp_ext::queue_state Recording = exp_ext::queue_state::recording;
const exp_ext::queue_state Executing = exp_ext::queue_state::executing;

auto assertQueueState = [&](exp_ext::queue_state ExpectedQ1,
exp_ext::queue_state ExpectedQ2) {
assert(Queue1.ext_oneapi_get_state() == ExpectedQ1);
assert(Queue2.ext_oneapi_get_state() == ExpectedQ2);
};

// Create a graph - native recording is enabled via
// SYCL_GRAPH_ENABLE_NATIVE_RECORDING environment variable
exp_ext::command_graph Graph{Ctx, Dev};
Expand All @@ -41,8 +50,11 @@ int main() {
int *PartialResult2 = malloc_device<int>(1, Dev, Ctx);
int *FinalResult = malloc_device<int>(1, Dev, Ctx);

assertQueueState(Executing, Executing);

// Begin graph recording on Queue1 only
Graph.begin_recording(Queue1);
assertQueueState(Recording, Executing);

// Transform VecA
event Fork =
Expand All @@ -57,6 +69,7 @@ int main() {
}
PartialResult1[0] = sum;
});
assertQueueState(Recording, Recording);

// Record partial dot product on second half (Queue1)
exp_ext::single_task(Queue1, [=]() {
Expand All @@ -73,6 +86,7 @@ int main() {
});

Graph.end_recording();
assertQueueState(Executing, Executing);

// Finalize and execute the graph
auto ExecutableGraph = Graph.finalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,12 @@ ur_result_t ur_command_list_manager::isGraphCaptureActive(bool *pResult) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

*pResult = graphCapture.isActive();
ze_result_t ZeResult = hContext.get()
->getPlatform()
->ZeGraphExt.zeCommandListIsGraphCaptureEnabledExp(
getZeCommandList());

*pResult = (ZeResult == ZE_RESULT_QUERY_TRUE);

return UR_RESULT_SUCCESS;
}