Command buffer event sync (#1606)

* Added initial commit for event sync test cases (issue #1369, p.3.3)

* Added test cases for return event scenarios with and without out-of-order, work in progress (#1369, p.3.3)

* Added support for return event test cases for both regular and out-of-order command queue (#1369, p.3.3)

* Added user event test cases, cosmetic corrections (#1369, p.3.3)

* Added correction for windows build (#1369, p.3.3)

* Corrected proper testing of test fail/skip conditions (#1369, p.3.3)

* Added corrections related to PR review (#1369, p.3.3)

* Added correction related to change of order Skip/SetUp (issue #1369, event sync)

* Added clang format correction for previous commit

* Reordered initialization of attributes.
This commit is contained in:
Marcin Hajder
2023-03-03 09:20:46 +01:00
committed by GitHub
parent dc8ee495bd
commit 33285facbe
5 changed files with 1115 additions and 81 deletions

View File

@@ -3,6 +3,7 @@ set(MODULE_NAME CL_KHR_COMMAND_BUFFER)
set(${MODULE_NAME}_SOURCES
main.cpp
basic_command_buffer.cpp
command_buffer_event_sync.cpp
command_buffer_out_of_order.cpp
command_buffer_profiling.cpp
command_buffer_queue_substitution.cpp

View File

@@ -53,7 +53,6 @@ bool BasicCommandBufferTest::Skip()
"CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR");
cl_command_queue_properties queue_properties;
error = clGetCommandQueueInfo(queue, CL_QUEUE_PROPERTIES,
sizeof(queue_properties), &queue_properties,
NULL);
@@ -145,6 +144,11 @@ cl_int BasicCommandBufferTest::SetUp(int elements)
{
return error;
}
if (elements <= 0)
{
return CL_INVALID_VALUE;
}
num_elements = static_cast<size_t>(elements);
error = SetUpKernel();
@@ -270,53 +274,6 @@ struct MixedCommandsTest : public BasicCommandBufferTest
}
};
// Test enqueueing a command-buffer blocked on a user-event
struct UserEventTest : public BasicCommandBufferTest
{
using BasicCommandBufferTest::BasicCommandBufferTest;
cl_int Run() override
{
cl_int error = clCommandNDRangeKernelKHR(
command_buffer, nullptr, nullptr, kernel, 1, nullptr, &num_elements,
nullptr, 0, nullptr, nullptr, nullptr);
test_error(error, "clCommandNDRangeKernelKHR failed");
error = clFinalizeCommandBufferKHR(command_buffer);
test_error(error, "clFinalizeCommandBufferKHR failed");
clEventWrapper user_event = clCreateUserEvent(context, &error);
test_error(error, "clCreateUserEvent failed");
const cl_int pattern = 42;
error = clEnqueueFillBuffer(queue, in_mem, &pattern, sizeof(cl_int), 0,
data_size(), 0, nullptr, nullptr);
test_error(error, "clEnqueueFillBuffer failed");
error = clEnqueueCommandBufferKHR(0, nullptr, command_buffer, 1,
&user_event, nullptr);
test_error(error, "clEnqueueCommandBufferKHR failed");
std::vector<cl_int> output_data(num_elements);
error = clEnqueueReadBuffer(queue, out_mem, CL_FALSE, 0, data_size(),
output_data.data(), 0, nullptr, nullptr);
test_error(error, "clEnqueueReadBuffer failed");
error = clSetUserEventStatus(user_event, CL_COMPLETE);
test_error(error, "clSetUserEventStatus failed");
error = clFinish(queue);
test_error(error, "clFinish failed");
for (size_t i = 0; i < num_elements; i++)
{
CHECK_VERIFICATION_ERROR(pattern, output_data[i], i);
}
return CL_SUCCESS;
}
};
// Test flushing the command-queue between command-buffer enqueues
struct ExplicitFlushTest : public BasicCommandBufferTest
{
@@ -472,9 +429,3 @@ int test_explicit_flush(cl_device_id device, cl_context context,
return MakeAndRunTest<ExplicitFlushTest>(device, context, queue,
num_elements);
}
int test_user_events(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements)
{
return MakeAndRunTest<UserEventTest>(device, context, queue, num_elements);
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,31 +15,43 @@
#include "procs.h"
#include "harness/testHarness.h"
test_definition test_list[] = { ADD_TEST(single_ndrange),
ADD_TEST(interleaved_enqueue),
ADD_TEST(mixed_commands),
ADD_TEST(explicit_flush),
ADD_TEST(user_events),
ADD_TEST(out_of_order),
ADD_TEST(simultaneous_out_of_order),
ADD_TEST(basic_profiling),
ADD_TEST(simultaneous_profiling),
ADD_TEST(queue_substitution),
ADD_TEST(properties_queue_substitution),
ADD_TEST(simultaneous_queue_substitution),
ADD_TEST(fill_image),
ADD_TEST(fill_buffer),
ADD_TEST(copy_image),
ADD_TEST(copy_buffer),
ADD_TEST(copy_buffer_to_image),
ADD_TEST(copy_image_to_buffer),
ADD_TEST(copy_buffer_rect),
ADD_TEST(barrier_wait_list),
ADD_TEST(event_info_command_type),
ADD_TEST(event_info_command_queue),
ADD_TEST(event_info_execution_status),
ADD_TEST(event_info_context),
ADD_TEST(event_info_reference_count) };
test_definition test_list[] = {
ADD_TEST(single_ndrange),
ADD_TEST(interleaved_enqueue),
ADD_TEST(mixed_commands),
ADD_TEST(explicit_flush),
ADD_TEST(out_of_order),
ADD_TEST(simultaneous_out_of_order),
ADD_TEST(basic_profiling),
ADD_TEST(simultaneous_profiling),
ADD_TEST(regular_wait_for_command_buffer),
ADD_TEST(command_buffer_wait_for_command_buffer),
ADD_TEST(command_buffer_wait_for_sec_command_buffer),
ADD_TEST(return_event_callback),
ADD_TEST(clwaitforevents_single),
ADD_TEST(clwaitforevents),
ADD_TEST(command_buffer_wait_for_regular),
ADD_TEST(wait_for_sec_queue_event),
ADD_TEST(user_event_wait),
ADD_TEST(user_events_wait),
ADD_TEST(user_event_callback),
ADD_TEST(queue_substitution),
ADD_TEST(properties_queue_substitution),
ADD_TEST(simultaneous_queue_substitution),
ADD_TEST(fill_image),
ADD_TEST(fill_buffer),
ADD_TEST(copy_image),
ADD_TEST(copy_buffer),
ADD_TEST(copy_buffer_to_image),
ADD_TEST(copy_image_to_buffer),
ADD_TEST(copy_buffer_rect),
ADD_TEST(barrier_wait_list),
ADD_TEST(event_info_command_type),
ADD_TEST(event_info_command_queue),
ADD_TEST(event_info_execution_status),
ADD_TEST(event_info_context),
ADD_TEST(event_info_reference_count)
};
int main(int argc, const char *argv[])
{

View File

@@ -27,10 +27,40 @@ extern int test_mixed_commands(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_explicit_flush(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_user_events(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_out_of_order(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_regular_wait_for_command_buffer(cl_device_id device,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_command_buffer_wait_for_command_buffer(cl_device_id device,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_command_buffer_wait_for_sec_command_buffer(
cl_device_id device, cl_context context, cl_command_queue queue,
int num_elements);
extern int test_return_event_callback(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_clwaitforevents_single(cl_device_id device, cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_clwaitforevents(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_command_buffer_wait_for_regular(cl_device_id device,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_wait_for_sec_queue_event(cl_device_id device,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_user_event_wait(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_user_events_wait(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_user_event_callback(cl_device_id device, cl_context context,
cl_command_queue queue, int num_elements);
extern int test_simultaneous_out_of_order(cl_device_id device,
cl_context context,
cl_command_queue queue,