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

#1900 
Tested on POCL, callback is not called.
This commit is contained in:
Kamil-Goras-Mobica
2024-08-20 17:55:03 +02:00
committed by GitHub
parent 746544af80
commit 6cbe8cae35
3 changed files with 94 additions and 0 deletions

View File

@@ -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);
@@ -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)
{
@@ -372,3 +383,76 @@ int test_callbacks_simultaneous(cl_device_id deviceID, cl_context context,
if (actionEvents) delete[] actionEvents;
return -1;
}
int test_callback_on_error_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_on_error_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;
}