diff --git a/test_conformance/buffers/array_info.cpp b/test_conformance/buffers/array_info.cpp index f143cf37..aa6c04c3 100644 --- a/test_conformance/buffers/array_info.cpp +++ b/test_conformance/buffers/array_info.cpp @@ -21,11 +21,9 @@ #include #include -#include "procs.h" +#include "testBase.h" - - -int test_array_info_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(array_info_size) { cl_mem memobj; cl_int err; diff --git a/test_conformance/buffers/main.cpp b/test_conformance/buffers/main.cpp index 7c5502a7..f2a8c2a3 100644 --- a/test_conformance/buffers/main.cpp +++ b/test_conformance/buffers/main.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 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 @@ -13,116 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "harness/compat.h" -#include -#include -#include -#include "procs.h" +#include "harness/compat.h" #include "harness/testHarness.h" -test_definition test_list[] = { - ADD_TEST(buffer_read_async_int), - ADD_TEST(buffer_read_async_uint), - ADD_TEST(buffer_read_async_long), - ADD_TEST(buffer_read_async_ulong), - ADD_TEST(buffer_read_async_short), - ADD_TEST(buffer_read_async_ushort), - ADD_TEST(buffer_read_async_char), - ADD_TEST(buffer_read_async_uchar), - ADD_TEST(buffer_read_async_float), - ADD_TEST(buffer_read_array_barrier_int), - ADD_TEST(buffer_read_array_barrier_uint), - ADD_TEST(buffer_read_array_barrier_long), - ADD_TEST(buffer_read_array_barrier_ulong), - ADD_TEST(buffer_read_array_barrier_short), - ADD_TEST(buffer_read_array_barrier_ushort), - ADD_TEST(buffer_read_array_barrier_char), - ADD_TEST(buffer_read_array_barrier_uchar), - ADD_TEST(buffer_read_array_barrier_float), - ADD_TEST(buffer_read_int), - ADD_TEST(buffer_read_uint), - ADD_TEST(buffer_read_long), - ADD_TEST(buffer_read_ulong), - ADD_TEST(buffer_read_short), - ADD_TEST(buffer_read_ushort), - ADD_TEST(buffer_read_float), - ADD_TEST(buffer_read_half), - ADD_TEST(buffer_read_char), - ADD_TEST(buffer_read_uchar), - ADD_TEST(buffer_read_struct), - ADD_TEST(buffer_read_random_size), - ADD_TEST(buffer_map_read_int), - ADD_TEST(buffer_map_read_uint), - ADD_TEST(buffer_map_read_long), - ADD_TEST(buffer_map_read_ulong), - ADD_TEST(buffer_map_read_short), - ADD_TEST(buffer_map_read_ushort), - ADD_TEST(buffer_map_read_char), - ADD_TEST(buffer_map_read_uchar), - ADD_TEST(buffer_map_read_float), - ADD_TEST(buffer_map_read_struct), - - ADD_TEST(buffer_map_write_int), - ADD_TEST(buffer_map_write_uint), - ADD_TEST(buffer_map_write_long), - ADD_TEST(buffer_map_write_ulong), - ADD_TEST(buffer_map_write_short), - ADD_TEST(buffer_map_write_ushort), - ADD_TEST(buffer_map_write_char), - ADD_TEST(buffer_map_write_uchar), - ADD_TEST(buffer_map_write_float), - ADD_TEST(buffer_map_write_struct), - - ADD_TEST(buffer_write_int), - ADD_TEST(buffer_write_uint), - ADD_TEST(buffer_write_short), - ADD_TEST(buffer_write_ushort), - ADD_TEST(buffer_write_char), - ADD_TEST(buffer_write_uchar), - ADD_TEST(buffer_write_float), - ADD_TEST(buffer_write_half), - ADD_TEST(buffer_write_long), - ADD_TEST(buffer_write_ulong), - ADD_TEST(buffer_write_struct), - ADD_TEST(buffer_write_async_int), - ADD_TEST(buffer_write_async_uint), - ADD_TEST(buffer_write_async_short), - ADD_TEST(buffer_write_async_ushort), - ADD_TEST(buffer_write_async_char), - ADD_TEST(buffer_write_async_uchar), - ADD_TEST(buffer_write_async_float), - ADD_TEST(buffer_write_async_long), - ADD_TEST(buffer_write_async_ulong), - ADD_TEST(buffer_copy), - ADD_TEST(buffer_partial_copy), - ADD_TEST(mem_read_write_flags), - ADD_TEST(mem_write_only_flags), - ADD_TEST(mem_read_only_flags), - ADD_TEST(mem_copy_host_flags), - ADD_TEST(mem_alloc_ref_flags), - ADD_TEST(array_info_size), - - ADD_TEST(sub_buffers_read_write), - ADD_TEST(sub_buffers_read_write_dual_devices), - ADD_TEST(sub_buffers_overlapping), - - ADD_TEST(buffer_fill_int), - ADD_TEST(buffer_fill_uint), - ADD_TEST(buffer_fill_short), - ADD_TEST(buffer_fill_ushort), - ADD_TEST(buffer_fill_char), - ADD_TEST(buffer_fill_uchar), - ADD_TEST(buffer_fill_long), - ADD_TEST(buffer_fill_ulong), - ADD_TEST(buffer_fill_float), - ADD_TEST(buffer_fill_struct), - - ADD_TEST(buffer_migrate), - ADD_TEST(image_migrate), -}; - -const int test_num = ARRAY_SIZE( test_list ); +#include "testBase.h" const cl_mem_flags flag_set[] = { CL_MEM_ALLOC_HOST_PTR, @@ -141,5 +36,6 @@ const char* flag_set_names[] = { int main( int argc, const char *argv[] ) { - return runTestHarness(argc, argv, test_num, test_list, false, 0); + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0); } diff --git a/test_conformance/buffers/procs.h b/test_conformance/buffers/procs.h deleted file mode 100644 index fb0f851a..00000000 --- a/test_conformance/buffers/procs.h +++ /dev/null @@ -1,132 +0,0 @@ -// -// Copyright (c) 2017 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. -// -#ifndef __PROCS_H__ -#define __PROCS_H__ - -#include "harness/kernelHelpers.h" -#include "harness/testHarness.h" -#include "harness/errorHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/mt19937.h" -#include "harness/conversions.h" - -#ifndef __APPLE__ -#include -#endif - -extern const cl_mem_flags flag_set[]; -extern const char* flag_set_names[]; -#define NUM_FLAGS 5 - -extern int test_buffer_read_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_random_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_read_array_barrier_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_partial_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_array_info_size( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_read_write_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_write_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_read_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_copy_host_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_mem_alloc_ref_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_buffer_map_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_map_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -extern int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); - -#endif // #ifndef __PROCS_H__ - diff --git a/test_conformance/buffers/testBase.h b/test_conformance/buffers/testBase.h new file mode 100644 index 00000000..8c5bb0e4 --- /dev/null +++ b/test_conformance/buffers/testBase.h @@ -0,0 +1,30 @@ +// +// Copyright (c) 2025 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. +// +#ifndef _testBase_h +#define _testBase_h + +#include + +#include "harness/conversions.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" + +extern const cl_mem_flags flag_set[]; +extern const char* flag_set_names[]; + +#define NUM_FLAGS 5 + +#endif // _testBase_h diff --git a/test_conformance/buffers/test_buffer_copy.cpp b/test_conformance/buffers/test_buffer_copy.cpp index 62862d2e..093987f8 100644 --- a/test_conformance/buffers/test_buffer_copy.cpp +++ b/test_conformance/buffers/test_buffer_copy.cpp @@ -21,10 +21,9 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" - static int verify_copy_buffer(int *inptr, int *outptr, int n) { int i; @@ -245,7 +244,7 @@ static int testPartialCopy( cl_command_queue queue, cl_context context, int num_ } // end testPartialCopy() -int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_copy) { int i, err = 0; int size; @@ -271,7 +270,7 @@ int test_buffer_copy( cl_device_id deviceID, cl_context context, cl_command_queu } // end test_buffer_copy() -int test_buffer_partial_copy( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_partial_copy) { int i, err = 0; int size; diff --git a/test_conformance/buffers/test_buffer_fill.cpp b/test_conformance/buffers/test_buffer_fill.cpp index 92079794..2e7a22de 100644 --- a/test_conformance/buffers/test_buffer_fill.cpp +++ b/test_conformance/buffers/test_buffer_fill.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" #define TEST_PRIME_CHAR 0x77 @@ -557,10 +557,13 @@ static int verify_fill_struct( void *ptr1, void *ptr2, int n ) } - -int test_buffer_fill( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, - int loops, void *inptr[5], void *hostptr[5], void *pattern[5], size_t offset_elements, size_t fill_elements, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int) ) +static int test_buffer_fill(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, void *inptr[5], + void *hostptr[5], void *pattern[5], + size_t offset_elements, size_t fill_elements, + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, void *, int)) { void *outptr[5]; clProgramWrapper program[5]; @@ -700,7 +703,7 @@ int test_buffer_fill( cl_device_id deviceID, cl_context context, cl_command_queu } // end test_buffer_fill() -int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_struct) { TestStruct pattern; size_t ptrSize = sizeof( TestStruct ); @@ -890,7 +893,7 @@ int test_buffer_fill_struct( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_fill_struct() -int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_int) { cl_int *inptr[5]; cl_int *hostptr[5]; @@ -934,10 +937,11 @@ int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_ memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, + if (test_buffer_fill(device, context, queue, num_elements, + sizeof(cl_int), (char *)"int", 5, (void **)inptr, + (void **)hostptr, (void **)pattern, offset_elements, fill_elements, - buffer_fill_int_kernel_code, int_kernel_name, foo )) + buffer_fill_int_kernel_code, int_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -955,7 +959,7 @@ int test_buffer_fill_int( cl_device_id deviceID, cl_context context, cl_command_ } // end test_buffer_int_fill() -int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_uint) { cl_uint *inptr[5]; cl_uint *hostptr[5]; @@ -999,10 +1003,11 @@ int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_uint_kernel_code, uint_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_uint), + (char *)"uint", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_uint_kernel_code, uint_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1020,7 +1025,7 @@ int test_buffer_fill_uint( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_uint_fill() -int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_short) { cl_short *inptr[5]; cl_short *hostptr[5]; @@ -1064,10 +1069,11 @@ int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_short_kernel_code, short_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_short), + (char *)"short", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_short_kernel_code, short_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1085,7 +1091,7 @@ int test_buffer_fill_short( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_short_fill() -int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_ushort) { cl_ushort *inptr[5]; cl_ushort *hostptr[5]; @@ -1129,10 +1135,11 @@ int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_comma memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_ushort_kernel_code, ushort_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_ushort), + (char *)"ushort", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_ushort_kernel_code, ushort_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1150,7 +1157,7 @@ int test_buffer_fill_ushort( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_ushort_fill() -int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_char) { cl_char *inptr[5]; cl_char *hostptr[5]; @@ -1194,10 +1201,11 @@ int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_char_kernel_code, char_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_char), + (char *)"char", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_char_kernel_code, char_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1215,7 +1223,7 @@ int test_buffer_fill_char( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_char_fill() -int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_uchar) { cl_uchar *inptr[5]; cl_uchar *hostptr[5]; @@ -1259,10 +1267,11 @@ int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_uchar_kernel_code, uchar_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_uchar), + (char *)"uchar", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_uchar_kernel_code, uchar_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1280,7 +1289,7 @@ int test_buffer_fill_uchar( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_uchar_fill() -int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_long) { cl_long *inptr[5]; cl_long *hostptr[5]; @@ -1331,10 +1340,11 @@ int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"long", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_long_kernel_code, long_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_long), + (char *)"long", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_long_kernel_code, long_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1352,7 +1362,7 @@ int test_buffer_fill_long( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_long_fill() -int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_ulong) { cl_ulong *inptr[5]; cl_ulong *hostptr[5]; @@ -1402,10 +1412,11 @@ int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_ulong_kernel_code, ulong_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_ulong), + (char *)"ulong", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_ulong_kernel_code, ulong_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ @@ -1423,7 +1434,7 @@ int test_buffer_fill_ulong( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_ulong_fill() -int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_fill_float) { cl_float *inptr[5]; cl_float *hostptr[5]; @@ -1467,10 +1478,11 @@ int test_buffer_fill_float( cl_device_id deviceID, cl_context context, cl_comman memset(hostptr[i], 0, ptrSizes[i] * num_elements); } - if (test_buffer_fill( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", - 5, (void**)inptr, (void**)hostptr, (void**)pattern, - offset_elements, fill_elements, - buffer_fill_float_kernel_code, float_kernel_name, foo )) + if (test_buffer_fill( + device, context, queue, num_elements, sizeof(cl_float), + (char *)"float", 5, (void **)inptr, (void **)hostptr, + (void **)pattern, offset_elements, fill_elements, + buffer_fill_float_kernel_code, float_kernel_name, foo)) err++; for ( i = 0; i < 5; i++ ){ diff --git a/test_conformance/buffers/test_buffer_map.cpp b/test_conformance/buffers/test_buffer_map.cpp index 382c7a35..5cac90ab 100644 --- a/test_conformance/buffers/test_buffer_map.cpp +++ b/test_conformance/buffers/test_buffer_map.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" @@ -672,12 +672,14 @@ static int test_buffer_map_read( cl_device_id deviceID, cl_context context, cl_c } // end test_buffer_map_read() -#define DECLARE_LOCK_TEST(type, realType) \ -int test_buffer_map_read_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_map_read( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_LOCK_TEST(type, realType) \ + REGISTER_TEST(buffer_map_read_##type) \ + { \ + return test_buffer_map_read(device, context, queue, num_elements, \ + sizeof(realType), (char *)#type, 5, \ + buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_LOCK_TEST(int, cl_int) DECLARE_LOCK_TEST(uint, cl_uint) @@ -689,13 +691,14 @@ DECLARE_LOCK_TEST(char, cl_char) DECLARE_LOCK_TEST(uchar, cl_uchar) DECLARE_LOCK_TEST(float, cl_float) -int test_buffer_map_read_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_read_struct) { int (*foo)(void *,int); foo = verify_read_struct; - return test_buffer_map_read( deviceID, context, queue, num_elements, sizeof( TestStruct ), (char*)"struct", 1, - buffer_read_struct_kernel_code, struct_kernel_name, foo ); - + return test_buffer_map_read(device, context, queue, num_elements, + sizeof(TestStruct), (char *)"struct", 1, + buffer_read_struct_kernel_code, + struct_kernel_name, foo); } // end test_buffer_map_struct_read() diff --git a/test_conformance/buffers/test_buffer_mem.cpp b/test_conformance/buffers/test_buffer_mem.cpp index 52eb7235..080569a1 100644 --- a/test_conformance/buffers/test_buffer_mem.cpp +++ b/test_conformance/buffers/test_buffer_mem.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #ifndef uchar typedef unsigned char uchar; @@ -66,9 +66,9 @@ static int verify_mem( int *outptr, int n ) } -int test_mem_flags(cl_context context, cl_command_queue queue, int num_elements, - cl_mem_flags flags, const char **kernel_program, - const char *kernel_name) +static int test_mem_flags(cl_context context, cl_command_queue queue, + int num_elements, cl_mem_flags flags, + const char **kernel_program, const char *kernel_name) { clMemWrapper buffers[2]; cl_int *inptr, *outptr; @@ -205,38 +205,35 @@ int test_mem_flags(cl_context context, cl_command_queue queue, int num_elements, return err; } // end test_mem_flags() -int test_mem_read_write_flags(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(mem_read_write_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_READ_WRITE, &mem_read_write_kernel_code, "test_mem_read_write"); } -int test_mem_write_only_flags(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(mem_write_only_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_WRITE_ONLY, &mem_write_kernel_code, "test_mem_write"); } -int test_mem_read_only_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(mem_read_only_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_READ_ONLY, &mem_read_kernel_code, "test_mem_read"); } -int test_mem_copy_host_flags( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(mem_copy_host_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_COPY_HOST_PTR | CL_MEM_READ_WRITE, &mem_read_write_kernel_code, "test_mem_read_write"); } -int test_mem_alloc_ref_flags(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(mem_alloc_ref_flags) { return test_mem_flags(context, queue, num_elements, CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, diff --git a/test_conformance/buffers/test_buffer_migrate.cpp b/test_conformance/buffers/test_buffer_migrate.cpp index 6cdc271b..7ad90668 100644 --- a/test_conformance/buffers/test_buffer_migrate.cpp +++ b/test_conformance/buffers/test_buffer_migrate.cpp @@ -16,7 +16,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" #include "harness/testHarness.h" @@ -96,7 +96,7 @@ static cl_int restoreBuffer(cl_command_queue *queues, cl_mem *buffers, cl_uint n return CL_SUCCESS; } -int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_migrate) { int failed = 0; cl_uint i, j; @@ -119,9 +119,12 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu const size_t wgs[1] = {BUFFER_SIZE}; /* Allocate arrays whose size varies according to the maximum number of sub-devices */ - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(max_sub_devices), &max_sub_devices, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(max_sub_devices), &max_sub_devices, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); + return -1; } if (max_sub_devices < 1) { log_error("ERROR: Invalid number of compute units returned.\n"); @@ -156,9 +159,12 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu } // Attempt to partition the device along each of the allowed affinity domain. - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(domains), &domains, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, + sizeof(domains), &domains, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); + return -1; } domains &= (CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE | CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE | @@ -175,7 +181,9 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu // Determine the number of partitions for the device given the specific domain. if (domain) { property[1] = domain; - err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, -1, NULL, &num_devices); + err = clCreateSubDevices(device, + (const cl_device_partition_property *)property, + -1, NULL, &num_devices); if ((err != CL_SUCCESS) || (num_devices == 0)) { print_error(err, "Obtaining the number of partions by affinity failed."); failed = 1; @@ -187,10 +195,14 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu if (num_devices > 1) { // Create each of the sub-devices and a corresponding context. - if ((err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, num_devices, devices, &num_devices)) != CL_SUCCESS) { - print_error(err, "Failed creating sub devices."); - failed = 1; - goto cleanup; + if ((err = clCreateSubDevices( + device, (const cl_device_partition_property *)property, + num_devices, devices, &num_devices)) + != CL_SUCCESS) + { + print_error(err, "Failed creating sub devices."); + failed = 1; + goto cleanup; } // Create a context containing all the sub-devices @@ -213,7 +225,7 @@ int test_buffer_migrate(cl_device_id deviceID, cl_context context, cl_command_qu } } else { // No partitioning available. Just exercise the APIs on a single device. - devices[0] = deviceID; + devices[0] = device; queues[0] = queue; ctx = context; } diff --git a/test_conformance/buffers/test_buffer_read.cpp b/test_conformance/buffers/test_buffer_read.cpp index 28317880..dbf39ab4 100644 --- a/test_conformance/buffers/test_buffer_read.cpp +++ b/test_conformance/buffers/test_buffer_read.cpp @@ -23,7 +23,7 @@ #include #include -#include "procs.h" +#include "testBase.h" //#define HK_DO_NOT_RUN_SHORT_ASYNC 1 //#define HK_DO_NOT_RUN_USHORT_ASYNC 1 @@ -618,8 +618,11 @@ static int verify_read_struct(TestStruct *outptr, int n) } //----- the test functions -int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) ) +static int test_buffer_read(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, int)) { void *outptr[5]; void *inptr[5]; @@ -758,8 +761,12 @@ int test_buffer_read( cl_device_id deviceID, cl_context context, cl_command_queu } // end test_buffer_read() -int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) ) +static int test_buffer_read_async(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, + const char *kernelCode[], + const char *kernelName[], + int (*fn)(void *, int)) { clProgramWrapper program[5]; clKernelWrapper kernel[5]; @@ -894,8 +901,10 @@ int test_buffer_read_async( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_read_array_async() -int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - const char *kernelCode[], const char *kernelName[], int (*fn)(void *,int) ) +static int test_buffer_read_array_barrier( + cl_device_id deviceID, cl_context context, cl_command_queue queue, + int num_elements, size_t size, char *type, int loops, + const char *kernelCode[], const char *kernelName[], int (*fn)(void *, int)) { clProgramWrapper program[5]; clKernelWrapper kernel[5]; @@ -1033,12 +1042,14 @@ int test_buffer_read_array_barrier( cl_device_id deviceID, cl_context context, c } // end test_buffer_read_array_barrier() -#define DECLARE_READ_TEST(type, realType) \ -int test_buffer_read_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_read( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_READ_TEST(type, realType) \ + REGISTER_TEST(buffer_read_##type) \ + { \ + return test_buffer_read(device, context, queue, num_elements, \ + sizeof(realType), (char *)#type, 5, \ + buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_READ_TEST(int, cl_int) DECLARE_READ_TEST(uint, cl_uint) @@ -1050,21 +1061,24 @@ DECLARE_READ_TEST(float, cl_float) DECLARE_READ_TEST(char, cl_char) DECLARE_READ_TEST(uchar, cl_uchar) -int test_buffer_read_half(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_read_half) { - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID) - return test_buffer_read( deviceID, context, queue, num_elements, sizeof( cl_float ) / 2, (char*)"half", 5, - buffer_read_half_kernel_code, half_kernel_name, verify_read_half ); + PASSIVE_REQUIRE_FP16_SUPPORT(device) + return test_buffer_read(device, context, queue, num_elements, + sizeof(cl_float) / 2, (char *)"half", 5, + buffer_read_half_kernel_code, half_kernel_name, + verify_read_half); } -#define DECLARE_ASYNC_TEST(type, realType) \ -int test_buffer_read_async_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_read_async( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_ASYNC_TEST(type, realType) \ + REGISTER_TEST(buffer_read_async_##type) \ + { \ + return test_buffer_read_async(device, context, queue, num_elements, \ + sizeof(realType), (char *)#type, 5, \ + buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_ASYNC_TEST(char, cl_char) DECLARE_ASYNC_TEST(uchar, cl_uchar) @@ -1077,12 +1091,14 @@ DECLARE_ASYNC_TEST(ulong, cl_ulong) DECLARE_ASYNC_TEST(float, cl_float) -#define DECLARE_BARRIER_TEST(type, realType) \ -int test_buffer_read_array_barrier_##type( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) \ -{ \ -return test_buffer_read_array_barrier( deviceID, context, queue, num_elements, sizeof( realType ), (char*)#type, 5, \ -buffer_read_##type##_kernel_code, type##_kernel_name, verify_read_##type ); \ -} +#define DECLARE_BARRIER_TEST(type, realType) \ + REGISTER_TEST(buffer_read_array_barrier_##type) \ + { \ + return test_buffer_read_array_barrier( \ + device, context, queue, num_elements, sizeof(realType), \ + (char *)#type, 5, buffer_read_##type##_kernel_code, \ + type##_kernel_name, verify_read_##type); \ + } DECLARE_BARRIER_TEST(int, cl_int) DECLARE_BARRIER_TEST(uint, cl_uint) @@ -1094,7 +1110,7 @@ DECLARE_BARRIER_TEST(char, cl_char) DECLARE_BARRIER_TEST(uchar, cl_uchar) DECLARE_BARRIER_TEST(float, cl_float) -int test_buffer_read_struct(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_read_struct) { cl_mem buffers[1]; TestStruct *output_ptr; @@ -1305,7 +1321,7 @@ static int testRandomReadSize( cl_device_id deviceID, cl_context context, cl_com } // end testRandomReadSize() -int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_read_random_size) { int err = 0; int i; @@ -1317,7 +1333,8 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c for ( i = 0; i < 8; i++ ){ start = (cl_uint)get_random_float( 0.f, (float)(num_elements - 8), d ); size = (size_t)get_random_float( 8.f, (float)(num_elements - start), d ); - if (testRandomReadSize( deviceID, context, queue, num_elements, start, size )) + if (testRandomReadSize(device, context, queue, num_elements, start, + size)) err++; } @@ -1325,4 +1342,3 @@ int test_buffer_read_random_size(cl_device_id deviceID, cl_context context, cl_c return err; } - diff --git a/test_conformance/buffers/test_buffer_write.cpp b/test_conformance/buffers/test_buffer_write.cpp index bf41e48c..36dcc963 100644 --- a/test_conformance/buffers/test_buffer_write.cpp +++ b/test_conformance/buffers/test_buffer_write.cpp @@ -21,7 +21,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" @@ -621,8 +621,11 @@ static int verify_write_struct( void *ptr1, void *ptr2, int n ) } -int test_buffer_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - void *inptr[5], const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int), MTdata d ) +static int test_buffer_write(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements, + size_t size, char *type, int loops, void *inptr[5], + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, void *, int), MTdata d) { void *outptr[5]; clProgramWrapper program[5]; @@ -787,9 +790,7 @@ int test_buffer_write( cl_device_id deviceID, cl_context context, cl_command_que } // end test_buffer_write() - - -int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_struct) { void *outptr[5]; @@ -966,8 +967,11 @@ int test_buffer_write_struct( cl_device_id deviceID, cl_context context, cl_comm } // end test_buffer_struct_write() -int test_buffer_write_array_async( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, size_t size, char *type, int loops, - void *inptr[5], const char *kernelCode[], const char *kernelName[], int (*fn)(void *,void *,int) ) +static int test_buffer_write_array_async( + cl_device_id deviceID, cl_context context, cl_command_queue queue, + int num_elements, size_t size, char *type, int loops, void *inptr[5], + const char *kernelCode[], const char *kernelName[], + int (*fn)(void *, void *, int)) { cl_mem buffers[10]; void *outptr[5]; @@ -1098,7 +1102,7 @@ int test_buffer_write_array_async( cl_device_id deviceID, cl_context context, cl } // end test_buffer_write_array_async() -int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_int) { int *inptr[5]; size_t ptrSizes[5]; @@ -1124,8 +1128,9 @@ int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command inptr[i][j] = (int)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - buffer_write_int_kernel_code, int_kernel_name, foo, d ); + err = test_buffer_write( + device, context, queue, num_elements, sizeof(cl_int), (char *)"int", 5, + (void **)inptr, buffer_write_int_kernel_code, int_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1137,7 +1142,7 @@ int test_buffer_write_int( cl_device_id deviceID, cl_context context, cl_command } // end test_buffer_int_write() -int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_uint) { cl_uint *inptr[5]; size_t ptrSizes[5]; @@ -1163,8 +1168,10 @@ int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - buffer_write_uint_kernel_code, uint_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_uint), (char *)"uint", 5, (void **)inptr, + buffer_write_uint_kernel_code, uint_kernel_name, + foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1176,7 +1183,7 @@ int test_buffer_write_uint( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_uint_write() -int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_short) { short *inptr[5]; size_t ptrSizes[5]; @@ -1202,8 +1209,10 @@ int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = (cl_short)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - buffer_write_short_kernel_code, short_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_short), (char *)"short", 5, + (void **)inptr, buffer_write_short_kernel_code, + short_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1216,7 +1225,7 @@ int test_buffer_write_short( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_short_write() -int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_ushort) { cl_ushort *inptr[5]; size_t ptrSizes[5]; @@ -1242,8 +1251,10 @@ int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_comm inptr[i][j] = (cl_ushort)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - buffer_write_ushort_kernel_code, ushort_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_ushort), (char *)"ushort", 5, + (void **)inptr, buffer_write_ushort_kernel_code, + ushort_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1256,7 +1267,7 @@ int test_buffer_write_ushort( cl_device_id deviceID, cl_context context, cl_comm } // end test_buffer_ushort_write() -int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_char) { char *inptr[5]; size_t ptrSizes[5]; @@ -1282,8 +1293,10 @@ int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = (char)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - buffer_write_char_kernel_code, char_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_char), (char *)"char", 5, (void **)inptr, + buffer_write_char_kernel_code, char_kernel_name, + foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1296,7 +1309,7 @@ int test_buffer_write_char( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_char_write() -int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_uchar) { uchar *inptr[5]; size_t ptrSizes[5]; @@ -1322,8 +1335,10 @@ int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = (uchar)genrand_int32(d); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - buffer_write_uchar_kernel_code, uchar_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_uchar), (char *)"uchar", 5, + (void **)inptr, buffer_write_uchar_kernel_code, + uchar_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1336,7 +1351,7 @@ int test_buffer_write_uchar( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_uchar_write() -int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_float) { float *inptr[5]; size_t ptrSizes[5]; @@ -1362,8 +1377,10 @@ int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d ); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - buffer_write_float_kernel_code, float_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_float), (char *)"float", 5, + (void **)inptr, buffer_write_float_kernel_code, + float_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1375,9 +1392,9 @@ int test_buffer_write_float( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_float_write() -int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_half) { - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID) + PASSIVE_REQUIRE_FP16_SUPPORT(device) float *inptr[5]; size_t ptrSizes[5]; int i, err; @@ -1402,7 +1419,7 @@ int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d ); } - err = test_buffer_write(deviceID, context, queue, num_elements, + err = test_buffer_write(device, context, queue, num_elements, sizeof(cl_half), (char *)"half", 5, (void **)inptr, buffer_write_half_kernel_code, half_kernel_name, foo, d); @@ -1417,7 +1434,7 @@ int test_buffer_write_half( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_half_write() -int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_long) { cl_long *inptr[5]; size_t ptrSizes[5]; @@ -1450,8 +1467,10 @@ int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_comman inptr[i][j] = (cl_long) genrand_int32(d) ^ ((cl_long) genrand_int32(d) << 32); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"cl_long", 5, (void**)inptr, - buffer_write_long_kernel_code, long_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_long), (char *)"cl_long", 5, + (void **)inptr, buffer_write_long_kernel_code, + long_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1463,7 +1482,7 @@ int test_buffer_write_long( cl_device_id deviceID, cl_context context, cl_comman } // end test_buffer_long_write() -int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_ulong) { cl_ulong *inptr[5]; size_t ptrSizes[5]; @@ -1495,8 +1514,10 @@ int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_comma inptr[i][j] = (cl_ulong) genrand_int32(d) | ((cl_ulong) genrand_int32(d) << 32); } - err = test_buffer_write( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong long", 5, (void**)inptr, - buffer_write_ulong_kernel_code, ulong_kernel_name, foo, d ); + err = test_buffer_write(device, context, queue, num_elements, + sizeof(cl_ulong), (char *)"ulong long", 5, + (void **)inptr, buffer_write_ulong_kernel_code, + ulong_kernel_name, foo, d); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1509,68 +1530,68 @@ int test_buffer_write_ulong( cl_device_id deviceID, cl_context context, cl_comma } // end test_buffer_ulong_write() -int test_buffer_map_write_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_int) { gTestMap = 1; - return test_buffer_write_int(deviceID, context, queue, num_elements); + return test_buffer_write_int(device, context, queue, num_elements); } -int test_buffer_map_write_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_uint) { gTestMap = 1; - return test_buffer_write_uint(deviceID, context, queue, num_elements); + return test_buffer_write_uint(device, context, queue, num_elements); } -int test_buffer_map_write_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_long) { gTestMap = 1; - return test_buffer_write_long(deviceID, context, queue, num_elements); + return test_buffer_write_long(device, context, queue, num_elements); } -int test_buffer_map_write_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_ulong) { gTestMap = 1; - return test_buffer_write_ulong(deviceID, context, queue, num_elements); + return test_buffer_write_ulong(device, context, queue, num_elements); } -int test_buffer_map_write_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_short) { gTestMap = 1; - return test_buffer_write_short(deviceID, context, queue, num_elements); + return test_buffer_write_short(device, context, queue, num_elements); } -int test_buffer_map_write_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_ushort) { gTestMap = 1; - return test_buffer_write_ushort(deviceID, context, queue, num_elements); + return test_buffer_write_ushort(device, context, queue, num_elements); } -int test_buffer_map_write_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_char) { gTestMap = 1; - return test_buffer_write_char(deviceID, context, queue, num_elements); + return test_buffer_write_char(device, context, queue, num_elements); } -int test_buffer_map_write_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_uchar) { gTestMap = 1; - return test_buffer_write_uchar(deviceID, context, queue, num_elements); + return test_buffer_write_uchar(device, context, queue, num_elements); } -int test_buffer_map_write_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_float) { gTestMap = 1; - return test_buffer_write_float(deviceID, context, queue, num_elements); + return test_buffer_write_float(device, context, queue, num_elements); } -int test_buffer_map_write_struct( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_map_write_struct) { gTestMap = 1; - return test_buffer_write_struct(deviceID, context, queue, num_elements); + return test_buffer_write_struct(device, context, queue, num_elements); } -int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_int) { int *inptr[5]; size_t ptrSizes[5]; @@ -1596,8 +1617,9 @@ int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_c inptr[i][j] = (int)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_int ), (char*)"int", 5, (void**)inptr, - buffer_write_int_kernel_code, int_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_int), (char *)"int", 5, + (void **)inptr, buffer_write_int_kernel_code, int_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1609,7 +1631,7 @@ int test_buffer_write_async_int( cl_device_id deviceID, cl_context context, cl_c } // end test_buffer_int_write_array_async() -int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_uint) { cl_uint *inptr[5]; size_t ptrSizes[5]; @@ -1635,8 +1657,10 @@ int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_ inptr[i][j] = (cl_uint)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_uint ), (char*)"uint", 5, (void**)inptr, - buffer_write_uint_kernel_code, uint_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_uint), (char *)"uint", + 5, (void **)inptr, buffer_write_uint_kernel_code, uint_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1648,7 +1672,7 @@ int test_buffer_write_async_uint( cl_device_id deviceID, cl_context context, cl_ } // end test_buffer_uint_write_array_async() -int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_short) { short *inptr[5]; size_t ptrSizes[5]; @@ -1674,8 +1698,10 @@ int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl inptr[i][j] = (short)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_short ), (char*)"short", 5, (void**)inptr, - buffer_write_short_kernel_code, short_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_short), (char *)"short", + 5, (void **)inptr, buffer_write_short_kernel_code, short_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1688,7 +1714,7 @@ int test_buffer_write_async_short( cl_device_id deviceID, cl_context context, cl } // end test_buffer_short_write_array_async() -int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_ushort) { cl_ushort *inptr[5]; size_t ptrSizes[5]; @@ -1714,8 +1740,10 @@ int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, c inptr[i][j] = (cl_ushort)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_ushort ), (char*)"ushort", 5, (void**)inptr, - buffer_write_ushort_kernel_code, ushort_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_ushort), + (char *)"ushort", 5, (void **)inptr, buffer_write_ushort_kernel_code, + ushort_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1728,7 +1756,7 @@ int test_buffer_write_async_ushort( cl_device_id deviceID, cl_context context, c } // end test_buffer_ushort_write_array_async() -int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_char) { char *inptr[5]; size_t ptrSizes[5]; @@ -1754,8 +1782,10 @@ int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_ inptr[i][j] = (char)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_char ), (char*)"char", 5, (void**)inptr, - buffer_write_char_kernel_code, char_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_char), (char *)"char", + 5, (void **)inptr, buffer_write_char_kernel_code, char_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1768,7 +1798,7 @@ int test_buffer_write_async_char( cl_device_id deviceID, cl_context context, cl_ } // end test_buffer_char_write_array_async() -int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_uchar) { uchar *inptr[5]; size_t ptrSizes[5]; @@ -1794,8 +1824,10 @@ int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl inptr[i][j] = (uchar)genrand_int32(d); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_uchar ), (char*)"uchar", 5, (void**)inptr, - buffer_write_uchar_kernel_code, uchar_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_uchar), (char *)"uchar", + 5, (void **)inptr, buffer_write_uchar_kernel_code, uchar_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1808,7 +1840,7 @@ int test_buffer_write_async_uchar( cl_device_id deviceID, cl_context context, cl } // end test_buffer_uchar_write_array_async() -int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_float) { float *inptr[5]; size_t ptrSizes[5]; @@ -1834,8 +1866,10 @@ int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d ); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_float ), (char*)"float", 5, (void**)inptr, - buffer_write_float_kernel_code, float_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_float), (char *)"float", + 5, (void **)inptr, buffer_write_float_kernel_code, float_kernel_name, + foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1847,7 +1881,7 @@ int test_buffer_write_async_float( cl_device_id deviceID, cl_context context, cl } // end test_buffer_float_write_array_async() -int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_long) { cl_long *inptr[5]; size_t ptrSizes[5]; @@ -1879,8 +1913,10 @@ int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_ inptr[i][j] = ((cl_long) genrand_int32(d)) ^ ((cl_long) genrand_int32(d) << 32); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_long ), (char*)"cl_long", 5, (void**)inptr, - buffer_write_long_kernel_code, long_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_long), + (char *)"cl_long", 5, (void **)inptr, buffer_write_long_kernel_code, + long_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); @@ -1892,7 +1928,7 @@ int test_buffer_write_async_long( cl_device_id deviceID, cl_context context, cl_ } // end test_buffer_long_write_array_async() -int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(buffer_write_async_ulong) { cl_ulong *inptr[5]; size_t ptrSizes[5]; @@ -1924,8 +1960,10 @@ int test_buffer_write_async_ulong( cl_device_id deviceID, cl_context context, cl inptr[i][j] = (cl_ulong) genrand_int32(d) | ((cl_ulong) genrand_int32(d) << 32); } - err = test_buffer_write_array_async( deviceID, context, queue, num_elements, sizeof( cl_ulong ), (char*)"ulong long", 5, (void**)inptr, - buffer_write_ulong_kernel_code, ulong_kernel_name, foo ); + err = test_buffer_write_array_async( + device, context, queue, num_elements, sizeof(cl_ulong), + (char *)"ulong long", 5, (void **)inptr, buffer_write_ulong_kernel_code, + ulong_kernel_name, foo); for ( i = 0; i < 5; i++ ){ align_free( (void *)inptr[i] ); diff --git a/test_conformance/buffers/test_image_migrate.cpp b/test_conformance/buffers/test_image_migrate.cpp index 6c8acdce..2f232b8c 100644 --- a/test_conformance/buffers/test_image_migrate.cpp +++ b/test_conformance/buffers/test_image_migrate.cpp @@ -16,7 +16,7 @@ #include #include -#include "procs.h" +#include "testBase.h" #include "harness/errorHelpers.h" #define MAX_SUB_DEVICES 16 // Limit the sub-devices to ensure no out of resource errors. @@ -113,7 +113,7 @@ static cl_int restoreImage(cl_command_queue *queues, cl_mem *mem_objects, cl_uin return CL_SUCCESS; } -int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(image_migrate) { int failed = 0; cl_uint i, j; @@ -139,15 +139,19 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que const size_t wls[2] = {1, 1}; // Check for image support. - if(checkForImageSupport(deviceID) == CL_IMAGE_FORMAT_NOT_SUPPORTED) { - log_info("Device does not support images. Skipping test.\n"); - return 0; + if (checkForImageSupport(device) == CL_IMAGE_FORMAT_NOT_SUPPORTED) + { + log_info("Device does not support images. Skipping test.\n"); + return 0; } // Allocate arrays whose size varies according to the maximum number of sub-devices. - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(max_sub_devices), &max_sub_devices, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(max_sub_devices), &max_sub_devices, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_DEVICE_MAX_COMPUTE_UNITS) failed"); + return -1; } if (max_sub_devices < 1) { log_error("ERROR: Invalid number of compute units returned.\n"); @@ -188,9 +192,12 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que // Attempt to partition the device along each of the allowed affinity domain. - if ((err = clGetDeviceInfo(deviceID, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, sizeof(domains), &domains, NULL)) != CL_SUCCESS) { - print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); - return -1; + if ((err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, + sizeof(domains), &domains, NULL)) + != CL_SUCCESS) + { + print_error(err, "clGetDeviceInfo(CL_PARTITION_AFFINITY_DOMAIN) failed"); + return -1; } domains &= (CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE | CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE | @@ -207,7 +214,9 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que // Determine the number of partitions for the device given the specific domain. if (domain) { property[1] = domain; - err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, -1, NULL, &num_devices); + err = clCreateSubDevices(device, + (const cl_device_partition_property *)property, + -1, NULL, &num_devices); if ((err != CL_SUCCESS) || (num_devices == 0)) { print_error(err, "Obtaining the number of partions by affinity failed."); failed = 1; @@ -219,10 +228,14 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que if (num_devices > 1) { // Create each of the sub-devices and a corresponding context. - if ((err = clCreateSubDevices(deviceID, (const cl_device_partition_property *)property, num_devices, devices, &num_devices)) != CL_SUCCESS) { - print_error(err, "Failed creating sub devices."); - failed = 1; - goto cleanup; + if ((err = clCreateSubDevices( + device, (const cl_device_partition_property *)property, + num_devices, devices, &num_devices)) + != CL_SUCCESS) + { + print_error(err, "Failed creating sub devices."); + failed = 1; + goto cleanup; } // Create a context containing all the sub-devices @@ -245,7 +258,7 @@ int test_image_migrate(cl_device_id deviceID, cl_context context, cl_command_que } } else { // No partitioning available. Just exercise the APIs on a single device. - devices[0] = deviceID; + devices[0] = device; queues[0] = queue; ctx = context; } diff --git a/test_conformance/buffers/test_sub_buffers.cpp b/test_conformance/buffers/test_sub_buffers.cpp index 7b0a3ccd..5cf404f8 100644 --- a/test_conformance/buffers/test_sub_buffers.cpp +++ b/test_conformance/buffers/test_sub_buffers.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 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 @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "procs.h" +#include "testBase.h" #include #include @@ -232,7 +232,11 @@ size_t find_subbuffer_by_index( SubBufferWrapper * subBuffers, size_t numSubBuff // This tests the read/write capabilities of sub buffers (if we are read/write, the sub buffers // can't overlap) -int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queueA, cl_command_queue queueB, size_t mainSize, size_t addressAlign ) +static int test_sub_buffers_read_write_core(cl_context context, + cl_command_queue queueA, + cl_command_queue queueB, + size_t mainSize, + size_t addressAlign) { clMemWrapper mainBuffer; SubBufferWrapper subBuffers[ 8 ]; @@ -380,18 +384,19 @@ int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queue return numErrors; } -int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(sub_buffers_read_write) { cl_int error; size_t mainSize; cl_uint addressAlignBits; // Get the size of the main buffer to use - error = get_reasonable_buffer_size( deviceID, mainSize ); + error = get_reasonable_buffer_size(device, mainSize); test_error( error, "Unable to get reasonable buffer size" ); // Determine the alignment of the device so we can make sure sub buffers are valid - error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlignBits ), &addressAlignBits, NULL ); + error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, + sizeof(addressAlignBits), &addressAlignBits, NULL); test_error( error, "Unable to get device's address alignment" ); size_t addressAlign = addressAlignBits/8; @@ -402,19 +407,19 @@ int test_sub_buffers_read_write( cl_device_id deviceID, cl_context context, cl_c // This test performs the same basic operations as sub_buffers_read_write, but instead of a single // device, it creates a context and buffer shared between two devices, then executes commands // on queues for each device to ensure that everything still operates as expected. -int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(sub_buffers_read_write_dual_devices) { cl_int error; // First obtain the second device - cl_device_id otherDevice = GetOpposingDevice( deviceID ); + cl_device_id otherDevice = GetOpposingDevice(device); if ( otherDevice == NULL ) { log_error( "ERROR: Unable to obtain a second device for sub-buffer dual-device test.\n" ); return -1; } - if ( otherDevice == deviceID ) + if (otherDevice == device) { log_info( "Note: Unable to run dual-device sub-buffer test (only one device available). Skipping test (implicitly passing).\n" ); return 0; @@ -433,12 +438,13 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context device_name.data()); // Create a shared context for these two devices - cl_device_id devices[ 2 ] = { deviceID, otherDevice }; + cl_device_id devices[2] = { device, otherDevice }; clContextWrapper testingContext = clCreateContext( NULL, 2, devices, NULL, NULL, &error ); test_error( error, "Unable to create shared context" ); // Create two queues (can't use the existing one, because it's on the wrong context) - clCommandQueueWrapper queue1 = clCreateCommandQueue( testingContext, deviceID, 0, &error ); + clCommandQueueWrapper queue1 = + clCreateCommandQueue(testingContext, device, 0, &error); test_error( error, "Unable to create command queue on main device" ); clCommandQueueWrapper queue2 = clCreateCommandQueue( testingContext, otherDevice, 0, &error ); @@ -446,7 +452,7 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context // Determine the reasonable buffer size and address alignment that applies to BOTH devices size_t maxBuffer1, maxBuffer2; - error = get_reasonable_buffer_size( deviceID, maxBuffer1 ); + error = get_reasonable_buffer_size(device, maxBuffer1); test_error( error, "Unable to get buffer size for main device" ); error = get_reasonable_buffer_size( otherDevice, maxBuffer2 ); @@ -454,7 +460,9 @@ int test_sub_buffers_read_write_dual_devices( cl_device_id deviceID, cl_context maxBuffer1 = std::min(maxBuffer1, maxBuffer2); cl_uint addressAlign1Bits, addressAlign2Bits; - error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign1Bits ), &addressAlign1Bits, NULL ); + error = + clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, + sizeof(addressAlign1Bits), &addressAlign1Bits, NULL); test_error( error, "Unable to get main device's address alignment" ); error = clGetDeviceInfo( otherDevice, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign2Bits ), &addressAlign2Bits, NULL ); @@ -503,7 +511,7 @@ cl_int read_buffer_via_kernel( cl_context context, cl_command_queue queue, cl_me } -int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(sub_buffers_overlapping) { cl_int error; size_t mainSize; @@ -514,14 +522,15 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_ // Create the main buffer to test against - error = get_reasonable_buffer_size( deviceID, mainSize ); + error = get_reasonable_buffer_size(device, mainSize); test_error( error, "Unable to get reasonable buffer size" ); mainBuffer = clCreateBuffer( context, CL_MEM_READ_WRITE, mainSize, NULL, &error ); test_error( error, "Unable to create test main buffer" ); // Determine the alignment of the device so we can make sure sub buffers are valid - error = clGetDeviceInfo( deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof( addressAlign ), &addressAlign, NULL ); + error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, + sizeof(addressAlign), &addressAlign, NULL); test_error( error, "Unable to get device's address alignment" ); // Create some sub-buffers to use. Note: they don't have to not overlap (we actually *want* them to overlap) @@ -638,4 +647,3 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_ return numErrors; } -