Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added two tests not calling event calback upon error status #2028

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions test_conformance/events/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ test_definition test_list[] = {
ADD_TEST(callbacks),
ADD_TEST(callbacks_simultaneous),
ADD_TEST(userevents_multithreaded),
ADD_TEST(callback_not_called_simple),
ADD_TEST(callback_not_called_enqueue_command)
};

const int test_num = ARRAY_SIZE(test_list);
Expand Down
8 changes: 8 additions & 0 deletions test_conformance/events/procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,11 @@ extern int test_userevents_multithreaded(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_callback_not_called_simple(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_callback_not_called_enqueue_command(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
84 changes: 84 additions & 0 deletions test_conformance/events/test_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#if !defined(_MSC_VER)
#include <unistd.h>
#endif // !_MSC_VER
#include <chrono>
#include <thread>

extern const char *IGetStatusString(cl_int status);

Expand Down Expand Up @@ -71,6 +73,15 @@ void CL_CALLBACK single_event_callback_function_flags(cl_event event,
sCallbackTriggered_flag[pdata->index] = true;
}

void CL_CALLBACK combuf_event_callback_function(cl_event event,
cl_int commandStatus,
void *userData)
{
bool *pdata = static_cast<bool *>(userData);
log_info("\tEvent callback triggered\n");
*pdata = true;
}

int test_callback_event_single(cl_device_id device, cl_context context,
cl_command_queue queue, Action *actionToTest)
{
Expand Down Expand Up @@ -372,3 +383,76 @@ int test_callbacks_simultaneous(cl_device_id deviceID, cl_context context,
if (actionEvents) delete[] actionEvents;
return -1;
}

int test_callback_not_called_simple(cl_device_id deviceID, cl_context context,
cl_command_queue queue, int num_elements)
{
cl_int error = CL_SUCCESS;
clEventWrapper user_event = clCreateUserEvent(context, &error);
test_error(error, "clCreateUserEvent failed");

bool confirmation = false;
error = clSetEventCallback(user_event, CL_COMPLETE,
combuf_event_callback_function, &confirmation);
test_error(error, "clSetEventCallback failed");

error = clSetUserEventStatus(user_event, CL_INVALID_VALUE);
test_error(error, "clSetUserEventStatus failed");

// Wait for callback
std::this_thread::sleep_for(std::chrono::milliseconds(500));

if (!confirmation)
{
log_error("callback not called upon error status different than "
"CL_SUCCESS\n");
return TEST_FAIL;
}

return CL_SUCCESS;
}

int test_callback_not_called_enqueue_command(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
{
cl_int error = CL_SUCCESS;
bool confirmation = false;

clEventWrapper user_event = clCreateUserEvent(context, &error);
test_error(error, "clCreateUserEvent failed");
clEventWrapper fill_event;

const cl_int pattern_pri = 0xA;
clMemWrapper in_mem =
clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(cl_int) * num_elements,
nullptr, &error);
test_error(error, "clCreateBuffer failed");

error = clEnqueueFillBuffer(queue, in_mem, &pattern_pri, sizeof(cl_int), 0,
num_elements * sizeof(cl_int), 1, &user_event,
&fill_event);
test_error(error, "clEnqueueFillBuffer failed");

error = clSetEventCallback(fill_event, CL_COMPLETE,
combuf_event_callback_function, &confirmation);
test_error(error, "clSetEventCallback failed");

error = clSetUserEventStatus(user_event, CL_INVALID_VALUE);
test_error(error, "clSetUserEventStatus failed");

error = clFinish(queue);

// Wait for callback
std::this_thread::sleep_for(std::chrono::milliseconds(500));

if (!confirmation)
{
log_error("callback not called upon error status different than "
"CL_SUCCESS\n");
return TEST_FAIL;
}

return CL_SUCCESS;
}
Loading