Skip to content

Commit

Permalink
Merge branch 'main' into semaphore_negative_release_retain + correcti…
Browse files Browse the repository at this point in the history
…on for unexpected result log
  • Loading branch information
shajder committed Jul 4, 2024
2 parents 0f54f72 + 6b4d57d commit f4d9321
Show file tree
Hide file tree
Showing 88 changed files with 9,839 additions and 1,248 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Install packages
run: sudo apt install -y clang-format clang-format-11
run: sudo apt install -y clang-format clang-format-14
- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion check-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Arg used to specify non-'origin/main' comparison branch
ORIGIN_BRANCH=${1:-"origin/main"}
CLANG_BINARY=${2:-"`which clang-format-11`"}
CLANG_BINARY=${2:-"`which clang-format-14`"}

# Run git-clang-format to check for violations
CLANG_FORMAT_OUTPUT=$(git-clang-format --diff $ORIGIN_BRANCH --extensions c,cpp,h,hpp --binary $CLANG_BINARY)
Expand Down
16 changes: 11 additions & 5 deletions test_common/gl/setup_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,26 @@ class X11GLEnvironment : public GLEnvironment
private:
cl_device_id m_devices[64];
cl_uint m_device_count;
bool m_glut_init;

public:
X11GLEnvironment()
{
m_device_count = 0;
m_glut_init = false;
}
virtual int Init( int *argc, char **argv, int use_opencl_32 )
{
// Create a GLUT window to render into
glutInit( argc, argv );
glutInitWindowSize( 512, 512 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow( "OpenCL <-> OpenGL Test" );
glewInit();
if (!m_glut_init)
{
glutInit(argc, argv);
glutInitWindowSize(512, 512);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("OpenCL <-> OpenGL Test");
glewInit();
m_glut_init = true;
}
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion test_common/harness/errorHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ static float Ulp_Error_Half_Float(float test, double reference)
return (float)scalbn(testVal - reference, ulp_exp);
}

float Ulp_Error_Half(cl_half test, float reference)
float Ulp_Error_Half(cl_half test, double reference)
{
return Ulp_Error_Half_Float(cl_half_to_float(test), reference);
}
Expand Down
2 changes: 1 addition & 1 deletion test_common/harness/errorHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int vlog_win32(const char *format, ...);

extern const char *IGetErrorString(int clErrorCode);

extern float Ulp_Error_Half(cl_half test, float reference);
extern float Ulp_Error_Half(cl_half test, double reference);
extern float Ulp_Error(float test, double reference);
extern float Ulp_Error_Double(double test, long double reference);

Expand Down
11 changes: 6 additions & 5 deletions test_common/harness/rounding_mode.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2017 The Khronos Group Inc.
// Copyright (c) 2017-2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,10 +42,11 @@ typedef enum
kshort = 3,
kuint = 4,
kint = 5,
kfloat = 6,
kdouble = 7,
kulong = 8,
klong = 9,
khalf = 6,
kfloat = 7,
kdouble = 8,
kulong = 9,
klong = 10,

// This goes last
kTypeCount
Expand Down
1 change: 1 addition & 0 deletions test_conformance/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(MODULE_NAME API)
set(${MODULE_NAME}_SOURCES
main.cpp
negative_platform.cpp
negative_queue.cpp
test_api_consistency.cpp
test_bool.cpp
test_retain.cpp
Expand Down
5 changes: 5 additions & 0 deletions test_conformance/api/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ test_definition test_list[] = {
ADD_TEST(work_group_suggested_local_size_1D),
ADD_TEST(work_group_suggested_local_size_2D),
ADD_TEST(work_group_suggested_local_size_3D),

ADD_TEST(negative_create_command_queue),
ADD_TEST_VERSION(negative_create_command_queue_with_properties,
Version(2, 0)),
ADD_TEST(negative_create_command_queue_with_properties_khr),
};

const int test_num = ARRAY_SIZE(test_list);
Expand Down
174 changes: 174 additions & 0 deletions test_conformance/api/negative_queue.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
//
// Copyright (c) 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "testBase.h"
#include "harness/typeWrappers.h"

int test_negative_create_command_queue(cl_device_id deviceID,
cl_context context,
cl_command_queue queue, int num_elements)
{
cl_command_queue_properties device_props = 0;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");

// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE is the only optional property to
// clCreateCommandQueue, CL_QUEUE_PROFILING_ENABLE is mandatory.
const bool out_of_order_device_support =
device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
if (out_of_order_device_support)
{
// Early return as we can't check correct error is returned for
// unsupported property.
return TEST_PASS;
}

// Try create a command queue with out-of-order property and check return
// code
cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_queue = clCreateCommandQueue(
context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &test_error);

test_failure_error_ret(
test_error, CL_INVALID_QUEUE_PROPERTIES,
"clCreateCommandQueue should return CL_INVALID_QUEUE_PROPERTIES if "
"values specified in properties are valid but are not supported by "
"the "
"device.",
TEST_FAIL);
return TEST_PASS;
}

int test_negative_create_command_queue_with_properties(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements)
{
cl_command_queue_properties device_props = 0;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");

cl_command_queue_properties device_on_host_props = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES,
sizeof(device_on_host_props), &device_on_host_props,
NULL);
test_error(error,
"clGetDeviceInfo for CL_DEVICE_QUEUE_ON_HOST_PROPERTIES failed");

if (device_on_host_props != device_props)
{
log_error(
"ERROR: CL_DEVICE_QUEUE_PROPERTIES and "
"CL_DEVICE_QUEUE_ON_HOST_PROPERTIES properties should match\n");
return TEST_FAIL;
}

// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE is the only optional host-queue
// property to clCreateCommandQueueWithProperties,
// CL_QUEUE_PROFILING_ENABLE is mandatory.
const bool out_of_order_device_support =
device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
if (out_of_order_device_support)
{
// Early return as we can't check correct error is returned for
// unsupported property.
return TEST_PASS;
}

// Try create a command queue with out-of-order property and check return
// code
cl_command_queue_properties queue_prop_def[] = {
CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0
};

cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_queue = clCreateCommandQueueWithProperties(
context, deviceID, queue_prop_def, &test_error);

test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES,
"clCreateCommandQueueWithProperties should "
"return CL_INVALID_QUEUE_PROPERTIES if "
"values specified in properties are valid but "
"are not supported by the "
"device.",
TEST_FAIL);

return TEST_PASS;
}

