Skip to content

Commit

Permalink
Apply temporary fixes for conformance tests
Browse files Browse the repository at this point in the history
* Execution range update is not supported by the L0 driver right now.
Currently it supports only kernel arguments update.

* There is a synchronization issue with immediate submission when used
for command buffers. It is reproducible even without changes of this
PR, so should be fixed separately. For now use batched submission for
command buffer update tests.
  • Loading branch information
againull committed Mar 14, 2024
1 parent b2c2163 commit f56612e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 24 deletions.
47 changes: 27 additions & 20 deletions test/conformance/exp_command_buffer/buffer_fill_kernel_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ TEST_P(BufferFillCommandTest, UpdateParameters) {

// Test updating the global size so that the fill outputs to a larger buffer
TEST_P(BufferFillCommandTest, UpdateGlobalSize) {
if (!updatable_execution_range_support) {
GTEST_SKIP() << "Execution range update is not supported.";
}

ASSERT_SUCCESS(urCommandBufferEnqueueExp(updatable_cmd_buf_handle, queue, 0,
nullptr, nullptr));
ASSERT_SUCCESS(urQueueFinish(queue));
Expand Down Expand Up @@ -181,7 +185,7 @@ TEST_P(BufferFillCommandTest, SeparateUpdateCalls) {
ValidateBuffer(buffer, sizeof(val) * global_size, val);

size_t new_global_size =
global_size; //64; // Try same value for testing purposes.
updatable_execution_range_support ? 64 : global_size;
const size_t new_buffer_size = sizeof(val) * new_global_size;
ASSERT_SUCCESS(urMemBufferCreate(context, UR_MEM_FLAG_READ_WRITE,
new_buffer_size, nullptr, &new_buffer));
Expand Down Expand Up @@ -248,25 +252,28 @@ TEST_P(BufferFillCommandTest, SeparateUpdateCalls) {
ASSERT_SUCCESS(urCommandBufferUpdateKernelLaunchExp(command_handle,
&input_update_desc));

/*ur_exp_command_buffer_update_kernel_launch_desc_t global_size_update_desc = {
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_DESC, // stype
nullptr, // pNext
0, // numNewMemObjArgs
0, // numNewPointerArgs
0, // numNewValueArgs
0, // numNewExecInfos
0, // newWorkDim
nullptr, // pNewMemObjArgList
nullptr, // pNewPointerArgList
nullptr, // pNewValueArgList
nullptr, // pNewExecInfoList
nullptr, // pNewGlobalWorkOffset
&new_global_size, // pNewGlobalWorkSize
nullptr, // pNewLocalWorkSize
};
ASSERT_SUCCESS(urCommandBufferUpdateKernelLaunchExp(
command_handle, &global_size_update_desc));*/
if (updatable_execution_range_support) {
ur_exp_command_buffer_update_kernel_launch_desc_t
global_size_update_desc = {
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_DESC, // stype
nullptr, // pNext
0, // numNewMemObjArgs
0, // numNewPointerArgs
0, // numNewValueArgs
0, // numNewExecInfos
0, // newWorkDim
nullptr, // pNewMemObjArgList
nullptr, // pNewPointerArgList
nullptr, // pNewValueArgList
nullptr, // pNewExecInfoList
nullptr, // pNewGlobalWorkOffset
&new_global_size, // pNewGlobalWorkSize
nullptr, // pNewLocalWorkSize
};

ASSERT_SUCCESS(urCommandBufferUpdateKernelLaunchExp(
command_handle, &global_size_update_desc));
}

ASSERT_SUCCESS(urCommandBufferEnqueueExp(updatable_cmd_buf_handle, queue, 0,
nullptr, nullptr));
Expand Down
28 changes: 28 additions & 0 deletions test/conformance/exp_command_buffer/fixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,52 @@ struct urUpdatableCommandBufferExpExecutionTest
GTEST_SKIP() << "Updating EXP command-buffers is not supported.";
}

// Currently level zero driver doesn't support updating execution range.
// Also disable immediate command lists because there is synchronization issue causing test failures.
if (backend == UR_PLATFORM_BACKEND_LEVEL_ZERO) {
setenv("UR_L0_USE_IMMEDIATE_COMMANDLISTS", "0", 0);
updatable_execution_range_support = false;
}

// Create a command-buffer with update enabled.
ur_exp_command_buffer_desc_t desc{
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, true};

ASSERT_SUCCESS(urCommandBufferCreateExp(context, device, &desc,
&updatable_cmd_buf_handle));
ASSERT_NE(updatable_cmd_buf_handle, nullptr);

// Currently there are synchronization issue with immediate submission when used for command buffers.
// So, create queue with batched submission for this test suite if the backend is Level Zero.
if (backend == UR_PLATFORM_BACKEND_LEVEL_ZERO) {
ur_queue_flags_t flags = UR_QUEUE_FLAG_SUBMISSION_BATCHED;
ur_queue_properties_t props = {
/*.stype =*/UR_STRUCTURE_TYPE_QUEUE_PROPERTIES,
/*.pNext =*/nullptr,
/*.flags =*/flags,
};
ASSERT_SUCCESS(urQueueCreate(context, device, &props, &queue));
ASSERT_NE(queue, nullptr);
} else {
queue = urCommandBufferExpExecutionTest::queue;
}
}

void TearDown() override {
if (updatable_cmd_buf_handle) {
EXPECT_SUCCESS(urCommandBufferReleaseExp(updatable_cmd_buf_handle));
}
if (backend == UR_PLATFORM_BACKEND_LEVEL_ZERO) {
ASSERT_SUCCESS(urQueueRelease(queue));
}

UUR_RETURN_ON_FATAL_FAILURE(
urCommandBufferExpExecutionTest::TearDown());
}

ur_exp_command_buffer_handle_t updatable_cmd_buf_handle = nullptr;
ur_bool_t updatable_execution_range_support = true;
ur_queue_handle_t queue;
};

struct urCommandBufferCommandExpTest
Expand Down
4 changes: 4 additions & 0 deletions test/conformance/exp_command_buffer/ndrange_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ struct NDRangeUpdateTest
UUR_RETURN_ON_FATAL_FAILURE(
urUpdatableCommandBufferExpExecutionTest::SetUp());

if (!updatable_execution_range_support) {
GTEST_SKIP() << "Execution range update is not supported.";
}

ur_device_usm_access_capability_flags_t shared_usm_flags;
ASSERT_SUCCESS(
uur::GetDeviceUSMSingleSharedSupport(device, shared_usm_flags));
Expand Down
10 changes: 6 additions & 4 deletions test/conformance/exp_command_buffer/usm_fill_kernel_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ TEST_P(USMFillCommandTest, UpdateParameters) {
ASSERT_SUCCESS(urQueueFinish(queue));
Validate((uint32_t *)shared_ptr, global_size, val);

// Allocate a new USM pointer of larger size
size_t new_global_size = global_size; // 64;
// Allocate a new USM pointer of larger size if feature is supported.
size_t new_global_size =
updatable_execution_range_support ? 64 : global_size;
const size_t new_allocation_size = sizeof(val) * new_global_size;
ASSERT_SUCCESS(urUSMSharedAlloc(context, device, nullptr, nullptr,
new_allocation_size, &new_shared_ptr));
Expand Down Expand Up @@ -128,8 +129,9 @@ TEST_P(USMFillCommandTest, UpdateParameters) {
&new_input_desc, // pNewValueArgList
nullptr, // pNewExecInfoList
nullptr, // pNewGlobalWorkOffset
nullptr, //&new_global_size, // pNewGlobalWorkSize
nullptr, // pNewLocalWorkSize
updatable_execution_range_support ? &new_global_size
: nullptr, // pNewGlobalWorkSize
nullptr, // pNewLocalWorkSize
};

// Update kernel and enqueue command-buffer again
Expand Down

0 comments on commit f56612e

Please sign in to comment.