Skip to content

Commit

Permalink
[OpenCL] Add more mappings from CL error codes to UR error codes.
Browse files Browse the repository at this point in the history
Also merge urQueueCreate InvalidValueProperties test into
InvalidQueueProperties test.
  • Loading branch information
aarongreig committed Oct 20, 2023
1 parent f0de2f4 commit 2792092
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
17 changes: 17 additions & 0 deletions source/adapters/opencl/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ ur_result_t mapCLErrorToUR(cl_int Result) {
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
case CL_INVALID_MEM_OBJECT:
return UR_RESULT_ERROR_INVALID_MEM_OBJECT;
case CL_INVALID_QUEUE_PROPERTIES:
return UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES;
case CL_INVALID_BUFFER_SIZE:
return UR_RESULT_ERROR_INVALID_BUFFER_SIZE;
case CL_INVALID_IMAGE_SIZE:
return UR_RESULT_ERROR_INVALID_IMAGE_SIZE;
case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
case CL_INVALID_IMAGE_DESCRIPTOR:
return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR;
case CL_IMAGE_FORMAT_NOT_SUPPORTED:
return UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT;
case CL_PROFILING_INFO_NOT_AVAILABLE:
return UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE;
case CL_LINK_PROGRAM_FAILURE:
return UR_RESULT_ERROR_PROGRAM_LINK_FAILURE;
case CL_INVALID_ARG_INDEX:
return UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX;
default:
return UR_RESULT_ERROR_UNKNOWN;
}
Expand Down
19 changes: 8 additions & 11 deletions test/conformance/queue/urQueueCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,23 @@ TEST_P(urQueueCreateTest, InvalidNullPointerQueue) {
urQueueCreate(context, device, 0, nullptr));
}

TEST_P(urQueueCreateTest, InvalidValueProperties) {
ur_queue_handle_t queue = nullptr;
TEST_P(urQueueCreateTest, InvalidQueueProperties) {
ur_queue_properties_t props = {
/*.stype =*/UR_STRUCTURE_TYPE_QUEUE_PROPERTIES,
/*.pNext =*/nullptr,
/*.flags =*/UR_QUEUE_FLAG_FORCE_UINT32,
};
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_VALUE,
urQueueCreate(context, device, &props, &queue));
}

TEST_P(urQueueCreateTest, InvalidQueueProperties) {
ur_queue_properties_t props = {
/*.stype =*/UR_STRUCTURE_TYPE_QUEUE_PROPERTIES,
/*.pNext =*/nullptr,
/*.flags =*/UR_QUEUE_FLAG_PRIORITY_HIGH | UR_QUEUE_FLAG_PRIORITY_LOW,
};
// Initial value is just not a valid enum
{
ur_queue_handle_t queue = nullptr;
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES,
urQueueCreate(context, device, &props, &queue));
}
// It should be an error to specify both low/high priorities
{
ur_queue_handle_t queue = nullptr;
props.flags = UR_QUEUE_FLAG_PRIORITY_HIGH | UR_QUEUE_FLAG_PRIORITY_LOW;
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES,
urQueueCreate(context, device, &props, &queue));
}
Expand Down

0 comments on commit 2792092

Please sign in to comment.