int test_negative_create_command_queue_with_properties_khr(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements)
{
if (!is_extension_available(deviceID, "cl_khr_create_command_queue"))
{
return TEST_SKIPPED_ITSELF;
}

cl_platform_id platform;
cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM,
sizeof(cl_platform_id), &platform, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed");

clCreateCommandQueueWithPropertiesKHR_fn
clCreateCommandQueueWithPropertiesKHR =
(clCreateCommandQueueWithPropertiesKHR_fn)
clGetExtensionFunctionAddressForPlatform(
platform, "clCreateCommandQueueWithPropertiesKHR");
if (clCreateCommandQueueWithPropertiesKHR == NULL)
{
log_error("ERROR: clGetExtensionFunctionAddressForPlatform failed\n");
return -1;
}

cl_command_queue_properties device_props = 0;
error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES,
sizeof(device_props), &device_props, NULL);
test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed");

// CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE is the only optional host-queue
// property to clCreateCommandQueueWithPropertiesKHR,
// CL_QUEUE_PROFILING_ENABLE is mandatory.
const bool out_of_order_device_support =
device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
if (out_of_order_device_support)
{
// Early return as we can't check correct error is returned for
// unsupported property.
return TEST_PASS;
}

// Try create a command queue with out-of-order property and check return
// code
cl_queue_properties_khr queue_prop_def[] = {
CL_QUEUE_PROPERTIES, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, 0
};

cl_int test_error = CL_SUCCESS;
clCommandQueueWrapper test_khr_queue =
clCreateCommandQueueWithPropertiesKHR(context, deviceID, queue_prop_def,
&test_error);

test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES,
"clCreateCommandQueueWithPropertiesKHR should "
"return CL_INVALID_QUEUE_PROPERTIES if "
"values specified in properties are valid but "
"are not supported by the "
"device.",
TEST_FAIL);
return TEST_PASS;
}
11 changes: 11 additions & 0 deletions test_conformance/api/procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,14 @@ extern int test_work_group_suggested_local_size_3D(cl_device_id device,
cl_context context,
cl_command_queue queue,
int n_elems);

