Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,13 @@ ur_result_t ur_command_list_manager::isGraphCaptureActive(bool *pResult) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

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

*pResult = (ZeResult == ZE_RESULT_QUERY_TRUE);

return UR_RESULT_SUCCESS;
}
Expand Down
17 changes: 17 additions & 0 deletions unified-runtime/test/conformance/exp_graph/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ struct urGraphSupportedExpTest : uur::urQueueTest {
}
};

struct urGraphSupportedExpMultiQueueTest : uur::urMultiQueueTest {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(urMultiQueueTest::SetUp());

ur_bool_t graph_supported = false;
ur_result_t result = urDeviceGetInfo(
device, UR_DEVICE_INFO_GRAPH_RECORD_AND_REPLAY_SUPPORT_EXP,
sizeof(graph_supported), &graph_supported, nullptr);
if (result == UR_RESULT_SUCCESS && !graph_supported) {
GTEST_SKIP();
}

UUR_KNOWN_FAILURE_ON(uur::CUDA{}, uur::HIP{}, uur::NativeCPU{},
uur::OpenCL{}, uur::LevelZero{});
}
};

struct urGraphExpTest : urGraphSupportedExpTest {
void SetUp() override {
UUR_RETURN_ON_FATAL_FAILURE(urGraphSupportedExpTest::SetUp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,51 @@ TEST_P(urQueueIsGraphCaptureEnabledExpTest, InvalidNullPtrResult) {
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_POINTER,
urQueueIsGraphCaptureEnabledExp(queue, nullptr));
}

struct urQueueIsGraphCaptureEnabledExpMultiQueueTest
: uur::urGraphSupportedExpMultiQueueTest {
void TearDown() override {
if (graph) {
EXPECT_SUCCESS(urGraphDestroyExp(graph));
}
UUR_RETURN_ON_FATAL_FAILURE(urGraphSupportedExpMultiQueueTest::TearDown());
}

ur_exp_graph_handle_t graph = nullptr;
};

UUR_DEVICE_TEST_SUITE_WITH_QUEUE_TYPES(
urQueueIsGraphCaptureEnabledExpMultiQueueTest,
::testing::Values(0 /* In-Order */,
UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE));

// Tests the fork-join pattern: When an operation is submitted to queue2 which
// is not recording with a dependent event from queue1 that is recording,
// queue2 temporarily transitions to a recording state (fork) which then must
// be joined back to queue1.
TEST_P(urQueueIsGraphCaptureEnabledExpMultiQueueTest, ForkJoinPattern) {
bool isEnabled = false;

ASSERT_SUCCESS(urQueueBeginGraphCaptureExp(queue1));

uur::raii::Event forkEvent = nullptr;
ASSERT_SUCCESS(
urEnqueueEventsWaitWithBarrier(queue1, 0, nullptr, forkEvent.ptr()));

uur::raii::Event joinEvent = nullptr;
ASSERT_SUCCESS(urEnqueueEventsWaitWithBarrier(queue2, 1, forkEvent.ptr(),
joinEvent.ptr()));
ASSERT_SUCCESS(urQueueIsGraphCaptureEnabledExp(queue2, &isEnabled));
ASSERT_TRUE(isEnabled);

ASSERT_SUCCESS(
urEnqueueEventsWaitWithBarrier(queue1, 1, joinEvent.ptr(), nullptr));

ASSERT_SUCCESS(urQueueEndGraphCaptureExp(queue1, &graph));

ASSERT_SUCCESS(urQueueIsGraphCaptureEnabledExp(queue1, &isEnabled));
ASSERT_FALSE(isEnabled);

ASSERT_SUCCESS(urQueueIsGraphCaptureEnabledExp(queue2, &isEnabled));
ASSERT_FALSE(isEnabled);
}
Loading