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

Corrected negative results of clCreateSemaphoreWithPropertiesKHR #114

Merged
merged 6 commits into from
Jun 21, 2024
Merged
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