From 6bc5236b1c5ef89bbf79edd2a62bbf7e3cb305c9 Mon Sep 17 00:00:00 2001 From: Grzegorz Wawiorko Date: Thu, 14 Mar 2019 15:45:49 +0100 Subject: [PATCH] Khronos Bug 15271 allocations test doesn't check if all events on the wait list are valid --- .../allocations/allocation_fill.cpp | 17 ++++------------- .../allocations/allocation_utils.cpp | 19 ++++++++++++++++++- .../allocations/allocation_utils.h | 7 +++++-- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/test_conformance/allocations/allocation_fill.cpp b/test_conformance/allocations/allocation_fill.cpp index 6aca3cb5..92d813c3 100644 --- a/test_conformance/allocations/allocation_fill.cpp +++ b/test_conformance/allocations/allocation_fill.cpp @@ -72,7 +72,7 @@ int fill_buffer_with_data(cl_context context, cl_device_id device_id, cl_command } error = clWaitForEvents(1, &event); - result = check_allocation_error(context, device_id, error, queue); + result = check_allocation_error(context, device_id, error, queue, &event); if (result == FAILED_ABORT) { print_error(error, "clWaitForEvents failed."); @@ -128,7 +128,7 @@ int fill_buffer_with_data(cl_context context, cl_device_id device_id, cl_command } error = clWaitForEvents(1, &event); - result = check_allocation_error(context, device_id, error, queue); + result = check_allocation_error(context, device_id, error, queue, &event); if (result == FAILED_ABORT) { print_error(error, "clWaitForEvents failed."); @@ -219,16 +219,7 @@ int fill_image_with_data(cl_context context, cl_device_id device_id, cl_command_ } error = clWaitForEvents(1, &event); - - // Dig out execution error if that is the problem - if (error == CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST) { - cl_int err, exec_status; - err = clGetEventInfo(event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(exec_status), &exec_status, NULL); - test_error(err, "clGetEventInfo failed getting CL_EVENT_COMMAND_EXECUTION_STATUS from failed event"); - error = exec_status; - } - - result = check_allocation_error(context, device_id, error, queue); + result = check_allocation_error(context, device_id, error, queue, &event); if (result == FAILED_ABORT) { print_error(error, "clWaitForEvents failed."); @@ -284,7 +275,7 @@ int fill_image_with_data(cl_context context, cl_device_id device_id, cl_command_ } error = clWaitForEvents(1, &event); - result = check_allocation_error(context, device_id, error, queue); + result = check_allocation_error(context, device_id, error, queue, &event); if (result == FAILED_ABORT) { print_error(error, "clWaitForEvents failed."); diff --git a/test_conformance/allocations/allocation_utils.cpp b/test_conformance/allocations/allocation_utils.cpp index 38282dfa..6877c86a 100644 --- a/test_conformance/allocations/allocation_utils.cpp +++ b/test_conformance/allocations/allocation_utils.cpp @@ -23,8 +23,25 @@ cl_command_queue reset_queue(cl_context context, cl_device_id device_id, cl_comm return *queue; } -int check_allocation_error(cl_context context, cl_device_id device_id, int error, cl_command_queue *queue) { +int check_allocation_error(cl_context context, cl_device_id device_id, int error, cl_command_queue *queue, cl_event *event) { //log_info("check_allocation_error context=%p device_id=%p error=%d *queue=%p\n", context, device_id, error, *queue); + if (error == CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST && event != 0) + { + // check for errors from clWaitForEvents (e.g after clEnqueueWriteBuffer) + cl_int eventError; + error = clGetEventInfo(*event, CL_EVENT_COMMAND_EXECUTION_STATUS, sizeof(error), &eventError, 0); + if (CL_SUCCESS != error) + { + log_error("Failed to get event execution status: %s\n", IGetErrorString(error)); + return FAILED_ABORT; + } + if (eventError >= 0) + { + log_error("Non-negative event execution status after CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: %s\n", IGetErrorString(error)); + return FAILED_ABORT; + } + error = eventError; + } if ((error == CL_MEM_OBJECT_ALLOCATION_FAILURE ) || (error == CL_OUT_OF_RESOURCES ) || (error == CL_OUT_OF_HOST_MEMORY) || (error == CL_INVALID_IMAGE_SIZE)) { return FAILED_TOO_BIG; } else if (error == CL_INVALID_COMMAND_QUEUE) { diff --git a/test_conformance/allocations/allocation_utils.h b/test_conformance/allocations/allocation_utils.h index a91a1235..2d165c1e 100644 --- a/test_conformance/allocations/allocation_utils.h +++ b/test_conformance/allocations/allocation_utils.h @@ -13,12 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. // +#ifndef _allocation_utils_h +#define _allocation_utils_h + #include "testBase.h" extern cl_uint checksum; -int check_allocation_error(cl_context context, cl_device_id device_id, int error, cl_command_queue *queue); +int check_allocation_error(cl_context context, cl_device_id device_id, int error, cl_command_queue *queue, cl_event *event = 0); double toMB(cl_ulong size_in); size_t get_actual_allocation_size(cl_mem mem); - +#endif // _allocation_utils_h \ No newline at end of file