extern int test_negative_create_command_queue(cl_device_id deviceID,
cl_context context,
cl_command_queue queue,
int num_elements);
extern int test_negative_create_command_queue_with_properties(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements);
extern int test_negative_create_command_queue_with_properties_khr(
cl_device_id deviceID, cl_context context, cl_command_queue queue,
int num_elements);
2 changes: 0 additions & 2 deletions test_conformance/api/test_kernel_arg_multi_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const char *multi_arg_kernel_source_pattern =
" dst3[tid] = src3[tid];\n"
"}\n";

#define MAX_ERROR_TOLERANCE 0.0005f

int test_multi_arg_set(cl_device_id device, cl_context context, cl_command_queue queue,
ExplicitType vec1Type, int vec1Size,
ExplicitType vec2Type, int vec2Size,
Expand Down
25 changes: 12 additions & 13 deletions test_conformance/api/test_native_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue
}

clMemWrapper streams[ 2 ];
#if !(defined (_WIN32) && defined (_MSC_VER))
cl_int inBuffer[ n_elems ], outBuffer[ n_elems ];
#else
cl_int* inBuffer = (cl_int *)_malloca( n_elems * sizeof(cl_int) );
cl_int* outBuffer = (cl_int *)_malloca( n_elems * sizeof(cl_int) );
#endif
std::vector<cl_int> inBuffer(n_elems), outBuffer(n_elems);
clEventWrapper finishEvent;

struct arg_struct
Expand All @@ -63,11 +58,12 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue


// Create some input values
generate_random_data( kInt, n_elems, seed, inBuffer );

generate_random_data(kInt, n_elems, seed, inBuffer.data());

// Create I/O streams
streams[ 0 ] = clCreateBuffer( context, CL_MEM_COPY_HOST_PTR, n_elems * sizeof(cl_int), inBuffer, &error );
streams[0] =
clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, n_elems * sizeof(cl_int),
inBuffer.data(), &error);
test_error( error, "Unable to create I/O stream" );
streams[ 1 ] = clCreateBuffer( context, 0, n_elems * sizeof(cl_int), NULL, &error );
test_error( error, "Unable to create I/O stream" );
Expand Down Expand Up @@ -97,15 +93,18 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue
test_error(error, "clWaitForEvents failed");

// Now read the results and verify
error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0, n_elems * sizeof(cl_int), outBuffer, 0, NULL, NULL );
error = clEnqueueReadBuffer(queue, streams[1], CL_TRUE, 0,
n_elems * sizeof(cl_int), outBuffer.data(), 0,
NULL, NULL);
test_error( error, "Unable to read results" );

for( int i = 0; i < n_elems; i++ )
{
if( inBuffer[ i ] != outBuffer[ i ] )
if (inBuffer[i] != outBuffer[i])
{
log_error( "ERROR: Data sample %d for native kernel did not validate (expected %d, got %d)\n",
i, (int)inBuffer[ i ], (int)outBuffer[ i ] );
log_error("ERROR: Data sample %d for native kernel did not "
"validate (expected %d, got %d)\n",
i, (int)inBuffer[i], (int)outBuffer[i]);
return 1;
}
}
Expand Down
14 changes: 0 additions & 14 deletions test_conformance/api/test_queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,20 +507,6 @@ int test_get_context_info(cl_device_id deviceID, cl_context context, cl_command_
return -1;
}

#define TEST_MEM_OBJECT_PARAM( mem, paramName, val, expected, name, type, cast ) \
error = clGetMemObjectInfo( mem, paramName, sizeof( val ), &val, &size ); \
test_error( error, "Unable to get mem object " name ); \
if( val != expected ) \
{ \
log_error( "ERROR: Mem object " name " did not validate! (expected " type ", got " type ")\n", (cast)(expected), (cast)val ); \
return -1; \
} \
if( size != sizeof( val ) ) \
{ \
log_error( "ERROR: Returned size of mem object " name " does not validate! (expected %d, got %d)\n", (int)sizeof( val ), (int)size ); \
return -1; \
}

void CL_CALLBACK mem_obj_destructor_callback( cl_mem, void *data )
{
free( data );
Expand Down
Loading

0 comments on commit f4d9321

Please sign in to comment.