Skip to content

Commit

Permalink
Corrected negative results of clCreateSemaphoreWithPropertiesKHR (#114)
Browse files Browse the repository at this point in the history
* Added missing interface for CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR property

* approach to correct CI checks errors around semaphore emulation layer to handle CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR flag

* Corrections related to negative CTS tests of clCreateSemaphoreWithPropertiesKHR

* corrections related to review #113

* Take into account additional property field

to distinguish between CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR and array
terminator

---------

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
  • Loading branch information
shajder and bashbaug authored Jun 21, 2024
1 parent dbc2b85 commit 3d95b21
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions layers/11_semaemu/emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ typedef struct _cl_semaphore_khr

std::vector<cl_device_id> devices;

if( properties )
if ( properties == nullptr )
errorCode = CL_INVALID_VALUE;

if ( context == nullptr )
errorCode = CL_INVALID_CONTEXT;

if( errorCode == CL_SUCCESS && properties )
{
const cl_semaphore_properties_khr* check = properties;
bool found_CL_SEMAPHORE_TYPE_KHR = false;
Expand All @@ -85,7 +91,7 @@ typedef struct _cl_semaphore_khr
case CL_SEMAPHORE_TYPE_KHR:
if( found_CL_SEMAPHORE_TYPE_KHR )
{
errorCode = CL_INVALID_VALUE;
errorCode = CL_INVALID_PROPERTY;
}
else
{
Expand All @@ -97,7 +103,7 @@ typedef struct _cl_semaphore_khr
case CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR:
if( found_CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR )
{
errorCode = CL_INVALID_VALUE;
errorCode = CL_INVALID_PROPERTY;
}
else
{
Expand All @@ -112,12 +118,15 @@ typedef struct _cl_semaphore_khr
}
break;
default:
errorCode = CL_INVALID_VALUE;
errorCode = CL_INVALID_PROPERTY;
break;
}
}
numProperties = check - properties + 1;

if ( errorCode == CL_SUCCESS && type == ~0)
errorCode = CL_INVALID_VALUE;

// validate device handles.
if (!devices.empty()) {
// for now - if CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR is specified
Expand All @@ -139,16 +148,17 @@ typedef struct _cl_semaphore_khr
}
}
}
switch( type )
{
case CL_SEMAPHORE_TYPE_BINARY_KHR:

if (errorCode == CL_SUCCESS) {
switch (type) {
case CL_SEMAPHORE_TYPE_BINARY_KHR:
break;
default:
errorCode = CL_INVALID_VALUE;
default:
errorCode = CL_INVALID_PROPERTY;
}
}
if( errcode_ret )
{
errcode_ret[0] = errorCode;
if (errcode_ret) {
errcode_ret[0] = errorCode;
}
if( errorCode == CL_SUCCESS )
{
Expand Down

0 comments on commit 3d95b21

Please sign in to comment.