From 56d383b2e9e9bacfcbfebe62462cf282a64b4ee4 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 10 Dec 2024 18:13:58 +0100 Subject: [PATCH 01/39] Fix more Wformat warnings related to size_t (#2166) Printing of a `size_t` requires the `%zu` specifier. This fixes occurrences where the previous wrong specifier appears to work in a typical 64-bit build, but causes a Wformat warning in 32-bit builds. --------- Signed-off-by: Sven van Haastregt --- test_conformance/buffers/test_sub_buffers.cpp | 24 ++- .../compiler/test_build_helpers.cpp | 6 +- test_conformance/compiler/test_compile.cpp | 16 +- .../contractions/contractions.cpp | 164 ++++++++++++++---- .../conversions/test_conversions.cpp | 2 +- .../test_device_partition.cpp | 19 +- .../images/clCopyImage/test_copy_generic.cpp | 15 +- .../images/clFillImage/test_fill_generic.cpp | 9 +- .../images/kernel_read_write/test_common.h | 12 +- .../kernel_read_write/test_iterations.cpp | 11 +- .../kernel_read_write/test_write_1D.cpp | 36 +++- .../kernel_read_write/test_write_1D_array.cpp | 36 +++- .../kernel_read_write/test_write_2D_array.cpp | 44 ++++- .../kernel_read_write/test_write_3D.cpp | 43 ++++- .../kernel_read_write/test_write_image.cpp | 36 +++- .../test_multiple_contexts.cpp | 23 ++- .../test_multiple_devices.cpp | 38 ++-- 17 files changed, 388 insertions(+), 146 deletions(-) diff --git a/test_conformance/buffers/test_sub_buffers.cpp b/test_conformance/buffers/test_sub_buffers.cpp index f1f07f84a3..7b0a3ccd07 100644 --- a/test_conformance/buffers/test_sub_buffers.cpp +++ b/test_conformance/buffers/test_sub_buffers.cpp @@ -344,16 +344,26 @@ int test_sub_buffers_read_write_core( cl_context context, cl_command_queue queue size_t sbThatFailed = find_subbuffer_by_index( subBuffers, numSubBuffers, i + j ); if ( sbThatFailed == numSubBuffers ) { - log_error( "ERROR: Validation failure outside of a sub-buffer! (Shouldn't be possible, but it happened at index %ld out of %ld...)\n", i + j, mainSize ); + log_error("ERROR: Validation failure outside of a " + "sub-buffer! (Shouldn't be possible, but it " + "happened at index %zu out of %zu...)\n", + i + j, mainSize); // Since this is a nonsensical, don't bother continuing to check // (we will, however, print our map of sub-buffers for comparison) for ( size_t k = 0; k < numSubBuffers; k++ ) { - log_error( "\tBuffer %ld: %ld to %ld (length %ld)\n", k, subBuffers[ k ].mOrigin, subBuffers[ k ].mOrigin + subBuffers[ k ].mSize, subBuffers[ k ].mSize ); + log_error("\tBuffer %zu: %zu to %zu (length %zu)\n", + k, subBuffers[k].mOrigin, + subBuffers[k].mOrigin + + subBuffers[k].mSize, + subBuffers[k].mSize); } return -1; } - log_error( "ERROR: Validation failure on sub-buffer %ld (start: %ld, length: %ld)\n", sbThatFailed, subBuffers[ sbThatFailed ].mOrigin, subBuffers[ sbThatFailed ].mSize ); + log_error("ERROR: Validation failure on sub-buffer %zu " + "(start: %zu, length: %zu)\n", + sbThatFailed, subBuffers[sbThatFailed].mOrigin, + subBuffers[sbThatFailed].mSize); size_t newPos = subBuffers[ sbThatFailed ].mOrigin + subBuffers[ sbThatFailed ].mSize - 1; i = newPos & ~65535; j = newPos - i; @@ -589,8 +599,10 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_ } } - log_info( "\tTesting %d sub-buffers with %lld overlapping Kbytes (%d%%; as many as %ld buffers overlapping at once)\n", - 16, ( delta / 1024LL ), (int)( delta * 100LL / (long long)mainSize ), maxOverlap ); + log_info("\tTesting %d sub-buffers with %lld overlapping Kbytes (%d%%; as " + "many as %zu buffers overlapping at once)\n", + 16, (delta / 1024LL), (int)(delta * 100LL / (long long)mainSize), + maxOverlap); // Write some random contents to the main buffer cl_char * contents = new cl_char[ mainSize ]; @@ -615,7 +627,7 @@ int test_sub_buffers_overlapping( cl_device_id deviceID, cl_context context, cl_ if ( memcmp( tempBuffer, contents + subBuffers[ i ].mOrigin, subBuffers[ i ].mSize ) != 0 ) { - log_error( "ERROR: Validation for sub-buffer %ld failed!\n", i ); + log_error("ERROR: Validation for sub-buffer %zu failed!\n", i); numErrors++; } } diff --git a/test_conformance/compiler/test_build_helpers.cpp b/test_conformance/compiler/test_build_helpers.cpp index c5ebb80707..72e11e735c 100644 --- a/test_conformance/compiler/test_build_helpers.cpp +++ b/test_conformance/compiler/test_build_helpers.cpp @@ -84,8 +84,8 @@ int test_load_program_source(cl_device_id deviceID, cl_context context, cl_comma // Note: according to spec section 5.4.5, the length returned should include the null terminator if (length != line_length + 1) { - log_error("ERROR: Length of program (%ld) does not match reference " - "length (%ld)!\n", + log_error("ERROR: Length of program (%zu) does not match reference " + "length (%zu)!\n", length, line_length + 1); return -1; } @@ -520,7 +520,7 @@ int test_get_program_build_info(cl_device_id deviceID, cl_context context, cl_co error = clGetProgramBuildInfo( program, deviceID, CL_PROGRAM_BUILD_LOG, 0, NULL, &length ); test_error( error, "Unable to get program build log length" ); - log_info("Build log is %ld long.\n", length); + log_info("Build log is %zu long.\n", length); buffer = (char*)malloc(length); diff --git a/test_conformance/compiler/test_compile.cpp b/test_conformance/compiler/test_compile.cpp index 3af8125a80..0ca37b3f27 100644 --- a/test_conformance/compiler/test_compile.cpp +++ b/test_conformance/compiler/test_compile.cpp @@ -1999,14 +1999,14 @@ static int verifyCopyBuffer(cl_context context, cl_command_queue queue, if (srcBuffer == NULL) { - log_error("ERROR: Unable to allocate srcBuffer float array with %lu " + log_error("ERROR: Unable to allocate srcBuffer float array with %zu " "floats! (in %s:%d)\n", cnDimension, __FILE__, __LINE__); return -1; } if (dstBuffer == NULL) { - log_error("ERROR: Unable to allocate dstBuffer float array with %lu " + log_error("ERROR: Unable to allocate dstBuffer float array with %zu " "floats! (in %s:%d)\n", cnDimension, __FILE__, __LINE__); return -1; @@ -2067,7 +2067,7 @@ static int verifyCopyBuffer(cl_context context, cl_command_queue queue, { if (mismatch < 4) { - log_info("Offset %08lX: Expected %08X, Got %08X\n", i * 4, + log_info("Offset %08zX: Expected %08X, Got %08X\n", i * 4, pSrc[i], pDst[i]); } else @@ -2292,7 +2292,7 @@ int test_execute_after_serialize_reload_object(cl_device_id deviceID, binary = (unsigned char *)malloc(sizeof(unsigned char) * binarySize); if (binary == NULL) { - log_error("ERROR: Unable to allocate binary character array with %lu " + log_error("ERROR: Unable to allocate binary character array with %zu " "characters! (in %s:%d)\n", binarySize, __FILE__, __LINE__); return -1; @@ -2404,7 +2404,7 @@ int test_execute_after_serialize_reload_library(cl_device_id deviceID, binary = (unsigned char *)malloc(sizeof(unsigned char) * binarySize); if (binary == NULL) { - log_error("ERROR: Unable to allocate binary character array with %lu " + log_error("ERROR: Unable to allocate binary character array with %zu " "characters (in %s:%d)!", binarySize, __FILE__, __LINE__); return -1; @@ -3308,7 +3308,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, if (binary == NULL) { log_error("ERROR: Unable to allocate binary character array with " - "%lu characters! (in %s:%d)\n", + "%zu characters! (in %s:%d)\n", binarySize, __FILE__, __LINE__); return -1; } @@ -3389,7 +3389,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, binary = (unsigned char *)malloc(sizeof(unsigned char) * binarySize); if (binary == NULL) { - log_error("ERROR: Unable to allocate binary character array with %lu " + log_error("ERROR: Unable to allocate binary character array with %zu " "characters! (in %s:%d)\n", binarySize, __FILE__, __LINE__); return -1; @@ -3487,7 +3487,7 @@ int test_program_binary_type(cl_device_id deviceID, cl_context context, if (binary == NULL) { log_error("ERROR: Unable to allocate binary character array with " - "%lu characters! (in %s:%d)\n", + "%zu characters! (in %s:%d)\n", binarySize, __FILE__, __LINE__); return -1; } diff --git a/test_conformance/contractions/contractions.cpp b/test_conformance/contractions/contractions.cpp index 474fd3640e..880a23ab5d 100644 --- a/test_conformance/contractions/contractions.cpp +++ b/test_conformance/contractions/contractions.cpp @@ -976,7 +976,7 @@ static int RunTest( int testNumber ) for( i = 0; i < sizeof(args ) / sizeof( args[0]); i++ ) if( (error = clSetKernelArg(k, i, sizeof( cl_mem ), args + i) )) { - vlog_error( "Error %d setting kernel arg # %ld\n", error, i ); + vlog_error("Error %d setting kernel arg # %zu\n", error, i); return error; } @@ -1021,24 +1021,72 @@ static int RunTest( int testNumber ) switch( testNumber ) { // Zeros for these should be positive - case 0: vlog_error( "%ld) Error for %s %s: %a * %a + %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; - case 1: vlog_error( "%ld) Error for %s %s: %a * %a - %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; - case 2: vlog_error( "%ld) Error for %s %s: %a + %a * %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; - case 3: vlog_error( "%ld) Error for %s %s: %a - %a * %a = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; - - // Zeros for these should be negative - case 4: vlog_error( "%ld) Error for %s %s: -(%a * %a + %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; - case 5: vlog_error( "%ld) Error for %s %s: -(%a * %a - %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; - case 6: vlog_error( "%ld) Error for %s %s: -(%a + %a * %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; - case 7: vlog_error( "%ld) Error for %s %s: -(%a - %a * %a) = *%a vs. %a\n", i, sizeNames[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); clReleaseKernel(k); return -1; + case 0: + vlog_error("%zu) Error for %s %s: %a * %a + %a = *%a " + "vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; + case 1: + vlog_error("%zu) Error for %s %s: %a * %a - %a = *%a " + "vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; + case 2: + vlog_error("%zu) Error for %s %s: %a + %a * %a = *%a " + "vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; + case 3: + vlog_error("%zu) Error for %s %s: %a - %a * %a = *%a " + "vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; + + // Zeros for these shouzu be negative + case 4: + vlog_error("%zu) Error for %s %s: -(%a * %a + %a) = " + "*%a vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; + case 5: + vlog_error("%zu) Error for %s %s: -(%a * %a - %a) = " + "*%a vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; + case 6: + vlog_error("%zu) Error for %s %s: -(%a + %a * %a) = " + "*%a vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; + case 7: + vlog_error("%zu) Error for %s %s: -(%a - %a * %a) = " + "*%a vs. %a\n", + i, sizeNames[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + clReleaseKernel(k); + return -1; default: vlog_error( "error: Unknown test number!\n" ); clReleaseKernel(k); @@ -1097,7 +1145,7 @@ static int RunTest_Double( int testNumber ) for( i = 0; i < sizeof(args ) / sizeof( args[0]); i++ ) if( (error = clSetKernelArg(k, i, sizeof( cl_mem ), args + i) )) { - vlog_error( "Error %d setting kernel arg # %ld\n", error, i ); + vlog_error("Error %d setting kernel arg # %zu\n", error, i); return error; } @@ -1138,24 +1186,64 @@ static int RunTest_Double( int testNumber ) switch( testNumber ) { // Zeros for these should be positive - case 0: vlog_error( "%ld) Error for %s %s: %a * %a + %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1; - case 1: vlog_error( "%ld) Error for %s %s: %a * %a - %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1; - case 2: vlog_error( "%ld) Error for %s %s: %a + %a * %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1; - case 3: vlog_error( "%ld) Error for %s %s: %a - %a * %a = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1; - - // Zeros for these should be negative - case 4: vlog_error( "%ld) Error for %s %s: -(%a * %a + %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1; - case 5: vlog_error( "%ld) Error for %s %s: -(%a * %a - %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - a[i], b[i], c[i], correct[testNumber][i], test[i] ); return -1; - case 6: vlog_error( "%ld) Error for %s %s: -(%a + %a * %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1; - case 7: vlog_error( "%ld) Error for %s %s: -(%a - %a * %a) = *%a vs. %a\n", i, sizeNames_double[ vectorSize], kernelName[ testNumber ], - c[i], a[i], b[i], correct[testNumber][i], test[i] ); return -1; + case 0: + vlog_error("%zu) Error for %s %s: %a * %a + %a = *%a " + "vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + return -1; + case 1: + vlog_error("%zu) Error for %s %s: %a * %a - %a = *%a " + "vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + return -1; + case 2: + vlog_error("%zu) Error for %s %s: %a + %a * %a = *%a " + "vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + return -1; + case 3: + vlog_error("%zu) Error for %s %s: %a - %a * %a = *%a " + "vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + return -1; + + // Zeros for these shouzu be negative + case 4: + vlog_error("%zu) Error for %s %s: -(%a * %a + %a) = " + "*%a vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + return -1; + case 5: + vlog_error("%zu) Error for %s %s: -(%a * %a - %a) = " + "*%a vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], a[i], b[i], c[i], + correct[testNumber][i], test[i]); + return -1; + case 6: + vlog_error("%zu) Error for %s %s: -(%a + %a * %a) = " + "*%a vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + return -1; + case 7: + vlog_error("%zu) Error for %s %s: -(%a - %a * %a) = " + "*%a vs. %a\n", + i, sizeNames_double[vectorSize], + kernelName[testNumber], c[i], a[i], b[i], + correct[testNumber][i], test[i]); + return -1; default: vlog_error( "error: Unknown test number!\n" ); return -2; diff --git a/test_conformance/conversions/test_conversions.cpp b/test_conformance/conversions/test_conversions.cpp index 122a841072..8225769ef9 100644 --- a/test_conformance/conversions/test_conversions.cpp +++ b/test_conformance/conversions/test_conversions.cpp @@ -534,7 +534,7 @@ test_status InitCL(cl_device_id device) vlog("\tCL C Version: %s\n", c); clGetDeviceInfo(device, CL_DRIVER_VERSION, sizeof(c), c, NULL); vlog("\tDriver Version: %s\n", c); - vlog("\tProcessing with %ld devices\n", gComputeDevices); + vlog("\tProcessing with %zu devices\n", gComputeDevices); vlog("\tDevice Frequency: %d MHz\n", gDeviceFrequency); vlog("\tSubnormal values supported for floats? %s\n", no_yes[0 != (CL_FP_DENORM & floatCapabilities)]); diff --git a/test_conformance/device_partition/test_device_partition.cpp b/test_conformance/device_partition/test_device_partition.cpp index e6db2e5afb..2daa09a04f 100644 --- a/test_conformance/device_partition/test_device_partition.cpp +++ b/test_conformance/device_partition/test_device_partition.cpp @@ -229,11 +229,14 @@ int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices RandomSeed seed( gRandomSeed ); if (queueCount > MAX_QUEUES) { - log_error("Number of queues (%ld) is greater than the number for which the test was written (%d).", queueCount, MAX_QUEUES); + log_error("Number of queues (%zu) is greater than the number for which " + "the test was written (%d).", + queueCount, MAX_QUEUES); return -1; } - log_info("Testing with %ld queues on %ld devices, %ld kernel executions.\n", queueCount, deviceCount, queueCount*num_elements/TEST_SIZE); + log_info("Testing with %zu queues on %zu devices, %zu kernel executions.\n", + queueCount, deviceCount, queueCount * num_elements / TEST_SIZE); for (i=0; iwidth); return NULL; } @@ -149,7 +149,9 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr { if ( NULL == host_ptr ) { - log_error( "ERROR: Unable to create backing store for pitched 3D image. %ld bytes\n", imageInfo->depth * imageInfo->slicePitch ); + log_error("ERROR: Unable to create backing store for pitched 3D " + "image. %zu bytes\n", + imageInfo->depth * imageInfo->slicePitch); return NULL; } if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) @@ -424,7 +426,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d // Update the host verification copy of the data. srcHost.reset(malloc(srcBytes),NULL,0,srcBytes); if (srcHost == NULL) { - log_error( "ERROR: Unable to malloc %lu bytes for srcHost\n", srcBytes ); + log_error("ERROR: Unable to malloc %zu bytes for srcHost\n", + srcBytes); return -1; } memcpy(srcHost,srcData,srcBytes); @@ -456,7 +459,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d log_info( " - Resizing destination buffer...\n" ); dstData.reset(malloc(destImageSize),NULL,0,destImageSize); if (dstData == NULL) { - log_error( "ERROR: Unable to malloc %lu bytes for dstData\n", destImageSize ); + log_error("ERROR: Unable to malloc %zu bytes for dstData\n", + destImageSize); return -1; } } @@ -467,7 +471,8 @@ int test_copy_image_generic( cl_context context, cl_command_queue queue, image_d dstHost.reset(malloc(destImageSize),NULL,0,destImageSize); if (dstHost == NULL) { dstData.reset(NULL); - log_error( "ERROR: Unable to malloc %lu bytes for dstHost\n", destImageSize ); + log_error("ERROR: Unable to malloc %zu bytes for dstHost\n", + destImageSize); return -1; } } diff --git a/test_conformance/images/clFillImage/test_fill_generic.cpp b/test_conformance/images/clFillImage/test_fill_generic.cpp index 92486a5356..17b6182ed4 100644 --- a/test_conformance/images/clFillImage/test_fill_generic.cpp +++ b/test_conformance/images/clFillImage/test_fill_generic.cpp @@ -136,7 +136,7 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr if (err != CL_SUCCESS) { log_error("ERROR: Could not create buffer for 1D buffer " - "image. %ld bytes\n", + "image. %zu bytes\n", imageInfo->rowPitch); return NULL; } @@ -149,7 +149,9 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr { if ( NULL == host_ptr ) { - log_error( "ERROR: Unable to create backing store for pitched 3D image. %ld bytes\n", imageInfo->depth * imageInfo->slicePitch ); + log_error("ERROR: Unable to create backing store for pitched 3D " + "image. %zu bytes\n", + imageInfo->depth * imageInfo->slicePitch); return NULL; } if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) @@ -418,7 +420,8 @@ int test_fill_image_generic( cl_context context, cl_command_queue queue, image_d imgHost.reset(malloc(dataBytes),NULL,0,dataBytes); if (imgHost == NULL) { - log_error( "ERROR: Unable to malloc %lu bytes for imgHost\n", dataBytes ); + log_error("ERROR: Unable to malloc %zu bytes for imgHost\n", + dataBytes); return -1; } } diff --git a/test_conformance/images/kernel_read_write/test_common.h b/test_conformance/images/kernel_read_write/test_common.h index 2a644dae51..5d2052bd95 100644 --- a/test_conformance/images/kernel_read_write/test_common.h +++ b/test_conformance/images/kernel_read_write/test_common.h @@ -86,7 +86,7 @@ int determine_validation_error_offset( { if (printAsFloat) { - log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did " + log_error("Sample %zu: coord {%f(%a),%f(%a),%f(%a)} did " "not validate! Expected (%g,%g,%g,%g), got " "(%g,%g,%g,%g), error of %g\n", j, x, x, y, y, z, z, (float)expected[0], @@ -98,7 +98,7 @@ int determine_validation_error_offset( else { log_error( - "Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not " + "Sample %zu: coord {%f(%a),%f(%a),%f(%a)} did not " "validate! Expected (%x,%x,%x,%x), got (%x,%x,%x,%x)\n", j, x, x, y, y, z, z, (int)expected[0], (int)expected[1], (int)expected[2], (int)expected[3], (int)resultPtr[0], @@ -134,7 +134,7 @@ int determine_validation_error_offset( { if (printAsFloat) { - log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did " + log_error("Sample %zu: coord {%f(%a),%f(%a),%f(%a)} did " "not validate! Expected (%g,%g,%g,%g), got " "(%g,%g,%g,%g), error of %g\n", j, x, x, y, y, z, z, (float)expected[0], @@ -146,7 +146,7 @@ int determine_validation_error_offset( else { log_error( - "Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not " + "Sample %zu: coord {%f(%a),%f(%a),%f(%a)} did not " "validate! Expected (%x,%x,%x,%x), got (%x,%x,%x,%x)\n", j, x, x, y, y, z, z, (int)expected[0], (int)expected[1], (int)expected[2], (int)expected[3], (int)resultPtr[0], @@ -164,7 +164,7 @@ int determine_validation_error_offset( { if (printAsFloat) { - log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not " + log_error("Sample %zu: coord {%f(%a),%f(%a),%f(%a)} did not " "validate!\n\tExpected (%g,%g,%g,%g),\n\t got " "(%g,%g,%g,%g), error of %g\n", j, x, x, y, y, z, z, (float)expected[0], @@ -175,7 +175,7 @@ int determine_validation_error_offset( } else { - log_error("Sample %ld: coord {%f(%a),%f(%a),%f(%a)} did not " + log_error("Sample %zu: coord {%f(%a),%f(%a),%f(%a)} did not " "validate!\n\tExpected (%x,%x,%x,%x),\n\t got " "(%x,%x,%x,%x)\n", j, x, x, y, y, z, z, (int)expected[0], (int)expected[1], diff --git a/test_conformance/images/kernel_read_write/test_iterations.cpp b/test_conformance/images/kernel_read_write/test_iterations.cpp index d30ac0d4e9..0c87d87dc7 100644 --- a/test_conformance/images/kernel_read_write/test_iterations.cpp +++ b/test_conformance/images/kernel_read_write/test_iterations.cpp @@ -97,7 +97,9 @@ template int determine_validation_error( void *imagePtr, image_descrip { if( (--numClamped) == 0 ) { - log_error( "ERROR: TEST FAILED: Read is erroneously clamping coordinates for image size %ld x %ld!\n", imageInfo->width, imageInfo->height ); + log_error("ERROR: TEST FAILED: Read is erroneously clamping " + "coordinates for image size %zu x %zu!\n", + imageInfo->width, imageInfo->height); if (imageInfo->format->image_channel_order == CL_DEPTH) { if( printAsFloat ) @@ -139,7 +141,9 @@ template int determine_validation_error( void *imagePtr, image_descrip { if( (--numClamped) == 0 ) { - log_error( "ERROR: TEST FAILED: Clamping is erroneously returning border color for image size %ld x %ld!\n", imageInfo->width, imageInfo->height ); + log_error("ERROR: TEST FAILED: Clamping is erroneously " + "returning border color for image size %zu x %zu!\n", + imageInfo->width, imageInfo->height); if (imageInfo->format->image_channel_order == CL_DEPTH) { if( printAsFloat ) @@ -203,7 +207,8 @@ template int determine_validation_error( void *imagePtr, image_descrip (int)resultPtr[ 0 ], (int)resultPtr[ 1 ], (int)resultPtr[ 2 ], (int)resultPtr[ 3 ] ); } } - log_error( "img size %ld,%ld (pitch %ld)", imageInfo->width, imageInfo->height, imageInfo->rowPitch ); + log_error("img size %zu,%zu (pitch %zu)", imageInfo->width, + imageInfo->height, imageInfo->rowPitch); if( clamped ) { log_error( " which would clamp to %d,%d\n", clampedX, clampedY ); diff --git a/test_conformance/images/kernel_read_write/test_write_1D.cpp b/test_conformance/images/kernel_read_write/test_write_1D.cpp index 8e5c15553b..74292f9bf7 100644 --- a/test_conformance/images/kernel_read_write/test_write_1D.cpp +++ b/test_conformance/images/kernel_read_write/test_write_1D.cpp @@ -207,8 +207,11 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que } if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 1D image of size %ld pitch %ld (%s, %s)\n", imageInfo->width, - imageInfo->rowPitch, IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create 1D image of size %zu pitch " + "%zu (%s, %s)\n", + imageInfo->width, imageInfo->rowPitch, + IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } @@ -234,8 +237,11 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que imageInfo->format, &image_desc, NULL, &error); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create %d level 1D image of size %ld (%s, %s)\n", imageInfo->num_mip_levels, imageInfo->width, - IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create %d level 1D image of " + "size %zu (%s, %s)\n", + imageInfo->num_mip_levels, imageInfo->width, + IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } } @@ -246,8 +252,11 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que imageValues, NULL, &error ); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 1D image of size %ld pitch %ld (%s, %s)\n", imageInfo->width, - imageInfo->rowPitch, IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create 1D image of size %zu " + "pitch %zu (%s, %s)\n", + imageInfo->width, imageInfo->rowPitch, + IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } } @@ -368,7 +377,9 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que { unsigned int *e = (unsigned int *)resultBuffer; unsigned int *a = (unsigned int *)resultPtr; - log_error( "ERROR: Sample %ld did not validate! (%s)\n", i, mem_flag_names[ mem_flag_index ] ); + log_error( + "ERROR: Sample %zu did not validate! (%s)\n", i, + mem_flag_names[mem_flag_index]); log_error( " Expected: %a %a %a %a\n", expected[ 0 ], expected[ 1 ], expected[ 2 ], expected[ 3 ] ); log_error( " Expected: %08x %08x %08x %08x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: %a %a %a %a\n", actual[ 0 ], actual[ 1 ], actual[ 2 ], actual[ 3 ] ); @@ -385,7 +396,9 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que if( !validate_half_write_results( e, a, imageInfo ) ) { totalErrors++; - log_error( "ERROR: Sample %ld did not validate! (%s)\n", i, mem_flag_names[ mem_flag_index ] ); + log_error( + "ERROR: Sample %zu did not validate! (%s)\n", i, + mem_flag_names[mem_flag_index]); log_error( " Expected: 0x%04x 0x%04x 0x%04x 0x%04x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: 0x%04x 0x%04x 0x%04x 0x%04x\n", a[ 0 ], a[ 1 ], a[ 2 ], a[ 3 ] ); if( inputType == kFloat ) @@ -435,7 +448,12 @@ int test_write_image_1D( cl_device_id device, cl_context context, cl_command_que deviceResults[ 4 ] == 5 && deviceResults[ 5 ] == 5 && deviceResults[ 6 ] == 6 && deviceResults[ 7 ] == 6 ) deviceRounding = "round to even"; - log_error( "ERROR: Rounding mode sample (%ld) did not validate, probably due to the device's rounding mode being wrong (%s)\n", i, mem_flag_names[mem_flag_index] ); + log_error( + "ERROR: Rounding mode sample (%zu) did " + "not validate, probably due to the " + "device's rounding mode being wrong " + "(%s)\n", + i, mem_flag_names[mem_flag_index]); log_error( " Actual values rounded by device: %x %x %x %x %x %x %x %x\n", deviceResults[ 0 ], deviceResults[ 1 ], deviceResults[ 2 ], deviceResults[ 3 ], deviceResults[ 4 ], deviceResults[ 5 ], deviceResults[ 6 ], deviceResults[ 7 ] ); log_error( " Rounding mode of device appears to be %s\n", deviceRounding ); diff --git a/test_conformance/images/kernel_read_write/test_write_1D_array.cpp b/test_conformance/images/kernel_read_write/test_write_1D_array.cpp index a6bf4ec25b..0e64600f46 100644 --- a/test_conformance/images/kernel_read_write/test_write_1D_array.cpp +++ b/test_conformance/images/kernel_read_write/test_write_1D_array.cpp @@ -218,8 +218,11 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma } if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 1D image array of size %ld x %ld pitch %ld (%s, %s)\n", imageInfo->width, imageInfo->arraySize, - imageInfo->rowPitch, IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create 1D image array of size %zu " + "x %zu pitch %zu (%s, %s)\n", + imageInfo->width, imageInfo->arraySize, + imageInfo->rowPitch, IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } @@ -245,8 +248,11 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma imageInfo->format, &image_desc, NULL, &error); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create %d level 1D image array of size %ld x %ld (%s, %s)\n", imageInfo->num_mip_levels, imageInfo->width, imageInfo->arraySize, - IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create %d level 1D image array " + "of size %zu x %zu (%s, %s)\n", + imageInfo->num_mip_levels, imageInfo->width, + imageInfo->arraySize, IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } } @@ -257,8 +263,11 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma imageValues, &error ); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 1D image array of size %ld x %ld pitch %ld (%s, %s)\n", imageInfo->width, imageInfo->arraySize, - imageInfo->rowPitch, IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create 1D image array of size " + "%zu x %zu pitch %zu (%s, %s)\n", + imageInfo->width, imageInfo->arraySize, + imageInfo->rowPitch, IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } } @@ -388,7 +397,9 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma { unsigned int *e = (unsigned int *)resultBuffer; unsigned int *a = (unsigned int *)resultPtr; - log_error( "ERROR: Sample %ld (%ld,%ld) did not validate! (%s)\n", i, x, y, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu) did not " + "validate! (%s)\n", + i, x, y, mem_flag_names[mem_flag_index]); log_error( " Expected: %a %a %a %a\n", expected[ 0 ], expected[ 1 ], expected[ 2 ], expected[ 3 ] ); log_error( " Expected: %08x %08x %08x %08x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: %a %a %a %a\n", actual[ 0 ], actual[ 1 ], actual[ 2 ], actual[ 3 ] ); @@ -405,7 +416,9 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma if( !validate_half_write_results( e, a, imageInfo ) ) { totalErrors++; - log_error( "ERROR: Sample %ld (%ld,%ld) did not validate! (%s)\n", i, x, y, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu) did not " + "validate! (%s)\n", + i, x, y, mem_flag_names[mem_flag_index]); log_error( " Expected: 0x%04x 0x%04x 0x%04x 0x%04x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: 0x%04x 0x%04x 0x%04x 0x%04x\n", a[ 0 ], a[ 1 ], a[ 2 ], a[ 3 ] ); if( inputType == kFloat ) @@ -456,7 +469,12 @@ int test_write_image_1D_array( cl_device_id device, cl_context context, cl_comma deviceResults[ 4 ] == 5 && deviceResults[ 5 ] == 5 && deviceResults[ 6 ] == 6 && deviceResults[ 7 ] == 6 ) deviceRounding = "round to even"; - log_error( "ERROR: Rounding mode sample (%ld) did not validate, probably due to the device's rounding mode being wrong (%s)\n", i, mem_flag_names[mem_flag_index] ); + log_error( + "ERROR: Rounding mode sample (%zu) did " + "not validate, probably due to the " + "device's rounding mode being wrong " + "(%s)\n", + i, mem_flag_names[mem_flag_index]); log_error( " Actual values rounded by device: %x %x %x %x %x %x %x %x\n", deviceResults[ 0 ], deviceResults[ 1 ], deviceResults[ 2 ], deviceResults[ 3 ], deviceResults[ 4 ], deviceResults[ 5 ], deviceResults[ 6 ], deviceResults[ 7 ] ); log_error( " Rounding mode of device appears to be %s\n", deviceRounding ); diff --git a/test_conformance/images/kernel_read_write/test_write_2D_array.cpp b/test_conformance/images/kernel_read_write/test_write_2D_array.cpp index 40c90e7be9..e049d8b8c8 100644 --- a/test_conformance/images/kernel_read_write/test_write_2D_array.cpp +++ b/test_conformance/images/kernel_read_write/test_write_2D_array.cpp @@ -245,7 +245,11 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 2D image array of size %ld x %ld x %ld pitch %ld (%s)\n", imageInfo->width, imageInfo->height, imageInfo->arraySize, imageInfo->rowPitch, IGetErrorString( error ) ); + log_error("ERROR: Unable to create 2D image array of size %zu " + "x %zu x %zu pitch %zu (%s)\n", + imageInfo->width, imageInfo->height, + imageInfo->arraySize, imageInfo->rowPitch, + IGetErrorString(error)); return error; } @@ -269,8 +273,12 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma imageInfo->format, &image_desc, NULL, &error); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create %d level 2D image array of size %ld x %ld x %ld (%s, %s)\n", imageInfo->num_mip_levels, imageInfo->width, imageInfo->height, imageInfo->arraySize, - IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create %d level 2D image array " + "of size %zu x %zu x %zu (%s, %s)\n", + imageInfo->num_mip_levels, imageInfo->width, + imageInfo->height, imageInfo->arraySize, + IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } } @@ -280,7 +288,11 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma imageInfo->width, imageInfo->height, imageInfo->arraySize, 0, 0, imageValues, &error ); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 2D image array of size %ld x %ld x %ld pitch %ld (%s)\n", imageInfo->width, imageInfo->height, imageInfo->arraySize, imageInfo->rowPitch, IGetErrorString( error ) ); + log_error("ERROR: Unable to create 2D image array of size " + "%zu x %zu x %zu pitch %zu (%s)\n", + imageInfo->width, imageInfo->height, + imageInfo->arraySize, imageInfo->rowPitch, + IGetErrorString(error)); return error; } } @@ -413,7 +425,10 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma { unsigned int *e = (unsigned int *)resultBuffer; unsigned int *a = (unsigned int *)resultPtr; - log_error( "ERROR: Sample %ld (%ld,%ld,%ld) did not validate! (%s)\n", i, x, y, z, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu,%zu) did " + "not validate! (%s)\n", + i, x, y, z, + mem_flag_names[mem_flag_index]); log_error( " Expected: %a %a %a %a\n", expected[ 0 ], expected[ 1 ], expected[ 2 ], expected[ 3 ] ); log_error( " Expected: %08x %08x %08x %08x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: %a %a %a %a\n", actual[ 0 ], actual[ 1 ], actual[ 2 ], actual[ 3 ] ); @@ -430,7 +445,10 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma if( !validate_half_write_results( e, a, imageInfo ) ) { totalErrors++; - log_error( "ERROR: Sample %ld (%ld,%ld,%ld) did not validate! (%s)\n", i, x, y, z, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu,%zu) did " + "not validate! (%s)\n", + i, x, y, z, + mem_flag_names[mem_flag_index]); unsigned short *e = (unsigned short *)resultBuffer; unsigned short *a = (unsigned short *)resultPtr; log_error( " Expected: 0x%04x 0x%04x 0x%04x 0x%04x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); @@ -484,7 +502,12 @@ int test_write_image_2D_array( cl_device_id device, cl_context context, cl_comma deviceResults[ 4 ] == 5 && deviceResults[ 5 ] == 5 && deviceResults[ 6 ] == 6 && deviceResults[ 7 ] == 6 ) deviceRounding = "round to even"; - log_error( "ERROR: Rounding mode sample (%ld) did not validate, probably due to the device's rounding mode being wrong (%s)\n", i, mem_flag_names[mem_flag_index] ); + log_error( + "ERROR: Rounding mode sample (%zu) " + "did not validate, probably due to " + "the device's rounding mode being " + "wrong (%s)\n", + i, mem_flag_names[mem_flag_index]); log_error( " Actual values rounded by device: %d %d %d %d %d %d %d %d\n", deviceResults[ 0 ], deviceResults[ 1 ], deviceResults[ 2 ], deviceResults[ 3 ], deviceResults[ 4 ], deviceResults[ 5 ], deviceResults[ 6 ], deviceResults[ 7 ] ); log_error( " Rounding mode of device appears to be %s\n", deviceRounding ); @@ -804,8 +827,11 @@ int test_write_image_2D_array_set(cl_device_id device, cl_context context, } while( size > maxAllocSize || buffSize > maxAllocSize || ( size * 3 ) > memSize ); if( gDebugTrace ) - log_info( " at size %ld,%ld,%ld (pitch %ld, slice %ld) out of %ld,%ld,%ld\n", imageInfo.width, imageInfo.height, imageInfo.arraySize, - imageInfo.rowPitch, imageInfo.slicePitch, maxWidth, maxHeight, maxArraySize ); + log_info(" at size %zu,%zu,%zu (pitch %zu, slice %zu) out of " + "%zu,%zu,%zu\n", + imageInfo.width, imageInfo.height, imageInfo.arraySize, + imageInfo.rowPitch, imageInfo.slicePitch, maxWidth, + maxHeight, maxArraySize); int retCode = test_write_image_2D_array( device, context, queue, kernel, &imageInfo, inputType, d ); if( retCode ) diff --git a/test_conformance/images/kernel_read_write/test_write_3D.cpp b/test_conformance/images/kernel_read_write/test_write_3D.cpp index b50ccb6112..cdfa0f2a00 100644 --- a/test_conformance/images/kernel_read_write/test_write_3D.cpp +++ b/test_conformance/images/kernel_read_write/test_write_3D.cpp @@ -249,7 +249,10 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 3D image of size %ld x %ld x %ld pitch %ld (%s)\n", imageInfo->width, imageInfo->height, imageInfo->depth, imageInfo->rowPitch, IGetErrorString( error ) ); + log_error("ERROR: Unable to create 3D image of size %zu x %zu " + "x %zu pitch %zu (%s)\n", + imageInfo->width, imageInfo->height, imageInfo->depth, + imageInfo->rowPitch, IGetErrorString(error)); return error; } @@ -273,8 +276,12 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que imageInfo->format, &image_desc, NULL, &error); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create %d level mipmapped 3D image of size %ld x %ld *%ld (%s, %s)\n", imageInfo->num_mip_levels, imageInfo->width, imageInfo->height, imageInfo->depth, - IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create %d level mipmapped 3D " + "image of size %zu x %zu *%zu (%s, %s)\n", + imageInfo->num_mip_levels, imageInfo->width, + imageInfo->height, imageInfo->depth, + IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } } @@ -284,7 +291,11 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que imageInfo->width, imageInfo->height, imageInfo->depth, 0, 0, imageValues, &error ); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create 3D image of size %ld x %ld x %ld pitch %ld (%s)\n", imageInfo->width, imageInfo->height, imageInfo->depth, imageInfo->rowPitch, IGetErrorString( error ) ); + log_error("ERROR: Unable to create 3D image of size %zu x " + "%zu x %zu pitch %zu (%s)\n", + imageInfo->width, imageInfo->height, + imageInfo->depth, imageInfo->rowPitch, + IGetErrorString(error)); return error; } } @@ -420,7 +431,10 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que { unsigned int *e = (unsigned int *)resultBuffer; unsigned int *a = (unsigned int *)resultPtr; - log_error( "ERROR: Sample %ld (%ld,%ld,%ld) did not validate! (%s)\n", i, x, y, z, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu,%zu) did " + "not validate! (%s)\n", + i, x, y, z, + mem_flag_names[mem_flag_index]); log_error( " Expected: %a %a %a %a\n", expected[ 0 ], expected[ 1 ], expected[ 2 ], expected[ 3 ] ); log_error( " Expected: %08x %08x %08x %08x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: %a %a %a %a\n", actual[ 0 ], actual[ 1 ], actual[ 2 ], actual[ 3 ] ); @@ -437,7 +451,10 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que if( !validate_half_write_results( e, a, imageInfo ) ) { totalErrors++; - log_error( "ERROR: Sample %ld (%ld,%ld,%ld) did not validate! (%s)\n", i, x, y, z, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu,%zu) did " + "not validate! (%s)\n", + i, x, y, z, + mem_flag_names[mem_flag_index]); unsigned short *e = (unsigned short *)resultBuffer; unsigned short *a = (unsigned short *)resultPtr; log_error( " Expected: 0x%04x 0x%04x 0x%04x 0x%04x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); @@ -491,7 +508,12 @@ int test_write_image_3D( cl_device_id device, cl_context context, cl_command_que deviceResults[ 4 ] == 5 && deviceResults[ 5 ] == 5 && deviceResults[ 6 ] == 6 && deviceResults[ 7 ] == 6 ) deviceRounding = "round to even"; - log_error( "ERROR: Rounding mode sample (%ld) did not validate, probably due to the device's rounding mode being wrong (%s)\n", i, mem_flag_names[mem_flag_index] ); + log_error( + "ERROR: Rounding mode sample (%zu) " + "did not validate, probably due to " + "the device's rounding mode being " + "wrong (%s)\n", + i, mem_flag_names[mem_flag_index]); log_error( " Actual values rounded by device: %d %d %d %d %d %d %d %d\n", deviceResults[ 0 ], deviceResults[ 1 ], deviceResults[ 2 ], deviceResults[ 3 ], deviceResults[ 4 ], deviceResults[ 5 ], deviceResults[ 6 ], deviceResults[ 7 ] ); log_error( " Rounding mode of device appears to be %s\n", deviceRounding ); @@ -798,8 +820,11 @@ int test_write_image_3D_set(cl_device_id device, cl_context context, } while( size > maxAllocSize || ( size * 3 ) > memSize ); if( gDebugTrace ) - log_info( " at size %ld,%ld,%ld (pitch %ld, slice %ld) out of %ld,%ld,%ld\n", imageInfo.width, imageInfo.height, imageInfo.depth, - imageInfo.rowPitch, imageInfo.slicePitch, maxWidth, maxHeight, maxDepth ); + log_info(" at size %zu,%zu,%zu (pitch %zu, slice %zu) out of " + "%zu,%zu,%zu\n", + imageInfo.width, imageInfo.height, imageInfo.depth, + imageInfo.rowPitch, imageInfo.slicePitch, maxWidth, + maxHeight, maxDepth); int retCode = test_write_image_3D( device, context, queue, kernel, &imageInfo, inputType, d ); if( retCode ) diff --git a/test_conformance/images/kernel_read_write/test_write_image.cpp b/test_conformance/images/kernel_read_write/test_write_image.cpp index 69097e3fa5..32f7c22fe9 100644 --- a/test_conformance/images/kernel_read_write/test_write_image.cpp +++ b/test_conformance/images/kernel_read_write/test_write_image.cpp @@ -261,8 +261,11 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue } } - log_error( "ERROR: Unable to create 2D image of size %ld x %ld pitch %ld (%s, %s)\n", imageInfo->width, imageInfo->height, - imageInfo->rowPitch, IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create 2D image of size %zu x %zu " + "pitch %zu (%s, %s)\n", + imageInfo->width, imageInfo->height, + imageInfo->rowPitch, IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } @@ -285,8 +288,11 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue imageInfo->format, &image_desc, NULL, &error); if( error != CL_SUCCESS ) { - log_error( "ERROR: Unable to create %d level 2D image of size %ld x %ld (%s, %s)\n", imageInfo->num_mip_levels, imageInfo->width, imageInfo->height, - IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create %d level 2D image of " + "size %zu x %zu (%s, %s)\n", + imageInfo->num_mip_levels, imageInfo->width, + imageInfo->height, IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } } @@ -320,8 +326,11 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue } } - log_error( "ERROR: Unable to create 2D image of size %ld x %ld pitch %ld (%s, %s)\n", imageInfo->width, imageInfo->height, - imageInfo->rowPitch, IGetErrorString( error ), mem_flag_names[mem_flag_index] ); + log_error("ERROR: Unable to create 2D image of size %zu x %zu " + "pitch %zu (%s, %s)\n", + imageInfo->width, imageInfo->height, + imageInfo->rowPitch, IGetErrorString(error), + mem_flag_names[mem_flag_index]); return error; } image = unprotImage; @@ -450,7 +459,9 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue { unsigned int *e = (unsigned int *)resultBuffer; unsigned int *a = (unsigned int *)resultPtr; - log_error( "ERROR: Sample %ld (%ld,%ld) did not validate! (%s)\n", i, x, y, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu) did not " + "validate! (%s)\n", + i, x, y, mem_flag_names[mem_flag_index]); log_error( " Expected: %a %a %a %a\n", expected[ 0 ], expected[ 1 ], expected[ 2 ], expected[ 3 ] ); log_error( " Expected: %08x %08x %08x %08x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: %a %a %a %a\n", actual[ 0 ], actual[ 1 ], actual[ 2 ], actual[ 3 ] ); @@ -467,7 +478,9 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue if( !validate_half_write_results( e, a, imageInfo ) ) { totalErrors++; - log_error( "ERROR: Sample %ld (%ld,%ld) did not validate! (%s)\n", i, x, y, mem_flag_names[ mem_flag_index ] ); + log_error("ERROR: Sample %zu (%zu,%zu) did not " + "validate! (%s)\n", + i, x, y, mem_flag_names[mem_flag_index]); log_error( " Expected: 0x%04x 0x%04x 0x%04x 0x%04x\n", e[ 0 ], e[ 1 ], e[ 2 ], e[ 3 ] ); log_error( " Actual: 0x%04x 0x%04x 0x%04x 0x%04x\n", a[ 0 ], a[ 1 ], a[ 2 ], a[ 3 ] ); if( inputType == kFloat ) @@ -518,7 +531,12 @@ int test_write_image( cl_device_id device, cl_context context, cl_command_queue deviceResults[ 4 ] == 5 && deviceResults[ 5 ] == 5 && deviceResults[ 6 ] == 6 && deviceResults[ 7 ] == 6 ) deviceRounding = "round to even"; - log_error( "ERROR: Rounding mode sample (%ld) did not validate, probably due to the device's rounding mode being wrong (%s)\n", i, mem_flag_names[mem_flag_index] ); + log_error( + "ERROR: Rounding mode sample (%zu) did " + "not validate, probably due to the " + "device's rounding mode being wrong " + "(%s)\n", + i, mem_flag_names[mem_flag_index]); log_error( " Actual values rounded by device: %x %x %x %x %x %x %x %x\n", deviceResults[ 0 ], deviceResults[ 1 ], deviceResults[ 2 ], deviceResults[ 3 ], deviceResults[ 4 ], deviceResults[ 5 ], deviceResults[ 6 ], deviceResults[ 7 ] ); log_error( " Rounding mode of device appears to be %s\n", deviceRounding ); diff --git a/test_conformance/multiple_device_context/test_multiple_contexts.cpp b/test_conformance/multiple_device_context/test_multiple_contexts.cpp index c432d79be7..52ac4682c9 100644 --- a/test_conformance/multiple_device_context/test_multiple_contexts.cpp +++ b/test_conformance/multiple_device_context/test_multiple_contexts.cpp @@ -180,7 +180,7 @@ TestItem *CreateTestItem( cl_device_id deviceID, cl_int *err ) { if( err ) { - log_error("FAILURE: clCreateBuffer( %ld bytes ) failed in " + log_error("FAILURE: clCreateBuffer( %zu bytes ) failed in " "CreateTestItem: %d\n", TEST_SIZE * sizeof(cl_uint), error); *err = error; @@ -294,7 +294,8 @@ cl_int UseTestItem( const TestItem *item, cl_int *err ) { if( err ) { - log_error( "FAILURE to set arg 0 for kernel # %ld : %d\n", j, error ); + log_error("FAILURE to set arg 0 for kernel # %zu : %d\n", j, + error); *err = error; } return error; @@ -305,7 +306,9 @@ cl_int UseTestItem( const TestItem *item, cl_int *err ) { if( err ) { - log_error( "FAILURE: Unable to set arg 1 for kernel # %ld : %d\n", j, error ); + log_error( + "FAILURE: Unable to set arg 1 for kernel # %zu : %d\n", j, + error); *err = error; } return error; @@ -318,7 +321,8 @@ cl_int UseTestItem( const TestItem *item, cl_int *err ) { if( err ) { - log_error( "FAILURE: Unable to enqueue kernel %ld: %d\n", j, error ); + log_error("FAILURE: Unable to enqueue kernel %zu: %d\n", j, + error); *err = error; } return error; @@ -360,7 +364,9 @@ cl_int UseTestItem( const TestItem *item, cl_int *err ) cl_uint result = mapped[i]; if( expected != result ) { - log_error( "FAILURE: Sample data at position %ld does not match expected result: *0x%8.8x vs. 0x%8.8x\n", i, expected, result ); + log_error("FAILURE: Sample data at position %zu does not " + "match expected result: *0x%8.8x vs. 0x%8.8x\n", + i, expected, result); if( err ) *err = -1; return -1; @@ -441,16 +447,17 @@ int test_context_multiple_contexts_same_device(cl_device_id deviceID, size_t max // Check to make sure we made the minimum amount if( i < minCount ) { - log_error( "FAILURE: only could make %ld of %ld contexts!\n", i, minCount ); + log_error("FAILURE: only could make %zu of %zu contexts!\n", i, + minCount); err = -1; goto exit; } // Report how many contexts we made if( i == maxCount ) - log_info( "Successfully created all %lu contexts.\n", i ); + log_info("Successfully created all %zu contexts.\n", i); else - log_info( "Successfully created %lu contexts out of %lu\n", i, maxCount ); + log_info("Successfully created %zu contexts out of %zu\n", i, maxCount); // Set the count to be the number we succesfully made maxCount = i; diff --git a/test_conformance/multiple_device_context/test_multiple_devices.cpp b/test_conformance/multiple_device_context/test_multiple_devices.cpp index 7a2a3492ae..8e45efd0f7 100644 --- a/test_conformance/multiple_device_context/test_multiple_devices.cpp +++ b/test_conformance/multiple_device_context/test_multiple_devices.cpp @@ -53,22 +53,27 @@ int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices RandomSeed seed( gRandomSeed ); if (deviceCount > MAX_DEVICES) { - log_error("Number of devices in set (%ld) is greater than the number for which the test was written (%d).", deviceCount, MAX_DEVICES); - return -1; + log_error("Number of devices in set (%zu) is greater than the number " + "for which the test was written (%d).", + deviceCount, MAX_DEVICES); + return -1; } if (queueCount > MAX_QUEUES) { - log_error("Number of queues (%ld) is greater than the number for which the test was written (%d).", queueCount, MAX_QUEUES); - return -1; + log_error("Number of queues (%zu) is greater than the number for which " + "the test was written (%d).", + queueCount, MAX_QUEUES); + return -1; } - log_info("Testing with %ld queues on %ld devices, %ld kernel executions.\n", queueCount, deviceCount, queueCount*num_elements/TEST_SIZE); + log_info("Testing with %zu queues on %zu devices, %zu kernel executions.\n", + queueCount, deviceCount, queueCount * num_elements / TEST_SIZE); for (i=0; i Date: Thu, 12 Dec 2024 21:24:04 +0000 Subject: [PATCH 02/39] [NFC] Change the name of the default device provided by the new registration framework (#2186) The code base uses a mix of 'device' and 'deviceID'. I suggest we standardise on 'device' which is shorter and slightly more prevalent. Contributes to #2181 Signed-off-by: Kevin Petit --- test_common/harness/testHarness.h | 4 +- .../SVM/test_allocate_shared_buffer.cpp | 7 +-- .../test_allocate_shared_buffer_negative.cpp | 7 +-- .../SVM/test_byte_granularity.cpp | 2 +- .../SVM/test_cross_buffer_pointers.cpp | 2 +- test_conformance/SVM/test_enqueue_api.cpp | 2 +- .../test_fine_grain_memory_consistency.cpp | 2 +- .../SVM/test_fine_grain_sync_buffers.cpp | 7 +-- test_conformance/SVM/test_migrate.cpp | 4 +- test_conformance/SVM/test_pointer_passing.cpp | 2 +- .../test_set_kernel_exec_info_svm_ptrs.cpp | 7 ++- ...test_shared_address_space_coarse_grain.cpp | 4 +- .../test_shared_address_space_fine_grain.cpp | 6 +- ...hared_address_space_fine_grain_buffers.cpp | 6 +- .../SVM/test_shared_sub_buffers.cpp | 2 +- .../device_timer/test_device_timer.cpp | 17 +++--- .../spirv_new/test_basic_versions.cpp | 8 +-- .../spirv_new/test_cl_khr_expect_assume.cpp | 16 ++--- test_conformance/spirv_new/test_decorate.cpp | 16 ++--- .../spirv_new/test_get_program_il.cpp | 4 +- test_conformance/spirv_new/test_linkage.cpp | 19 +++--- .../test_no_integer_wrap_decoration.cpp | 8 +-- test_conformance/spirv_new/test_op_atomic.cpp | 8 +-- test_conformance/spirv_new/test_op_branch.cpp | 2 +- .../spirv_new/test_op_branch_conditional.cpp | 2 +- .../spirv_new/test_op_composite_construct.cpp | 6 +- .../spirv_new/test_op_constant.cpp | 21 ++++--- .../spirv_new/test_op_copy_object.cpp | 23 ++++---- test_conformance/spirv_new/test_op_fmath.cpp | 4 +- .../spirv_new/test_op_function.cpp | 2 +- .../spirv_new/test_op_lifetime.cpp | 3 +- .../spirv_new/test_op_loop_merge.cpp | 2 +- test_conformance/spirv_new/test_op_negate.cpp | 2 +- test_conformance/spirv_new/test_op_opaque.cpp | 4 +- test_conformance/spirv_new/test_op_phi.cpp | 6 +- .../spirv_new/test_op_selection_merge.cpp | 4 +- .../spirv_new/test_op_spec_constant.cpp | 6 +- test_conformance/spirv_new/test_op_undef.cpp | 16 ++--- .../spirv_new/test_op_vector_extract.cpp | 4 +- .../spirv_new/test_op_vector_insert.cpp | 4 +- .../spirv_new/test_op_vector_times_scalar.cpp | 6 +- test_conformance/spirv_new/test_spirv_14.cpp | 59 +++++++++---------- 42 files changed, 174 insertions(+), 162 deletions(-) diff --git a/test_common/harness/testHarness.h b/test_common/harness/testHarness.h index 45f4ce7995..e9ac53a884 100644 --- a/test_common/harness/testHarness.h +++ b/test_common/harness/testHarness.h @@ -133,7 +133,7 @@ template T *register_test(const char *name, Version version) } #define REGISTER_TEST_VERSION(name, version) \ - extern int test_##name(cl_device_id deviceID, cl_context context, \ + extern int test_##name(cl_device_id device, cl_context context, \ cl_command_queue queue, int num_elements); \ class test_##name##_class : public test { \ private: \ @@ -145,7 +145,7 @@ template T *register_test(const char *name, Version version) }; \ test_##name##_class *var_##name = \ register_test(#name, version); \ - int test_##name(cl_device_id deviceID, cl_context context, \ + int test_##name(cl_device_id device, cl_context context, \ cl_command_queue queue, int num_elements) #define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2)) diff --git a/test_conformance/SVM/test_allocate_shared_buffer.cpp b/test_conformance/SVM/test_allocate_shared_buffer.cpp index e4dcffda87..ad6f21c061 100644 --- a/test_conformance/SVM/test_allocate_shared_buffer.cpp +++ b/test_conformance/SVM/test_allocate_shared_buffer.cpp @@ -50,14 +50,13 @@ REGISTER_TEST(svm_allocate_shared_buffer) clCommandQueueWrapper queues[MAXQ]; cl_device_svm_capabilities caps; - err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES, + err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES, sizeof(cl_device_svm_capabilities), &caps, NULL); test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES"); // under construction... - err = - create_cl_objects(deviceID, NULL, &contextWrapper, &program, &queues[0], - &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); + err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0], + &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); context = contextWrapper; if (err) return -1; diff --git a/test_conformance/SVM/test_allocate_shared_buffer_negative.cpp b/test_conformance/SVM/test_allocate_shared_buffer_negative.cpp index 5d8513bbda..3118f5c039 100644 --- a/test_conformance/SVM/test_allocate_shared_buffer_negative.cpp +++ b/test_conformance/SVM/test_allocate_shared_buffer_negative.cpp @@ -50,14 +50,13 @@ REGISTER_TEST(svm_allocate_shared_buffer_negative) clCommandQueueWrapper queues[MAXQ]; cl_device_svm_capabilities caps; - err = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES, + err = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES, sizeof(cl_device_svm_capabilities), &caps, NULL); test_error(err, "clGetDeviceInfo failed for CL_DEVICE_SVM_CAPABILITIES"); // under construction... - err = - create_cl_objects(deviceID, NULL, &contextWrapper, &program, &queues[0], - &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); + err = create_cl_objects(device, NULL, &contextWrapper, &program, &queues[0], + &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); context = contextWrapper; if (err) return err; diff --git a/test_conformance/SVM/test_byte_granularity.cpp b/test_conformance/SVM/test_byte_granularity.cpp index d9d1222113..fe0c10e235 100644 --- a/test_conformance/SVM/test_byte_granularity.cpp +++ b/test_conformance/SVM/test_byte_granularity.cpp @@ -58,7 +58,7 @@ REGISTER_TEST(svm_byte_granularity) cl_uint num_devices = 0; cl_int err = CL_SUCCESS; - err = create_cl_objects(deviceID, &byte_manipulation_kernels[0], + err = create_cl_objects(device, &byte_manipulation_kernels[0], &contextWrapper, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER); context = contextWrapper; diff --git a/test_conformance/SVM/test_cross_buffer_pointers.cpp b/test_conformance/SVM/test_cross_buffer_pointers.cpp index cd2b168c51..3f29b3134e 100644 --- a/test_conformance/SVM/test_cross_buffer_pointers.cpp +++ b/test_conformance/SVM/test_cross_buffer_pointers.cpp @@ -136,7 +136,7 @@ REGISTER_TEST(svm_cross_buffer_pointers_coarse_grain) cl_int error = CL_SUCCESS; clCommandQueueWrapper queues[MAXQ]; - error = create_cl_objects(deviceID, &SVMCrossBufferPointers_test_kernel[0], + error = create_cl_objects(device, &SVMCrossBufferPointers_test_kernel[0], &contextWrapper, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); context = contextWrapper; diff --git a/test_conformance/SVM/test_enqueue_api.cpp b/test_conformance/SVM/test_enqueue_api.cpp index 27b483fa64..20fa4432e5 100644 --- a/test_conformance/SVM/test_enqueue_api.cpp +++ b/test_conformance/SVM/test_enqueue_api.cpp @@ -80,7 +80,7 @@ REGISTER_TEST(svm_enqueue_api) cl_int error = CL_SUCCESS; RandomSeed seed(0); - error = create_cl_objects(deviceID, NULL, &contextWrapper, NULL, &queues[0], + error = create_cl_objects(device, NULL, &contextWrapper, NULL, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); context = contextWrapper; if (error) return TEST_FAIL; diff --git a/test_conformance/SVM/test_fine_grain_memory_consistency.cpp b/test_conformance/SVM/test_fine_grain_memory_consistency.cpp index 1c39e33fd7..c219e9eab8 100644 --- a/test_conformance/SVM/test_fine_grain_memory_consistency.cpp +++ b/test_conformance/SVM/test_fine_grain_memory_consistency.cpp @@ -158,7 +158,7 @@ REGISTER_TEST(svm_fine_grain_memory_consistency) char *source[] = { hash_table_kernel }; err = create_cl_objects( - deviceID, (const char **)source, &contextWrapper, &program, &queues[0], + device, (const char **)source, &contextWrapper, &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS, required_extensions); context = contextWrapper; diff --git a/test_conformance/SVM/test_fine_grain_sync_buffers.cpp b/test_conformance/SVM/test_fine_grain_sync_buffers.cpp index f2572a8a0d..1f2e25858b 100644 --- a/test_conformance/SVM/test_fine_grain_sync_buffers.cpp +++ b/test_conformance/SVM/test_fine_grain_sync_buffers.cpp @@ -52,10 +52,9 @@ REGISTER_TEST(svm_fine_grain_sync_buffers) cl_int err = CL_SUCCESS; clCommandQueueWrapper queues[MAXQ]; - err = create_cl_objects(deviceID, &find_targets_kernel[0], &contextWrapper, - &program, &queues[0], &num_devices, - CL_DEVICE_SVM_FINE_GRAIN_BUFFER - | CL_DEVICE_SVM_ATOMICS); + err = create_cl_objects( + device, &find_targets_kernel[0], &contextWrapper, &program, &queues[0], + &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER | CL_DEVICE_SVM_ATOMICS); context = contextWrapper; if (err == 1) return 0; // no devices capable of requested SVM level, so don't execute diff --git a/test_conformance/SVM/test_migrate.cpp b/test_conformance/SVM/test_migrate.cpp index b697b48ac5..30dbebf71d 100644 --- a/test_conformance/SVM/test_migrate.cpp +++ b/test_conformance/SVM/test_migrate.cpp @@ -92,7 +92,7 @@ REGISTER_TEST(svm_migrate) clProgramWrapper program; cl_int error; - error = create_cl_objects(deviceID, &sources[0], &contextWrapper, &program, + error = create_cl_objects(device, &sources[0], &contextWrapper, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); context = contextWrapper; @@ -202,7 +202,7 @@ REGISTER_TEST(svm_migrate) // Check the event command type for clEnqueueSVMMigrateMem (OpenCL 3.0 and // newer) - Version version = get_device_cl_version(deviceID); + Version version = get_device_cl_version(device); if (version >= Version(3, 0)) { cl_command_type commandType; diff --git a/test_conformance/SVM/test_pointer_passing.cpp b/test_conformance/SVM/test_pointer_passing.cpp index 9493edfcea..d1aa5005dd 100644 --- a/test_conformance/SVM/test_pointer_passing.cpp +++ b/test_conformance/SVM/test_pointer_passing.cpp @@ -43,7 +43,7 @@ REGISTER_TEST(svm_pointer_passing) cl_int error = CL_SUCCESS; clCommandQueueWrapper queues[MAXQ]; - error = create_cl_objects(deviceID, &SVMPointerPassing_test_kernel[0], + error = create_cl_objects(device, &SVMPointerPassing_test_kernel[0], &contextWrapper, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); context = contextWrapper; diff --git a/test_conformance/SVM/test_set_kernel_exec_info_svm_ptrs.cpp b/test_conformance/SVM/test_set_kernel_exec_info_svm_ptrs.cpp index 88fd5f9410..13e4b20f86 100644 --- a/test_conformance/SVM/test_set_kernel_exec_info_svm_ptrs.cpp +++ b/test_conformance/SVM/test_set_kernel_exec_info_svm_ptrs.cpp @@ -50,8 +50,11 @@ REGISTER_TEST(svm_set_kernel_exec_info_svm_ptrs) cl_int error = CL_SUCCESS; clCommandQueueWrapper queues[MAXQ]; - //error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN); - error = create_cl_objects(deviceID, &set_kernel_exec_info_svm_ptrs_kernel[0], &c, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); + // error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0], + // &context, &program, &q, &num_devices, CL_DEVICE_SVM_FINE_GRAIN); + error = create_cl_objects(device, &set_kernel_exec_info_svm_ptrs_kernel[0], + &c, &program, &queues[0], &num_devices, + CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); if(error == 1) return 0; // no devices capable of requested SVM level, so don't execute but count test as passing. if(error < 0) return -1; // fail test. diff --git a/test_conformance/SVM/test_shared_address_space_coarse_grain.cpp b/test_conformance/SVM/test_shared_address_space_coarse_grain.cpp index ac34252800..c5c96611ca 100644 --- a/test_conformance/SVM/test_shared_address_space_coarse_grain.cpp +++ b/test_conformance/SVM/test_shared_address_space_coarse_grain.cpp @@ -274,12 +274,12 @@ int shared_address_space_coarse_grain(cl_device_id deviceID, cl_context context2 REGISTER_TEST(svm_shared_address_space_coarse_grain_old_api) { - return shared_address_space_coarse_grain(deviceID, context, queue, + return shared_address_space_coarse_grain(device, context, queue, num_elements, CL_FALSE); } REGISTER_TEST(svm_shared_address_space_coarse_grain_new_api) { - return shared_address_space_coarse_grain(deviceID, context, queue, + return shared_address_space_coarse_grain(device, context, queue, num_elements, CL_TRUE); } diff --git a/test_conformance/SVM/test_shared_address_space_fine_grain.cpp b/test_conformance/SVM/test_shared_address_space_fine_grain.cpp index 4462f61b8e..64fedca0da 100644 --- a/test_conformance/SVM/test_shared_address_space_fine_grain.cpp +++ b/test_conformance/SVM/test_shared_address_space_fine_grain.cpp @@ -28,9 +28,9 @@ REGISTER_TEST(svm_shared_address_space_fine_grain) cl_int error = CL_SUCCESS; clCommandQueueWrapper queues[MAXQ]; - error = create_cl_objects( - deviceID, &linked_list_create_and_verify_kernels[0], &contextWrapper, - &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM); + error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0], + &contextWrapper, &program, &queues[0], + &num_devices, CL_DEVICE_SVM_FINE_GRAIN_SYSTEM); context = contextWrapper; if (error == 1) return 0; // no devices capable of requested SVM level, so don't execute diff --git a/test_conformance/SVM/test_shared_address_space_fine_grain_buffers.cpp b/test_conformance/SVM/test_shared_address_space_fine_grain_buffers.cpp index 1e07554af8..7f207d8567 100644 --- a/test_conformance/SVM/test_shared_address_space_fine_grain_buffers.cpp +++ b/test_conformance/SVM/test_shared_address_space_fine_grain_buffers.cpp @@ -69,9 +69,9 @@ REGISTER_TEST(svm_shared_address_space_fine_grain_buffers) cl_int error = CL_SUCCESS; clCommandQueueWrapper queues[MAXQ]; - error = create_cl_objects( - deviceID, &linked_list_create_and_verify_kernels[0], &contextWrapper, - &program, &queues[0], &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER); + error = create_cl_objects(device, &linked_list_create_and_verify_kernels[0], + &contextWrapper, &program, &queues[0], + &num_devices, CL_DEVICE_SVM_FINE_GRAIN_BUFFER); context = contextWrapper; if (error == 1) return 0; // no devices capable of requested SVM level, so don't execute diff --git a/test_conformance/SVM/test_shared_sub_buffers.cpp b/test_conformance/SVM/test_shared_sub_buffers.cpp index 1c4056c669..700c3b6aad 100644 --- a/test_conformance/SVM/test_shared_sub_buffers.cpp +++ b/test_conformance/SVM/test_shared_sub_buffers.cpp @@ -133,7 +133,7 @@ REGISTER_TEST(svm_shared_sub_buffers) cl_int error = CL_SUCCESS; clCommandQueueWrapper queues[MAXQ]; - error = create_cl_objects(deviceID, &shared_sub_buffers_test_kernel[0], + error = create_cl_objects(device, &shared_sub_buffers_test_kernel[0], &contextWrapper, &program, &queues[0], &num_devices, CL_DEVICE_SVM_COARSE_GRAIN_BUFFER); context = contextWrapper; diff --git a/test_conformance/device_timer/test_device_timer.cpp b/test_conformance/device_timer/test_device_timer.cpp index 88bd9a3caa..be6df38248 100644 --- a/test_conformance/device_timer/test_device_timer.cpp +++ b/test_conformance/device_timer/test_device_timer.cpp @@ -35,14 +35,14 @@ REGISTER_TEST(device_and_host_timers) cl_ulong observedDiff; cl_ulong allowedDiff; - result = clGetDeviceAndHostTimer(deviceID, &deviceStartTime, &hostStartTime); + result = clGetDeviceAndHostTimer(device, &deviceStartTime, &hostStartTime); if (result != CL_SUCCESS) { log_error("clGetDeviceAndHostTimer failed with error %s\n", IGetErrorString(result)); errors++; goto End; } - result = clGetHostTimer(deviceID, &hostOnlyStartTime); + result = clGetHostTimer(device, &hostOnlyStartTime); if (result != CL_SUCCESS) { log_error("clGetHostTimer failed with error %s\n", IGetErrorString(result)); errors++; @@ -52,14 +52,14 @@ REGISTER_TEST(device_and_host_timers) // Wait for a while to allow the timers to increment substantially. sleep(5); - result = clGetDeviceAndHostTimer(deviceID, &deviceEndTime, &hostEndTime); + result = clGetDeviceAndHostTimer(device, &deviceEndTime, &hostEndTime); if (result != CL_SUCCESS) { log_error("clGetDeviceAndHostTimer failed with error %s\n", IGetErrorString(result)); errors++; goto End; } - result = clGetHostTimer(deviceID, &hostOnlyEndTime); + result = clGetHostTimer(device, &hostOnlyEndTime); if (result != CL_SUCCESS) { log_error("clGetHostTimer failed with error %s\n", IGetErrorString(result)); errors++; @@ -133,13 +133,16 @@ REGISTER_TEST(timer_resolution_queries) cl_ulong deviceTimerResolution = 0; cl_ulong hostTimerResolution = 0; - result = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); + result = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), + &platform, NULL); if (result != CL_SUCCESS) { log_error("clGetDeviceInfo(CL_DEVICE_PLATFORM) failed with error %s.\n", IGetErrorString(result)); errors++; } - - result = clGetDeviceInfo(deviceID, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(deviceTimerResolution), &deviceTimerResolution, NULL); + + result = clGetDeviceInfo(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION, + sizeof(deviceTimerResolution), + &deviceTimerResolution, NULL); if (result != CL_SUCCESS) { log_error("clGetDeviceInfo(CL_DEVICE_PROFILING_TIMER_RESOLUTION) failed with error %s.\n", IGetErrorString(result)); errors++; diff --git a/test_conformance/spirv_new/test_basic_versions.cpp b/test_conformance/spirv_new/test_basic_versions.cpp index 011234c541..29c599870e 100644 --- a/test_conformance/spirv_new/test_basic_versions.cpp +++ b/test_conformance/spirv_new/test_basic_versions.cpp @@ -52,13 +52,13 @@ REGISTER_TEST(basic_versions) }); size_t sz = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_IL_VERSION, 0, NULL, &sz); + error = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &sz); test_error(error, "Unable to query device IL versions size"); std::string ilVersions; ilVersions.resize(sz); - error = clGetDeviceInfo(deviceID, CL_DEVICE_IL_VERSION, sz, &ilVersions[0], - NULL); + error = + clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, sz, &ilVersions[0], NULL); test_error(error, "Unable to query device IL versions string"); for (auto& testCase : mapILtoSubdir) @@ -88,7 +88,7 @@ REGISTER_TEST(basic_versions) std::string filename = testCase.second + "/basic"; clProgramWrapper prog; - error = get_program_with_il(prog, deviceID, context, filename.c_str()); + error = get_program_with_il(prog, device, context, filename.c_str()); test_error(error, "Unable to build SPIR-V program"); clKernelWrapper kernel = clCreateKernel(prog, "test_basic", &error); diff --git a/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp b/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp index 74a425c4ce..4b5fbbbc9a 100644 --- a/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp +++ b/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp @@ -119,7 +119,7 @@ static int test_expect_type(cl_device_id device, cl_context context, REGISTER_TEST(op_expect) { - if (!is_extension_available(deviceID, "cl_khr_expect_assume")) + if (!is_extension_available(device, "cl_khr_expect_assume")) { log_info("cl_khr_expect_assume is not supported; skipping test.\n"); return TEST_SKIPPED_ITSELF; @@ -127,21 +127,21 @@ REGISTER_TEST(op_expect) int result = TEST_PASS; - result |= test_expect_type(deviceID, context, queue); - result |= test_expect_type(deviceID, context, queue); - result |= test_expect_type(deviceID, context, queue); + result |= test_expect_type(device, context, queue); + result |= test_expect_type(device, context, queue); + result |= test_expect_type(device, context, queue); if (gHasLong) { - result |= test_expect_type(deviceID, context, queue); + result |= test_expect_type(device, context, queue); } - result |= test_expect_type(deviceID, context, queue); + result |= test_expect_type(device, context, queue); return result; } REGISTER_TEST(op_assume) { - if (!is_extension_available(deviceID, "cl_khr_expect_assume")) + if (!is_extension_available(device, "cl_khr_expect_assume")) { log_info("cl_khr_expect_assume is not supported; skipping test.\n"); return TEST_SKIPPED_ITSELF; @@ -154,7 +154,7 @@ REGISTER_TEST(op_assume) test_error(error, "Unable to create destination buffer"); clProgramWrapper prog; - error = get_program_with_il(prog, deviceID, context, "assume"); + error = get_program_with_il(prog, device, context, "assume"); test_error(error, "Unable to build SPIR-V program"); clKernelWrapper kernel = clCreateKernel(prog, "test_assume", &error); diff --git a/test_conformance/spirv_new/test_decorate.cpp b/test_conformance/spirv_new/test_decorate.cpp index 8c76aa225a..b1168fe0c0 100644 --- a/test_conformance/spirv_new/test_decorate.cpp +++ b/test_conformance/spirv_new/test_decorate.cpp @@ -112,24 +112,24 @@ int test_decorate_full(cl_device_id deviceID, REGISTER_TEST(decorate_restrict) { - return test_decorate_full(deviceID, context, queue, "decorate_restrict"); + return test_decorate_full(device, context, queue, "decorate_restrict"); } REGISTER_TEST(decorate_aliased) { - return test_decorate_full(deviceID, context, queue, "decorate_aliased"); + return test_decorate_full(device, context, queue, "decorate_aliased"); } REGISTER_TEST(decorate_alignment) { //TODO: Check for results ? How to ensure buffers are aligned clProgramWrapper prog; - return get_program_with_il(prog, deviceID, context, "decorate_alignment"); + return get_program_with_il(prog, device, context, "decorate_alignment"); } REGISTER_TEST(decorate_constant) { - return test_decorate_full(deviceID, context, queue, "decorate_constant"); + return test_decorate_full(device, context, queue, "decorate_constant"); } REGISTER_TEST(decorate_cpacked) @@ -145,7 +145,7 @@ REGISTER_TEST(decorate_cpacked) std::vector packed(num); clProgramWrapper prog; - cl_int err = get_program_with_il(prog, deviceID, context, "decorate_cpacked"); + cl_int err = get_program_with_il(prog, device, context, "decorate_cpacked"); clKernelWrapper kernel = clCreateKernel(prog, "decorate_cpacked", &err); SPIRV_CHECK_ERROR(err, "Failed to create spv kernel"); @@ -388,8 +388,8 @@ int test_saturate_full(cl_device_id deviceID, typedef cl_##Tl cl_Tl; \ typedef cl_##To cl_To; \ const char *name = "decorate_saturated_conversion_" #Ti "_to_" #To; \ - return test_saturate_full( \ - deviceID, context, queue, name, #Ti #Tl #To); \ + return test_saturate_full(device, context, queue, \ + name, #Ti #Tl #To); \ } TEST_SATURATED_CONVERSION(half, short, char) @@ -547,7 +547,7 @@ static inline Ti generate_fprounding_input(RandomSeed &seed) out[i] = func(in[i]); \ } \ const char *name = "decorate_rounding_" #name "_" #Ti "_" #To; \ - return test_fp_rounding(deviceID, context, queue, name, in, out); \ + return test_fp_rounding(device, context, queue, name, in, out); \ } TEST_SPIRV_FP_ROUNDING_DECORATE(rte, round_to_even, half, short); diff --git a/test_conformance/spirv_new/test_get_program_il.cpp b/test_conformance/spirv_new/test_get_program_il.cpp index 7c0d39dfea..83c08769cd 100644 --- a/test_conformance/spirv_new/test_get_program_il.cpp +++ b/test_conformance/spirv_new/test_get_program_il.cpp @@ -34,7 +34,7 @@ REGISTER_TEST(get_program_il) /* If a program has been created with clCreateProgramWithIL, CL_PROGRAM_IL * should return the program IL it was created with and it's size */ - if (gCoreILProgram || is_extension_available(deviceID, "cl_khr_il_program")) + if (gCoreILProgram || is_extension_available(device, "cl_khr_il_program")) { clProgramWrapper il_program; std::string spvStr = "op_function_none"; @@ -51,7 +51,7 @@ REGISTER_TEST(get_program_il) /* Create program with IL */ unsigned char *spirv_buffer = &spirv_binary[0]; - error = get_program_with_il(il_program, deviceID, context, spvName); + error = get_program_with_il(il_program, device, context, spvName); SPIRV_CHECK_ERROR(error, "Unable to create program with IL."); if (il_program == NULL) diff --git a/test_conformance/spirv_new/test_linkage.cpp b/test_conformance/spirv_new/test_linkage.cpp index 6e991bd701..bf45292755 100644 --- a/test_conformance/spirv_new/test_linkage.cpp +++ b/test_conformance/spirv_new/test_linkage.cpp @@ -80,13 +80,13 @@ static int test_linkage_compile(cl_device_id deviceID, REGISTER_TEST(linkage_export_function_compile) { clProgramWrapper prog; - return test_linkage_compile(deviceID, context, queue, "linkage_export", prog); + return test_linkage_compile(device, context, queue, "linkage_export", prog); } REGISTER_TEST(linkage_import_function_compile) { clProgramWrapper prog; - return test_linkage_compile(deviceID, context, queue, "linkage_import", prog); + return test_linkage_compile(device, context, queue, "linkage_import", prog); } REGISTER_TEST(linkage_import_function_link) @@ -94,16 +94,19 @@ REGISTER_TEST(linkage_import_function_link) int err = 0; clProgramWrapper prog_export; - err = test_linkage_compile(deviceID, context, queue, "linkage_export", prog_export); + err = test_linkage_compile(device, context, queue, "linkage_export", + prog_export); SPIRV_CHECK_ERROR(err, "Failed to compile export program"); clProgramWrapper prog_import; - err = test_linkage_compile(deviceID, context, queue, "linkage_import", prog_import); + err = test_linkage_compile(device, context, queue, "linkage_import", + prog_import); SPIRV_CHECK_ERROR(err, "Failed to compile import program"); cl_program progs[] = {prog_export, prog_import}; - clProgramWrapper prog = clLinkProgram(context, 1, &deviceID, NULL, 2, progs, NULL, NULL, &err); + clProgramWrapper prog = + clLinkProgram(context, 1, &device, NULL, 2, progs, NULL, NULL, &err); SPIRV_CHECK_ERROR(err, "Failed to link programs"); clKernelWrapper kernel = clCreateKernel(prog, "test_linkage", &err); @@ -214,7 +217,7 @@ static int test_linkonce_odr_helper(cl_device_id deviceID, cl_context context, REGISTER_TEST(linkage_linkonce_odr) { - if (!is_extension_available(deviceID, "cl_khr_spirv_linkonce_odr")) + if (!is_extension_available(device, "cl_khr_spirv_linkonce_odr")) { log_info("Extension cl_khr_spirv_linkonce_odr not supported; skipping " "tests.\n"); @@ -226,13 +229,13 @@ REGISTER_TEST(linkage_linkonce_odr) // For this test, use the default main module, which has an "a" function // with the linkonce_odr linkage type. This ensures that having two "a" // functions with linkonce_odr works properly. - result |= test_linkonce_odr_helper(deviceID, context, queue, + result |= test_linkonce_odr_helper(device, context, queue, "linkage_linkonce_odr_main"); // For this test, use a main module without the "a" function. This ensures // that the "a" function is properly exported with the linkonce_odr linkage // type. - result |= test_linkonce_odr_helper(deviceID, context, queue, + result |= test_linkonce_odr_helper(device, context, queue, "linkage_linkonce_odr_noa_main"); return result; diff --git a/test_conformance/spirv_new/test_no_integer_wrap_decoration.cpp b/test_conformance/spirv_new/test_no_integer_wrap_decoration.cpp index 15088f5189..a4fb9618c8 100644 --- a/test_conformance/spirv_new/test_no_integer_wrap_decoration.cpp +++ b/test_conformance/spirv_new/test_no_integer_wrap_decoration.cpp @@ -229,14 +229,14 @@ int test_no_integer_wrap_decoration(cl_device_id deviceID, cl_context context, REGISTER_TEST(ext_cl_khr_spirv_no_integer_wrap_decoration_##FUNC##_##TYPE) \ { \ if (!is_extension_available( \ - deviceID, "cl_khr_spirv_no_integer_wrap_decoration")) \ + device, "cl_khr_spirv_no_integer_wrap_decoration")) \ { \ log_info("Extension cl_khr_spirv_no_integer_wrap_decoration not " \ "supported; skipping tests.\n"); \ return TEST_SKIPPED_ITSELF; \ } \ return test_no_integer_wrap_decoration( \ - deviceID, context, queue, \ + device, context, queue, \ "ext_cl_khr_spirv_no_integer_wrap_decoration_" #FUNC "_" #TYPE, \ #FUNC, #TYPE); \ } @@ -254,13 +254,13 @@ TEST_FMATH_FUNC_KHR(uint, fshiftleft) #define TEST_FMATH_FUNC_14(TYPE, FUNC) \ REGISTER_TEST(spirv14_no_integer_wrap_decoration_##FUNC##_##TYPE) \ { \ - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) \ + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) \ { \ log_info("SPIR-V 1.4 not supported; skipping tests.\n"); \ return TEST_SKIPPED_ITSELF; \ } \ return test_no_integer_wrap_decoration( \ - deviceID, context, queue, \ + device, context, queue, \ "spv1.4/no_integer_wrap_decoration_" #FUNC "_" #TYPE, #FUNC, \ #TYPE); \ } diff --git a/test_conformance/spirv_new/test_op_atomic.cpp b/test_conformance/spirv_new/test_op_atomic.cpp index dca310d7b1..aa7f6d39aa 100644 --- a/test_conformance/spirv_new/test_op_atomic.cpp +++ b/test_conformance/spirv_new/test_op_atomic.cpp @@ -90,13 +90,13 @@ int test_atomic(cl_device_id deviceID, cl_context context, REGISTER_TEST(op_atomic_inc_global) { int num = 1 << 16; - return test_atomic(deviceID, context, queue, - "atomic_inc_global", num, true); + return test_atomic(device, context, queue, "atomic_inc_global", num, + true); } REGISTER_TEST(op_atomic_dec_global) { int num = 1 << 16; - return test_atomic(deviceID, context, queue, - "atomic_dec_global", num, false); + return test_atomic(device, context, queue, "atomic_dec_global", num, + false); } diff --git a/test_conformance/spirv_new/test_op_branch.cpp b/test_conformance/spirv_new/test_op_branch.cpp index 6ffeb5ed8f..45ce2ec70b 100644 --- a/test_conformance/spirv_new/test_op_branch.cpp +++ b/test_conformance/spirv_new/test_op_branch.cpp @@ -75,7 +75,7 @@ int test_branch_simple(cl_device_id deviceID, cl_context context, { \ results[i] = genrand(seed); \ } \ - return test_branch_simple(deviceID, context, queue, #NAME "_simple", \ + return test_branch_simple(device, context, queue, #NAME "_simple", \ results); \ } diff --git a/test_conformance/spirv_new/test_op_branch_conditional.cpp b/test_conformance/spirv_new/test_op_branch_conditional.cpp index d7705e8b64..705c062232 100644 --- a/test_conformance/spirv_new/test_op_branch_conditional.cpp +++ b/test_conformance/spirv_new/test_op_branch_conditional.cpp @@ -100,7 +100,7 @@ int test_branch_conditional(cl_device_id deviceID, out[i] = lhs[i] < rhs[i] ? (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); \ } \ \ - return test_branch_conditional(deviceID, context, queue, #name, lhs, \ + return test_branch_conditional(device, context, queue, #name, lhs, \ rhs, out); \ } diff --git a/test_conformance/spirv_new/test_op_composite_construct.cpp b/test_conformance/spirv_new/test_op_composite_construct.cpp index 3d8d450fd8..0f8f33f7fa 100644 --- a/test_conformance/spirv_new/test_op_composite_construct.cpp +++ b/test_conformance/spirv_new/test_op_composite_construct.cpp @@ -60,7 +60,8 @@ REGISTER_TEST(op_composite_construct_int4) { cl_int4 value = { { 123, 122, 121, 119 } }; std::vector results(256, value); - return test_composite_construct(deviceID, context, queue, "composite_construct_int4", results); + return test_composite_construct(device, context, queue, + "composite_construct_int4", results); } REGISTER_TEST(op_composite_construct_struct) @@ -73,5 +74,6 @@ REGISTER_TEST(op_composite_construct_struct) CustomType2 value2 = {intvals, value1}; std::vector results(256, value2); - return test_composite_construct(deviceID, context, queue, "composite_construct_struct", results); + return test_composite_construct(device, context, queue, + "composite_construct_struct", results); } diff --git a/test_conformance/spirv_new/test_op_constant.cpp b/test_conformance/spirv_new/test_op_constant.cpp index abbee1ebb6..df58aca7c3 100644 --- a/test_conformance/spirv_new/test_op_constant.cpp +++ b/test_conformance/spirv_new/test_op_constant.cpp @@ -68,7 +68,7 @@ int test_constant(cl_device_id deviceID, cl_context context, REGISTER_TEST(op_constant_##NAME##_simple) \ { \ std::vector results(1024, (type)value); \ - return test_constant(deviceID, context, queue, \ + return test_constant(device, context, queue, \ "constant_" #NAME "_simple", results); \ } @@ -101,14 +101,15 @@ REGISTER_TEST(op_constant_int4_simple) { cl_int4 value = { { 123, 122, 121, 119 } }; std::vector results(256, value); - return test_constant(deviceID, context, queue, "constant_int4_simple", results); + return test_constant(device, context, queue, "constant_int4_simple", + results); } REGISTER_TEST(op_constant_int3_simple) { cl_int3 value = { { 123, 122, 121, 0 } }; std::vector results(256, value); - return test_constant(deviceID, context, queue, "constant_int3_simple", + return test_constant(device, context, queue, "constant_int3_simple", results, isVectorNotEqual); } @@ -116,14 +117,16 @@ REGISTER_TEST(op_constant_struct_int_float_simple) { AbstractStruct2 value = {1024, 3.1415}; std::vector > results(256, value); - return test_constant(deviceID, context, queue, "constant_struct_int_float_simple", results); + return test_constant(device, context, queue, + "constant_struct_int_float_simple", results); } REGISTER_TEST(op_constant_struct_int_char_simple) { AbstractStruct2 value = { 2100483600, (char)128 }; std::vector > results(256, value); - return test_constant(deviceID, context, queue, "constant_struct_int_char_simple", results); + return test_constant(device, context, queue, + "constant_struct_int_char_simple", results); } REGISTER_TEST(op_constant_struct_struct_simple) @@ -136,14 +139,14 @@ REGISTER_TEST(op_constant_struct_struct_simple) CustomType2 value2 = {intvals, value1}; std::vector results(256, value2); - return test_constant(deviceID, context, queue, "constant_struct_struct_simple", results); + return test_constant(device, context, queue, + "constant_struct_struct_simple", results); } REGISTER_TEST(op_constant_half_simple) { - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); + PASSIVE_REQUIRE_FP16_SUPPORT(device); std::vector results(1024, 3.25); - return test_constant(deviceID, context, queue, - "constant_half_simple", + return test_constant(device, context, queue, "constant_half_simple", results); } diff --git a/test_conformance/spirv_new/test_op_copy_object.cpp b/test_conformance/spirv_new/test_op_copy_object.cpp index fa76581cd9..ec794b93ba 100644 --- a/test_conformance/spirv_new/test_op_copy_object.cpp +++ b/test_conformance/spirv_new/test_op_copy_object.cpp @@ -68,7 +68,7 @@ int test_copy(cl_device_id deviceID, cl_context context, REGISTER_TEST(op_copy_##NAME##_simple) \ { \ std::vector results(1024, (type)value); \ - return test_copy(deviceID, context, queue, "copy_" #NAME "_simple", \ + return test_copy(device, context, queue, "copy_" #NAME "_simple", \ results); \ } @@ -97,29 +97,31 @@ REGISTER_TEST(op_copy_int4_simple) { cl_int4 value = { { 123, 122, 121, 119 } }; std::vector results(256, value); - return test_copy(deviceID, context, queue, "copy_int4_simple", results); + return test_copy(device, context, queue, "copy_int4_simple", results); } REGISTER_TEST(op_copy_int3_simple) { cl_int3 value = { { 123, 122, 121, 0 } }; std::vector results(256, value); - return test_copy(deviceID, context, queue, "copy_int3_simple", - results, isVectorNotEqual); + return test_copy(device, context, queue, "copy_int3_simple", results, + isVectorNotEqual); } REGISTER_TEST(op_copy_struct_int_float_simple) { AbstractStruct2 value = {1024, 3.1415}; std::vector > results(256, value); - return test_copy(deviceID, context, queue, "copy_struct_int_float_simple", results); + return test_copy(device, context, queue, "copy_struct_int_float_simple", + results); } REGISTER_TEST(op_copy_struct_int_char_simple) { AbstractStruct2 value = { 2100483600, (char)128 }; std::vector > results(256, value); - return test_copy(deviceID, context, queue, "copy_struct_int_char_simple", results); + return test_copy(device, context, queue, "copy_struct_int_char_simple", + results); } REGISTER_TEST(op_copy_struct_struct_simple) @@ -132,14 +134,13 @@ REGISTER_TEST(op_copy_struct_struct_simple) CustomType2 value2 = {intvals, value1}; std::vector results(256, value2); - return test_copy(deviceID, context, queue, "copy_struct_struct_simple", results); + return test_copy(device, context, queue, "copy_struct_struct_simple", + results); } REGISTER_TEST(op_copy_half_simple) { - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); + PASSIVE_REQUIRE_FP16_SUPPORT(device); std::vector results(1024, 3.25); - return test_copy(deviceID, context, queue, - "copy_half_simple", - results); + return test_copy(device, context, queue, "copy_half_simple", results); } diff --git a/test_conformance/spirv_new/test_op_fmath.cpp b/test_conformance/spirv_new/test_op_fmath.cpp index 3dfe901497..4a45b81e29 100644 --- a/test_conformance/spirv_new/test_op_fmath.cpp +++ b/test_conformance/spirv_new/test_op_fmath.cpp @@ -155,7 +155,7 @@ int test_fmath(cl_device_id deviceID, { \ if (sizeof(cl_##TYPE) == 2) \ { \ - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ + PASSIVE_REQUIRE_FP16_SUPPORT(device); \ } \ const int num = 1 << 20; \ std::vector lhs(num); \ @@ -170,7 +170,7 @@ int test_fmath(cl_device_id deviceID, } \ \ const char *mode = #MODE; \ - return test_fmath(deviceID, context, queue, #FUNC "_" #TYPE, #FUNC, \ + return test_fmath(device, context, queue, #FUNC "_" #TYPE, #FUNC, \ #TYPE, mode[0] == 'f', lhs, rhs); \ } diff --git a/test_conformance/spirv_new/test_op_function.cpp b/test_conformance/spirv_new/test_op_function.cpp index 4f8c4442c9..889d86674d 100644 --- a/test_conformance/spirv_new/test_op_function.cpp +++ b/test_conformance/spirv_new/test_op_function.cpp @@ -77,7 +77,7 @@ int test_function(cl_device_id deviceID, { \ in[i] = genrand(seed); \ } \ - return test_function(deviceID, context, queue, #TYPE, in); \ + return test_function(device, context, queue, #TYPE, in); \ } TEST_FUNCTION(none) diff --git a/test_conformance/spirv_new/test_op_lifetime.cpp b/test_conformance/spirv_new/test_op_lifetime.cpp index f8b7dd5f40..2c9058178d 100644 --- a/test_conformance/spirv_new/test_op_lifetime.cpp +++ b/test_conformance/spirv_new/test_op_lifetime.cpp @@ -100,8 +100,7 @@ int test_op_lifetime(cl_device_id deviceID, out[i] = lhs[i] - rhs[i]; \ } \ \ - return test_op_lifetime(deviceID, context, queue, #name, lhs, rhs, \ - out); \ + return test_op_lifetime(device, context, queue, #name, lhs, rhs, out); \ } TEST_LIFETIME(lifetime_simple) diff --git a/test_conformance/spirv_new/test_op_loop_merge.cpp b/test_conformance/spirv_new/test_op_loop_merge.cpp index 2e9f65b0ce..cbb0459b7e 100644 --- a/test_conformance/spirv_new/test_op_loop_merge.cpp +++ b/test_conformance/spirv_new/test_op_loop_merge.cpp @@ -103,7 +103,7 @@ int test_selection_merge(cl_device_id deviceID, out[i] = res; \ } \ \ - return test_selection_merge(deviceID, context, queue, \ + return test_selection_merge(device, context, queue, \ "loop_merge_branch_" #control, in, out, \ rep); \ } diff --git a/test_conformance/spirv_new/test_op_negate.cpp b/test_conformance/spirv_new/test_op_negate.cpp index 7ff2b844be..9d23bae260 100644 --- a/test_conformance/spirv_new/test_op_negate.cpp +++ b/test_conformance/spirv_new/test_op_negate.cpp @@ -95,7 +95,7 @@ int test_negation(cl_device_id deviceID, { \ in[i] = genrand(seed); \ } \ - return test_negation(deviceID, context, queue, #TYPE, #OP, in, \ + return test_negation(device, context, queue, #TYPE, #OP, in, \ FUNC); \ } diff --git a/test_conformance/spirv_new/test_op_opaque.cpp b/test_conformance/spirv_new/test_op_opaque.cpp index 19e3c3db7b..154f190261 100644 --- a/test_conformance/spirv_new/test_op_opaque.cpp +++ b/test_conformance/spirv_new/test_op_opaque.cpp @@ -41,7 +41,7 @@ REGISTER_TEST(op_type_opaque_simple) else { cl_platform_id platform; - err = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, + err = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); SPIRV_CHECK_ERROR(err, "Failed to get platform info with clGetDeviceInfo"); @@ -61,7 +61,7 @@ REGISTER_TEST(op_type_opaque_simple) err, "Failed to create program with clCreateProgramWithILKHR"); } - err = clCompileProgram(prog, 1, &deviceID, + err = clCompileProgram(prog, 1, &device, NULL, // options 0, // num headers NULL, // input headers diff --git a/test_conformance/spirv_new/test_op_phi.cpp b/test_conformance/spirv_new/test_op_phi.cpp index 3f5e86c4dc..92856ef1dd 100644 --- a/test_conformance/spirv_new/test_op_phi.cpp +++ b/test_conformance/spirv_new/test_op_phi.cpp @@ -98,7 +98,7 @@ REGISTER_TEST(op_phi_2_blocks) out[i] = lhs[i] < rhs[i] ? (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); } - return test_phi(deviceID, context, queue, "phi_2", lhs, rhs, out); + return test_phi(device, context, queue, "phi_2", lhs, rhs, out); } REGISTER_TEST(op_phi_3_blocks) @@ -120,7 +120,7 @@ REGISTER_TEST(op_phi_3_blocks) } } - return test_phi(deviceID, context, queue, "phi_3", lhs, rhs, out); + return test_phi(device, context, queue, "phi_3", lhs, rhs, out); } REGISTER_TEST(op_phi_4_blocks) @@ -142,5 +142,5 @@ REGISTER_TEST(op_phi_4_blocks) } } - return test_phi(deviceID, context, queue, "phi_4", lhs, rhs, out); + return test_phi(device, context, queue, "phi_4", lhs, rhs, out); } diff --git a/test_conformance/spirv_new/test_op_selection_merge.cpp b/test_conformance/spirv_new/test_op_selection_merge.cpp index e719108575..b178fa44f0 100644 --- a/test_conformance/spirv_new/test_op_selection_merge.cpp +++ b/test_conformance/spirv_new/test_op_selection_merge.cpp @@ -100,7 +100,7 @@ int test_selection_merge(cl_device_id deviceID, out[i] = lhs[i] < rhs[i] ? (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); \ } \ \ - return test_selection_merge(deviceID, context, queue, \ + return test_selection_merge(device, context, queue, \ "select_if_" #control, lhs, rhs, out); \ } @@ -125,7 +125,7 @@ TEST_SELECT_IF(dont_flatten) out[i] = (lhs[i] + rhs[i]) % 4; \ } \ \ - return test_selection_merge(deviceID, context, queue, \ + return test_selection_merge(device, context, queue, \ "select_switch_" #control, lhs, rhs, out); \ } diff --git a/test_conformance/spirv_new/test_op_spec_constant.cpp b/test_conformance/spirv_new/test_op_spec_constant.cpp index 3bf2e825ed..26f32e8445 100644 --- a/test_conformance/spirv_new/test_op_spec_constant.cpp +++ b/test_conformance/spirv_new/test_op_spec_constant.cpp @@ -120,7 +120,7 @@ int test_spec_constant(cl_device_id deviceID, cl_context context, type init_value = init_buffer; \ type final_value = init_value + spec_constant_value; \ return test_spec_constant( \ - deviceID, context, queue, "op_spec_constant_" #NAME "_simple", \ + device, context, queue, "op_spec_constant_" #NAME "_simple", \ init_value, (type)spec_constant_value, final_value); \ } @@ -144,7 +144,7 @@ REGISTER_TEST_VERSION(op_spec_constant_true_simple, Version(2, 2)) cl_uchar value = (cl_uchar)7; cl_uchar init_value = value; cl_uchar final_value = value + 1; - return test_spec_constant(deviceID, context, queue, + return test_spec_constant(device, context, queue, "op_spec_constant_true_simple", init_value, 0, final_value); } @@ -156,7 +156,7 @@ REGISTER_TEST_VERSION(op_spec_constant_false_simple, Version(2, 2)) cl_uchar value = (cl_uchar)7; cl_uchar init_value = value; cl_uchar final_value = value + 1; - return test_spec_constant(deviceID, context, queue, + return test_spec_constant(device, context, queue, "op_spec_constant_false_simple", init_value, 1, final_value); } diff --git a/test_conformance/spirv_new/test_op_undef.cpp b/test_conformance/spirv_new/test_op_undef.cpp index 36cb66cc1d..642f26faeb 100644 --- a/test_conformance/spirv_new/test_op_undef.cpp +++ b/test_conformance/spirv_new/test_op_undef.cpp @@ -60,7 +60,7 @@ int test_undef(cl_device_id deviceID, cl_context context, #define TEST_UNDEF(NAME, TYPE) \ REGISTER_TEST(op_undef_##NAME##_simple) \ { \ - return test_undef(deviceID, context, queue, \ + return test_undef(device, context, queue, \ "undef_" #NAME "_simple"); \ } @@ -95,25 +95,27 @@ TEST_UNDEF(int3 , cl_int3) REGISTER_TEST(op_undef_struct_int_float_simple) { typedef AbstractStruct2 CustomType; - return test_undef(deviceID, context, queue, "undef_struct_int_float_simple"); + return test_undef(device, context, queue, + "undef_struct_int_float_simple"); } REGISTER_TEST(op_undef_struct_int_char_simple) { typedef AbstractStruct2 CustomType; - return test_undef(deviceID, context, queue, "undef_struct_int_char_simple"); + return test_undef(device, context, queue, + "undef_struct_int_char_simple"); } REGISTER_TEST(op_undef_struct_struct_simple) { typedef AbstractStruct2 CustomType1; typedef AbstractStruct2 CustomType2; - return test_undef(deviceID, context, queue, "undef_struct_struct_simple"); + return test_undef(device, context, queue, + "undef_struct_struct_simple"); } REGISTER_TEST(op_undef_half_simple) { - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); - return test_undef(deviceID, context, queue, - "undef_half_simple"); + PASSIVE_REQUIRE_FP16_SUPPORT(device); + return test_undef(device, context, queue, "undef_half_simple"); } diff --git a/test_conformance/spirv_new/test_op_vector_extract.cpp b/test_conformance/spirv_new/test_op_vector_extract.cpp index 9188a0a32d..dd01f2634a 100644 --- a/test_conformance/spirv_new/test_op_vector_extract.cpp +++ b/test_conformance/spirv_new/test_op_vector_extract.cpp @@ -95,7 +95,7 @@ int test_extract(cl_device_id deviceID, cl_context context, { \ if (sizeof(cl_##TYPE) == 2) \ { \ - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ + PASSIVE_REQUIRE_FP16_SUPPORT(device); \ } \ typedef cl_##TYPE##N Tv; \ typedef cl_##TYPE Ts; \ @@ -110,7 +110,7 @@ int test_extract(cl_device_id deviceID, cl_context context, in[i] = genrand(seed); \ } \ \ - return test_extract(deviceID, context, queue, name, in, N); \ + return test_extract(device, context, queue, name, in, N); \ } TEST_VECTOR_EXTRACT(half, 8) diff --git a/test_conformance/spirv_new/test_op_vector_insert.cpp b/test_conformance/spirv_new/test_op_vector_insert.cpp index 32e883e3f5..eb3f9e18f1 100644 --- a/test_conformance/spirv_new/test_op_vector_insert.cpp +++ b/test_conformance/spirv_new/test_op_vector_insert.cpp @@ -113,7 +113,7 @@ int test_insert(cl_device_id deviceID, cl_context context, { \ if (sizeof(cl_##TYPE) == 2) \ { \ - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ + PASSIVE_REQUIRE_FP16_SUPPORT(device); \ } \ typedef cl_##TYPE##N Tv; \ typedef cl_##TYPE Ts; \ @@ -128,7 +128,7 @@ int test_insert(cl_device_id deviceID, cl_context context, in[i] = genrand(seed); \ } \ \ - return test_insert(deviceID, context, queue, name, in, N); \ + return test_insert(device, context, queue, name, in, N); \ } TEST_VECTOR_INSERT(half, 8) diff --git a/test_conformance/spirv_new/test_op_vector_times_scalar.cpp b/test_conformance/spirv_new/test_op_vector_times_scalar.cpp index de92438d94..4763bb1b4b 100644 --- a/test_conformance/spirv_new/test_op_vector_times_scalar.cpp +++ b/test_conformance/spirv_new/test_op_vector_times_scalar.cpp @@ -166,7 +166,7 @@ int test_vector_times_scalar(cl_device_id deviceID, { \ if (sizeof(cl_##TYPE) == 2) \ { \ - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ + PASSIVE_REQUIRE_FP16_SUPPORT(device); \ } \ typedef cl_##TYPE##N Tv; \ typedef cl_##TYPE Ts; \ @@ -182,8 +182,8 @@ int test_vector_times_scalar(cl_device_id deviceID, rhs[i] = genrandReal(seed); \ } \ \ - return test_vector_times_scalar(deviceID, context, queue, \ - #TYPE, lhs, rhs); \ + return test_vector_times_scalar(device, context, queue, #TYPE, \ + lhs, rhs); \ } diff --git a/test_conformance/spirv_new/test_spirv_14.cpp b/test_conformance/spirv_new/test_spirv_14.cpp index 360250597c..6a643dfc4b 100644 --- a/test_conformance/spirv_new/test_spirv_14.cpp +++ b/test_conformance/spirv_new/test_spirv_14.cpp @@ -92,22 +92,22 @@ static int test_image_operand_helper(cl_device_id deviceID, cl_context context, REGISTER_TEST(spirv14_image_operand_signextend) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_image_operand_helper(deviceID, context, queue, true); + return test_image_operand_helper(device, context, queue, true); } REGISTER_TEST(spirv14_image_operand_zeroextend) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_image_operand_helper(deviceID, context, queue, false); + return test_image_operand_helper(device, context, queue, false); } static int test_loop_control_helper(cl_device_id deviceID, cl_context context, @@ -157,62 +157,62 @@ static int test_loop_control_helper(cl_device_id deviceID, cl_context context, REGISTER_TEST(spirv14_loop_control_miniterations) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_loop_control_helper(deviceID, context, queue, + return test_loop_control_helper(device, context, queue, "loop_control_miniterations"); } REGISTER_TEST(spirv14_loop_control_maxiterations) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_loop_control_helper(deviceID, context, queue, + return test_loop_control_helper(device, context, queue, "loop_control_maxiterations"); } REGISTER_TEST(spirv14_loop_control_iterationmultiple) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_loop_control_helper(deviceID, context, queue, + return test_loop_control_helper(device, context, queue, "loop_control_iterationmultiple"); } REGISTER_TEST(spirv14_loop_control_peelcount) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_loop_control_helper(deviceID, context, queue, + return test_loop_control_helper(device, context, queue, "loop_control_peelcount"); } REGISTER_TEST(spirv14_loop_control_partialcount) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_loop_control_helper(deviceID, context, queue, + return test_loop_control_helper(device, context, queue, "loop_control_partialcount"); } REGISTER_TEST(spirv14_ptrops) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; @@ -221,7 +221,7 @@ REGISTER_TEST(spirv14_ptrops) cl_int error = CL_SUCCESS; clProgramWrapper prog; - error = get_program_with_il(prog, deviceID, context, "spv1.4/ptrops"); + error = get_program_with_il(prog, device, context, "spv1.4/ptrops"); SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); clKernelWrapper kernel = clCreateKernel(prog, "ptrops_test", &error); @@ -333,29 +333,29 @@ static int test_usersemantic_decoration(cl_device_id deviceID, REGISTER_TEST(spirv14_usersemantic_decoratestring) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_usersemantic_decoration(deviceID, context, queue, false); + return test_usersemantic_decoration(device, context, queue, false); } REGISTER_TEST(spirv14_usersemantic_memberdecoratestring) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; } - return test_usersemantic_decoration(deviceID, context, queue, true); + return test_usersemantic_decoration(device, context, queue, true); } REGISTER_TEST(spirv14_nonwriteable_decoration) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; @@ -365,7 +365,7 @@ REGISTER_TEST(spirv14_nonwriteable_decoration) clProgramWrapper prog; error = get_program_with_il( - prog, deviceID, context, + prog, device, context, "spv1.4/nonwriteable_decoration_function_storage_class"); SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); @@ -401,7 +401,7 @@ REGISTER_TEST(spirv14_nonwriteable_decoration) REGISTER_TEST(spirv14_copymemory_memory_operands) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; @@ -410,7 +410,7 @@ REGISTER_TEST(spirv14_copymemory_memory_operands) cl_int error = CL_SUCCESS; clProgramWrapper prog; - error = get_program_with_il(prog, deviceID, context, + error = get_program_with_il(prog, device, context, "spv1.4/copymemory_memory_operands"); SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); @@ -454,7 +454,7 @@ REGISTER_TEST(spirv14_select_composite) { constexpr size_t global_size = 16; - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; @@ -463,8 +463,7 @@ REGISTER_TEST(spirv14_select_composite) cl_int error = CL_SUCCESS; clProgramWrapper prog; - error = - get_program_with_il(prog, deviceID, context, "spv1.4/select_struct"); + error = get_program_with_il(prog, device, context, "spv1.4/select_struct"); SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); clKernelWrapper kernel = clCreateKernel(prog, "select_struct_test", &error); @@ -514,7 +513,7 @@ REGISTER_TEST(spirv14_select_composite) REGISTER_TEST(spirv14_copylogical) { - if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + if (!is_spirv_version_supported(device, "SPIR-V_1.4")) { log_info("SPIR-V 1.4 not supported; skipping tests.\n"); return TEST_SKIPPED_ITSELF; @@ -522,8 +521,8 @@ REGISTER_TEST(spirv14_copylogical) cl_int error = CL_SUCCESS; clProgramWrapper prog; - error = get_program_with_il(prog, deviceID, context, - "spv1.4/copylogical_struct"); + error = + get_program_with_il(prog, device, context, "spv1.4/copylogical_struct"); SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); clKernelWrapper kernel = clCreateKernel(prog, "copylogical_test", &error); From 2fe382ec8a2dedc9de619a037eaca23d33b455aa Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:33:56 +0000 Subject: [PATCH 03/39] Migrate atomics suite to the new test registration framework (#2189) Contributes to #2181 --- test_conformance/atomics/main.cpp | 34 +----- test_conformance/atomics/procs.h | 51 -------- test_conformance/atomics/testBase.h | 28 ----- test_conformance/atomics/test_atomics.cpp | 110 ++++++++---------- .../atomics/test_indexed_cases.cpp | 12 +- 5 files changed, 56 insertions(+), 179 deletions(-) delete mode 100644 test_conformance/atomics/procs.h delete mode 100644 test_conformance/atomics/testBase.h diff --git a/test_conformance/atomics/main.cpp b/test_conformance/atomics/main.cpp index 987d6bfa1c..6e7c6d4807 100644 --- a/test_conformance/atomics/main.cpp +++ b/test_conformance/atomics/main.cpp @@ -13,39 +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/testHarness.h" - -#if !defined(_WIN32) -#include -#endif - -// clang-format off -test_definition test_list[] = { - ADD_TEST( atomic_add ), - ADD_TEST( atomic_sub ), - ADD_TEST( atomic_xchg ), - ADD_TEST( atomic_min ), - ADD_TEST( atomic_max ), - ADD_TEST( atomic_inc ), - ADD_TEST( atomic_dec ), - ADD_TEST( atomic_cmpxchg ), - ADD_TEST( atomic_and ), - ADD_TEST( atomic_or ), - ADD_TEST( atomic_xor ), - ADD_TEST( atomic_add_index ), - ADD_TEST( atomic_add_index_bin ), -}; -// clang-format on - -const int test_num = ARRAY_SIZE(test_list); +#include "harness/testHarness.h" 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/atomics/procs.h b/test_conformance/atomics/procs.h deleted file mode 100644 index 46bb34bd95..0000000000 --- a/test_conformance/atomics/procs.h +++ /dev/null @@ -1,51 +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. -// -#include "harness/errorHelpers.h" -#include "harness/kernelHelpers.h" -#include "harness/typeWrappers.h" - -extern int create_program_and_kernel(const char *source, - const char *kernel_name, - cl_program *program_ret, - cl_kernel *kernel_ret); - -extern int test_atomic_add(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_sub(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_xchg(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_min(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_max(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_inc(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_dec(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_cmpxchg(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_and(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_or(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_xor(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_atomic_add_index(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_atomic_add_index_bin(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); diff --git a/test_conformance/atomics/testBase.h b/test_conformance/atomics/testBase.h deleted file mode 100644 index 22bce1d2d4..0000000000 --- a/test_conformance/atomics/testBase.h +++ /dev/null @@ -1,28 +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 _testBase_h -#define _testBase_h - -#include "harness/compat.h" -#include -#include -#include -#include -#include - -#include "procs.h" - -#endif // _testBase_h diff --git a/test_conformance/atomics/test_atomics.cpp b/test_conformance/atomics/test_atomics.cpp index db0d000a7b..d74cd033cf 100644 --- a/test_conformance/atomics/test_atomics.cpp +++ b/test_conformance/atomics/test_atomics.cpp @@ -13,11 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "testBase.h" #include "harness/conversions.h" -#ifndef _WIN32 -#include -#endif +#include "harness/typeWrappers.h" #include @@ -568,8 +565,7 @@ cl_long test_atomic_add_result_long(size_t size, cl_long *startRefValues, return total; } -int test_atomic_add(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_add) { TestFns set = { 0, 0LL, @@ -582,12 +578,12 @@ int test_atomic_add(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_add_core, set, false, + device, context, queue, num_elements, atom_add_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_add_core, set, false, + device, context, queue, num_elements, atomic_add_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -618,8 +614,7 @@ cl_long test_atomic_sub_result_long(size_t size, cl_long *startRefValues, return total; } -int test_atomic_sub(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_sub) { TestFns set = { INT_TEST_VALUE, LONG_TEST_VALUE, @@ -632,12 +627,12 @@ int test_atomic_sub(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_sub_core, set, false, + device, context, queue, num_elements, atom_sub_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_sub_core, set, false, + device, context, queue, num_elements, atomic_sub_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -852,8 +847,7 @@ bool test_atomic_xchg_verify_float(size_t size, cl_float *refValues, return true; } -int test_atomic_xchg(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_xchg) { TestFns set = { INT_TEST_VALUE, LONG_TEST_VALUE, @@ -868,17 +862,17 @@ int test_atomic_xchg(cl_device_id deviceID, cl_context context, NULL, test_atomic_xchg_verify_float }; - int errors = test_atomic_function_set( - deviceID, context, queue, num_elements, atom_xchg_core, set, false, - true, /*usingAtomicPrefix*/ false); - errors |= test_atomic_function_set(deviceID, context, queue, num_elements, + int errors = test_atomic_function_set(device, context, queue, num_elements, + atom_xchg_core, set, false, true, + /*usingAtomicPrefix*/ false); + errors |= test_atomic_function_set(device, context, queue, num_elements, atomic_xchg_core, set, false, true, /*usingAtomicPrefix*/ true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atomic_xchg_float_core, set, false, false, kFloat, true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atomic_xchg_float_core, set, false, true, kFloat, true); @@ -931,8 +925,7 @@ void test_atomic_min_gen_long(size_t size, cl_long *startRefValues, MTdata d) | (((cl_long)genrand_int32(d) & 0x7fffffffL) << 16)); } -int test_atomic_min(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_min) { TestFns set = { 0x7fffffffL, 0x7fffffffffffffffLL, @@ -945,12 +938,12 @@ int test_atomic_min(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_min_core, set, true, + device, context, queue, num_elements, atom_min_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_min_core, set, true, + device, context, queue, num_elements, atomic_min_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -1003,8 +996,7 @@ void test_atomic_max_gen_long(size_t size, cl_long *startRefValues, MTdata d) | (((cl_long)genrand_int32(d) & 0x7fffffffL) << 16)); } -int test_atomic_max(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_max) { TestFns set = { 0, 0, @@ -1017,12 +1009,12 @@ int test_atomic_max(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_max_core, set, true, + device, context, queue, num_elements, atom_max_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_max_core, set, true, + device, context, queue, num_elements, atomic_max_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -1050,8 +1042,7 @@ cl_long test_atomic_inc_result_long(size_t size, cl_long *startRefValues, return LONG_TEST_VALUE + size; } -int test_atomic_inc(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_inc) { TestFns set = { INT_TEST_VALUE, LONG_TEST_VALUE, @@ -1064,12 +1055,12 @@ int test_atomic_inc(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_inc_core, set, false, + device, context, queue, num_elements, atom_inc_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_inc_core, set, false, + device, context, queue, num_elements, atomic_inc_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -1097,8 +1088,7 @@ cl_long test_atomic_dec_result_long(size_t size, cl_long *startRefValues, return LONG_TEST_VALUE - size; } -int test_atomic_dec(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_dec) { TestFns set = { INT_TEST_VALUE, LONG_TEST_VALUE, @@ -1111,12 +1101,12 @@ int test_atomic_dec(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_dec_core, set, false, + device, context, queue, num_elements, atom_dec_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_dec_core, set, false, + device, context, queue, num_elements, atomic_dec_core, set, false, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -1172,8 +1162,7 @@ cl_long test_atomic_cmpxchg_result_long(size_t size, cl_long *startRefValues, return total; } -int test_atomic_cmpxchg(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_cmpxchg) { TestFns set = { INT_TEST_VALUE, LONG_TEST_VALUE, @@ -1189,42 +1178,42 @@ int test_atomic_cmpxchg(cl_device_id deviceID, cl_context context, log_info(" Testing atom_ functions...\n"); errors |= - test_atomic_function(deviceID, context, queue, num_elements, + test_atomic_function(device, context, queue, num_elements, atom_cmpxchg_core, set, false, false, kInt, true); errors |= - test_atomic_function(deviceID, context, queue, num_elements, + test_atomic_function(device, context, queue, num_elements, atom_cmpxchg_core, set, false, false, kUInt, true); errors |= - test_atomic_function(deviceID, context, queue, num_elements, + test_atomic_function(device, context, queue, num_elements, atom_cmpxchg_core, set, false, true, kInt, true); errors |= - test_atomic_function(deviceID, context, queue, num_elements, + test_atomic_function(device, context, queue, num_elements, atom_cmpxchg_core, set, false, true, kUInt, true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atom_cmpxchg64_core, set, false, false, kLong, true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atom_cmpxchg64_core, set, false, false, kULong, true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atom_cmpxchg64_core, set, false, true, kLong, true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atom_cmpxchg64_core, set, false, true, kULong, true); log_info(" Testing atomic_ functions...\n"); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atomic_cmpxchg_core, set, false, false, kInt, true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atomic_cmpxchg_core, set, false, false, kUInt, true); errors |= - test_atomic_function(deviceID, context, queue, num_elements, + test_atomic_function(device, context, queue, num_elements, atomic_cmpxchg_core, set, false, true, kInt, true); - errors |= test_atomic_function(deviceID, context, queue, num_elements, + errors |= test_atomic_function(device, context, queue, num_elements, atomic_cmpxchg_core, set, false, true, kUInt, true); @@ -1289,8 +1278,7 @@ cl_long test_atomic_and_result_long(size_t size, cl_long *startRefValues, return bits; } -int test_atomic_and(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_and) { TestFns set = { (cl_int)0xffffffff, (cl_long)0xffffffffffffffffLL, @@ -1303,12 +1291,12 @@ int test_atomic_and(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_and_core, set, true, + device, context, queue, num_elements, atom_and_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_and_core, set, true, + device, context, queue, num_elements, atomic_and_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -1362,8 +1350,7 @@ cl_long test_atomic_or_result_long(size_t size, cl_long *startRefValues, return bits; } -int test_atomic_or(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_or) { TestFns set = { 0, 0LL, test_bitwise_num_results, test_atomic_or_result_int, @@ -1372,12 +1359,12 @@ int test_atomic_or(cl_device_id deviceID, cl_context context, }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_or_core, set, true, + device, context, queue, num_elements, atom_or_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_or_core, set, true, + device, context, queue, num_elements, atomic_or_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; @@ -1415,8 +1402,7 @@ cl_long test_atomic_xor_result_long(size_t size, cl_long *startRefValues, return total; } -int test_atomic_xor(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_xor) { TestFns set = { 0x2f08ab41, 0x2f08ab418ba0541LL, @@ -1429,12 +1415,12 @@ int test_atomic_xor(cl_device_id deviceID, cl_context context, NULL }; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atom_xor_core, set, true, + device, context, queue, num_elements, atom_xor_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ false) != 0) return -1; if (test_atomic_function_set( - deviceID, context, queue, num_elements, atomic_xor_core, set, true, + device, context, queue, num_elements, atomic_xor_core, set, true, /*matchGroupSize*/ false, /*usingAtomicPrefix*/ true) != 0) return -1; diff --git a/test_conformance/atomics/test_indexed_cases.cpp b/test_conformance/atomics/test_indexed_cases.cpp index ce0410bcfc..af2d4a9d11 100644 --- a/test_conformance/atomics/test_indexed_cases.cpp +++ b/test_conformance/atomics/test_indexed_cases.cpp @@ -16,8 +16,8 @@ #include -#include "testBase.h" #include "harness/conversions.h" +#include "harness/typeWrappers.h" // clang-format off const char *atomic_index_source = @@ -36,8 +36,7 @@ const char *atomic_index_source = "}"; // clang-format on -int test_atomic_add_index(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_add_index) { clProgramWrapper program; clKernelWrapper kernel; @@ -46,7 +45,7 @@ int test_atomic_add_index(cl_device_id deviceID, cl_context context, int fail = 0, err; /* Check if atomics are supported. */ - if (!is_extension_available(deviceID, "cl_khr_global_int32_base_atomics")) + if (!is_extension_available(device, "cl_khr_global_int32_base_atomics")) { log_info("Base atomics not supported " "(cl_khr_global_int32_base_atomics). Skipping test.\n"); @@ -474,8 +473,7 @@ int add_index_bin_test(size_t *global_threads, cl_command_queue queue, } } -int test_atomic_add_index_bin(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(atomic_add_index_bin) { //===== add_index_bin test size_t numGlobalThreads = 2048; @@ -484,7 +482,7 @@ int test_atomic_add_index_bin(cl_device_id deviceID, cl_context context, MTdata d = init_genrand(gRandomSeed); /* Check if atomics are supported. */ - if (!is_extension_available(deviceID, "cl_khr_global_int32_base_atomics")) + if (!is_extension_available(device, "cl_khr_global_int32_base_atomics")) { log_info("Base atomics not supported " "(cl_khr_global_int32_base_atomics). Skipping test.\n"); From 7d9ecaaf737575475b636fbf36b8e8925e8104e1 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:47:01 +0000 Subject: [PATCH 04/39] Migrate vectors suite to the new test registration framework (#2190) Contributes to #2181 --- test_conformance/vectors/main.cpp | 25 +--------- test_conformance/vectors/procs.h | 54 --------------------- test_conformance/vectors/testBase.h | 2 - test_conformance/vectors/test_step.cpp | 20 +++----- test_conformance/vectors/test_vec_align.cpp | 29 +++++------ 5 files changed, 22 insertions(+), 108 deletions(-) delete mode 100644 test_conformance/vectors/procs.h diff --git a/test_conformance/vectors/main.cpp b/test_conformance/vectors/main.cpp index e499faf9c7..6e7c6d4807 100644 --- a/test_conformance/vectors/main.cpp +++ b/test_conformance/vectors/main.cpp @@ -13,32 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#include "harness/compat.h" -#include -#include -#include "procs.h" #include "harness/testHarness.h" -#if !defined(_WIN32) -#include -#endif - -test_definition test_list[] = { - ADD_TEST(step_type), - ADD_TEST(step_var), - ADD_TEST(step_typedef_type), - ADD_TEST(step_typedef_var), - ADD_TEST(vec_align_array), - ADD_TEST(vec_align_struct), - ADD_TEST(vec_align_packed_struct), - ADD_TEST(vec_align_struct_arr), - ADD_TEST(vec_align_packed_struct_arr), -}; - -const int test_num = ARRAY_SIZE(test_list); - 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/vectors/procs.h b/test_conformance/vectors/procs.h deleted file mode 100644 index 7a6dba4175..0000000000 --- a/test_conformance/vectors/procs.h +++ /dev/null @@ -1,54 +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. -// -#include "harness/errorHelpers.h" -#include "harness/kernelHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/conversions.h" -#include "harness/mt19937.h" - -// The number of errors to print out for each test in the shuffle tests -#define MAX_ERRORS_TO_PRINT 1 - - -extern int create_program_and_kernel(const char *source, - const char *kernel_name, - cl_program *program_ret, - cl_kernel *kernel_ret); - -extern int test_step_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_step_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_step_typedef_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_step_typedef_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_array(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - - -int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -int test_vec_align_packed_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); diff --git a/test_conformance/vectors/testBase.h b/test_conformance/vectors/testBase.h index 63086d7e9b..a358b81a7f 100644 --- a/test_conformance/vectors/testBase.h +++ b/test_conformance/vectors/testBase.h @@ -23,6 +23,4 @@ #include #include -#include "procs.h" - #endif // _testBase_h diff --git a/test_conformance/vectors/test_step.cpp b/test_conformance/vectors/test_step.cpp index 4549cf1ead..1aa2e29d6d 100644 --- a/test_conformance/vectors/test_step.cpp +++ b/test_conformance/vectors/test_step.cpp @@ -222,30 +222,26 @@ static const char* patterns[] = { test_step_typedef_var, */ -int test_step_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_type) { - return test_step_internal(deviceID, context, queue, patterns[0], + return test_step_internal(device, context, queue, patterns[0], "test_step_type"); } -int test_step_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_var) { - return test_step_internal(deviceID, context, queue, patterns[1], + return test_step_internal(device, context, queue, patterns[1], "test_step_var"); } -int test_step_typedef_type(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_typedef_type) { - return test_step_internal(deviceID, context, queue, patterns[2], + return test_step_internal(device, context, queue, patterns[2], "test_step_typedef_type"); } -int test_step_typedef_var(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(step_typedef_var) { - return test_step_internal(deviceID, context, queue, patterns[3], + return test_step_internal(device, context, queue, patterns[3], "test_step_typedef_var"); } diff --git a/test_conformance/vectors/test_vec_align.cpp b/test_conformance/vectors/test_vec_align.cpp index 6c0d48b5a1..36fc6c471b 100644 --- a/test_conformance/vectors/test_vec_align.cpp +++ b/test_conformance/vectors/test_vec_align.cpp @@ -352,8 +352,7 @@ size_t post_align_arr[] = { 0, sizeof(cl_char), size_t type_multiple_post_align_arr[] = { 0, 0, 3, 5, 4, 12 }; // there hsould be a packed version of this? -int test_vec_align_array(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_array) { char tmp[2048]; int result; @@ -361,14 +360,13 @@ int test_vec_align_array(cl_device_id deviceID, cl_context context, log_info("Testing global\n"); doReplace(tmp, (size_t)2048, patterns[0], ".SRC_SCOPE.", "__global", ".DST_SCOPE.", "__global"); // - result = test_vec_internal(deviceID, context, queue, tmp, + result = test_vec_internal(device, context, queue, tmp, "test_vec_align_array", BUFFER_SIZE, 0, 0, 0, 0); return result; } -int test_vec_align_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_struct) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -387,7 +385,7 @@ int test_vec_align_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = - test_vec_internal(deviceID, context, queue, tmp1, + test_vec_internal(device, context, queue, tmp1, "test_vec_align_struct", 512, 0, 0, 0, 0); if (result != 0) { @@ -409,7 +407,7 @@ int test_vec_align_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = - test_vec_internal(deviceID, context, queue, tmp1, + test_vec_internal(device, context, queue, tmp1, "test_vec_align_struct", 512, 0, 0, 0, 0); if (result != 0) { @@ -420,8 +418,7 @@ int test_vec_align_struct(cl_device_id deviceID, cl_context context, return 0; } -int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_packed_struct) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -441,7 +438,7 @@ int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = test_vec_internal( - deviceID, context, queue, tmp1, "test_vec_align_packed_struct", + device, context, queue, tmp1, "test_vec_align_packed_struct", 512, pre_align_arr[preIdx], type_multiple_pre_align_arr[preIdx], post_align_arr[postIdx], type_multiple_post_align_arr[postIdx]); if (result != 0) @@ -464,7 +461,7 @@ int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = test_vec_internal( - deviceID, context, queue, tmp1, "test_vec_align_packed_struct", + device, context, queue, tmp1, "test_vec_align_packed_struct", 512, pre_align_arr[preIdx], type_multiple_pre_align_arr[preIdx], post_align_arr[postIdx], type_multiple_post_align_arr[postIdx]); if (result != 0) @@ -476,8 +473,7 @@ int test_vec_align_packed_struct(cl_device_id deviceID, cl_context context, return 0; } -int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_struct_arr) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -496,7 +492,7 @@ int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, pre_substitution_arr[preIdx], ".POST.", post_substitution_arr[postIdx]); - result = test_vec_internal(deviceID, context, queue, tmp1, + result = test_vec_internal(device, context, queue, tmp1, "test_vec_align_struct_arr", BUFFER_SIZE, 0, 0, 0, 0); if (result != 0) @@ -508,8 +504,7 @@ int test_vec_align_struct_arr(cl_device_id deviceID, cl_context context, return 0; } -int test_vec_align_packed_struct_arr(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(vec_align_packed_struct_arr) { char tmp1[2048], tmp2[2048]; int result = 0; @@ -529,7 +524,7 @@ int test_vec_align_packed_struct_arr(cl_device_id deviceID, cl_context context, post_substitution_arr[postIdx]); result = test_vec_internal( - deviceID, context, queue, tmp1, + device, context, queue, tmp1, "test_vec_align_packed_struct_arr", BUFFER_SIZE, pre_align_arr[preIdx], type_multiple_pre_align_arr[preIdx], post_align_arr[postIdx], type_multiple_post_align_arr[postIdx]); From e61da21cd6a2088f6961b029f2f3268e499b168e Mon Sep 17 00:00:00 2001 From: Michael Rizkalla Date: Tue, 17 Dec 2024 08:30:48 +0000 Subject: [PATCH 05/39] Fix using incorrect free function in arrayimagecopy and imagearraycopy basic tests' unique_ptr (#2177) This change addresses a free function mis-match issue where `delete` is used to free memory allocated via `malloc` within `create_random_data` and in the test function. The change involves the following tests: 1. arrayimagecopy 2. arrayimagecopy3d 3. imagearraycopy 4. imagearraycopy3d This should address #2173 Signed-off-by: Michael Rizkalla --- test_conformance/basic/test_arrayimagecopy.cpp | 3 ++- test_conformance/basic/test_imagearraycopy.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test_conformance/basic/test_arrayimagecopy.cpp b/test_conformance/basic/test_arrayimagecopy.cpp index b0322ed540..91e308a04f 100644 --- a/test_conformance/basic/test_arrayimagecopy.cpp +++ b/test_conformance/basic/test_arrayimagecopy.cpp @@ -37,7 +37,8 @@ int test_arrayimagecopy_single_format(cl_device_id device, cl_context context, cl_mem_object_type image_type, const cl_image_format *format) { - std::unique_ptr bufptr, imgptr; + std::unique_ptr bufptr{ nullptr, free }, + imgptr{ nullptr, free }; clMemWrapper buffer, image; int img_width = 512; int img_height = 512; diff --git a/test_conformance/basic/test_imagearraycopy.cpp b/test_conformance/basic/test_imagearraycopy.cpp index abd3323614..eb784a4922 100644 --- a/test_conformance/basic/test_imagearraycopy.cpp +++ b/test_conformance/basic/test_imagearraycopy.cpp @@ -37,7 +37,8 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context, cl_mem_object_type image_type, const cl_image_format *format) { - std::unique_ptr bufptr, imgptr; + std::unique_ptr bufptr{ nullptr, free }, + imgptr{ nullptr, free }; clMemWrapper buffer, image; const int img_width = 512; const int img_height = 512; From 2df00c65a10b1db8e672b95de467bd944c1db502 Mon Sep 17 00:00:00 2001 From: Kamil-Goras-Mobica <141216953+kamil-goras-mobica@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:44:27 +0100 Subject: [PATCH 06/39] Added unique_ptrs and MTdataHolder to test_atomics.cpp (#2169) Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1793 according to description --- test_conformance/atomics/test_atomics.cpp | 133 ++++++++++------------ 1 file changed, 61 insertions(+), 72 deletions(-) diff --git a/test_conformance/atomics/test_atomics.cpp b/test_conformance/atomics/test_atomics.cpp index d74cd033cf..754ec2aad1 100644 --- a/test_conformance/atomics/test_atomics.cpp +++ b/test_conformance/atomics/test_atomics.cpp @@ -17,6 +17,7 @@ #include "harness/typeWrappers.h" #include +#include #define INT_TEST_VALUE 402258822 #define LONG_TEST_VALUE 515154531254381446LL @@ -133,12 +134,12 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, int error; size_t threads[1]; clMemWrapper streams[2]; - void *refValues, *startRefValues; + std::vector refValues; + std::vector startRefValues; size_t threadSize, groupSize; const char *programLines[4]; char pragma[512]; char programHeader[512]; - MTdata d; size_t typeSize = get_explicit_type_size(dataType); @@ -244,23 +245,20 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, log_info("\t(thread count %d, group size %d)\n", (int)threadSize, (int)groupSize); - refValues = (cl_int *)malloc(typeSize * threadSize); + refValues.resize(typeSize * threadSize); if (testFns.GenerateRefsIntFn != NULL) { // We have a ref generator provided - d = init_genrand(gRandomSeed); - startRefValues = malloc(typeSize * threadSize); + MTdataHolder d_holder(gRandomSeed); + startRefValues.resize(typeSize * threadSize); if (typeSize == 4) - testFns.GenerateRefsIntFn(threadSize, (cl_int *)startRefValues, d); + testFns.GenerateRefsIntFn( + threadSize, (cl_int *)startRefValues.data(), d_holder); else - testFns.GenerateRefsLongFn(threadSize, (cl_long *)startRefValues, - d); - free_mtdata(d); - d = NULL; + testFns.GenerateRefsLongFn( + threadSize, (cl_long *)startRefValues.data(), d_holder); } - else - startRefValues = NULL; // If we're given a num_results function, we need to determine how many // result objects we need. If we don't have it, we assume it's just 1 @@ -268,28 +266,26 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, ? testFns.NumResultsFn(threadSize, dataType) : 1; - char *destItems = new char[typeSize * numDestItems]; - if (destItems == NULL) - { - log_error("ERROR: Unable to allocate memory!\n"); - return -1; - } + std::vector destItems(typeSize * numDestItems); + void *startValue = (typeSize == 4) ? (void *)&testFns.mIntStartValue : (void *)&testFns.mLongStartValue; for (size_t i = 0; i < numDestItems; i++) - memcpy(destItems + i * typeSize, startValue, typeSize); + memcpy(destItems.data() + i * typeSize, startValue, typeSize); - streams[0] = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, - typeSize * numDestItems, destItems, NULL); + streams[0] = + clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, typeSize * numDestItems, + destItems.data(), NULL); if (!streams[0]) { log_error("ERROR: Creating output array failed!\n"); return -1; } - streams[1] = clCreateBuffer( - context, - ((startRefValues != NULL ? CL_MEM_COPY_HOST_PTR : CL_MEM_READ_WRITE)), - typeSize * threadSize, startRefValues, NULL); + streams[1] = + clCreateBuffer(context, + ((startRefValues.data() != NULL ? CL_MEM_COPY_HOST_PTR + : CL_MEM_READ_WRITE)), + typeSize * threadSize, startRefValues.data(), NULL); if (!streams[1]) { log_error("ERROR: Creating reference array failed!\n"); @@ -307,7 +303,7 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, error = clSetKernelArg(kernel, 2, typeSize * numDestItems, NULL); test_error(error, "Unable to set indexed local kernel argument"); - cl_int numDestItemsInt = (cl_int)numDestItems; + cl_int numDestItemsInt = numDestItems; error = clSetKernelArg(kernel, 3, sizeof(cl_int), &numDestItemsInt); test_error(error, "Unable to set indexed kernel argument"); } @@ -320,12 +316,12 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, error = clEnqueueReadBuffer(queue, streams[0], true, 0, typeSize * numDestItems, - destItems, 0, NULL, NULL); + destItems.data(), 0, NULL, NULL); test_error(error, "Unable to read result value!"); error = clEnqueueReadBuffer(queue, streams[1], true, 0, typeSize * threadSize, - refValues, 0, NULL, NULL); + refValues.data(), 0, NULL, NULL); test_error(error, "Unable to read reference values!"); // If we have an expectedFn, then we need to generate a final value to @@ -342,27 +338,29 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, { // Int version intVal = testFns.ExpectedValueIntFn( - threadSize, (cl_int *)startRefValues, i); + threadSize, (cl_int *)startRefValues.data(), i); memcpy(expected, &intVal, sizeof(intVal)); } else { // Long version longVal = testFns.ExpectedValueLongFn( - threadSize, (cl_long *)startRefValues, i); + threadSize, (cl_long *)startRefValues.data(), i); memcpy(expected, &longVal, sizeof(longVal)); } - if (memcmp(expected, destItems + i * typeSize, typeSize) != 0) + if (memcmp(expected, destItems.data() + i * typeSize, typeSize) + != 0) { if (typeSize == 4) { - cl_int *outValue = (cl_int *)(destItems + i * typeSize); + cl_int *outValue = + (cl_int *)(destItems.data() + i * typeSize); log_error("ERROR: Result %zu from kernel does not " "validate! (should be %d, was %d)\n", i, intVal, *outValue); - cl_int *startRefs = (cl_int *)startRefValues; - cl_int *refs = (cl_int *)refValues; + cl_int *startRefs = (cl_int *)startRefValues.data(); + cl_int *refs = (cl_int *)refValues.data(); for (i = 0; i < threadSize; i++) { if (startRefs != NULL) @@ -374,13 +372,14 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, } else { - cl_long *outValue = (cl_long *)(destItems + i * typeSize); + cl_long *outValue = + (cl_long *)(destItems.data() + i * typeSize); log_error("ERROR: Result %zu from kernel does not " "validate! (should be %" PRId64 ", was %" PRId64 ")\n", i, longVal, *outValue); - cl_long *startRefs = (cl_long *)startRefValues; - cl_long *refs = (cl_long *)refValues; + cl_long *startRefs = (cl_long *)startRefValues.data(); + cl_long *refs = (cl_long *)refValues.data(); for (i = 0; i < threadSize; i++) { if (startRefs != NULL) @@ -400,9 +399,9 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, /* Use the verify function to also check the results */ if (dataType == kFloat) { - cl_float *outValue = (cl_float *)destItems; - if (!testFns.VerifyRefsFloatFn(threadSize, (cl_float *)refValues, - *outValue) + cl_float *outValue = (cl_float *)destItems.data(); + if (!testFns.VerifyRefsFloatFn( + threadSize, (cl_float *)refValues.data(), *outValue) != 0) { log_error("ERROR: Reference values did not validate!\n"); @@ -411,8 +410,8 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, } else if (typeSize == 4) { - cl_int *outValue = (cl_int *)destItems; - if (!testFns.VerifyRefsIntFn(threadSize, (cl_int *)refValues, + cl_int *outValue = (cl_int *)destItems.data(); + if (!testFns.VerifyRefsIntFn(threadSize, (cl_int *)refValues.data(), *outValue) != 0) { @@ -422,9 +421,9 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, } else { - cl_long *outValue = (cl_long *)destItems; - if (!testFns.VerifyRefsLongFn(threadSize, (cl_long *)refValues, - *outValue) + cl_long *outValue = (cl_long *)destItems.data(); + if (!testFns.VerifyRefsLongFn( + threadSize, (cl_long *)refValues.data(), *outValue) != 0) { log_error("ERROR: Reference values did not validate!\n"); @@ -442,10 +441,10 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, /* Re-write the starting value */ for (size_t i = 0; i < numDestItems; i++) - memcpy(destItems + i * typeSize, startValue, typeSize); - error = - clEnqueueWriteBuffer(queue, streams[0], true, 0, - typeSize * numDestItems, destItems, 0, NULL, NULL); + memcpy(destItems.data() + i * typeSize, startValue, typeSize); + error = clEnqueueWriteBuffer(queue, streams[0], true, 0, + typeSize * numDestItems, destItems.data(), 0, + NULL, NULL); test_error(error, "Unable to write starting values!"); /* Run the kernel once for a single thread, so we can verify that the @@ -455,16 +454,16 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, NULL, NULL); test_error(error, "Unable to execute test kernel"); - error = clEnqueueReadBuffer(queue, streams[1], true, 0, typeSize, refValues, - 0, NULL, NULL); + error = clEnqueueReadBuffer(queue, streams[1], true, 0, typeSize, + refValues.data(), 0, NULL, NULL); test_error(error, "Unable to read reference values!"); - if (memcmp(refValues, destItems, typeSize) != 0) + if (memcmp(refValues.data(), destItems.data(), typeSize) != 0) { if (typeSize == 4) { - cl_int *s = (cl_int *)destItems; - cl_int *r = (cl_int *)refValues; + cl_int *s = (cl_int *)destItems.data(); + cl_int *r = (cl_int *)refValues.data(); log_error("ERROR: atomic function operated correctly but did NOT " "return correct 'old' value " " (should have been %d, returned %d)!\n", @@ -472,8 +471,8 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, } else { - cl_long *s = (cl_long *)destItems; - cl_long *r = (cl_long *)refValues; + cl_long *s = (cl_long *)destItems.data(); + cl_long *r = (cl_long *)refValues.data(); log_error("ERROR: atomic function operated correctly but did NOT " "return correct 'old' value " " (should have been %" PRId64 ", returned %" PRId64 @@ -483,10 +482,6 @@ int test_atomic_function(cl_device_id deviceID, cl_context context, return -1; } - delete[] destItems; - free(refValues); - if (startRefValues != NULL) free(startRefValues); - return 0; } @@ -654,12 +649,11 @@ bool test_atomic_xchg_verify_int(size_t size, cl_int *refValues, { /* For xchg, each value from 0 to size - 1 should have an entry in the ref * array, and ONLY one entry */ - char *valids; + std::vector valids(sizeof(char) * size); size_t i; char originalValidCount = 0; - valids = (char *)malloc(sizeof(char) * size); - memset(valids, 0, sizeof(char) * size); + memset(valids.data(), 0, sizeof(char) * size); for (i = 0; i < size; i++) { @@ -710,7 +704,6 @@ bool test_atomic_xchg_verify_int(size_t size, cl_int *refValues, } } - free(valids); return true; } @@ -719,12 +712,11 @@ bool test_atomic_xchg_verify_long(size_t size, cl_long *refValues, { /* For xchg, each value from 0 to size - 1 should have an entry in the ref * array, and ONLY one entry */ - char *valids; + std::vector valids(sizeof(char) * size); size_t i; char originalValidCount = 0; - valids = (char *)malloc(sizeof(char) * size); - memset(valids, 0, sizeof(char) * size); + memset(valids.data(), 0, sizeof(char) * size); for (i = 0; i < size; i++) { @@ -777,7 +769,6 @@ bool test_atomic_xchg_verify_long(size_t size, cl_long *refValues, } } - free(valids); return true; } @@ -786,12 +777,11 @@ bool test_atomic_xchg_verify_float(size_t size, cl_float *refValues, { /* For xchg, each value from 0 to size - 1 should have an entry in the ref * array, and ONLY one entry */ - char *valids; + std::vector valids(sizeof(char) * size); size_t i; char originalValidCount = 0; - valids = (char *)malloc(sizeof(char) * size); - memset(valids, 0, sizeof(char) * size); + memset(valids.data(), 0, sizeof(char) * size); for (i = 0; i < size; i++) { @@ -843,7 +833,6 @@ bool test_atomic_xchg_verify_float(size_t size, cl_float *refValues, } } - free(valids); return true; } From 177be0969b49df8397ad70bcddee74e9cafddb2d Mon Sep 17 00:00:00 2001 From: John Kesapides <46718829+JohnKesapidesARM@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:53:35 +0000 Subject: [PATCH 07/39] Extend `clSetDefaultDeviceCommandQueue` test coverage (#1551) Fixes #23 Signed-off-by: Vikas Katariya --------- Signed-off-by: Vikas Katariya Signed-off-by: John Kesapides Co-authored-by: Vikas Katariya --- test_conformance/api/CMakeLists.txt | 1 + test_conformance/api/main.cpp | 2 + test_conformance/api/procs.h | 4 + .../api/test_device_command_queue.cpp | 88 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 test_conformance/api/test_device_command_queue.cpp diff --git a/test_conformance/api/CMakeLists.txt b/test_conformance/api/CMakeLists.txt index b32fe92a5d..3df9a81f73 100644 --- a/test_conformance/api/CMakeLists.txt +++ b/test_conformance/api/CMakeLists.txt @@ -38,6 +38,7 @@ set(${MODULE_NAME}_SOURCES test_queue_properties_queries.cpp test_pipe_properties_queries.cpp test_wg_suggested_local_work_size.cpp + test_device_command_queue.cpp ) include(../CMakeCommon.txt) diff --git a/test_conformance/api/main.cpp b/test_conformance/api/main.cpp index abdd026e46..83b6b987b3 100644 --- a/test_conformance/api/main.cpp +++ b/test_conformance/api/main.cpp @@ -164,6 +164,8 @@ test_definition test_list[] = { Version(2, 0)), ADD_TEST(negative_create_command_queue_with_properties_khr), ADD_TEST(kernel_local_memory_size), + + ADD_TEST_VERSION(set_default_device_command_queue, Version(2, 1)), }; const int test_num = ARRAY_SIZE(test_list); diff --git a/test_conformance/api/procs.h b/test_conformance/api/procs.h index 780b39de8b..18981b702c 100644 --- a/test_conformance/api/procs.h +++ b/test_conformance/api/procs.h @@ -252,3 +252,7 @@ extern int test_negative_create_command_queue_with_properties( extern int test_negative_create_command_queue_with_properties_khr( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_set_default_device_command_queue(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); diff --git a/test_conformance/api/test_device_command_queue.cpp b/test_conformance/api/test_device_command_queue.cpp new file mode 100644 index 0000000000..a977c510b1 --- /dev/null +++ b/test_conformance/api/test_device_command_queue.cpp @@ -0,0 +1,88 @@ +// +// Copyright (c) 2021 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 + +using namespace std; + + +int test_command_queue_helper(cl_context context, cl_device_id deviceID, + cl_command_queue queue) +{ + cl_int error; + cl_command_queue check_queue; + + error = clSetDefaultDeviceCommandQueue(context, deviceID, queue); + test_error(error, "clSetDefaultDeviceCommandQueue failed "); + + error = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE_DEFAULT, + sizeof(check_queue), &check_queue, nullptr); + test_error(error, + "clGetCommandQueueInfo failed for CL_QUEUE_DEVICE_DEFAULT"); + test_assert_error( + (check_queue == queue), + "Expected the queue to be returned as default device queue failed"); + + return TEST_PASS; +} + +int test_set_default_device_command_queue(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + cl_int error; + constexpr cl_command_queue_properties PROPERTIES = CL_QUEUE_ON_DEVICE + | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | CL_QUEUE_PROFILING_ENABLE; + std::array properties = { + CL_QUEUE_PROPERTIES, (PROPERTIES | CL_QUEUE_ON_DEVICE_DEFAULT), 0 + }; + + if (get_device_cl_version(deviceID) >= Version(3, 0)) + { + cl_device_device_enqueue_capabilities dseCaps = 0; + error = clGetDeviceInfo(deviceID, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, + sizeof(dseCaps), &dseCaps, NULL); + test_error(error, + "Unable to query CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES"); + + if (0 == (dseCaps & CL_DEVICE_QUEUE_REPLACEABLE_DEFAULT)) + return TEST_SKIPPED_ITSELF; + } + + clCommandQueueWrapper cmd_queue_1 = clCreateCommandQueueWithProperties( + context, deviceID, properties.data(), &error); + test_error(error, "clCreateCommandQueueWithProperties failed"); + + properties[1] = PROPERTIES; + clCommandQueueWrapper cmd_queue_2 = clCreateCommandQueueWithProperties( + context, deviceID, properties.data(), &error); + test_error(error, "clCreateCommandQueueWithProperties failed"); + + // cmd_queue_1 + if (test_command_queue_helper(context, deviceID, cmd_queue_1) != 0) + { + test_fail("test_command_queue_helper failed for cmd_queue_1.\n"); + } + + // cmd_queue_2 - without CL_QUEUE_ON_DEVICE_DEFAULT + if (test_command_queue_helper(context, deviceID, cmd_queue_2) != 0) + { + test_fail("test_command_queue_helper failed for cmd_queue_2.\n"); + } + + return TEST_PASS; +} From 09e4d03e4680dfc2567b419b0adbb21197d044b4 Mon Sep 17 00:00:00 2001 From: Michael Rizkalla Date: Tue, 17 Dec 2024 17:53:56 +0000 Subject: [PATCH 08/39] Fix clCopyImage 1D buffer images tests with use_pitches flag (#2167) This change fixes the following issues when running `clCopyImage` test with `use_pitches` flag for 1D buffer images. 1. Query device CL version using `get_device_cl_version` rather than using `CL_DEVICE_VERSION`. Previously, using `char` may not be enough to store the return value. 2. Pass `host_ptr` to `clCreateBuffer` when creating the buffer for the 1D image. `host_ptr` may not be `nullptr` if use_pitches flag is used. Also, `buffer_flags` will contain `CL_MEM_USE_HOST_PTR` which requires a host pointer to be passed. 3. Conditionally use the `host_ptr` when calling `clCreateImage`, it will not be used with 1D image buffer. This is made to align with the spec, in which if `mem_flags` has `CL_MEM_USE_HOST_PTR` a host pointer must be present, but if the memory flag is not present, host pointer must be `nullptr`. 4. Use the correct free function `free` and `align_free` based on the allocation function that was used. Signed-off-by: Michael Rizkalla --- .../images/clCopyImage/test_copy_generic.cpp | 84 ++++++++++++------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/test_conformance/images/clCopyImage/test_copy_generic.cpp b/test_conformance/images/clCopyImage/test_copy_generic.cpp index 1cb579e34f..37fc8e30e2 100644 --- a/test_conformance/images/clCopyImage/test_copy_generic.cpp +++ b/test_conformance/images/clCopyImage/test_copy_generic.cpp @@ -16,9 +16,24 @@ #include "../testBase.h" #include -static void CL_CALLBACK free_pitch_buffer( cl_mem image, void *buf ) +struct pitch_buffer_data { - free( buf ); + void *buf; + bool is_aligned; +}; + +static void CL_CALLBACK free_pitch_buffer(cl_mem image, void *data) +{ + pitch_buffer_data *d = static_cast(data); + if (d->is_aligned) + { + align_free(d->buf); + } + else + { + free(d->buf); + } + free(d); } static void CL_CALLBACK release_cl_buffer(cl_mem image, void *buf) @@ -32,6 +47,7 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr cl_image_desc imageDesc; cl_mem_flags mem_flags = CL_MEM_READ_ONLY; void *host_ptr = NULL; + bool is_host_ptr_aligned = false; memset(&imageDesc, 0x0, sizeof(cl_image_desc)); imageDesc.image_type = imageInfo->type; @@ -43,6 +59,19 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr imageDesc.image_slice_pitch = gEnablePitch ? imageInfo->slicePitch : 0; imageDesc.num_mip_levels = gTestMipmaps ? imageInfo->num_mip_levels : 0; + Version version; + cl_device_id device; + { + cl_int err = clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, + sizeof(device), &device, nullptr); + if (err != CL_SUCCESS) + { + log_error("Error: Could not get CL_QUEUE_DEVICE from queue"); + return nullptr; + } + version = get_device_cl_version(device); + } + switch (imageInfo->type) { case CL_MEM_OBJECT_IMAGE1D: @@ -84,27 +113,7 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr cl_mem_flags buffer_flags = CL_MEM_READ_WRITE; if (gEnablePitch) { - cl_device_id device; - err = - clGetCommandQueueInfo(queue, CL_QUEUE_DEVICE, - sizeof(device), &device, nullptr); - if (err != CL_SUCCESS) - { - log_error( - "Error: Could not get CL_QUEUE_DEVICE from queue"); - return NULL; - } - char major_version; - err = clGetDeviceInfo(device, CL_DEVICE_VERSION, - sizeof(major_version), &major_version, - nullptr); - if (err != CL_SUCCESS) - { - log_error("Error: Could not get CL_DEVICE_VERSION from " - "device"); - return NULL; - } - if (major_version == '1') + if (version.major() == 1) { host_ptr = malloc(imageInfo->rowPitch); } @@ -124,12 +133,13 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr } host_ptr = align_malloc(imageInfo->rowPitch, base_address_alignment); + is_host_ptr_aligned = true; } buffer_flags |= CL_MEM_USE_HOST_PTR; } - cl_mem buffer = clCreateBuffer(context, buffer_flags, - imageInfo->rowPitch, NULL, &err); + cl_mem buffer = clCreateBuffer( + context, buffer_flags, imageInfo->rowPitch, host_ptr, &err); if (err != CL_SUCCESS) { log_error("ERROR: Could not create buffer for 1D buffer " @@ -160,23 +170,39 @@ cl_mem create_image( cl_context context, cl_command_queue queue, BufferOwningPtr } } - img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, host_ptr, error); + if (imageInfo->type != CL_MEM_OBJECT_IMAGE1D_BUFFER) + { + img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, + host_ptr, error); + } + else + { + img = clCreateImage(context, mem_flags, imageInfo->format, &imageDesc, + nullptr, error); + } if (gEnablePitch) { + pitch_buffer_data *data = + static_cast(malloc(sizeof(pitch_buffer_data))); + data->buf = host_ptr; + data->is_aligned = is_host_ptr_aligned; if ( *error == CL_SUCCESS ) { - int callbackError = clSetMemObjectDestructorCallback( img, free_pitch_buffer, host_ptr ); + int callbackError = + clSetMemObjectDestructorCallback(img, free_pitch_buffer, data); if ( CL_SUCCESS != callbackError ) { - free( host_ptr ); + free_pitch_buffer(img, data); log_error( "ERROR: Unable to attach destructor callback to pitched 3D image. Err: %d\n", callbackError ); clReleaseMemObject( img ); return NULL; } } else - free(host_ptr); + { + free_pitch_buffer(img, data); + } } if (imageDesc.buffer != NULL) From be1278d5b2cdf5fc2ffd54796ee407b1e73864f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 17 Dec 2024 17:54:51 +0000 Subject: [PATCH 09/39] Add utility macro to skip test when an extension is not supported (#2178) Use in cl_khr_external_semaphore suite as an example. Signed-off-by: Kevin Petit --- test_common/harness/testHarness.h | 11 +++ .../test_external_semaphore.cpp | 76 +++---------------- 2 files changed, 23 insertions(+), 64 deletions(-) diff --git a/test_common/harness/testHarness.h b/test_common/harness/testHarness.h index e9ac53a884..32f88bd80b 100644 --- a/test_common/harness/testHarness.h +++ b/test_common/harness/testHarness.h @@ -150,6 +150,17 @@ template T *register_test(const char *name, Version version) #define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2)) +#define REQUIRE_EXTENSION(name) \ + do \ + { \ + if (!is_extension_available(deviceID, name)) \ + { \ + log_info(name \ + " is not supported on this device. Skipping test.\n"); \ + return TEST_SKIPPED_ITSELF; \ + } \ + } while (0) + extern int gFailCount; extern int gTestCount; extern cl_uint gReSeed; diff --git a/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp index 78431c76e5..1d3010e73a 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp +++ b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp @@ -122,19 +122,8 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - if (!is_extension_available(deviceID, "cl_khr_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } - - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_semaphore"); + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -214,13 +203,7 @@ int test_external_semaphores_cross_context(cl_device_id deviceID, cl_command_queue defaultQueue, int num_elements) { - cl_int err = CL_SUCCESS; - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); @@ -228,10 +211,10 @@ int test_external_semaphores_cross_context(cl_device_id deviceID, GET_PFN(deviceID, clGetSemaphoreHandleForTypeKHR); GET_PFN(deviceID, clReleaseSemaphoreKHR); - std::vector import_handle_types; std::vector export_handle_types; + cl_int err = CL_SUCCESS; err = get_device_semaphore_handle_types( deviceID, CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR, import_handle_types); @@ -345,12 +328,7 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -425,12 +403,7 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -537,12 +510,7 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -662,12 +630,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, cl_command_queue queue_1, cl_command_queue queue_2) { - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -782,12 +745,7 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, cl_command_queue defaultQueue, int num_elements) { - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -896,12 +854,7 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, cl_command_queue defaultQueue, int num_elements) { - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -992,12 +945,7 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, cl_command_queue defaultQueue, int num_elements) { - if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) - { - log_info("cl_khr_semaphore is not supported on this platform. " - "Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } + REQUIRE_EXTENSION("cl_khr_external_semaphore"); if (init_vuikan_device(1, &deviceID)) { @@ -1080,4 +1028,4 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, } return TEST_PASS; -} \ No newline at end of file +} From 7693ffe0a5c1ff19dc2634a46c879ec56f2bff9e Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 17 Dec 2024 18:55:37 +0100 Subject: [PATCH 10/39] Fix more 32-bit Wformat warnings (#2185) This fixes occurrences where the previous wrong specifier appears to work in a typical 64-bit build, but causes a Wformat warning in 32-bit builds. Signed-off-by: Sven van Haastregt --- .../test_compiler_defines_for_extensions.cpp | 5 ++- test_conformance/computeinfo/main.cpp | 2 +- .../device_timer/test_device_timer.cpp | 31 ++++++++++++++----- .../generic_address_space/advanced_tests.cpp | 9 ++++-- .../generic_address_space/basic_tests.cpp | 9 ++++-- .../generic_address_space/stress_tests.cpp | 9 ++++-- 6 files changed, 46 insertions(+), 19 deletions(-) diff --git a/test_conformance/compiler/test_compiler_defines_for_extensions.cpp b/test_conformance/compiler/test_compiler_defines_for_extensions.cpp index 4a6545b6c2..0b5dd449ea 100644 --- a/test_conformance/compiler/test_compiler_defines_for_extensions.cpp +++ b/test_conformance/compiler/test_compiler_defines_for_extensions.cpp @@ -16,6 +16,7 @@ #include "testBase.h" #include #include +#include #ifndef _WIN32 #include #endif @@ -216,7 +217,9 @@ int test_compiler_defines_for_extensions(cl_device_id device, cl_context context char *extension = (char *)malloc((extension_length + 1) * sizeof(char)); if (extension == NULL) { - log_error( "Error: unable to allocate memory to hold extension name: %ld chars\n", extension_length ); + log_error("Error: unable to allocate memory to hold extension " + "name: %" PRIdPTR " chars\n", + extension_length); return -1; } extensions_supported[num_of_supported_extensions] = extension; diff --git a/test_conformance/computeinfo/main.cpp b/test_conformance/computeinfo/main.cpp index 3f0551687e..4b02445fd3 100644 --- a/test_conformance/computeinfo/main.cpp +++ b/test_conformance/computeinfo/main.cpp @@ -736,7 +736,7 @@ void dumpConfigInfo(config_info* info) } break; case type_cl_device_id: - log_info("\t%s == %ld\n", info->opcode_name, + log_info("\t%s == %" PRIdPTR "\n", info->opcode_name, (intptr_t)info->config.device_id); break; case type_cl_device_affinity_domain: diff --git a/test_conformance/device_timer/test_device_timer.cpp b/test_conformance/device_timer/test_device_timer.cpp index be6df38248..0a5556d758 100644 --- a/test_conformance/device_timer/test_device_timer.cpp +++ b/test_conformance/device_timer/test_device_timer.cpp @@ -14,6 +14,7 @@ // limitations under the License. // #include +#include #include #include "harness/errorHelpers.h" #include "harness/compat.h" @@ -74,13 +75,16 @@ REGISTER_TEST(device_and_host_timers) if (deviceEndTime <= deviceStartTime) { log_error("Device timer is not monotonically increasing.\n"); - log_error(" deviceStartTime: %lu, deviceEndTime: %lu\n", deviceStartTime, deviceEndTime); + log_error(" deviceStartTime: %" PRIu64 ", deviceEndTime: %" PRIu64 + "\n", + deviceStartTime, deviceEndTime); errors++; } if (hostEndTime <= hostStartTime) { log_error("Error: Host timer is not monotonically increasing.\n"); - log_error(" hostStartTime: %lu, hostEndTime: %lu\n", hostStartTime, hostEndTime); + log_error(" hostStartTime: %" PRIu64 ", hostEndTime: %" PRIu64 "\n", + hostStartTime, hostEndTime); errors++; } @@ -95,7 +99,9 @@ REGISTER_TEST(device_and_host_timers) if (observedDiff > allowedDiff) { log_error("Error: Device and host timers did not increase by same amount\n"); - log_error(" Observed difference between timers %lu (max allowed %lu).\n", observedDiff, allowedDiff); + log_error(" Observed difference between timers %" PRIu64 + " (max allowed %" PRIu64 ").\n", + observedDiff, allowedDiff); errors++; } @@ -103,21 +109,26 @@ REGISTER_TEST(device_and_host_timers) if (hostOnlyEndTime <= hostOnlyStartTime) { log_error("Error: Host timer is not monotonically increasing.\n"); - log_error(" hostStartTime: %lu, hostEndTime: %lu\n", hostOnlyStartTime, hostOnlyEndTime); + log_error(" hostStartTime: %" PRIu64 ", hostEndTime: %" PRIu64 "\n", + hostOnlyStartTime, hostOnlyEndTime); errors++; } if (hostOnlyStartTime < hostStartTime) { log_error("Error: Host start times do not correlate.\n"); log_error("clGetDeviceAndHostTimer was called before clGetHostTimer but timers are not in that order.\n"); - log_error(" clGetDeviceAndHostTimer: %lu, clGetHostTimer: %lu\n", hostStartTime, hostOnlyStartTime); + log_error(" clGetDeviceAndHostTimer: %" PRIu64 + ", clGetHostTimer: %" PRIu64 "\n", + hostStartTime, hostOnlyStartTime); errors++; } if (hostOnlyEndTime < hostEndTime) { log_error("Error: Host end times do not correlate.\n"); log_error("clGetDeviceAndHostTimer was called before clGetHostTimer but timers are not in that order.\n"); - log_error(" clGetDeviceAndHostTimer: %lu, clGetHostTimer: %lu\n", hostEndTime, hostOnlyEndTime); + log_error(" clGetDeviceAndHostTimer: %" PRIu64 + ", clGetHostTimer: %" PRIu64 "\n", + hostEndTime, hostOnlyEndTime); errors++; } @@ -148,7 +159,9 @@ REGISTER_TEST(timer_resolution_queries) errors++; } else { - log_info("CL_DEVICE_PROFILING_TIMER_RESOLUTION == %lu nanoseconds\n", deviceTimerResolution); + log_info("CL_DEVICE_PROFILING_TIMER_RESOLUTION == %" PRIu64 + " nanoseconds\n", + deviceTimerResolution); } if (platform) { @@ -158,7 +171,9 @@ REGISTER_TEST(timer_resolution_queries) errors++; } else { - log_info("CL_PLATFORM_HOST_TIMER_RESOLUTION == %lu nanoseconds\n", hostTimerResolution); + log_info("CL_PLATFORM_HOST_TIMER_RESOLUTION == %" PRIu64 + " nanoseconds\n", + hostTimerResolution); } } else { diff --git a/test_conformance/generic_address_space/advanced_tests.cpp b/test_conformance/generic_address_space/advanced_tests.cpp index 01cfe8a6de..74330e52af 100644 --- a/test_conformance/generic_address_space/advanced_tests.cpp +++ b/test_conformance/generic_address_space/advanced_tests.cpp @@ -264,8 +264,10 @@ class CAdvancedTest : public CTest { size_t passCount = std::count(results.begin(), results.end(), 1); if (passCount != results.size()) { std::vector::iterator iter = std::find(results.begin(), results.end(), 0); - log_error("Verification on device failed at index %ld\n", std::distance(results.begin(), iter)); - log_error("%ld out of %ld failed\n", (results.size()-passCount), results.size()); + log_error("Verification on device failed at index %td\n", + std::distance(results.begin(), iter)); + log_error("%zu out of %zu failed\n", (results.size() - passCount), + results.size()); return -1; } @@ -276,7 +278,8 @@ class CAdvancedTest : public CTest { cl_int result = CL_SUCCESS; for (std::vector::const_iterator it = _kernels.begin(); it != _kernels.end(); ++it) { - log_info("Executing subcase #%ld out of %ld\n", (it - _kernels.begin() + 1), _kernels.size()); + log_info("Executing subcase #%zu out of %zu\n", + (it - _kernels.begin() + 1), _kernels.size()); result |= ExecuteSubcase(deviceID, context, queue, num_elements, *it); } diff --git a/test_conformance/generic_address_space/basic_tests.cpp b/test_conformance/generic_address_space/basic_tests.cpp index b2e745c0fe..114fafa08f 100644 --- a/test_conformance/generic_address_space/basic_tests.cpp +++ b/test_conformance/generic_address_space/basic_tests.cpp @@ -70,8 +70,10 @@ class CBasicTest : CTest { size_t passCount = std::count(results.begin(), results.end(), 1); if (passCount != results.size()) { std::vector::iterator iter = std::find(results.begin(), results.end(), 0); - log_error("Verification on device failed at index %ld\n", std::distance(results.begin(), iter)); - log_error("%ld out of %ld failed\n", (results.size()-passCount), results.size()); + log_error("Verification on device failed at index %td\n", + std::distance(results.begin(), iter)); + log_error("%zu out of %zu failed\n", (results.size() - passCount), + results.size()); return -1; } @@ -82,7 +84,8 @@ class CBasicTest : CTest { cl_int result = CL_SUCCESS; for (std::vector::const_iterator it = _kernels.begin(); it != _kernels.end(); ++it) { - log_info("Executing subcase #%ld out of %ld\n", (it - _kernels.begin() + 1), _kernels.size()); + log_info("Executing subcase #%zu out of %zu\n", + (it - _kernels.begin() + 1), _kernels.size()); result |= ExecuteSubcase(deviceID, context, queue, num_elements, *it); } diff --git a/test_conformance/generic_address_space/stress_tests.cpp b/test_conformance/generic_address_space/stress_tests.cpp index 7193e69236..a21432291e 100644 --- a/test_conformance/generic_address_space/stress_tests.cpp +++ b/test_conformance/generic_address_space/stress_tests.cpp @@ -72,8 +72,10 @@ class CStressTest : public CTest { size_t passCount = std::count(results.begin(), results.end(), 1); if (passCount != results.size()) { std::vector::iterator iter = std::find(results.begin(), results.end(), 0); - log_error("Verification on device failed at index %ld\n", std::distance(results.begin(), iter)); - log_error("%ld out of %ld failed\n", (results.size()-passCount), results.size()); + log_error("Verification on device failed at index %td\n", + std::distance(results.begin(), iter)); + log_error("%zu out of %zu failed\n", (results.size() - passCount), + results.size()); return -1; } @@ -84,7 +86,8 @@ class CStressTest : public CTest { cl_int result = CL_SUCCESS; for (std::vector::const_iterator it = _kernels.begin(); it != _kernels.end(); ++it) { - log_info("Executing subcase #%ld out of %ld\n", (it - _kernels.begin() + 1), _kernels.size()); + log_info("Executing subcase #%zu out of %zu\n", + (it - _kernels.begin() + 1), _kernels.size()); result |= ExecuteSubcase(deviceID, context, queue, num_elements, *it); } From 57a91b7ffefc11f387f6f18aef91ace09e8a7ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 17 Dec 2024 17:57:27 +0000 Subject: [PATCH 11/39] [NFC] Migrate profiling suite to new registration framework (#2187) Contributes to #2181 Signed-off-by: Kevin Petit --- test_conformance/profiling/copy.cpp | 8 ++-- test_conformance/profiling/execute.cpp | 2 +- .../profiling/execute_multipass.cpp | 2 +- test_conformance/profiling/main.cpp | 41 +------------------ test_conformance/profiling/procs.h | 39 ------------------ .../profiling/profiling_timebase.cpp | 3 +- test_conformance/profiling/readArray.cpp | 22 +++++----- test_conformance/profiling/readImage.cpp | 18 ++++---- test_conformance/profiling/writeArray.cpp | 22 +++++----- test_conformance/profiling/writeImage.cpp | 18 ++++---- 10 files changed, 49 insertions(+), 126 deletions(-) diff --git a/test_conformance/profiling/copy.cpp b/test_conformance/profiling/copy.cpp index 46d156055c..d7507fb428 100644 --- a/test_conformance/profiling/copy.cpp +++ b/test_conformance/profiling/copy.cpp @@ -381,7 +381,7 @@ static int copy_partial_size( cl_device_id device, cl_context context, cl_comman } // end copy_partial_size() -int test_copy_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(copy_array) { int i, err = 0; int size; @@ -405,7 +405,7 @@ int test_copy_array( cl_device_id device, cl_context context, cl_command_queue q } // end copy_array() -int test_copy_partial_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(copy_partial_array) { int i, err = 0; int size; @@ -681,7 +681,7 @@ static int copy_image_size( cl_device_id device, cl_context context, } // end copy_image_size() -int test_copy_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(copy_image) { int err = 0; int i; @@ -754,7 +754,7 @@ int test_copy_image( cl_device_id device, cl_context context, cl_command_queue q } // end copy_image() -int test_copy_array_to_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(copy_array_to_image) { cl_mem memobjs[3]; cl_image_format image_format_desc = { CL_RGBA, CL_UNORM_INT8 }; diff --git a/test_conformance/profiling/execute.cpp b/test_conformance/profiling/execute.cpp index d4fd51e390..d404a97f7c 100644 --- a/test_conformance/profiling/execute.cpp +++ b/test_conformance/profiling/execute.cpp @@ -360,7 +360,7 @@ static int basicFilter( int w, int h, int nChannels, uchar *inptr, uchar *outptr } // end of basicFilter() -int test_execute( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(execute) { uchar *inptr; uchar *outptr[2]; diff --git a/test_conformance/profiling/execute_multipass.cpp b/test_conformance/profiling/execute_multipass.cpp index a264232e11..921be5b994 100644 --- a/test_conformance/profiling/execute_multipass.cpp +++ b/test_conformance/profiling/execute_multipass.cpp @@ -264,7 +264,7 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue // use 3d to exercise the multipass events. In the future 3d may not be multpass, in which // case we will need to ensure that we use gdims large enough to force multipass. -int execute_multipass( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(execute_multipass) { cl_uchar *inptr; cl_uchar *outptr; diff --git a/test_conformance/profiling/main.cpp b/test_conformance/profiling/main.cpp index 012786ccd2..026dd30dc3 100644 --- a/test_conformance/profiling/main.cpp +++ b/test_conformance/profiling/main.cpp @@ -18,50 +18,12 @@ #include #include #include -#include "procs.h" #include "harness/testHarness.h" // FIXME: To use certain functions in harness/imageHelpers.h // (for example, generate_random_image_data()), the tests are required to declare // the following variables (): -test_definition test_list[] = { - ADD_TEST(read_array_int), - ADD_TEST(read_array_uint), - ADD_TEST(read_array_long), - ADD_TEST(read_array_ulong), - ADD_TEST(read_array_short), - ADD_TEST(read_array_ushort), - ADD_TEST(read_array_float), - ADD_TEST(read_array_char), - ADD_TEST(read_array_uchar), - ADD_TEST(read_array_struct), - ADD_TEST(write_array_int), - ADD_TEST(write_array_uint), - ADD_TEST(write_array_long), - ADD_TEST(write_array_ulong), - ADD_TEST(write_array_short), - ADD_TEST(write_array_ushort), - ADD_TEST(write_array_float), - ADD_TEST(write_array_char), - ADD_TEST(write_array_uchar), - ADD_TEST(write_array_struct), - ADD_TEST(read_image_float), - ADD_TEST(read_image_char), - ADD_TEST(read_image_uchar), - ADD_TEST(write_image_float), - ADD_TEST(write_image_char), - ADD_TEST(write_image_uchar), - ADD_TEST(copy_array), - ADD_TEST(copy_partial_array), - ADD_TEST(copy_image), - ADD_TEST(copy_array_to_image), - ADD_TEST(execute), - ADD_TEST_VERSION(profiling_timebase, Version(2, 1)), -}; - -const int test_num = ARRAY_SIZE( test_list ); - // FIXME: use timer resolution rather than hardcoding 1µs per tick. #define QUEUE_SECONDS_LIMIT 30 @@ -133,7 +95,8 @@ int check_times(cl_ulong queueStart, cl_ulong commandSubmit, cl_ulong commandSta int main( int argc, const char *argv[] ) { - return runTestHarness(argc, argv, test_num, test_list, false, + return runTestHarness(argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, CL_QUEUE_PROFILING_ENABLE); } diff --git a/test_conformance/profiling/procs.h b/test_conformance/profiling/procs.h index aa91a75199..f3bff40360 100644 --- a/test_conformance/profiling/procs.h +++ b/test_conformance/profiling/procs.h @@ -21,47 +21,8 @@ #include "harness/imageHelpers.h" #include "harness/mt19937.h" - extern int check_times(cl_ulong queueStart, cl_ulong submitStart, cl_ulong commandStart, cl_ulong commandEnd, cl_device_id device); -extern int test_read_array_int( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_uint( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_long( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_ulong( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_short( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_ushort( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_array_struct( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_int( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_uint( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_long( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_ulong( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_short( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_ushort( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_array_struct( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_image_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_image_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_read_image_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_image_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_image_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_write_image_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_copy_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_copy_partial_array( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_copy_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_copy_array_to_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_execute( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_parallel_kernels( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_profiling_timebase(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); - - #endif // #ifndef __PROCS_H__ diff --git a/test_conformance/profiling/profiling_timebase.cpp b/test_conformance/profiling/profiling_timebase.cpp index 1b12464c59..f26a9d89d1 100644 --- a/test_conformance/profiling/profiling_timebase.cpp +++ b/test_conformance/profiling/profiling_timebase.cpp @@ -18,8 +18,7 @@ const char *kernelCode = "__kernel void kernel_empty(){}"; -int test_profiling_timebase(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(profiling_timebase) { Version version = get_device_cl_version(device); cl_platform_id platform = getPlatformFromDevice(device); diff --git a/test_conformance/profiling/readArray.cpp b/test_conformance/profiling/readArray.cpp index 85ab9a2759..021c3ff43b 100644 --- a/test_conformance/profiling/readArray.cpp +++ b/test_conformance/profiling/readArray.cpp @@ -758,7 +758,7 @@ int test_stream_read( cl_device_id device, cl_context context, cl_command_queue } // end test_stream_read() -int test_read_array_int( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_int) { int (*foo)(void *,int); foo = verify_read_int; @@ -768,7 +768,7 @@ int test_read_array_int( cl_device_id device, cl_context context, cl_command_que } -int test_read_array_uint( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_uint) { int (*foo)(void *,int); foo = verify_read_uint; @@ -778,7 +778,7 @@ int test_read_array_uint( cl_device_id device, cl_context context, cl_command_qu } -int test_read_array_long( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_long) { int (*foo)(void *,int); foo = verify_read_long; @@ -794,7 +794,7 @@ int test_read_array_long( cl_device_id device, cl_context context, cl_command_qu } -int test_read_array_ulong( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_ulong) { int (*foo)(void *,int); foo = verify_read_ulong; @@ -810,7 +810,7 @@ int test_read_array_ulong( cl_device_id device, cl_context context, cl_command_q } -int test_read_array_short( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_short) { int (*foo)(void *,int); foo = verify_read_short; @@ -820,7 +820,7 @@ int test_read_array_short( cl_device_id device, cl_context context, cl_command_q } -int test_read_array_ushort( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_ushort) { int (*foo)(void *,int); foo = verify_read_ushort; @@ -830,7 +830,7 @@ int test_read_array_ushort( cl_device_id device, cl_context context, cl_command_ } -int test_read_array_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_float) { int (*foo)(void *,int); foo = verify_read_float; @@ -840,7 +840,7 @@ int test_read_array_float( cl_device_id device, cl_context context, cl_command_q } -int test_read_array_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_half) { int (*foo)(void *,int); foo = verify_read_half; @@ -850,7 +850,7 @@ int test_read_array_half( cl_device_id device, cl_context context, cl_command_qu } -int test_read_array_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_char) { int (*foo)(void *,int); foo = verify_read_char; @@ -860,7 +860,7 @@ int test_read_array_char( cl_device_id device, cl_context context, cl_command_qu } -int test_read_array_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_uchar) { int (*foo)(void *,int); foo = verify_read_uchar; @@ -870,7 +870,7 @@ int test_read_array_uchar( cl_device_id device, cl_context context, cl_command_q } -int test_read_array_struct( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(read_array_struct) { int (*foo)(void *,int); foo = verify_read_struct; diff --git a/test_conformance/profiling/readImage.cpp b/test_conformance/profiling/readImage.cpp index fd4da128e1..9f9268966a 100644 --- a/test_conformance/profiling/readImage.cpp +++ b/test_conformance/profiling/readImage.cpp @@ -339,33 +339,33 @@ int read_image( cl_device_id device, cl_context context, cl_command_queue queue, } // end read_image() -int test_read_image_float( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(read_image_float) { cl_image_format image_format_desc = { CL_RGBA, CL_UNORM_INT8 }; PASSIVE_REQUIRE_IMAGE_SUPPORT( device ) // 0 to 255 for unsigned image data - return read_image( device, context, queue, numElements, readKernelCode[0], readKernelName[0], image_format_desc ); - + return read_image(device, context, queue, num_elements, readKernelCode[0], + readKernelName[0], image_format_desc); } -int test_read_image_char( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(read_image_char) { cl_image_format image_format_desc = { CL_RGBA, CL_SIGNED_INT8 }; PASSIVE_REQUIRE_IMAGE_SUPPORT( device ) // -128 to 127 for signed iamge data - return read_image( device, context, queue, numElements, readKernelCode[1], readKernelName[1], image_format_desc ); - + return read_image(device, context, queue, num_elements, readKernelCode[1], + readKernelName[1], image_format_desc); } -int test_read_image_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(read_image_uchar) { cl_image_format image_format_desc = { CL_RGBA, CL_UNSIGNED_INT8 }; PASSIVE_REQUIRE_IMAGE_SUPPORT( device ) // 0 to 255 for unsigned image data - return read_image( device, context, queue, numElements, readKernelCode[2], readKernelName[2], image_format_desc ); - + return read_image(device, context, queue, num_elements, readKernelCode[2], + readKernelName[2], image_format_desc); } diff --git a/test_conformance/profiling/writeArray.cpp b/test_conformance/profiling/writeArray.cpp index acfe8f29db..f6028273dc 100644 --- a/test_conformance/profiling/writeArray.cpp +++ b/test_conformance/profiling/writeArray.cpp @@ -821,7 +821,7 @@ int test_stream_write( cl_device_id device, cl_context context, cl_command_queue } // end test_stream_write() -int test_write_array_int( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_int) { int *inptr[5]; size_t ptrSizes[5]; @@ -857,7 +857,7 @@ int test_write_array_int( cl_device_id device, cl_context context, cl_command_qu } // end write_int_array() -int test_write_array_uint( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_uint) { cl_uint *inptr[5]; size_t ptrSizes[5]; @@ -892,7 +892,7 @@ int test_write_array_uint( cl_device_id device, cl_context context, cl_command_q } // end write_uint_array() -int test_write_array_short( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_short) { short *inptr[5]; size_t ptrSizes[5]; @@ -927,7 +927,7 @@ int test_write_array_short( cl_device_id device, cl_context context, cl_command_ } // end write_short_array() -int test_write_array_ushort( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_ushort) { cl_ushort *inptr[5]; size_t ptrSizes[5]; @@ -962,7 +962,7 @@ int test_write_array_ushort( cl_device_id device, cl_context context, cl_command } // end write_ushort_array() -int test_write_array_char( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_char) { char *inptr[5]; size_t ptrSizes[5]; @@ -997,7 +997,7 @@ int test_write_array_char( cl_device_id device, cl_context context, cl_command_q } // end write_char_array() -int test_write_array_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_uchar) { uchar *inptr[5]; size_t ptrSizes[5]; @@ -1032,7 +1032,7 @@ int test_write_array_uchar( cl_device_id device, cl_context context, cl_command_ } // end write_uchar_array() -int test_write_array_float( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_float) { float *inptr[5]; size_t ptrSizes[5]; @@ -1067,7 +1067,7 @@ int test_write_array_float( cl_device_id device, cl_context context, cl_command_ } // end write_float_array() -int test_write_array_half( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_half) { float *inptr[5]; size_t ptrSizes[5]; @@ -1102,7 +1102,7 @@ int test_write_array_half( cl_device_id device, cl_context context, cl_command_q } // end write_half_array() -int test_write_array_long( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_long) { cl_long *inptr[5]; size_t ptrSizes[5]; @@ -1143,7 +1143,7 @@ int test_write_array_long( cl_device_id device, cl_context context, cl_command_q } // end write_long_array() -int test_write_array_ulong( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_ulong) { cl_ulong *inptr[5]; size_t ptrSizes[5]; @@ -1184,7 +1184,7 @@ int test_write_array_ulong( cl_device_id device, cl_context context, cl_command_ } // end write_ulong_array() -int test_write_array_struct( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ) +REGISTER_TEST(write_array_struct) { TestStruct *inptr[1]; size_t ptrSizes[1]; diff --git a/test_conformance/profiling/writeImage.cpp b/test_conformance/profiling/writeImage.cpp index e2a6dd5935..29164ff95a 100644 --- a/test_conformance/profiling/writeImage.cpp +++ b/test_conformance/profiling/writeImage.cpp @@ -636,33 +636,33 @@ int write_image( cl_device_id device, cl_context context, cl_command_queue queue } // end write_image() -int test_write_image_float( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(write_image_float) { cl_image_format image_format_desc = { CL_RGBA, CL_UNORM_INT8 }; PASSIVE_REQUIRE_IMAGE_SUPPORT( device ) // 0 to 255 for unsigned image data - return write_image( device, context, queue, numElements, readKernelCode[0], readKernelName[0], image_format_desc, 1 ); - + return write_image(device, context, queue, num_elements, readKernelCode[0], + readKernelName[0], image_format_desc, 1); } -int test_write_image_char( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(write_image_char) { cl_image_format image_format_desc = { CL_RGBA, CL_SIGNED_INT8 }; PASSIVE_REQUIRE_IMAGE_SUPPORT( device ) // -128 to 127 for signed iamge data - return write_image( device, context, queue, numElements, readKernelCode[1], readKernelName[1], image_format_desc, 0 ); - + return write_image(device, context, queue, num_elements, readKernelCode[1], + readKernelName[1], image_format_desc, 0); } -int test_write_image_uchar( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) +REGISTER_TEST(write_image_uchar) { cl_image_format image_format_desc = { CL_RGBA, CL_UNSIGNED_INT8 }; PASSIVE_REQUIRE_IMAGE_SUPPORT( device ) // 0 to 255 for unsigned image data - return write_image( device, context, queue, numElements, readKernelCode[2], readKernelName[2], image_format_desc, 0 ); - + return write_image(device, context, queue, num_elements, readKernelCode[2], + readKernelName[2], image_format_desc, 0); } From e17e6eef7b43f4edad95769fbb45e2a4a897aa0d Mon Sep 17 00:00:00 2001 From: Katarzyna Cencelewska Date: Tue, 17 Dec 2024 18:58:03 +0100 Subject: [PATCH 12/39] add option to bruteforce test to force count of worker threads (#2188) - to be able to have deterministic results it is useful to have a mechanism to force the same count of workers - this commit doesn't change the default settings but expands functionality Signed-off-by: Katarzyna Cencelewska Signed-off-by: Katarzyna Cencelewska --- test_conformance/math_brute_force/main.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test_conformance/math_brute_force/main.cpp b/test_conformance/math_brute_force/main.cpp index ec504e6030..38954f3f25 100644 --- a/test_conformance/math_brute_force/main.cpp +++ b/test_conformance/math_brute_force/main.cpp @@ -379,6 +379,7 @@ static int ParseArgs(int argc, const char **argv) gTestNames.push_back(""); int singleThreaded = 0; + int forcedWorkerThreads = 0; { // Extract the app name strncpy(appName, argv[0], MAXPATHLEN - 1); @@ -430,6 +431,11 @@ static int ParseArgs(int argc, const char **argv) case 'm': singleThreaded ^= 1; break; + case 't': + forcedWorkerThreads = atoi(argv[++i]); + vlog(" %d", forcedWorkerThreads); + break; + case 'g': gHasHalf ^= 1; break; case 'r': gTestFastRelaxed ^= 1; break; @@ -540,7 +546,17 @@ static int ParseArgs(int argc, const char **argv) gWimpyReductionFactor); } - if (singleThreaded) SetThreadCount(1); + if (singleThreaded) + { + vlog("*** WARNING: Force 1 worker thread ***\n"); + SetThreadCount(1); + } + else if (forcedWorkerThreads > 0) + { + vlog("*** WARNING: Force %d worker threads ***\n", + forcedWorkerThreads); + SetThreadCount(forcedWorkerThreads); + } return 0; } From 9bb8a89bbd86e485fcd6f452d05b0380292c35a1 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 17 Dec 2024 19:11:36 +0100 Subject: [PATCH 13/39] semaphore: fix Wformat warning (#2194) `i` is an `int`, so shouldn't use the `%zu` specifier for printing. Signed-off-by: Sven van Haastregt --- .../extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp index 0ee126f2d7..0a86d5aaef 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp @@ -277,7 +277,7 @@ struct SemaphoreOutOfOrderOps : public SemaphoreTestBase { if (pattern != host_buffer[i]) { - log_error("Expected %d was %d at index %zu\n", pattern, + log_error("Expected %d was %d at index %d\n", pattern, host_buffer[i], i); return false; } From 2316c6343f82c6ce8df8a1686c09dc73a17da8ee Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:42:12 +0000 Subject: [PATCH 14/39] Migrate allocations suite to the new test registration framework (#2191) Contributes to #2181 --- test_conformance/allocations/main.cpp | 41 +++++++-------------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/test_conformance/allocations/main.cpp b/test_conformance/allocations/main.cpp index 80a5ed2e1f..50533d6292 100644 --- a/test_conformance/allocations/main.cpp +++ b/test_conformance/allocations/main.cpp @@ -272,48 +272,28 @@ int doTest(cl_device_id device, cl_context context, cl_command_queue queue, return failure_counts; } -int test_buffer(cl_device_id device, cl_context context, cl_command_queue queue, - int num_elements) -{ - return doTest(device, context, queue, BUFFER); -} -int test_image2d_read(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer) { return doTest(device, context, queue, BUFFER); } +REGISTER_TEST(image2d_read) { return doTest(device, context, queue, IMAGE_READ); } -int test_image2d_write(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(image2d_write) { return doTest(device, context, queue, IMAGE_WRITE); } -int test_buffer_non_blocking(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(buffer_non_blocking) { return doTest(device, context, queue, BUFFER_NON_BLOCKING); } -int test_image2d_read_non_blocking(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(image2d_read_non_blocking) { return doTest(device, context, queue, IMAGE_READ_NON_BLOCKING); } -int test_image2d_write_non_blocking(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(image2d_write_non_blocking) { return doTest(device, context, queue, IMAGE_WRITE_NON_BLOCKING); } -test_definition test_list[] = { - ADD_TEST(buffer), - ADD_TEST(image2d_read), - ADD_TEST(image2d_write), - ADD_TEST(buffer_non_blocking), - ADD_TEST(image2d_read_non_blocking), - ADD_TEST(image2d_write_non_blocking), -}; - -const int test_num = ARRAY_SIZE(test_list); - int main(int argc, const char *argv[]) { char *endPtr; @@ -382,8 +362,9 @@ int main(int argc, const char *argv[]) } } - int ret = runTestHarnessWithCheck(argCount, argList, test_num, test_list, - false, 0, init_cl); + int ret = runTestHarnessWithCheck( + argCount, argList, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0, init_cl); free(argList); return ret; @@ -416,8 +397,8 @@ void printUsage(const char *execName) "of the memory objects.\n"); log_info("\n"); log_info("Test names (Allocation Types):\n"); - for (int i = 0; i < test_num; i++) + for (int i = 0; i < test_registry::getInstance().num_tests(); i++) { - log_info("\t%s\n", test_list[i].name); + log_info("\t%s\n", test_registry::getInstance().definitions()[i].name); } } From 794d332bab7589262f0e9c5d38aadbf313b47e38 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:29:08 +0000 Subject: [PATCH 15/39] Migrate API suite to the new test registration framework (#2196) Contributes to #2181 Signed-off-by: Ahmed Hesham --- test_conformance/api/main.cpp | 157 +------- test_conformance/api/negative_platform.cpp | 8 +- test_conformance/api/negative_queue.cpp | 32 +- test_conformance/api/procs.h | 258 ------------- test_conformance/api/testBase.h | 11 +- test_conformance/api/test_api_consistency.cpp | 189 +++++----- test_conformance/api/test_api_min_max.cpp | 224 +++++------- test_conformance/api/test_binary.cpp | 18 +- test_conformance/api/test_bool.cpp | 3 +- test_conformance/api/test_clone_kernel.cpp | 22 +- .../api/test_context_destructor_callback.cpp | 5 +- .../api/test_create_context_from_type.cpp | 27 +- test_conformance/api/test_create_kernels.cpp | 24 +- .../api/test_device_command_queue.cpp | 17 +- ...ice_min_data_type_align_size_alignment.cpp | 55 +-- .../api/test_kernel_arg_changes.cpp | 4 +- test_conformance/api/test_kernel_arg_info.cpp | 111 +++--- .../api/test_kernel_arg_multi_setup.cpp | 6 +- .../api/test_kernel_attributes.cpp | 21 +- .../api/test_kernel_local_memory_size.cpp | 9 +- .../api/test_kernel_private_memory_size.cpp | 6 +- test_conformance/api/test_kernels.cpp | 21 +- test_conformance/api/test_mem_object_info.cpp | 34 +- .../test_mem_object_properties_queries.cpp | 8 +- test_conformance/api/test_mem_objects.cpp | 7 +- .../api/test_min_image_formats.cpp | 3 +- test_conformance/api/test_native_kernel.cpp | 26 +- test_conformance/api/test_null_buffer_arg.cpp | 5 +- .../api/test_pipe_properties_queries.cpp | 7 +- test_conformance/api/test_platform.cpp | 340 +++++++++--------- test_conformance/api/test_queries.cpp | 147 ++++---- test_conformance/api/test_queue.cpp | 11 +- test_conformance/api/test_queue_hint.cpp | 15 +- .../api/test_queue_properties.cpp | 29 +- .../api/test_queue_properties_queries.cpp | 33 +- test_conformance/api/test_retain.cpp | 44 +-- test_conformance/api/test_retain_program.cpp | 6 +- .../api/test_sub_group_dispatch.cpp | 63 +++- .../api/test_wg_suggested_local_work_size.cpp | 15 +- .../api/test_zero_sized_enqueue.cpp | 18 +- 40 files changed, 794 insertions(+), 1245 deletions(-) delete mode 100644 test_conformance/api/procs.h diff --git a/test_conformance/api/main.cpp b/test_conformance/api/main.cpp index 83b6b987b3..6e7c6d4807 100644 --- a/test_conformance/api/main.cpp +++ b/test_conformance/api/main.cpp @@ -13,164 +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/testHarness.h" -#if !defined(_WIN32) -#include -#endif - -// FIXME: To use certain functions in harness/imageHelpers.h -// (for example, generate_random_image_data()), the tests are required to -// declare the following variables (): - -test_definition test_list[] = { - ADD_TEST(get_platform_info), - ADD_TEST_VERSION(get_sampler_info, Version(2, 0)), - ADD_TEST(get_sampler_info_compatibility), - ADD_TEST_VERSION(get_command_queue_info, Version(2, 0)), - ADD_TEST(get_command_queue_info_compatibility), - ADD_TEST(get_context_info), - ADD_TEST(get_device_info), - ADD_TEST(enqueue_task), - ADD_TEST(binary_get), - ADD_TEST(binary_create), - ADD_TEST(kernel_required_group_size), - - ADD_TEST(release_kernel_order), - ADD_TEST(release_during_execute), - - ADD_TEST(load_single_kernel), - ADD_TEST(load_two_kernels), - ADD_TEST(load_two_kernels_in_one), - ADD_TEST(load_two_kernels_manually), - ADD_TEST(get_program_info_kernel_names), - ADD_TEST(get_kernel_arg_info), - ADD_TEST(create_kernels_in_program), - ADD_TEST(get_kernel_info), - ADD_TEST(kernel_private_memory_size), - ADD_TEST(execute_kernel_local_sizes), - ADD_TEST(set_kernel_arg_by_index), - ADD_TEST(set_kernel_arg_constant), - ADD_TEST(set_kernel_arg_struct_array), - ADD_TEST(kernel_global_constant), - ADD_TEST(kernel_attributes), - - ADD_TEST(min_max_thread_dimensions), - ADD_TEST(min_max_work_items_sizes), - ADD_TEST(min_max_work_group_size), - ADD_TEST(min_max_read_image_args), - ADD_TEST(min_max_write_image_args), - ADD_TEST(min_max_mem_alloc_size), - ADD_TEST(min_max_image_2d_width), - ADD_TEST(min_max_image_2d_height), - ADD_TEST(min_max_image_3d_width), - ADD_TEST(min_max_image_3d_height), - ADD_TEST(min_max_image_3d_depth), - ADD_TEST(min_max_image_array_size), - ADD_TEST(min_max_image_buffer_size), - ADD_TEST(min_max_parameter_size), - ADD_TEST(min_max_samplers), - ADD_TEST(min_max_constant_buffer_size), - ADD_TEST(min_max_constant_args), - ADD_TEST(min_max_compute_units), - ADD_TEST(min_max_address_bits), - ADD_TEST(min_max_single_fp_config), - ADD_TEST(min_max_double_fp_config), - ADD_TEST(min_max_local_mem_size), - ADD_TEST(min_max_kernel_preferred_work_group_size_multiple), - ADD_TEST(min_max_execution_capabilities), - ADD_TEST(min_max_queue_properties), - ADD_TEST(min_max_device_version), - ADD_TEST(min_max_language_version), - - ADD_TEST(kernel_arg_changes), - ADD_TEST(kernel_arg_multi_setup_random), - - ADD_TEST(native_kernel), - - ADD_TEST(create_context_from_type), - ADD_TEST(create_context_from_type_device_type_all), - ADD_TEST(create_context_from_type_device_type_default), - - ADD_TEST(platform_extensions), - ADD_TEST(get_platform_ids), - ADD_TEST(bool_type), - - ADD_TEST(repeated_setup_cleanup), - - ADD_TEST(retain_queue_single), - ADD_TEST(retain_queue_multiple), - ADD_TEST(retain_mem_object_single), - ADD_TEST(retain_mem_object_multiple), - ADD_TEST(retain_mem_object_set_kernel_arg), - ADD_TEST(min_data_type_align_size_alignment), - - ADD_TEST_VERSION(context_destructor_callback, Version(3, 0)), - ADD_TEST(mem_object_destructor_callback), - ADD_TEST(null_buffer_arg), - ADD_TEST(get_buffer_info), - ADD_TEST(get_image2d_info), - ADD_TEST(get_image3d_info), - ADD_TEST(get_image1d_info), - ADD_TEST(get_image1d_array_info), - ADD_TEST(get_image2d_array_info), - ADD_TEST(queue_flush_on_release), - ADD_TEST(queue_hint), - ADD_TEST(queue_properties), - ADD_TEST_VERSION(sub_group_dispatch, Version(2, 1)), - ADD_TEST_VERSION(clone_kernel, Version(2, 1)), - ADD_TEST_VERSION(zero_sized_enqueue, Version(2, 1)), - - ADD_TEST_VERSION(buffer_properties_queries, Version(3, 0)), - ADD_TEST_VERSION(image_properties_queries, Version(3, 0)), - ADD_TEST_VERSION(queue_properties_queries, Version(3, 0)), - ADD_TEST_VERSION(pipe_properties_queries, Version(3, 0)), - - ADD_TEST_VERSION(consistency_svm, Version(3, 0)), - ADD_TEST_VERSION(consistency_memory_model, Version(3, 0)), - ADD_TEST_VERSION(consistency_device_enqueue, Version(3, 0)), - ADD_TEST_VERSION(consistency_pipes, Version(3, 0)), - ADD_TEST_VERSION(consistency_progvar, Version(3, 0)), - ADD_TEST_VERSION(consistency_non_uniform_work_group, Version(3, 0)), - ADD_TEST_VERSION(consistency_read_write_images, Version(3, 0)), - ADD_TEST_VERSION(consistency_2d_image_from_buffer, Version(3, 0)), - ADD_TEST_VERSION(consistency_depth_images, Version(3, 0)), - ADD_TEST_VERSION(consistency_device_and_host_timer, Version(3, 0)), - ADD_TEST_VERSION(consistency_il_programs, Version(3, 0)), - ADD_TEST_VERSION(consistency_subgroups, Version(3, 0)), - ADD_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0)), - ADD_TEST_VERSION(consistency_3d_image_writes, Version(3, 0)), - ADD_TEST(consistency_requirements_fp64), - ADD_TEST(consistency_requirements_fp16), - - ADD_TEST(min_image_formats), - ADD_TEST(set_command_queue_property), - - ADD_TEST(negative_get_platform_info), - ADD_TEST(negative_get_platform_ids), - - 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), - ADD_TEST(kernel_local_memory_size), - - ADD_TEST_VERSION(set_default_device_command_queue, Version(2, 1)), -}; - -const int test_num = ARRAY_SIZE(test_list); - 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/api/negative_platform.cpp b/test_conformance/api/negative_platform.cpp index 861d47484e..f98ec13a3d 100644 --- a/test_conformance/api/negative_platform.cpp +++ b/test_conformance/api/negative_platform.cpp @@ -16,8 +16,7 @@ #include "testBase.h" -int test_negative_get_platform_ids(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(negative_get_platform_ids) { cl_platform_id platform; cl_int err = clGetPlatformIDs(0, &platform, nullptr); @@ -37,10 +36,9 @@ int test_negative_get_platform_ids(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_negative_get_platform_info(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(negative_get_platform_info) { - cl_platform_id platform = getPlatformFromDevice(deviceID); + cl_platform_id platform = getPlatformFromDevice(device); constexpr cl_platform_info INVALID_PARAM_VALUE = 0; cl_int err = diff --git a/test_conformance/api/negative_queue.cpp b/test_conformance/api/negative_queue.cpp index f3b4fb2c90..c25b571da3 100644 --- a/test_conformance/api/negative_queue.cpp +++ b/test_conformance/api/negative_queue.cpp @@ -16,12 +16,10 @@ #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) +REGISTER_TEST(negative_create_command_queue) { cl_command_queue_properties device_props = 0; - cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, + cl_int error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES, sizeof(device_props), &device_props, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed"); @@ -40,7 +38,7 @@ int test_negative_create_command_queue(cl_device_id deviceID, // code cl_int test_error = CL_SUCCESS; clCommandQueueWrapper test_queue = clCreateCommandQueue( - context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &test_error); + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &test_error); test_failure_error_ret( test_error, CL_INVALID_QUEUE_PROPERTIES, @@ -52,18 +50,16 @@ int test_negative_create_command_queue(cl_device_id deviceID, 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) +REGISTER_TEST_VERSION(negative_create_command_queue_with_properties, + Version(2, 0)) { cl_command_queue_properties device_props = 0; - cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, + cl_int error = clGetDeviceInfo(device, 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, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, sizeof(device_on_host_props), &device_on_host_props, NULL); test_error(error, @@ -97,7 +93,7 @@ int test_negative_create_command_queue_with_properties(cl_device_id deviceID, cl_int test_error = CL_SUCCESS; clCommandQueueWrapper test_queue = clCreateCommandQueueWithProperties( - context, deviceID, queue_prop_def, &test_error); + context, device, queue_prop_def, &test_error); test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES, "clCreateCommandQueueWithProperties should " @@ -110,17 +106,15 @@ int test_negative_create_command_queue_with_properties(cl_device_id deviceID, 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) +REGISTER_TEST(negative_create_command_queue_with_properties_khr) { - if (!is_extension_available(deviceID, "cl_khr_create_command_queue")) + if (!is_extension_available(device, "cl_khr_create_command_queue")) { return TEST_SKIPPED_ITSELF; } cl_platform_id platform; - cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, + cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); @@ -136,7 +130,7 @@ int test_negative_create_command_queue_with_properties_khr( } cl_command_queue_properties device_props = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES, sizeof(device_props), &device_props, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed"); @@ -160,7 +154,7 @@ int test_negative_create_command_queue_with_properties_khr( cl_int test_error = CL_SUCCESS; clCommandQueueWrapper test_khr_queue = - clCreateCommandQueueWithPropertiesKHR(context, deviceID, queue_prop_def, + clCreateCommandQueueWithPropertiesKHR(context, device, queue_prop_def, &test_error); test_failure_error_ret(test_error, CL_INVALID_QUEUE_PROPERTIES, diff --git a/test_conformance/api/procs.h b/test_conformance/api/procs.h deleted file mode 100644 index 18981b702c..0000000000 --- a/test_conformance/api/procs.h +++ /dev/null @@ -1,258 +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. -// -#include "harness/errorHelpers.h" -#include "harness/kernelHelpers.h" -#include "harness/typeWrappers.h" -#include "harness/clImageHelper.h" -#include "harness/imageHelpers.h" -extern float calculate_ulperror(float a, float b); - -extern int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_load_two_kernels_manually(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_platform_extensions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_platform_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_sampler_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_sampler_info_compatibility(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_command_queue_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_command_queue_info_compatibility(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_context_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_release_kernel_order(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_release_during_execute(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_get_kernel_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_kernel_private_memory_size(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_execute_kernel_local_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_set_kernel_arg_by_index(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_set_kernel_arg_struct(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_set_command_queue_property(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_work_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_read_image_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_write_image_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_parameter_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_samplers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_constant_args(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_compute_units(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_address_bits(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_single_fp_config(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_double_fp_config(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_kernel_preferred_work_group_size_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_execution_capabilities(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_queue_properties(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_device_version(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_max_language_version(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems ); - -extern int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_create_context_from_type_device_type_all(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_create_context_from_type_device_type_default( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements); - -extern int test_get_platform_ids(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_kernel_arg_changes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_kernel_arg_multi_setup_random(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_retain_queue_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_retain_queue_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_retain_mem_object_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_retain_mem_object_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_retain_mem_object_set_kernel_arg(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min_data_type_align_size_alignment(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems ); - -extern int test_context_destructor_callback(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_mem_object_destructor_callback(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_null_buffer_arg( cl_device_id device_id, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ); -extern int test_get_image2d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ); -extern int test_get_image3d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ); -extern int test_get_image1d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ); -extern int test_get_image1d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ); -extern int test_get_image2d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ); -extern int test_get_kernel_arg_info( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_queue_properties( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements ); -extern int test_queue_flush_on_release(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_buffer_properties_queries(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_image_properties_queries(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_queue_properties_queries(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -int test_pipe_properties_queries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_consistency_svm(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_consistency_memory_model(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_device_enqueue(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_pipes(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_consistency_progvar(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_consistency_non_uniform_work_group(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_read_write_images(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_2d_image_from_buffer(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_depth_images(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_device_and_host_timer(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_il_programs(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_subgroups(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_consistency_prog_ctor_dtor(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_3d_image_writes(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_requirements_fp64(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_consistency_requirements_fp16(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); - -extern int test_min_image_formats(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_kernel_local_memory_size(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_negative_get_platform_info(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_negative_get_platform_ids(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_kernel_attributes(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_work_group_suggested_local_size_1D(cl_device_id device, - cl_context context, - cl_command_queue queue, - int n_elems); -extern int test_work_group_suggested_local_size_2D(cl_device_id device, - cl_context context, - cl_command_queue queue, - int n_elems); -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); -extern int test_set_default_device_command_queue(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); diff --git a/test_conformance/api/testBase.h b/test_conformance/api/testBase.h index ba67d1403e..02f76e94e1 100644 --- a/test_conformance/api/testBase.h +++ b/test_conformance/api/testBase.h @@ -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 @@ -17,15 +17,14 @@ #define _testBase_h #include "harness/compat.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" +#include "harness/imageHelpers.h" + #include #include #include #include #include -#include "procs.h" - #endif // _testBase_h - - - diff --git a/test_conformance/api/test_api_consistency.cpp b/test_conformance/api/test_api_consistency.cpp index 974d552d0f..a859a7019c 100644 --- a/test_conformance/api/test_api_consistency.cpp +++ b/test_conformance/api/test_api_consistency.cpp @@ -25,8 +25,7 @@ __kernel void test(__global int* dst) { } )CLC"; -int test_consistency_svm(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_svm, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_SVM_CAPABILITIES: // May return 0, indicating that device does not support Shared Virtual @@ -39,8 +38,8 @@ int test_consistency_svm(cl_device_id deviceID, cl_context context, clKernelWrapper kernel; cl_device_svm_capabilities svmCaps = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_SVM_CAPABILITIES, - sizeof(svmCaps), &svmCaps, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_SVM_CAPABILITIES, sizeof(svmCaps), + &svmCaps, NULL); test_error(error, "Unable to query CL_DEVICE_SVM_CAPABILITIES"); if (svmCaps == 0) @@ -202,13 +201,12 @@ static int check_atomic_capabilities(cl_device_atomic_capabilities atomicCaps, return TEST_PASS; } -int test_consistency_memory_model(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_memory_model, Version(3, 0)) { cl_int error; cl_device_atomic_capabilities atomicCaps = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, + error = clGetDeviceInfo(device, CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES, sizeof(atomicCaps), &atomicCaps, NULL); test_error(error, "Unable to query CL_DEVICE_ATOMIC_MEMORY_CAPABILITIES"); @@ -221,7 +219,7 @@ int test_consistency_memory_model(cl_device_id deviceID, cl_context context, return error; } - error = clGetDeviceInfo(deviceID, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, + error = clGetDeviceInfo(device, CL_DEVICE_ATOMIC_FENCE_CAPABILITIES, sizeof(atomicCaps), &atomicCaps, NULL); test_error(error, "Unable to query CL_DEVICE_ATOMIC_FENCE_CAPABILITIES"); @@ -238,8 +236,7 @@ int test_consistency_memory_model(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_device_enqueue, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES // May return 0, indicating that device does not support Device-Side Enqueue @@ -247,7 +244,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, cl_int error; cl_device_device_enqueue_capabilities dseCaps = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, + error = clGetDeviceInfo(device, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, sizeof(dseCaps), &dseCaps, NULL); test_error(error, "Unable to query CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES"); @@ -258,7 +255,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, // On-Device Queues. cl_command_queue_properties devQueueProps = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, sizeof(devQueueProps), &devQueueProps, NULL); test_error(error, "Unable to query CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES"); @@ -278,7 +275,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, cl_uint u = 0; error = - clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, + clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE, sizeof(u), &u, NULL); test_error(error, "Unable to query CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE"); @@ -287,7 +284,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, "but CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE " "returned a non-zero value"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, sizeof(u), &u, NULL); test_error(error, "Unable to query CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE"); test_assert_error( @@ -295,7 +292,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, "CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 but " "CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE returned a non-zero value"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_ON_DEVICE_QUEUES, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_QUEUES, sizeof(u), &u, NULL); test_error(error, "Unable to query CL_DEVICE_MAX_ON_DEVICE_QUEUES"); test_assert_error( @@ -303,7 +300,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, "CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 but " "CL_DEVICE_MAX_ON_DEVICE_QUEUES returned a non-zero value"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_ON_DEVICE_EVENTS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_ON_DEVICE_EVENTS, sizeof(u), &u, NULL); test_error(error, "Unable to query CL_DEVICE_MAX_ON_DEVICE_EVENTS"); test_assert_error( @@ -334,7 +331,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, // clSetDefaultDeviceCommandQueue // Returns CL_INVALID_OPERATION if device does not support On-Device // Queues. - error = clSetDefaultDeviceCommandQueue(context, deviceID, NULL); + error = clSetDefaultDeviceCommandQueue(context, device, NULL); test_failure_error(error, CL_INVALID_OPERATION, "CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES returned 0 " "but clSetDefaultDeviceCommandQueue did not return " @@ -347,7 +344,7 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, // clSetDefaultDeviceCommandQueue // Returns CL_INVALID_OPERATION if device does not support a // replaceable default On-Device Queue. - error = clSetDefaultDeviceCommandQueue(context, deviceID, NULL); + error = clSetDefaultDeviceCommandQueue(context, device, NULL); test_failure_error( error, CL_INVALID_OPERATION, "CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES did not " @@ -371,9 +368,9 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, if ((dseCaps & CL_DEVICE_QUEUE_SUPPORTED) != 0) { cl_bool b; - error = clGetDeviceInfo(deviceID, - CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, - sizeof(b), &b, NULL); + error = + clGetDeviceInfo(device, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, + sizeof(b), &b, NULL); test_error( error, "Unable to query CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT"); @@ -387,16 +384,15 @@ int test_consistency_device_enqueue(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_pipes(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_pipes, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_PIPE_SUPPORT // May return CL_FALSE, indicating that device does not support Pipes. cl_int error; cl_bool pipeSupport = CL_FALSE; - error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_SUPPORT, - sizeof(pipeSupport), &pipeSupport, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_PIPE_SUPPORT, sizeof(pipeSupport), + &pipeSupport, NULL); test_error(error, "Unable to query CL_DEVICE_PIPE_SUPPORT"); if (pipeSupport == CL_FALSE) @@ -409,16 +405,15 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context, cl_uint u = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PIPE_ARGS, sizeof(u), - &u, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_MAX_PIPE_ARGS, sizeof(u), &u, + NULL); test_error(error, "Unable to query CL_DEVICE_MAX_PIPE_ARGS"); test_assert_error(u == 0, "CL_DEVICE_PIPE_SUPPORT returned CL_FALSE, but " "CL_DEVICE_MAX_PIPE_ARGS returned a non-zero value"); - error = - clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, - sizeof(u), &u, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS, + sizeof(u), &u, NULL); test_error(error, "Unable to query CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS"); test_assert_error(u == 0, @@ -426,7 +421,7 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context, "CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS returned " "a non-zero value"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_PACKET_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_PACKET_SIZE, sizeof(u), &u, NULL); test_error(error, "Unable to query CL_DEVICE_PIPE_MAX_PACKET_SIZE"); test_assert_error( @@ -461,9 +456,8 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context, // Devices that support pipes must also return CL_TRUE // for CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT. cl_bool b; - error = - clGetDeviceInfo(deviceID, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, - sizeof(b), &b, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, + sizeof(b), &b, NULL); test_error(error, "Unable to query CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT"); test_assert_error( @@ -475,8 +469,7 @@ int test_consistency_pipes(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_progvar(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_progvar, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE // May return 0, indicating that device does not support Program Scope @@ -487,7 +480,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context, clKernelWrapper kernel; size_t maxGlobalVariableSize = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, sizeof(maxGlobalVariableSize), &maxGlobalVariableSize, NULL); test_error(error, "Unable to query CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE"); @@ -506,7 +499,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context, // CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE // Returns 0 if device does not support Program Scope Global Variables. - error = clGetDeviceInfo(deviceID, + error = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE, sizeof(sz), &sz, NULL); test_error( @@ -523,7 +516,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context, // Returns 0 if device does not support Program Scope Global Variables. error = clGetProgramBuildInfo( - program, deviceID, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, + program, device, CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE, sizeof(sz), &sz, NULL); test_error( error, @@ -537,10 +530,7 @@ int test_consistency_progvar(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_non_uniform_work_group(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST_VERSION(consistency_non_uniform_work_group, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT: // May return CL_FALSE, indicating that device does not support Non-Uniform @@ -553,7 +543,7 @@ int test_consistency_non_uniform_work_group(cl_device_id deviceID, clKernelWrapper kernel; cl_bool nonUniformWorkGroupSupport = CL_FALSE; - error = clGetDeviceInfo(deviceID, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, + error = clGetDeviceInfo(device, CL_DEVICE_NON_UNIFORM_WORK_GROUP_SUPPORT, sizeof(nonUniformWorkGroupSupport), &nonUniformWorkGroupSupport, NULL); test_error(error, @@ -620,9 +610,7 @@ int test_consistency_non_uniform_work_group(cl_device_id deviceID, return TEST_PASS; } -int test_consistency_read_write_images(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_read_write_images, Version(3, 0)) { // clGetDeviceInfo, passing // CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS May return 0, @@ -630,7 +618,7 @@ int test_consistency_read_write_images(cl_device_id deviceID, cl_int error; cl_uint maxReadWriteImageArgs = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, sizeof(maxReadWriteImageArgs), &maxReadWriteImageArgs, NULL); test_error(error, @@ -683,10 +671,7 @@ int test_consistency_read_write_images(cl_device_id deviceID, return TEST_PASS; } -int test_consistency_2d_image_from_buffer(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST_VERSION(consistency_2d_image_from_buffer, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_IMAGE_PITCH_ALIGNMENT or // CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT @@ -703,7 +688,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID, clMemWrapper image; cl_uint imagePitchAlignment = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_PITCH_ALIGNMENT, sizeof(imagePitchAlignment), &imagePitchAlignment, NULL); test_error(error, @@ -711,7 +696,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID, "CL_DEVICE_IMAGE_PITCH_ALIGNMENT"); cl_uint imageBaseAddressAlignment = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, sizeof(imageBaseAddressAlignment), &imageBaseAddressAlignment, NULL); test_error(error, @@ -719,7 +704,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID, "CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT"); bool supports_cl_khr_image2d_from_buffer = - is_extension_available(deviceID, "cl_khr_image2d_from_buffer"); + is_extension_available(device, "cl_khr_image2d_from_buffer"); if (imagePitchAlignment == 0 || imageBaseAddressAlignment == 0) { @@ -790,8 +775,7 @@ int test_consistency_2d_image_from_buffer(cl_device_id deviceID, // All of the sRGB Image Channel Orders (such as CL_​sRGBA) are optional for // devices supporting OpenCL 3.0. -int test_consistency_depth_images(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_depth_images, Version(3, 0)) { // The CL_DEPTH Image Channel Order is optional for devices supporting // OpenCL 3.0. @@ -830,7 +814,7 @@ int test_consistency_depth_images(cl_device_id deviceID, cl_context context, } bool supports_cl_khr_depth_images = - is_extension_available(deviceID, "cl_khr_depth_images"); + is_extension_available(device, "cl_khr_depth_images"); if (totalDepthImageFormats == 0) { @@ -848,10 +832,7 @@ int test_consistency_depth_images(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_device_and_host_timer(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST_VERSION(consistency_device_and_host_timer, Version(3, 0)) { // clGetPlatformInfo, passing CL_PLATFORM_HOST_TIMER_RESOLUTION // May return 0, indicating that platform does not support Device and Host @@ -859,7 +840,7 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID, cl_int error; cl_platform_id platform = NULL; - error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), + error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); test_error(error, "Unable to query CL_DEVICE_PLATFORM"); @@ -878,13 +859,13 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID, cl_ulong dt = 0; cl_ulong ht = 0; - error = clGetDeviceAndHostTimer(deviceID, &dt, &ht); + error = clGetDeviceAndHostTimer(device, &dt, &ht); test_failure_error( error, CL_INVALID_OPERATION, "CL_PLATFORM_HOST_TIMER_RESOLUTION returned 0 but " "clGetDeviceAndHostTimer did not return CL_INVALID_OPERATION"); - error = clGetHostTimer(deviceID, &ht); + error = clGetHostTimer(device, &ht); test_failure_error( error, CL_INVALID_OPERATION, "CL_PLATFORM_HOST_TIMER_RESOLUTION returned 0 but " @@ -894,8 +875,7 @@ int test_consistency_device_and_host_timer(cl_device_id deviceID, return TEST_PASS; } -int test_consistency_il_programs(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_il_programs, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_IL_VERSION or // CL_DEVICE_ILS_WITH_VERSION @@ -909,14 +889,14 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context, // Even if the device does not support Intermediate Language Programs the // size of the string query should not be zero. size_t sz = SIZE_MAX; - error = clGetDeviceInfo(deviceID, CL_DEVICE_IL_VERSION, 0, NULL, &sz); + error = clGetDeviceInfo(device, CL_DEVICE_IL_VERSION, 0, NULL, &sz); test_error(error, "Unable to query CL_DEVICE_IL_VERSION"); test_assert_error(sz != 0, "CL_DEVICE_IL_VERSION should return a non-zero size"); - std::string ilVersion = get_device_il_version_string(deviceID); + std::string ilVersion = get_device_il_version_string(device); - error = clGetDeviceInfo(deviceID, CL_DEVICE_ILS_WITH_VERSION, 0, NULL, &sz); + error = clGetDeviceInfo(device, CL_DEVICE_ILS_WITH_VERSION, 0, NULL, &sz); test_error(error, "Unable to query CL_DEVICE_ILS_WITH_VERSION"); if (ilVersion == "" || sz == 0) @@ -935,7 +915,7 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context, "but CL_DEVICE_IL_VERSION returned an empty string"); bool supports_cl_khr_il_program = - is_extension_available(deviceID, "cl_khr_il_program"); + is_extension_available(device, "cl_khr_il_program"); test_assert_error(supports_cl_khr_il_program == false, "Device does not support IL Programs but does " "support cl_khr_il_program"); @@ -985,8 +965,7 @@ int test_consistency_il_programs(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_subgroups(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_subgroups, Version(3, 0)) { // clGetDeviceInfo, passing CL_DEVICE_MAX_NUM_SUB_GROUPS // May return 0, indicating that device does not support Subgroups. @@ -996,7 +975,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context, clKernelWrapper kernel; cl_uint maxNumSubGroups = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_NUM_SUB_GROUPS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_NUM_SUB_GROUPS, sizeof(maxNumSubGroups), &maxNumSubGroups, NULL); test_error(error, "Unable to query CL_DEVICE_MAX_NUM_SUB_GROUPS"); @@ -1014,7 +993,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context, cl_bool ifp = CL_FALSE; error = clGetDeviceInfo( - deviceID, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, + device, CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, sizeof(ifp), &ifp, NULL); test_error( error, @@ -1029,7 +1008,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context, // device does not support Subgroups. bool supports_cl_khr_subgroups = - is_extension_available(deviceID, "cl_khr_subgroups"); + is_extension_available(device, "cl_khr_subgroups"); test_assert_error(supports_cl_khr_subgroups == false, "Device does not support Subgroups but does " "support cl_khr_subgroups"); @@ -1038,7 +1017,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context, // Returns CL_INVALID_OPERATION if device does not support Subgroups. size_t sz = SIZE_MAX; - error = clGetKernelSubGroupInfo(kernel, deviceID, + error = clGetKernelSubGroupInfo(kernel, device, CL_KERNEL_MAX_NUM_SUB_GROUPS, 0, NULL, sizeof(sz), &sz, NULL); test_failure_error( @@ -1052,8 +1031,7 @@ int test_consistency_subgroups(cl_device_id deviceID, cl_context context, static void CL_CALLBACK program_callback(cl_program, void*) {} -int test_consistency_prog_ctor_dtor(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0)) { cl_int error; @@ -1099,8 +1077,7 @@ int test_consistency_prog_ctor_dtor(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(consistency_3d_image_writes, Version(3, 0)) { // clGetSupportedImageFormats, passing CL_MEM_OBJECT_IMAGE3D and one of // CL_MEM_WRITE_ONLY, CL_MEM_READ_WRITE, or CL_MEM_KERNEL_READ_AND_WRITE @@ -1131,7 +1108,7 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context, } bool supports_cl_khr_3d_image_writes = - is_extension_available(deviceID, "cl_khr_3d_image_writes"); + is_extension_available(device, "cl_khr_3d_image_writes"); if (total3DImageWriteFormats == 0) { @@ -1152,18 +1129,16 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context, return TEST_PASS; } -int test_consistency_requirements_fp64(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(consistency_requirements_fp64) { cl_int error = CL_SUCCESS; cl_device_fp_config value = 0; - if (is_extension_available(deviceID, "cl_khr_fp64")) + if (is_extension_available(device, "cl_khr_fp64")) { - const Version version = get_device_cl_version(deviceID); + const Version version = get_device_cl_version(device); - error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG, + error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(value), &value, nullptr); test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG"); test_assert_error( @@ -1187,9 +1162,8 @@ int test_consistency_requirements_fp64(cl_device_id deviceID, "for OpenCL 2.0 or newer devices"); } - error = - clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, - sizeof(value), &value, nullptr); + error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, + sizeof(value), &value, nullptr); test_error( error, "Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE"); @@ -1197,7 +1171,7 @@ int test_consistency_requirements_fp64(cl_device_id deviceID, "CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return " "nonzero value"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, + error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, sizeof(value), &value, nullptr); test_error(error, "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE"); @@ -1207,15 +1181,14 @@ int test_consistency_requirements_fp64(cl_device_id deviceID, } else { - error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG, + error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(value), &value, nullptr); test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG"); test_assert_error(value == 0, "CL_DEVICE_DOUBLE_FP_CONFIG must return 0"); - error = - clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, - sizeof(value), &value, nullptr); + error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, + sizeof(value), &value, nullptr); test_error( error, "Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE"); @@ -1223,7 +1196,7 @@ int test_consistency_requirements_fp64(cl_device_id deviceID, value == 0, "CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return 0"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, + error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, sizeof(value), &value, nullptr); test_error(error, "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE"); @@ -1234,17 +1207,15 @@ int test_consistency_requirements_fp64(cl_device_id deviceID, return TEST_PASS; } -int test_consistency_requirements_fp16(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(consistency_requirements_fp16) { cl_int error = CL_SUCCESS; cl_device_fp_config value = 0; - if (is_extension_available(deviceID, "cl_khr_fp16")) + if (is_extension_available(device, "cl_khr_fp16")) { - error = clGetDeviceInfo(deviceID, CL_DEVICE_HALF_FP_CONFIG, - sizeof(value), &value, nullptr); + error = clGetDeviceInfo(device, CL_DEVICE_HALF_FP_CONFIG, sizeof(value), + &value, nullptr); test_error(error, "Unable to get device CL_DEVICE_HALF_FP_CONFIG"); test_assert_error(value > 0, "CL_DEVICE_HALF_FP_CONFIG must return nonzero value"); @@ -1253,7 +1224,7 @@ int test_consistency_requirements_fp16(cl_device_id deviceID, || (value & CL_FP_ROUND_TO_ZERO), "Reported half fp config doesn't meet minimum set"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, + error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, sizeof(value), &value, nullptr); test_error( error, @@ -1262,7 +1233,7 @@ int test_consistency_requirements_fp16(cl_device_id deviceID, "CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return " "nonzero value"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, + error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, sizeof(value), &value, nullptr); test_error(error, "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF"); @@ -1272,14 +1243,14 @@ int test_consistency_requirements_fp16(cl_device_id deviceID, } else { - error = clGetDeviceInfo(deviceID, CL_DEVICE_HALF_FP_CONFIG, - sizeof(value), &value, nullptr); + error = clGetDeviceInfo(device, CL_DEVICE_HALF_FP_CONFIG, sizeof(value), + &value, nullptr); test_failure_error( error, CL_INVALID_VALUE, "cl_khr_fp16 is not available; CL_DEVICE_HALF_FP_CONFIG must fail " "with CL_INVALID_VALUE"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, + error = clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, sizeof(value), &value, nullptr); test_error( error, @@ -1288,7 +1259,7 @@ int test_consistency_requirements_fp16(cl_device_id deviceID, "CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return " "0"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, + error = clGetDeviceInfo(device, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, sizeof(value), &value, nullptr); test_error(error, "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF"); diff --git a/test_conformance/api/test_api_min_max.cpp b/test_conformance/api/test_api_min_max.cpp index eb119006a4..cd0934d0c8 100644 --- a/test_conformance/api/test_api_min_max.cpp +++ b/test_conformance/api/test_api_min_max.cpp @@ -115,8 +115,7 @@ const char *sample_const_max_arg_kernel_pattern = #define MAX_REDUCTION_FACTOR 4 -int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_thread_dimensions) { int error, retVal; unsigned int maxThreadDim, threadDim, i; @@ -129,7 +128,7 @@ int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context, /* Get the max thread dimensions */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(maxThreadDim), &maxThreadDim, NULL); test_error(error, "Unable to get max work item dimensions from device"); @@ -202,22 +201,21 @@ int test_min_max_thread_dimensions(cl_device_id deviceID, cl_context context, } -int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_work_items_sizes) { int error; size_t *deviceMaxWorkItemSize; unsigned int maxWorkItemDim; /* Get the max work item dimensions */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(maxWorkItemDim), &maxWorkItemDim, NULL); test_error(error, "Unable to get max work item dimensions from device"); log_info("CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS returned %d\n", maxWorkItemDim); deviceMaxWorkItemSize = (size_t *)malloc(sizeof(size_t) * maxWorkItemDim); - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_SIZES, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(size_t) * maxWorkItemDim, deviceMaxWorkItemSize, NULL); test_error(error, "clDeviceInfo for CL_DEVICE_MAX_WORK_ITEM_SIZES failed"); @@ -246,14 +244,13 @@ int test_min_max_work_items_sizes(cl_device_id deviceID, cl_context context, } -int test_min_max_work_group_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_work_group_size) { int error; size_t deviceMaxThreadSize; /* Get the max thread dimensions */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_GROUP_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(deviceMaxThreadSize), &deviceMaxThreadSize, NULL); test_error(error, "Unable to get max work group size from device"); @@ -268,8 +265,7 @@ int test_min_max_work_group_size(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_read_image_args(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_read_image_args) { int error; unsigned int maxReadImages, i; @@ -290,12 +286,12 @@ int test_min_max_read_image_args(cl_device_id deviceID, cl_context context, cl_uint minRequiredReadImages = gIsEmbedded ? 8 : 128; cl_device_type deviceType; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) image_format_desc.image_channel_order = CL_RGBA; image_format_desc.image_channel_data_type = CL_FLOAT; /* Get the max read image arg count */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_READ_IMAGE_ARGS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_READ_IMAGE_ARGS, sizeof(maxReadImages), &maxReadImages, NULL); test_error(error, "Unable to get max read image arg count from device"); @@ -310,19 +306,19 @@ int test_min_max_read_image_args(cl_device_id deviceID, cl_context context, log_info("Reported %d max read image args.\n", maxReadImages); error = - clGetDeviceInfo(deviceID, CL_DEVICE_ADDRESS_BITS, + clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(deviceAddressSize), &deviceAddressSize, NULL); test_error(error, "Unable to query CL_DEVICE_ADDRESS_BITS for device"); deviceAddressSize /= 8; // convert from bits to bytes - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(maxParameterSize), &maxParameterSize, NULL); test_error(error, "Unable to get max parameter size from device"); if (!gIsEmbedded && maxReadImages >= 128 && maxParameterSize == 1024) { - error = clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(deviceType), + error = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(deviceType), &deviceType, NULL); test_error(error, "Unable to get device type from device"); @@ -434,8 +430,7 @@ int test_min_max_read_image_args(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_write_image_args(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_write_image_args) { int error; unsigned int maxWriteImages, i; @@ -452,12 +447,12 @@ int test_min_max_write_image_args(cl_device_id deviceID, cl_context context, cl_uint minRequiredWriteImages = gIsEmbedded ? 1 : 8; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) image_format_desc.image_channel_order = CL_RGBA; image_format_desc.image_channel_data_type = CL_UNORM_INT8; /* Get the max read image arg count */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, sizeof(maxWriteImages), &maxWriteImages, NULL); test_error(error, "Unable to get max write image arg count from device"); @@ -480,7 +475,7 @@ int test_min_max_write_image_args(cl_device_id deviceID, cl_context context, log_info("Reported %d max write image args.\n", maxWriteImages); - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(maxParameterSize), &maxParameterSize, NULL); test_error(error, "Unable to get max parameter size from device"); @@ -563,8 +558,7 @@ int test_min_max_write_image_args(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_mem_alloc_size) { int error; cl_ulong maxAllocSize, memSize, minSizeToTry, currentSize; @@ -580,9 +574,9 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context, /* Get the max mem alloc size, limit the alloc to half of the available * memory */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); - memSize = get_device_info_global_mem_size(deviceID, - MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + memSize = + get_device_info_global_mem_size(device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if (memSize < maxAllocSize) { @@ -635,8 +629,7 @@ int test_min_max_mem_alloc_size(cl_device_id deviceID, cl_context context, return -1; } -int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_image_2d_width) { int error; size_t maxDimension; @@ -645,9 +638,9 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, cl_ulong maxAllocSize; cl_uint minRequiredDimension; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) - auto version = get_device_cl_version(deviceID); + auto version = get_device_cl_version(device); if (version == Version(1, 0)) { minRequiredDimension = gIsEmbedded ? 2048 : 4096; @@ -664,7 +657,7 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, test_error(error, "Unable to obtain suitable image format to test with!"); /* Get the max 2d image width */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE2D_MAX_WIDTH, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof(maxDimension), &maxDimension, NULL); test_error(error, "Unable to get max image 2d width from device"); @@ -689,7 +682,7 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, /* Verify that we can actually allocate an image that large */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize) { log_error("Can not allocate a large enough image (min size: %" PRIu64 @@ -713,8 +706,7 @@ int test_min_max_image_2d_width(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_image_2d_height) { int error; size_t maxDimension; @@ -723,9 +715,9 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, cl_ulong maxAllocSize; cl_uint minRequiredDimension; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) - auto version = get_device_cl_version(deviceID); + auto version = get_device_cl_version(device); if (version == Version(1, 0)) { minRequiredDimension = gIsEmbedded ? 2048 : 4096; @@ -741,7 +733,7 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, test_error(error, "Unable to obtain suitable image format to test with!"); /* Get the max 2d image width */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE2D_MAX_HEIGHT, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(maxDimension), &maxDimension, NULL); test_error(error, "Unable to get max image 2d height from device"); @@ -766,7 +758,7 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, /* Verify that we can actually allocate an image that large */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize) { log_error("Can not allocate a large enough image (min size: %" PRIu64 @@ -790,8 +782,7 @@ int test_min_max_image_2d_height(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_image_3d_width) { int error; size_t maxDimension; @@ -800,7 +791,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, cl_ulong maxAllocSize; - PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device) /* Just get any ol format to test with */ error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE3D, @@ -808,7 +799,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, test_error(error, "Unable to obtain suitable image format to test with!"); /* Get the max 2d image width */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE3D_MAX_WIDTH, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof(maxDimension), &maxDimension, NULL); test_error(error, "Unable to get max image 3d width from device"); @@ -833,7 +824,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, /* Verify that we can actually allocate an image that large */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize) { log_error("Can not allocate a large enough image (min size: %" PRIu64 @@ -858,8 +849,7 @@ int test_min_max_image_3d_width(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_image_3d_height) { int error; size_t maxDimension; @@ -868,7 +858,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, cl_ulong maxAllocSize; - PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device) /* Just get any ol format to test with */ error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE3D, @@ -876,7 +866,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, test_error(error, "Unable to obtain suitable image format to test with!"); /* Get the max 2d image width */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE3D_MAX_HEIGHT, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof(maxDimension), &maxDimension, NULL); test_error(error, "Unable to get max image 3d height from device"); @@ -901,7 +891,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, /* Verify that we can actually allocate an image that large */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if ((cl_ulong)maxDimension * 2 * 4 > maxAllocSize) { log_error("Can not allocate a large enough image (min size: %" PRIu64 @@ -927,8 +917,7 @@ int test_min_max_image_3d_height(cl_device_id deviceID, cl_context context, } -int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_image_3d_depth) { int error; size_t maxDimension; @@ -937,7 +926,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, cl_ulong maxAllocSize; - PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device) /* Just get any ol format to test with */ error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE3D, @@ -945,7 +934,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, test_error(error, "Unable to obtain suitable image format to test with!"); /* Get the max 2d image width */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE3D_MAX_DEPTH, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(maxDimension), &maxDimension, NULL); test_error(error, "Unable to get max image 3d depth from device"); @@ -970,7 +959,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, /* Verify that we can actually allocate an image that large */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize) { log_error("Can not allocate a large enough image (min size: %" PRIu64 @@ -994,8 +983,7 @@ int test_min_max_image_3d_depth(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_image_array_size) { int error; size_t maxDimension; @@ -1004,7 +992,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, cl_ulong maxAllocSize; size_t minRequiredDimension = gIsEmbedded ? 256 : 2048; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID); + PASSIVE_REQUIRE_IMAGE_SUPPORT(device); /* Just get any ol format to test with */ error = get_8_bit_image_format(context, CL_MEM_OBJECT_IMAGE2D_ARRAY, @@ -1012,7 +1000,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, test_error(error, "Unable to obtain suitable image format to test with!"); /* Get the max image array width */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, sizeof(maxDimension), &maxDimension, NULL); test_error(error, "Unable to get max image array size from device"); @@ -1038,7 +1026,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, /* Verify that we can actually allocate an image that large */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if ((cl_ulong)maxDimension * 1 * 4 > maxAllocSize) { log_error("Can not allocate a large enough image (min size: %" PRIu64 @@ -1064,8 +1052,7 @@ int test_min_max_image_array_size(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_image_buffer_size) { int error; size_t maxDimensionPixels; @@ -1076,15 +1063,15 @@ int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context, unsigned int i = 0; size_t pixelBytes = 0; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID); + PASSIVE_REQUIRE_IMAGE_SUPPORT(device); /* Get the max memory allocation size, divide it */ maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); /* Get the max image array width */ error = - clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, + clGetDeviceInfo(device, CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, sizeof(maxDimensionPixels), &maxDimensionPixels, NULL); test_error(error, "Unable to get max image buffer size from device"); @@ -1154,8 +1141,7 @@ int test_min_max_image_buffer_size(cl_device_id deviceID, cl_context context, } -int test_min_max_parameter_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_parameter_size) { int error, i; size_t maxSize; @@ -1174,7 +1160,7 @@ int test_min_max_parameter_size(cl_device_id deviceID, cl_context context, /* Get the max param size */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(maxSize), &maxSize, NULL); test_error(error, "Unable to get max parameter size from device"); @@ -1407,8 +1393,7 @@ int test_min_max_parameter_size(cl_device_id deviceID, cl_context context, return -1; } -int test_min_max_samplers(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_samplers) { int error; cl_uint maxSamplers, i; @@ -1421,11 +1406,11 @@ int test_min_max_samplers(cl_device_id deviceID, cl_context context, cl_uint minRequiredSamplers = gIsEmbedded ? 8 : 16; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) /* Get the max value */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_SAMPLERS, - sizeof(maxSamplers), &maxSamplers, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_MAX_SAMPLERS, sizeof(maxSamplers), + &maxSamplers, NULL); test_error(error, "Unable to get max sampler count from device"); if (maxSamplers < minRequiredSamplers) @@ -1438,7 +1423,7 @@ int test_min_max_samplers(cl_device_id deviceID, cl_context context, log_info("Reported max %d samplers.\n", maxSamplers); - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(maxParameterSize), &maxParameterSize, NULL); test_error(error, "Unable to get max parameter size from device"); @@ -1531,8 +1516,7 @@ int test_min_max_samplers(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_constant_buffer_size) { int error; clProgramWrapper program; @@ -1547,7 +1531,7 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, /* Verify our test buffer won't be bigger than allowed */ maxSize = get_device_info_max_constant_buffer_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if ((0 == gIsEmbedded && (maxSize * MAX_DEVICE_MEMORY_SIZE_DIVISOR) < 64L * 1024L) @@ -1564,12 +1548,12 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, /* We have four buffers allocations */ maxGlobalSize = get_device_info_global_mem_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR * 4); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR * 4); if (maxSize > maxGlobalSize) maxSize = maxGlobalSize; maxAllocSize = get_device_info_max_mem_alloc_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if (maxSize > maxAllocSize) maxSize = maxAllocSize; @@ -1731,8 +1715,7 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, return -1; } -int test_min_max_constant_args(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_constant_args) { int error; clProgramWrapper program; @@ -1751,11 +1734,11 @@ int test_min_max_constant_args(cl_device_id deviceID, cl_context context, /* Verify our test buffer won't be bigger than allowed */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_CONSTANT_ARGS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_CONSTANT_ARGS, sizeof(maxArgs), &maxArgs, 0); test_error(error, "Unable to get max constant arg count"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PARAMETER_SIZE, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(maxParameterSize), &maxParameterSize, NULL); test_error(error, "Unable to get max parameter size from device"); @@ -1782,7 +1765,7 @@ int test_min_max_constant_args(cl_device_id deviceID, cl_context context, } maxSize = get_device_info_max_constant_buffer_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); individualBufferSize = ((int)maxSize / 2) / maxArgs; log_info("Reported max constant arg count of %u and max constant buffer " @@ -1873,15 +1856,14 @@ int test_min_max_constant_args(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_compute_units(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_compute_units) { int error; cl_uint value; - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_COMPUTE_UNITS, - sizeof(value), &value, 0); + error = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(value), + &value, 0); test_error(error, "Unable to get compute unit count"); if (value < 1) @@ -1897,14 +1879,13 @@ int test_min_max_compute_units(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_address_bits(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_address_bits) { int error; cl_uint value; - error = clGetDeviceInfo(deviceID, CL_DEVICE_ADDRESS_BITS, sizeof(value), + error = clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(value), &value, 0); test_error(error, "Unable to get address bit count"); @@ -1921,19 +1902,18 @@ int test_min_max_address_bits(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_single_fp_config(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_single_fp_config) { int error; cl_device_fp_config value; char profile[128] = ""; - error = clGetDeviceInfo(deviceID, CL_DEVICE_SINGLE_FP_CONFIG, sizeof(value), + error = clGetDeviceInfo(device, CL_DEVICE_SINGLE_FP_CONFIG, sizeof(value), &value, 0); test_error(error, "Unable to get device single fp config"); // Check to see if we are an embedded profile device - if ((error = clGetDeviceInfo(deviceID, CL_DEVICE_PROFILE, sizeof(profile), + if ((error = clGetDeviceInfo(device, CL_DEVICE_PROFILE, sizeof(profile), profile, NULL))) { log_error("FAILURE: Unable to get CL_DEVICE_PROFILE: error %d\n", @@ -1965,13 +1945,12 @@ int test_min_max_single_fp_config(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_double_fp_config(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_double_fp_config) { int error; cl_device_fp_config value; - error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(value), + error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(value), &value, 0); test_error(error, "Unable to get device double fp config"); @@ -1991,8 +1970,7 @@ int test_min_max_double_fp_config(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_local_mem_size) { int error; clProgramWrapper program; @@ -2007,13 +1985,13 @@ int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context, MTdata d; /* Verify our test buffer won't be bigger than allowed */ - error = clGetDeviceInfo(deviceID, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(maxSize), + error = clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(maxSize), &maxSize, 0); test_error(error, "Unable to get max local buffer size"); try { - device_version = get_device_cl_version(deviceID); + device_version = get_device_cl_version(device); } catch (const std::runtime_error &e) { log_error("%s", e.what()); @@ -2052,7 +2030,7 @@ int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context, return -1; } - error = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, + error = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernelLocalUsage), &kernelLocalUsage, NULL); test_error(error, @@ -2142,9 +2120,7 @@ int test_min_max_local_mem_size(cl_device_id deviceID, cl_context context, return err; } -int test_min_max_kernel_preferred_work_group_size_multiple( - cl_device_id deviceID, cl_context context, cl_command_queue queue, - int num_elements) +REGISTER_TEST(min_max_kernel_preferred_work_group_size_multiple) { int err; clProgramWrapper program; @@ -2157,17 +2133,17 @@ int test_min_max_kernel_preferred_work_group_size_multiple( sample_local_arg_kernel, "sample_test"); test_error(err, "Failed to build kernel/program."); - err = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_WORK_GROUP_SIZE, + err = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_WORK_GROUP_SIZE, sizeof(max_workgroup_size), &max_workgroup_size, NULL); test_error(err, "clGetKernelWorkgroupInfo failed."); err = clGetKernelWorkGroupInfo( - kernel, deviceID, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, + kernel, device, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, sizeof(preferred_workgroup_size), &preferred_workgroup_size, NULL); test_error(err, "clGetKernelWorkgroupInfo failed."); - err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_SIZES, + err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(max_local_workgroup_size), max_local_workgroup_size, NULL); test_error(err, "clGetDeviceInfo failed for CL_DEVICE_MAX_WORK_ITEM_SIZES"); @@ -2188,16 +2164,13 @@ int test_min_max_kernel_preferred_work_group_size_multiple( return 0; } -int test_min_max_execution_capabilities(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(min_max_execution_capabilities) { int error; cl_device_exec_capabilities value; - error = clGetDeviceInfo(deviceID, CL_DEVICE_EXECUTION_CAPABILITIES, + error = clGetDeviceInfo(device, CL_DEVICE_EXECUTION_CAPABILITIES, sizeof(value), &value, 0); test_error(error, "Unable to get execution capabilities"); @@ -2211,14 +2184,13 @@ int test_min_max_execution_capabilities(cl_device_id deviceID, return 0; } -int test_min_max_queue_properties(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_queue_properties) { int error; cl_command_queue_properties value; - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, sizeof(value), &value, 0); test_error(error, "Unable to get queue properties"); @@ -2232,11 +2204,10 @@ int test_min_max_queue_properties(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_device_version(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_device_version) { // Query for the device version. - Version device_cl_version = get_device_cl_version(deviceID); + Version device_cl_version = get_device_cl_version(device); log_info("Returned version %s.\n", device_cl_version.to_string().c_str()); // Make sure 2.x devices support required extensions for 2.x @@ -2264,7 +2235,7 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context, "devices...\n"); for (size_t i = 0; i < ARRAY_SIZE(requiredExtensions11); i++) { - if (!is_extension_available(deviceID, requiredExtensions11[i])) + if (!is_extension_available(device, requiredExtensions11[i])) { log_error("ERROR: Required extension for 1.1 and greater " "devices is not in extension string: %s\n", @@ -2283,13 +2254,13 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context, // cl_khr_fp64 and it is only required if double precision is // supported. cl_device_fp_config doubles_supported; - cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG, + cl_int error = clGetDeviceInfo(device, CL_DEVICE_DOUBLE_FP_CONFIG, sizeof(doubles_supported), &doubles_supported, 0); test_error(error, "Unable to get device double fp config"); if (doubles_supported) { - if (!is_extension_available(deviceID, "cl_khr_fp64")) + if (!is_extension_available(device, "cl_khr_fp64")) { log_error( "ERROR: Required extension for 1.2 and greater devices " @@ -2309,7 +2280,7 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context, "2.2 devices...\n"); for (size_t i = 0; i < ARRAY_SIZE(requiredExtensions2x); i++) { - if (!is_extension_available(deviceID, requiredExtensions2x[i])) + if (!is_extension_available(device, requiredExtensions2x[i])) { log_error("ERROR: Required extension for 2.0, 2.1 and 2.2 " "devices is not in extension string: %s\n", @@ -2329,16 +2300,15 @@ int test_min_max_device_version(cl_device_id deviceID, cl_context context, return 0; } -int test_min_max_language_version(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_max_language_version) { cl_int error; cl_char buffer[4098]; size_t length; // Device version should fit the regex "OpenCL [0-9]+\.[0-9]+ *.*" - error = clGetDeviceInfo(deviceID, CL_DEVICE_OPENCL_C_VERSION, - sizeof(buffer), buffer, &length); + error = clGetDeviceInfo(device, CL_DEVICE_OPENCL_C_VERSION, sizeof(buffer), + buffer, &length); test_error(error, "Unable to get device opencl c version string"); if (memcmp(buffer, "OpenCL C ", strlen("OpenCL C ")) != 0) { diff --git a/test_conformance/api/test_binary.cpp b/test_conformance/api/test_binary.cpp index 8d3c01e517..0004368a73 100644 --- a/test_conformance/api/test_binary.cpp +++ b/test_conformance/api/test_binary.cpp @@ -25,7 +25,7 @@ static const char *sample_binary_kernel_source[] = { "}\n" }; -int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(binary_get) { int error; clProgramWrapper program; @@ -71,7 +71,7 @@ int test_binary_get(cl_device_id deviceID, cl_context context, cl_command_queue } -int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(binary_create) { /* To test this in a self-contained fashion, we have to create a program with source, then get the binary, then use that binary to reload the program, and then verify */ @@ -103,12 +103,13 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que test_error( error, "Unable to get program binary" ); cl_int loadErrors[ 1 ]; - program_from_binary = clCreateProgramWithBinary( context, 1, &deviceID, &binarySize, buffers, loadErrors, &error ); + program_from_binary = clCreateProgramWithBinary( + context, 1, &device, &binarySize, buffers, loadErrors, &error); test_error( error, "Unable to load valid program binary" ); test_error( loadErrors[ 0 ], "Unable to load valid device binary into program" ); - error = clBuildProgram( program_from_binary, 1, &deviceID, NULL, NULL, NULL ); - test_error( error, "Unable to build binary program" ); + error = clBuildProgram(program_from_binary, 1, &device, NULL, NULL, NULL); + test_error(error, "Unable to build binary program"); // Get the size of the binary built from the first binary size_t binary2Size; @@ -123,10 +124,11 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que // Try again, this time without passing the status ptr in, to make sure we still // get a valid binary - clProgramWrapper programWithoutStatus = clCreateProgramWithBinary( context, 1, &deviceID, &binary2Size, buffers, NULL, &error ); + clProgramWrapper programWithoutStatus = clCreateProgramWithBinary( + context, 1, &device, &binary2Size, buffers, NULL, &error); test_error( error, "Unable to load valid program binary when binary_status pointer is NULL" ); - error = clBuildProgram( programWithoutStatus, 1, &deviceID, NULL, NULL, NULL ); + error = clBuildProgram(programWithoutStatus, 1, &device, NULL, NULL, NULL); test_error( error, "Unable to build binary program created without binary_status" ); // Get the size of the binary created without passing binary_status @@ -214,5 +216,3 @@ int test_binary_create(cl_device_id deviceID, cl_context context, cl_command_que free(out_data_binary); return 0; } - - diff --git a/test_conformance/api/test_bool.cpp b/test_conformance/api/test_bool.cpp index 9c91f613db..61327193a3 100644 --- a/test_conformance/api/test_bool.cpp +++ b/test_conformance/api/test_bool.cpp @@ -35,7 +35,7 @@ const char *kernel_with_bool[] = { "}\n" }; -int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(bool_type) { clProgramWrapper program; @@ -48,4 +48,3 @@ int test_bool_type(cl_device_id deviceID, cl_context context, cl_command_queue q "kernel_with_bool" ); return err; } - diff --git a/test_conformance/api/test_clone_kernel.cpp b/test_conformance/api/test_clone_kernel.cpp index 8cf88b3fc4..b4c3093735 100644 --- a/test_conformance/api/test_clone_kernel.cpp +++ b/test_conformance/api/test_clone_kernel.cpp @@ -92,7 +92,9 @@ struct structArg float f; }; -int test_image_arg_shallow_clone(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, void* pbufRes, clMemWrapper& bufOut) +int test_image_arg_shallow_clone(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements, + void* pbufRes, clMemWrapper& bufOut) { int error; cl_image_format img_format; @@ -191,7 +193,9 @@ int test_image_arg_shallow_clone(cl_device_id deviceID, cl_context context, cl_c return 0; } -int test_double_arg_clone(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements, void* pbufRes, clMemWrapper& bufOut) +int test_double_arg_clone(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements, + void* pbufRes, clMemWrapper& bufOut) { int error = 0; clProgramWrapper program; @@ -228,7 +232,7 @@ int test_double_arg_clone(cl_device_id deviceID, cl_context context, cl_command_ return 0; } -int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(clone_kernel, Version(2, 1)) { int error; clProgramWrapper program; @@ -250,11 +254,12 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu cl_bool bimg = CL_FALSE; cl_bool bdouble = CL_FALSE; // test image support - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &bimg, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), + &bimg, NULL); test_error( error, "clGetDeviceInfo failed." ); // test double support - if (is_extension_available(deviceID, "cl_khr_fp64")) + if (is_extension_available(device, "cl_khr_fp64")) { bdouble = CL_TRUE; } @@ -377,13 +382,15 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu if (bimg) { - error = test_image_arg_shallow_clone(deviceID, context, queue, num_elements, pbufRes, bufOut); + error = test_image_arg_shallow_clone(device, context, queue, + num_elements, pbufRes, bufOut); test_error( error, "image arg shallow clone test failed." ); } if (bdouble) { - error = test_double_arg_clone(deviceID, context, queue, num_elements, pbufRes, bufOut); + error = test_double_arg_clone(device, context, queue, num_elements, + pbufRes, bufOut); test_error( error, "double arg clone test failed." ); } @@ -392,4 +399,3 @@ int test_clone_kernel(cl_device_id deviceID, cl_context context, cl_command_queu return 0; } - diff --git a/test_conformance/api/test_context_destructor_callback.cpp b/test_conformance/api/test_context_destructor_callback.cpp index d29d90390a..1079c4f875 100644 --- a/test_conformance/api/test_context_destructor_callback.cpp +++ b/test_conformance/api/test_context_destructor_callback.cpp @@ -26,12 +26,11 @@ void CL_CALLBACK context_destructor_callback(cl_context context, void *userData) *userPtr = ++sDestructorIndex; } -int test_context_destructor_callback(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(context_destructor_callback, Version(3, 0)) { cl_int error; clContextWrapper localContext = - clCreateContext(NULL, 1, &deviceID, NULL, NULL, &error); + clCreateContext(NULL, 1, &device, NULL, NULL, &error); test_error(error, "Unable to create local context"); // Set up some variables to catch the order in which callbacks are called diff --git a/test_conformance/api/test_create_context_from_type.cpp b/test_conformance/api/test_create_context_from_type.cpp index 1335534a36..e2ce29c334 100644 --- a/test_conformance/api/test_create_context_from_type.cpp +++ b/test_conformance/api/test_create_context_from_type.cpp @@ -23,7 +23,7 @@ #include "harness/conversions.h" #include -int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(create_context_from_type) { int error; clProgramWrapper program; @@ -47,11 +47,12 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_ "}\n" }; cl_device_type type; - error = clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(type), &type, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n"); cl_platform_id platform; - error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), + &platform, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n"); cl_context_properties properties[3] = { @@ -67,7 +68,7 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_ return -1; } - queue_to_test = clCreateCommandQueue(context_to_test, deviceID, 0, &error); + queue_to_test = clCreateCommandQueue(context_to_test, device, 0, &error); test_error(error, "clCreateCommandQueue failed"); if (queue_to_test == NULL) { log_error("clCreateCommandQueue returned NULL, but error was CL_SUCCESS."); @@ -128,14 +129,11 @@ int test_create_context_from_type(cl_device_id deviceID, cl_context context, cl_ return 0; } -int test_create_context_from_type_device_type_all(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(create_context_from_type_device_type_all) { cl_device_type type; cl_int error = - clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(type), &type, NULL); + clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n"); std::bitset type_bits(type); @@ -148,7 +146,7 @@ int test_create_context_from_type_device_type_all(cl_device_id deviceID, return -1; } cl_platform_id platform; - error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), + error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n"); @@ -172,14 +170,11 @@ int test_create_context_from_type_device_type_all(cl_device_id deviceID, return 0; } -int test_create_context_from_type_device_type_default(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(create_context_from_type_device_type_default) { cl_device_type type; cl_int error = - clGetDeviceInfo(deviceID, CL_DEVICE_TYPE, sizeof(type), &type, NULL); + clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_TYPE failed\n"); std::bitset type_bits(type); @@ -192,7 +187,7 @@ int test_create_context_from_type_device_type_default(cl_device_id deviceID, return -1; } cl_platform_id platform; - error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), + error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), &platform, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed\n"); diff --git a/test_conformance/api/test_create_kernels.cpp b/test_conformance/api/test_create_kernels.cpp index 0aa43614a2..8f3704e2cf 100644 --- a/test_conformance/api/test_create_kernels.cpp +++ b/test_conformance/api/test_create_kernels.cpp @@ -72,8 +72,7 @@ const char *repeate_test_kernel = "}\n"; - -int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_single_kernel) { int error; clProgramWrapper program; @@ -159,7 +158,7 @@ int test_load_single_kernel(cl_device_id deviceID, cl_context context, cl_comman return 0; } -int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_two_kernels) { int error; clProgramWrapper program; @@ -239,7 +238,7 @@ int test_load_two_kernels(cl_device_id deviceID, cl_context context, cl_command_ return 0; } -int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_two_kernels_in_one) { int error; clProgramWrapper program; @@ -320,7 +319,7 @@ int test_load_two_kernels_in_one(cl_device_id deviceID, cl_context context, cl_c return 0; } -int test_load_two_kernels_manually( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(load_two_kernels_manually) { clProgramWrapper program; clKernelWrapper kernel1, kernel2; @@ -351,7 +350,7 @@ int test_load_two_kernels_manually( cl_device_id deviceID, cl_context context, c return 0; } -int test_get_program_info_kernel_names( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(get_program_info_kernel_names) { clProgramWrapper program; clKernelWrapper kernel1, kernel2; @@ -442,7 +441,7 @@ static const char *single_task_kernel[] = { "\n" "}\n" }; -int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(enqueue_task) { int error; clProgramWrapper program; @@ -491,9 +490,8 @@ int test_enqueue_task(cl_device_id deviceID, cl_context context, cl_command_queu } - #define TEST_SIZE 1000 -int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(repeated_setup_cleanup) { cl_context local_context; @@ -519,10 +517,11 @@ int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_co for (i=0; i<100; i++) { memset(outData, 0, sizeof(cl_int)*TEST_SIZE); - local_context = clCreateContext(NULL, 1, &deviceID, notify_callback, NULL, &error); + local_context = + clCreateContext(NULL, 1, &device, notify_callback, NULL, &error); test_error( error, "clCreateContext failed"); - local_queue = clCreateCommandQueue(local_context, deviceID, 0, &error); + local_queue = clCreateCommandQueue(local_context, device, 0, &error); test_error( error, "clCreateCommandQueue failed"); error = create_single_kernel_helper( @@ -590,6 +589,3 @@ int test_repeated_setup_cleanup(cl_device_id deviceID, cl_context context, cl_co return 0; } - - - diff --git a/test_conformance/api/test_device_command_queue.cpp b/test_conformance/api/test_device_command_queue.cpp index a977c510b1..9450e868e0 100644 --- a/test_conformance/api/test_device_command_queue.cpp +++ b/test_conformance/api/test_device_command_queue.cpp @@ -39,10 +39,7 @@ int test_command_queue_helper(cl_context context, cl_device_id deviceID, return TEST_PASS; } -int test_set_default_device_command_queue(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST_VERSION(set_default_device_command_queue, Version(2, 1)) { cl_int error; constexpr cl_command_queue_properties PROPERTIES = CL_QUEUE_ON_DEVICE @@ -51,10 +48,10 @@ int test_set_default_device_command_queue(cl_device_id deviceID, CL_QUEUE_PROPERTIES, (PROPERTIES | CL_QUEUE_ON_DEVICE_DEFAULT), 0 }; - if (get_device_cl_version(deviceID) >= Version(3, 0)) + if (get_device_cl_version(device) >= Version(3, 0)) { cl_device_device_enqueue_capabilities dseCaps = 0; - error = clGetDeviceInfo(deviceID, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, + error = clGetDeviceInfo(device, CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES, sizeof(dseCaps), &dseCaps, NULL); test_error(error, "Unable to query CL_DEVICE_DEVICE_ENQUEUE_CAPABILITIES"); @@ -64,22 +61,22 @@ int test_set_default_device_command_queue(cl_device_id deviceID, } clCommandQueueWrapper cmd_queue_1 = clCreateCommandQueueWithProperties( - context, deviceID, properties.data(), &error); + context, device, properties.data(), &error); test_error(error, "clCreateCommandQueueWithProperties failed"); properties[1] = PROPERTIES; clCommandQueueWrapper cmd_queue_2 = clCreateCommandQueueWithProperties( - context, deviceID, properties.data(), &error); + context, device, properties.data(), &error); test_error(error, "clCreateCommandQueueWithProperties failed"); // cmd_queue_1 - if (test_command_queue_helper(context, deviceID, cmd_queue_1) != 0) + if (test_command_queue_helper(context, device, cmd_queue_1) != 0) { test_fail("test_command_queue_helper failed for cmd_queue_1.\n"); } // cmd_queue_2 - without CL_QUEUE_ON_DEVICE_DEFAULT - if (test_command_queue_helper(context, deviceID, cmd_queue_2) != 0) + if (test_command_queue_helper(context, device, cmd_queue_2) != 0) { test_fail("test_command_queue_helper failed for cmd_queue_2.\n"); } diff --git a/test_conformance/api/test_device_min_data_type_align_size_alignment.cpp b/test_conformance/api/test_device_min_data_type_align_size_alignment.cpp index 0115a2bc83..1662b06eab 100644 --- a/test_conformance/api/test_device_min_data_type_align_size_alignment.cpp +++ b/test_conformance/api/test_device_min_data_type_align_size_alignment.cpp @@ -25,36 +25,41 @@ int IsAPowerOfTwo( unsigned long x ) } -int test_min_data_type_align_size_alignment(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems ) +REGISTER_TEST(min_data_type_align_size_alignment) { - cl_uint min_alignment; + cl_uint min_alignment; - if (gHasLong) - min_alignment = sizeof(cl_long)*16; - else - min_alignment = sizeof(cl_int)*16; + if (gHasLong) + min_alignment = sizeof(cl_long) * 16; + else + min_alignment = sizeof(cl_int) * 16; - int error = 0; - cl_uint alignment; + int error = 0; + cl_uint alignment; - error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(alignment), &alignment, NULL); - test_error(error, "clGetDeviceInfo for CL_DEVICE_MEM_BASE_ADDR_ALIGN failed"); - log_info("Device reported CL_DEVICE_MEM_BASE_ADDR_ALIGN = %lu bits.\n", (unsigned long)alignment); + error = clGetDeviceInfo(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, + sizeof(alignment), &alignment, NULL); + test_error(error, + "clGetDeviceInfo for CL_DEVICE_MEM_BASE_ADDR_ALIGN failed"); + log_info("Device reported CL_DEVICE_MEM_BASE_ADDR_ALIGN = %lu bits.\n", + (unsigned long)alignment); - // Verify the size is large enough - if (alignment < min_alignment*8) { - log_error("ERROR: alignment too small. Minimum alignment for %s16 is %lu bits, device reported %lu bits.", - (gHasLong) ? "long" : "int", - (unsigned long)(min_alignment*8), (unsigned long)alignment); - return -1; - } + // Verify the size is large enough + if (alignment < min_alignment * 8) + { + log_error("ERROR: alignment too small. Minimum alignment for %s16 is " + "%lu bits, device reported %lu bits.", + (gHasLong) ? "long" : "int", + (unsigned long)(min_alignment * 8), (unsigned long)alignment); + return -1; + } - // Verify the size is a power of two - if (!IsAPowerOfTwo((unsigned long)alignment)) { - log_error("ERROR: alignment is not a power of two.\n"); - return -1; - } - - return 0; + // Verify the size is a power of two + if (!IsAPowerOfTwo((unsigned long)alignment)) + { + log_error("ERROR: alignment is not a power of two.\n"); + return -1; + } + return 0; } diff --git a/test_conformance/api/test_kernel_arg_changes.cpp b/test_conformance/api/test_kernel_arg_changes.cpp index eb798a9025..6e20efd9c3 100644 --- a/test_conformance/api/test_kernel_arg_changes.cpp +++ b/test_conformance/api/test_kernel_arg_changes.cpp @@ -32,7 +32,7 @@ const char *inspect_image_kernel_source[] = { #define NUM_TRIES 100 #define NUM_THREADS 2048 -int test_kernel_arg_changes(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(kernel_arg_changes) { clProgramWrapper program; clKernelWrapper kernel; @@ -137,5 +137,3 @@ int test_kernel_arg_changes(cl_device_id device, cl_context context, cl_command_ // If we got here, everything verified successfully return 0; } - - diff --git a/test_conformance/api/test_kernel_arg_info.cpp b/test_conformance/api/test_kernel_arg_info.cpp index f862ceda06..90b302b24c 100644 --- a/test_conformance/api/test_kernel_arg_info.cpp +++ b/test_conformance/api/test_kernel_arg_info.cpp @@ -300,16 +300,16 @@ static int compare_expected_actual(const KernelArgInfo& expected, return ret; } -static bool device_supports_pipes(cl_device_id deviceID) +static bool device_supports_pipes(cl_device_id device) { - auto version = get_device_cl_version(deviceID); + auto version = get_device_cl_version(device); if (version < MINIMUM_OPENCL_PIPE_VERSION) { return false; } cl_uint max_packet_size = 0; cl_int err = - clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_MAX_PACKET_SIZE, + clGetDeviceInfo(device, CL_DEVICE_PIPE_MAX_PACKET_SIZE, sizeof(max_packet_size), &max_packet_size, nullptr); test_error_ret(err, "clGetDeviceInfo", false); if ((max_packet_size == 0) && (version >= Version(3, 0))) @@ -319,14 +319,14 @@ static bool device_supports_pipes(cl_device_id deviceID) return true; } -static std::string get_build_options(cl_device_id deviceID) +static std::string get_build_options(cl_device_id device) { std::string ret = "-cl-kernel-arg-info"; - if (get_device_cl_version(deviceID) >= MINIMUM_OPENCL_PIPE_VERSION) + if (get_device_cl_version(device) >= MINIMUM_OPENCL_PIPE_VERSION) { - if (device_supports_pipes(deviceID)) + if (device_supports_pipes(device)) { - if (get_device_cl_version(deviceID) >= Version(3, 0)) + if (get_device_cl_version(device) >= Version(3, 0)) { ret += " -cl-std=CL3.0"; } @@ -435,8 +435,7 @@ create_expected_arg_info(const KernelArgInfo& kernel_argument, bool is_pointer) /* There are too many vector arguments for it to be worth writing down * statically and are instead generated here and combined with all of the scalar * and unsigned scalar types in a single data structure */ -static std::vector -generate_all_type_arguments(cl_device_id deviceID) +static std::vector generate_all_type_arguments(cl_device_id device) { std::vector ret = { "char", "short", "int", "float", @@ -460,11 +459,11 @@ generate_all_type_arguments(cl_device_id deviceID) vector_types.push_back("long"); vector_types.push_back("ulong"); } - if (device_supports_half(deviceID)) + if (device_supports_half(device)) { vector_types.push_back("half"); } - if (device_supports_double(deviceID)) + if (device_supports_double(device)) { vector_types.push_back("double"); } @@ -481,7 +480,7 @@ generate_all_type_arguments(cl_device_id deviceID) } static int -compare_kernel_with_expected(cl_context context, cl_device_id deviceID, +compare_kernel_with_expected(cl_context context, cl_device_id device, const char* kernel_src, const std::vector& expected_args) { @@ -490,7 +489,7 @@ compare_kernel_with_expected(cl_context context, cl_device_id deviceID, clProgramWrapper program; cl_int err = create_single_kernel_helper_with_build_options( context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info", - get_build_options(deviceID).c_str()); + get_build_options(device).c_str()); test_error(err, "create_single_kernel_helper_with_build_options"); for (size_t i = 0; i < expected_args.size(); ++i) { @@ -525,7 +524,7 @@ compare_kernel_with_expected(cl_context context, cl_device_id deviceID, return failed_tests; } -size_t get_param_size(const std::string& arg_type, cl_device_id deviceID, +size_t get_param_size(const std::string& arg_type, cl_device_id device, bool is_pipe) { if (is_pipe) @@ -535,7 +534,7 @@ size_t get_param_size(const std::string& arg_type, cl_device_id deviceID, if (arg_type.find("*") != std::string::npos) { cl_uint device_address_bits = 0; - cl_int err = clGetDeviceInfo(deviceID, CL_DEVICE_ADDRESS_BITS, + cl_int err = clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(device_address_bits), &device_address_bits, NULL); test_error_ret(err, "clGetDeviceInfo", 0); @@ -595,12 +594,12 @@ size_t get_param_size(const std::string& arg_type, cl_device_id deviceID, return ret; } -static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID) +static int run_scalar_vector_tests(cl_context context, cl_device_id device) { int failed_tests = 0; std::vector type_arguments = - generate_all_type_arguments(deviceID); + generate_all_type_arguments(device); const std::vector access_qualifiers = { CL_KERNEL_ARG_ACCESS_NONE, CL_KERNEL_ARG_ACCESS_READ_ONLY, @@ -608,7 +607,7 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID) }; std::vector all_args, expected_args; - size_t max_param_size = get_max_param_size(deviceID); + size_t max_param_size = get_max_param_size(device); size_t total_param_size(0); for (auto address_qualifier : address_qualifiers) { @@ -671,15 +670,14 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID) arg_type += "*"; } size_t param_size = - get_param_size(arg_type, deviceID, is_pipe); + get_param_size(arg_type, device, is_pipe); if (param_size + total_param_size >= max_param_size || all_args.size() == MAX_NUMBER_OF_KERNEL_ARGS) { const std::string kernel_src = generate_kernel( - all_args, false, device_supports_half(deviceID)); + all_args, false, device_supports_half(device)); failed_tests += compare_kernel_with_expected( - context, deviceID, kernel_src.c_str(), - expected_args); + context, device, kernel_src.c_str(), expected_args); all_args.clear(); expected_args.clear(); total_param_size = 0; @@ -699,36 +697,36 @@ static int run_scalar_vector_tests(cl_context context, cl_device_id deviceID) } } const std::string kernel_src = - generate_kernel(all_args, false, device_supports_half(deviceID)); + generate_kernel(all_args, false, device_supports_half(device)); failed_tests += compare_kernel_with_expected( - context, deviceID, kernel_src.c_str(), expected_args); + context, device, kernel_src.c_str(), expected_args); return failed_tests; } -static cl_uint get_max_number_of_pipes(cl_device_id deviceID, cl_int& err) +static cl_uint get_max_number_of_pipes(cl_device_id device, cl_int& err) { cl_uint ret(0); - err = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_PIPE_ARGS, sizeof(ret), &ret, + err = clGetDeviceInfo(device, CL_DEVICE_MAX_PIPE_ARGS, sizeof(ret), &ret, nullptr); return ret; } -static int run_pipe_tests(cl_context context, cl_device_id deviceID) +static int run_pipe_tests(cl_context context, cl_device_id device) { int failed_tests = 0; cl_kernel_arg_address_qualifier address_qualifier = CL_KERNEL_ARG_ADDRESS_PRIVATE; std::vector type_arguments = - generate_all_type_arguments(deviceID); + generate_all_type_arguments(device); const std::vector access_qualifiers = { CL_KERNEL_ARG_ACCESS_READ_ONLY, CL_KERNEL_ARG_ACCESS_WRITE_ONLY }; std::vector all_args, expected_args; - size_t max_param_size = get_max_param_size(deviceID); + size_t max_param_size = get_max_param_size(device); size_t total_param_size(0); cl_int err = CL_SUCCESS; - cl_uint max_number_of_pipes = get_max_number_of_pipes(deviceID, err); + cl_uint max_number_of_pipes = get_max_number_of_pipes(device, err); test_error_ret(err, "get_max_number_of_pipes", TEST_FAIL); cl_uint number_of_pipes(0); @@ -747,13 +745,13 @@ static int run_pipe_tests(cl_context context, cl_device_id deviceID) continue; } - size_t param_size = get_param_size(arg_type, deviceID, is_pipe); + size_t param_size = get_param_size(arg_type, device, is_pipe); if (param_size + total_param_size >= max_param_size || number_of_pipes == max_number_of_pipes) { const std::string kernel_src = generate_kernel(all_args); failed_tests += compare_kernel_with_expected( - context, deviceID, kernel_src.c_str(), expected_args); + context, device, kernel_src.c_str(), expected_args); all_args.clear(); expected_args.clear(); total_param_size = 0; @@ -775,11 +773,11 @@ static int run_pipe_tests(cl_context context, cl_device_id deviceID) } const std::string kernel_src = generate_kernel(all_args); failed_tests += compare_kernel_with_expected( - context, deviceID, kernel_src.c_str(), expected_args); + context, device, kernel_src.c_str(), expected_args); return failed_tests; } -static int run_sampler_test(cl_context context, cl_device_id deviceID) +static int run_sampler_test(cl_context context, cl_device_id device) { cl_kernel_arg_address_qualifier address_qualifier = CL_KERNEL_ARG_ADDRESS_PRIVATE; @@ -797,27 +795,27 @@ static int run_sampler_test(cl_context context, cl_device_id deviceID) const std::string kernel_src = generate_kernel({ kernel_argument }); - return compare_kernel_with_expected(context, deviceID, kernel_src.c_str(), + return compare_kernel_with_expected(context, device, kernel_src.c_str(), { expected }); } -static int run_image_tests(cl_context context, cl_device_id deviceID) +static int run_image_tests(cl_context context, cl_device_id device) { int failed_tests = 0; bool supports_3d_image_writes = - is_extension_available(deviceID, "cl_khr_3d_image_writes"); + is_extension_available(device, "cl_khr_3d_image_writes"); bool is_pointer = false; cl_kernel_arg_type_qualifier type_qualifier = CL_KERNEL_ARG_TYPE_NONE; cl_kernel_arg_address_qualifier address_qualifier = CL_KERNEL_ARG_ADDRESS_GLOBAL; - Version version = get_device_cl_version(deviceID); + Version version = get_device_cl_version(device); bool supports_read_write_images = false; if (version >= Version(3, 0)) { cl_uint maxReadWriteImageArgs = 0; cl_int error = clGetDeviceInfo( - deviceID, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, + device, CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, sizeof(maxReadWriteImageArgs), &maxReadWriteImageArgs, NULL); test_error(error, "Unable to query " @@ -862,23 +860,23 @@ static int run_image_tests(cl_context context, cl_device_id deviceID) generate_kernel({ kernel_argument }, supports_3d_image_writes); failed_tests += compare_kernel_with_expected( - context, deviceID, kernel_src.c_str(), { expected }); + context, device, kernel_src.c_str(), { expected }); } } - failed_tests += run_sampler_test(context, deviceID); + failed_tests += run_sampler_test(context, device); return failed_tests; } /* Ensure clGetKernelArgInfo returns successfully when param_value is * set to null */ -static int test_null_param(cl_context context, cl_device_id deviceID, +static int test_null_param(cl_context context, cl_device_id device, char const* kernel_src) { clProgramWrapper program; clKernelWrapper kernel; cl_int err = create_single_kernel_helper_with_build_options( context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info", - get_build_options(deviceID).c_str()); + get_build_options(device).c_str()); test_error_ret(err, "create_single_kernel_helper_with_build_options", TEST_FAIL); @@ -909,7 +907,7 @@ static int test_null_param(cl_context context, cl_device_id deviceID, /* Ensure clGetKernelArgInfo returns the correct size in bytes for the * kernel arg name */ -static int test_arg_name_size(cl_context context, cl_device_id deviceID, +static int test_arg_name_size(cl_context context, cl_device_id device, char const* kernel_src) { size_t size; @@ -920,7 +918,7 @@ static int test_arg_name_size(cl_context context, cl_device_id deviceID, clKernelWrapper kernel; cl_int err = create_single_kernel_helper_with_build_options( context, &program, &kernel, 1, &kernel_src, "get_kernel_arg_info", - get_build_options(deviceID).c_str()); + get_build_options(device).c_str()); test_error_ret(err, "create_single_kernel_helper_with_build_options", TEST_FAIL); @@ -939,7 +937,7 @@ static int test_arg_name_size(cl_context context, cl_device_id deviceID, } } -static int run_boundary_tests(cl_context context, cl_device_id deviceID) +static int run_boundary_tests(cl_context context, cl_device_id device) { int failed_tests = 0; @@ -952,9 +950,9 @@ static int run_boundary_tests(cl_context context, cl_device_id deviceID) arg_type, SINGLE_KERNEL_ARG_NUMBER); const std::string kernel_src = generate_kernel({ arg_info }); - failed_tests += test_arg_name_size(context, deviceID, kernel_src.c_str()); + failed_tests += test_arg_name_size(context, device, kernel_src.c_str()); - if (test_null_param(context, deviceID, kernel_src.c_str()) != TEST_PASS) + if (test_null_param(context, device, kernel_src.c_str()) != TEST_PASS) { failed_tests++; } @@ -962,10 +960,10 @@ static int run_boundary_tests(cl_context context, cl_device_id deviceID) return failed_tests; } -static int run_all_tests(cl_context context, cl_device_id deviceID) +static int run_all_tests(cl_context context, cl_device_id device) { - int failed_scalar_tests = run_scalar_vector_tests(context, deviceID); + int failed_scalar_tests = run_scalar_vector_tests(context, device); if (failed_scalar_tests == 0) { log_info("All Data Type Tests Passed\n"); @@ -976,9 +974,9 @@ static int run_all_tests(cl_context context, cl_device_id deviceID) } int failed_image_tests = 0; - if (checkForImageSupport(deviceID) == 0) + if (checkForImageSupport(device) == 0) { - failed_image_tests = run_image_tests(context, deviceID); + failed_image_tests = run_image_tests(context, device); if (failed_image_tests == 0) { log_info("All Image Tests Passed\n"); @@ -992,7 +990,7 @@ static int run_all_tests(cl_context context, cl_device_id deviceID) // TODO https://github.com/KhronosGroup/OpenCL-CTS/issues/1244 if (false) { - failed_pipe_tests = run_pipe_tests(context, deviceID); + failed_pipe_tests = run_pipe_tests(context, device); if (failed_pipe_tests == 0) { log_info("All Pipe Tests Passed\n"); @@ -1003,7 +1001,7 @@ static int run_all_tests(cl_context context, cl_device_id deviceID) } } - int failed_boundary_tests = run_boundary_tests(context, deviceID); + int failed_boundary_tests = run_boundary_tests(context, device); if (failed_boundary_tests == 0) { log_info("All Edge Case Tests Passed\n"); @@ -1017,10 +1015,9 @@ static int run_all_tests(cl_context context, cl_device_id deviceID) + failed_boundary_tests); } -int test_get_kernel_arg_info(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(get_kernel_arg_info) { - int failed_tests = run_all_tests(context, deviceID); + int failed_tests = run_all_tests(context, device); if (failed_tests != 0) { log_error("%d Test(s) Failed\n", failed_tests); diff --git a/test_conformance/api/test_kernel_arg_multi_setup.cpp b/test_conformance/api/test_kernel_arg_multi_setup.cpp index 79294bd65c..896a6a9531 100644 --- a/test_conformance/api/test_kernel_arg_multi_setup.cpp +++ b/test_conformance/api/test_kernel_arg_multi_setup.cpp @@ -240,7 +240,7 @@ int test_kernel_arg_multi_setup_exhaustive(cl_device_id device, cl_context conte return 0; } -int test_kernel_arg_multi_setup_random(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(kernel_arg_multi_setup_random) { // Loop through a selection of combinations ExplicitType types[] = { kChar, kShort, kInt, kFloat, kNumExplicitTypes }; @@ -282,7 +282,3 @@ int test_kernel_arg_multi_setup_random(cl_device_id device, cl_context context, } return 0; } - - - - diff --git a/test_conformance/api/test_kernel_attributes.cpp b/test_conformance/api/test_kernel_attributes.cpp index ad4baa0f50..f8c9ec0690 100644 --- a/test_conformance/api/test_kernel_attributes.cpp +++ b/test_conformance/api/test_kernel_attributes.cpp @@ -17,7 +17,7 @@ #include #include #include -#include "procs.h" + #include "harness/errorHelpers.h" #include "harness/typeWrappers.h" #include "harness/parseParameters.h" @@ -57,7 +57,7 @@ AttributePermutations reqd_vect_work_tests; // Generate a vector with vec_type_hint() so that it can be used to // generate different kernels -static KernelAttributes generate_vec_type_hint_data(cl_device_id deviceID) +static KernelAttributes generate_vec_type_hint_data(cl_device_id device) { KernelAttributes vec_type_hint_data; // TODO Test for signed vectors (char/short/int/etc) @@ -67,11 +67,11 @@ static KernelAttributes generate_vec_type_hint_data(cl_device_id deviceID) { vector_types.push_back("ulong"); } - if (device_supports_half(deviceID)) + if (device_supports_half(device)) { vector_types.push_back("half"); } - if (device_supports_double(deviceID)) + if (device_supports_double(device)) { vector_types.push_back("double"); } @@ -239,7 +239,7 @@ generate_attribute_tests(const KernelAttributes& vec_type_hint_data, } static const std::vector -initialise_attribute_data(cl_device_id deviceID) +initialise_attribute_data(cl_device_id device) { // This vector stores different work group dimensions that can be used by // the reqd_work_group_size and work_group_size_hint attributes. It @@ -248,7 +248,7 @@ initialise_attribute_data(cl_device_id deviceID) static const std::vector work_group_dimensions = { { 1, 1, 1 } }; - KernelAttributes vec_type_hint_data = generate_vec_type_hint_data(deviceID); + KernelAttributes vec_type_hint_data = generate_vec_type_hint_data(device); KernelAttributes work_group_size_hint_data = generate_work_group_size_data(work_group_dimensions); KernelAttributes reqd_work_group_size_data = @@ -261,7 +261,7 @@ initialise_attribute_data(cl_device_id deviceID) reqd_work_group_size_data); } -static bool run_test(cl_context context, cl_device_id deviceID, +static bool run_test(cl_context context, cl_device_id device, const AttributePermutations& permutations) { bool success = true; @@ -322,18 +322,17 @@ static bool run_test(cl_context context, cl_device_id deviceID, return success; } -int test_kernel_attributes(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(kernel_attributes) { bool success = true; // Vector to store all of the tests const std::vector all_tests = - initialise_attribute_data(deviceID); + initialise_attribute_data(device); for (auto permutations : all_tests) { - success = success && run_test(context, deviceID, *permutations); + success = success && run_test(context, device, *permutations); } return success ? TEST_PASS : TEST_FAIL; } diff --git a/test_conformance/api/test_kernel_local_memory_size.cpp b/test_conformance/api/test_kernel_local_memory_size.cpp index 5cd613f83f..7dcf384650 100644 --- a/test_conformance/api/test_kernel_local_memory_size.cpp +++ b/test_conformance/api/test_kernel_local_memory_size.cpp @@ -78,8 +78,7 @@ __kernel void local_param_local_memory_kernel(__local int* local_ptr, } )CLC"; -int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(kernel_local_memory_size) { int error; clProgramWrapper program; @@ -97,7 +96,7 @@ int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context, } error = clGetKernelWorkGroupInfo( - kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), + kernel, device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), &kernel_local_usage, ¶m_value_size_ret); test_error(error, "clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed"); @@ -194,7 +193,7 @@ int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context, test_error(error, "clEnqueueReadBuffer failed"); error = clGetKernelWorkGroupInfo( - kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), + kernel, device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), &kernel_local_usage, ¶m_value_size_ret); test_error(error, "clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed"); @@ -268,7 +267,7 @@ int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context, error = clGetKernelWorkGroupInfo( - kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), + kernel, device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), &kernel_local_usage, ¶m_value_size_ret); test_error(error, "clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed"); diff --git a/test_conformance/api/test_kernel_private_memory_size.cpp b/test_conformance/api/test_kernel_private_memory_size.cpp index a789b4d191..d291afdbd4 100644 --- a/test_conformance/api/test_kernel_private_memory_size.cpp +++ b/test_conformance/api/test_kernel_private_memory_size.cpp @@ -16,10 +16,8 @@ #include "harness/errorHelpers.h" #include "harness/typeWrappers.h" #include -#include "procs.h" -int test_kernel_private_memory_size(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(kernel_private_memory_size) { const char* TEST_KERNEL = R"(__kernel void private_memory( __global uint *buffer ){ @@ -33,7 +31,7 @@ int test_kernel_private_memory_size(cl_device_id deviceID, cl_context context, &TEST_KERNEL, "private_memory"); test_error(err, "create_single_kernel_helper"); cl_ulong size = CL_ULONG_MAX; - err = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_PRIVATE_MEM_SIZE, + err = clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_PRIVATE_MEM_SIZE, sizeof(cl_ulong), &size, nullptr); test_error(err, "clGetKernelWorkGroupInfo"); diff --git a/test_conformance/api/test_kernels.cpp b/test_conformance/api/test_kernels.cpp index 82bebabc9d..2b5e9c5686 100644 --- a/test_conformance/api/test_kernels.cpp +++ b/test_conformance/api/test_kernels.cpp @@ -76,9 +76,7 @@ const char *sample_two_kernel_program[] = { "}\n" }; - - -int test_get_kernel_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(get_kernel_info) { int error; cl_program program, testProgram; @@ -171,7 +169,7 @@ int test_get_kernel_info(cl_device_id deviceID, cl_context context, cl_command_q return 0; } -int test_execute_kernel_local_sizes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(execute_kernel_local_sizes) { int error; clProgramWrapper program; @@ -302,7 +300,7 @@ int test_execute_kernel_local_sizes(cl_device_id deviceID, cl_context context, c return 0; } -int test_set_kernel_arg_by_index(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(set_kernel_arg_by_index) { int error; clProgramWrapper program; @@ -372,7 +370,7 @@ int test_set_kernel_arg_by_index(cl_device_id deviceID, cl_context context, cl_c return 0; } -int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(set_kernel_arg_constant) { int error; clProgramWrapper program; @@ -390,7 +388,7 @@ int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_c /* Verify our test buffer won't be bigger than allowed */ maxSize = get_device_info_max_constant_buffer_size( - deviceID, MAX_DEVICE_MEMORY_SIZE_DIVISOR); + device, MAX_DEVICE_MEMORY_SIZE_DIVISOR); if (maxSize < sizeof(cl_int) * num_elements) { log_error( "ERROR: Unable to test constant argument to kernel: max size of constant buffer is reported as %d!\n", (int)maxSize ); @@ -459,7 +457,7 @@ int test_set_kernel_arg_constant(cl_device_id deviceID, cl_context context, cl_c return 0; } -int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(set_kernel_arg_struct_array) { int error; clProgramWrapper program; @@ -536,7 +534,7 @@ int test_set_kernel_arg_struct_array(cl_device_id deviceID, cl_context context, return 0; } -int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(create_kernels_in_program) { int error; cl_program program; @@ -565,7 +563,7 @@ int test_create_kernels_in_program(cl_device_id deviceID, cl_context context, cl return 0; } -int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(kernel_global_constant) { int error; clProgramWrapper program; @@ -633,6 +631,3 @@ int test_kernel_global_constant(cl_device_id deviceID, cl_context context, cl_co return 0; } - - - diff --git a/test_conformance/api/test_mem_object_info.cpp b/test_conformance/api/test_mem_object_info.cpp index e99b125a49..2dfe485749 100644 --- a/test_conformance/api/test_mem_object_info.cpp +++ b/test_conformance/api/test_mem_object_info.cpp @@ -56,7 +56,7 @@ get_image_dim(MTdata *d, unsigned int mod) } -int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ) +REGISTER_TEST(get_buffer_info) { int error; size_t size; @@ -150,7 +150,8 @@ int test_get_buffer_info( cl_device_id deviceID, cl_context context, cl_command_ // Get the address alignment, so we can make sure the sub-buffer test later works properly. cl_uint addressAlignBits; - 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); size_t addressAlign = addressAlignBits/8; if ( addressAlign < 128 ) @@ -420,7 +421,8 @@ int test_get_imageObject_info( cl_mem * image, cl_mem_flags objectFlags, cl_imag } -int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_object_type type ) +int test_get_image_info(cl_device_id device, cl_context context, + cl_mem_object_type type) { int error; size_t size; @@ -494,7 +496,7 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec MTdataHolder d_holder(gRandomSeed); MTdata d = static_cast(d_holder); - PASSIVE_REQUIRE_IMAGE_SUPPORT( deviceID ) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) cl_image_format imageFormat; size_t pixelSize = 4; @@ -530,7 +532,7 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec break; case CL_MEM_OBJECT_IMAGE3D: - error = checkFor3DImageSupport(deviceID); + error = checkFor3DImageSupport(device); if (error == CL_IMAGE_FORMAT_NOT_SUPPORTED) { log_info("Device doesn't support 3D images. Skipping test.\n"); @@ -738,29 +740,27 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec } -int test_get_image2d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ) +REGISTER_TEST(get_image2d_info) { - return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE2D); + return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE2D); } -int test_get_image3d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ) +REGISTER_TEST(get_image3d_info) { - return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE3D); + return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE3D); } -int test_get_image1d_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ) +REGISTER_TEST(get_image1d_info) { - return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE1D); + return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE1D); } -int test_get_image1d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ) +REGISTER_TEST(get_image1d_array_info) { - return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE1D_ARRAY); + return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE1D_ARRAY); } -int test_get_image2d_array_info( cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements ) +REGISTER_TEST(get_image2d_array_info) { - return test_get_image_info(deviceID, context, CL_MEM_OBJECT_IMAGE2D_ARRAY); + return test_get_image_info(device, context, CL_MEM_OBJECT_IMAGE2D_ARRAY); } - - diff --git a/test_conformance/api/test_mem_object_properties_queries.cpp b/test_conformance/api/test_mem_object_properties_queries.cpp index 7a5cb0cea2..67998d001e 100644 --- a/test_conformance/api/test_mem_object_properties_queries.cpp +++ b/test_conformance/api/test_mem_object_properties_queries.cpp @@ -271,13 +271,12 @@ static int run_test_query_properties(cl_context context, cl_command_queue queue, return TEST_PASS; } -int test_image_properties_queries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(image_properties_queries, Version(3, 0)) { int error = CL_SUCCESS; cl_bool supports_images = CL_TRUE; - error = clGetDeviceInfo(deviceID, CL_DEVICE_IMAGE_SUPPORT, + error = clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, sizeof(supports_images), &supports_images, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_IMAGE_SUPPORT failed"); @@ -321,8 +320,7 @@ int test_image_properties_queries(cl_device_id deviceID, cl_context context, return error; } -int test_buffer_properties_queries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(buffer_properties_queries, Version(3, 0)) { int error = CL_SUCCESS; diff --git a/test_conformance/api/test_mem_objects.cpp b/test_conformance/api/test_mem_objects.cpp index f1a4e99339..9d5e0ebd6f 100644 --- a/test_conformance/api/test_mem_objects.cpp +++ b/test_conformance/api/test_mem_objects.cpp @@ -83,10 +83,7 @@ int test_mem_object_destructor_callback_single(clMemWrapper &memObject) return (numErrors > 0) ? TEST_FAIL : TEST_PASS; } -int test_mem_object_destructor_callback(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(mem_object_destructor_callback) { clMemWrapper testBuffer, testImage; cl_int error; @@ -102,7 +99,7 @@ int test_mem_object_destructor_callback(cl_device_id deviceID, return TEST_FAIL; } - if (checkForImageSupport(deviceID) == 0) + if (checkForImageSupport(device) == 0) { cl_image_format imageFormat = { CL_RGBA, CL_SIGNED_INT8 }; testImage = create_image_2d(context, CL_MEM_READ_ONLY, &imageFormat, 16, diff --git a/test_conformance/api/test_min_image_formats.cpp b/test_conformance/api/test_min_image_formats.cpp index 5da8a162a6..616d95886e 100644 --- a/test_conformance/api/test_min_image_formats.cpp +++ b/test_conformance/api/test_min_image_formats.cpp @@ -15,8 +15,7 @@ // #include "testBase.h" -int test_min_image_formats(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(min_image_formats) { int missingFormats = 0; diff --git a/test_conformance/api/test_native_kernel.cpp b/test_conformance/api/test_native_kernel.cpp index d9c93628b4..531954efc3 100644 --- a/test_conformance/api/test_native_kernel.cpp +++ b/test_conformance/api/test_native_kernel.cpp @@ -33,7 +33,7 @@ static void CL_CALLBACK test_native_kernel_fn( void *userData ) args->dest[ i ] = args->source[ i ]; } -int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue queue, int n_elems ) +REGISTER_TEST(native_kernel) { int error; RandomSeed seed( gRandomSeed ); @@ -46,7 +46,7 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue } clMemWrapper streams[ 2 ]; - std::vector inBuffer(n_elems), outBuffer(n_elems); + std::vector inBuffer(num_elements), outBuffer(num_elements); clEventWrapper finishEvent; struct arg_struct @@ -58,21 +58,22 @@ 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.data()); + generate_random_data(kInt, num_elements, seed, inBuffer.data()); // Create I/O streams streams[0] = - clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, n_elems * sizeof(cl_int), - inBuffer.data(), &error); + clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, + num_elements * 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 ); + streams[1] = + clCreateBuffer(context, 0, num_elements * sizeof(cl_int), NULL, &error); test_error( error, "Unable to create I/O stream" ); // Set up the arrays to call with args.inputStream = streams[ 0 ]; args.outputStream = streams[ 1 ]; - args.count = n_elems; + args.count = num_elements; void * memLocs[ 2 ] = { &args.inputStream, &args.outputStream }; @@ -94,11 +95,11 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue // Now read the results and verify error = clEnqueueReadBuffer(queue, streams[1], CL_TRUE, 0, - n_elems * sizeof(cl_int), outBuffer.data(), 0, - NULL, NULL); + num_elements * sizeof(cl_int), outBuffer.data(), + 0, NULL, NULL); test_error( error, "Unable to read results" ); - for( int i = 0; i < n_elems; i++ ) + for (int i = 0; i < num_elements; i++) { if (inBuffer[i] != outBuffer[i]) { @@ -111,8 +112,3 @@ int test_native_kernel(cl_device_id device, cl_context context, cl_command_queue return 0; } - - - - - diff --git a/test_conformance/api/test_null_buffer_arg.cpp b/test_conformance/api/test_null_buffer_arg.cpp index 83fcb63647..8c9cf9fa23 100644 --- a/test_conformance/api/test_null_buffer_arg.cpp +++ b/test_conformance/api/test_null_buffer_arg.cpp @@ -24,8 +24,6 @@ #include "testBase.h" #include "harness/typeWrappers.h" #include "harness/testHarness.h" -#include "procs.h" - enum { SUCCESS, FAILURE }; typedef enum { NON_NULL_PATH, ADDROF_NULL_PATH, NULL_PATH } test_type; @@ -150,8 +148,7 @@ static int test_setargs_and_execution(cl_command_queue queue, cl_kernel kernel, return test_success; } -int test_null_buffer_arg(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(null_buffer_arg) { unsigned int test_success = 0; unsigned int buffer_size; diff --git a/test_conformance/api/test_pipe_properties_queries.cpp b/test_conformance/api/test_pipe_properties_queries.cpp index 099bb2ca22..e0a57f0aa4 100644 --- a/test_conformance/api/test_pipe_properties_queries.cpp +++ b/test_conformance/api/test_pipe_properties_queries.cpp @@ -71,14 +71,13 @@ static int create_pipe_and_check_array_properties( return TEST_FAIL; } -int test_pipe_properties_queries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(pipe_properties_queries, Version(3, 0)) { cl_int error = CL_SUCCESS; cl_bool pipeSupport = CL_FALSE; - error = clGetDeviceInfo(deviceID, CL_DEVICE_PIPE_SUPPORT, - sizeof(pipeSupport), &pipeSupport, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_PIPE_SUPPORT, sizeof(pipeSupport), + &pipeSupport, NULL); test_error(error, "Unable to query CL_DEVICE_PIPE_SUPPORT"); if (pipeSupport == CL_FALSE) diff --git a/test_conformance/api/test_platform.cpp b/test_conformance/api/test_platform.cpp index 841612a753..9247fa094f 100644 --- a/test_conformance/api/test_platform.cpp +++ b/test_conformance/api/test_platform.cpp @@ -21,8 +21,7 @@ #define PRINT_EXTENSION_INFO 0 -int test_platform_extensions(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(platform_extensions) { const char * extensions[] = { "cl_khr_byte_addressable_store", @@ -64,17 +63,14 @@ int test_platform_extensions(cl_device_id deviceID, cl_context context, char device_extensions[EXTENSION_NAME_BUF_SIZE]; // Okay, so what we're going to do is just check the device indicated by - // deviceID against the platform that includes this device + // device against the platform that includes this device // pass CL_DEVICE_PLATFORM to clGetDeviceInfo // to get a result of type cl_platform_id - err = clGetDeviceInfo(deviceID, - CL_DEVICE_PLATFORM, - sizeof(cl_platform_id), - (void *)(&platformID), - NULL); + err = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), + (void *)(&platformID), NULL); if(err != CL_SUCCESS) { @@ -115,11 +111,9 @@ int test_platform_extensions(cl_device_id deviceID, cl_context context, // and then we grab the set of extensions specified by the device // (this can be turned into a "loop over all devices in this platform") - err = clGetDeviceInfo(deviceID, - CL_DEVICE_EXTENSIONS, - sizeof(device_extensions), - (void *)(&device_extensions[0]), - NULL); + err = + clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(device_extensions), + (void *)(&device_extensions[0]), NULL); if(err != CL_SUCCESS) { vlog_error("test_platform_extensions : could not get extension string from device\n"); @@ -149,186 +143,206 @@ int test_platform_extensions(cl_device_id deviceID, cl_context context, return 0; } -int test_get_platform_ids(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { - cl_platform_id platforms[16]; - cl_uint num_platforms; - char *string_returned; - - string_returned = (char*)malloc(8192); - - int total_errors = 0; - int err = CL_SUCCESS; - - - err = clGetPlatformIDs(16, platforms, &num_platforms); - test_error(err, "clGetPlatformIDs failed"); - - if (num_platforms <= 16) { - // Try with NULL - err = clGetPlatformIDs(num_platforms, platforms, NULL); - test_error(err, "clGetPlatformIDs failed with NULL for return size"); - } - - if (num_platforms < 1) { - log_error("Found 0 platforms.\n"); - return -1; - } - log_info("Found %d platforms.\n", num_platforms); +REGISTER_TEST(get_platform_ids) +{ + cl_platform_id platforms[16]; + cl_uint num_platforms; + char *string_returned; + string_returned = (char *)malloc(8192); - for (int p=0; p<(int)num_platforms; p++) { - cl_device_id *devices; - cl_uint num_devices; - size_t size; + int total_errors = 0; + int err = CL_SUCCESS; - log_info("Platform %d (%p):\n", p, platforms[p]); + err = clGetPlatformIDs(16, platforms, &num_platforms); + test_error(err, "clGetPlatformIDs failed"); - memset(string_returned, 0, 8192); - err = clGetPlatformInfo(platforms[p], CL_PLATFORM_PROFILE, 8192, string_returned, &size); - test_error(err, "clGetPlatformInfo for CL_PLATFORM_PROFILE failed"); - log_info("\tCL_PLATFORM_PROFILE: %s\n", string_returned); - if (strlen(string_returned)+1 != size) { - log_error( - "Returned string length %zu does not equal reported one %zu.\n", - strlen(string_returned) + 1, size); - total_errors++; + if (num_platforms <= 16) + { + // Try with NULL + err = clGetPlatformIDs(num_platforms, platforms, NULL); + test_error(err, "clGetPlatformIDs failed with NULL for return size"); } - memset(string_returned, 0, 8192); - err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VERSION, 8192, string_returned, &size); - test_error(err, "clGetPlatformInfo for CL_PLATFORM_VERSION failed"); - log_info("\tCL_PLATFORM_VERSION: %s\n", string_returned); - if (strlen(string_returned)+1 != size) { - log_error( - "Returned string length %zu does not equal reported one %zu.\n", - strlen(string_returned) + 1, size); - total_errors++; + if (num_platforms < 1) + { + log_error("Found 0 platforms.\n"); + return -1; } + log_info("Found %d platforms.\n", num_platforms); - memset(string_returned, 0, 8192); - err = clGetPlatformInfo(platforms[p], CL_PLATFORM_NAME, 8192, string_returned, &size); - test_error(err, "clGetPlatformInfo for CL_PLATFORM_NAME failed"); - log_info("\tCL_PLATFORM_NAME: %s\n", string_returned); - if (strlen(string_returned)+1 != size) { - log_error( - "Returned string length %zu does not equal reported one %zu.\n", - strlen(string_returned) + 1, size); - total_errors++; - } - memset(string_returned, 0, 8192); - err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VENDOR, 8192, string_returned, &size); - test_error(err, "clGetPlatformInfo for CL_PLATFORM_VENDOR failed"); - log_info("\tCL_PLATFORM_VENDOR: %s\n", string_returned); - if (strlen(string_returned)+1 != size) { - log_error( - "Returned string length %zu does not equal reported one %zu.\n", - strlen(string_returned) + 1, size); - total_errors++; - } + for (int p = 0; p < (int)num_platforms; p++) + { + cl_device_id *devices; + cl_uint num_devices; + size_t size; - memset(string_returned, 0, 8192); - err = clGetPlatformInfo(platforms[p], CL_PLATFORM_EXTENSIONS, 8192, string_returned, &size); - test_error(err, "clGetPlatformInfo for CL_PLATFORM_EXTENSIONS failed"); - log_info("\tCL_PLATFORM_EXTENSIONS: %s\n", string_returned); - if (strlen(string_returned)+1 != size) { - log_error( - "Returned string length %zu does not equal reported one %zu.\n", - strlen(string_returned) + 1, size); - total_errors++; - } - err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices); - test_error(err, "clGetDeviceIDs failed.\n"); - if (num_devices == 0) - { - log_error("clGetDeviceIDs must return at least one device\n"); - total_errors++; - } + log_info("Platform %d (%p):\n", p, platforms[p]); - devices = (cl_device_id *)malloc(num_devices*sizeof(cl_device_id)); - memset(devices, 0, sizeof(cl_device_id)*num_devices); - err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, num_devices, devices, NULL); - test_error(err, "clGetDeviceIDs failed.\n"); + memset(string_returned, 0, 8192); + err = clGetPlatformInfo(platforms[p], CL_PLATFORM_PROFILE, 8192, + string_returned, &size); + test_error(err, "clGetPlatformInfo for CL_PLATFORM_PROFILE failed"); + log_info("\tCL_PLATFORM_PROFILE: %s\n", string_returned); + if (strlen(string_returned) + 1 != size) + { + log_error( + "Returned string length %zu does not equal reported one %zu.\n", + strlen(string_returned) + 1, size); + total_errors++; + } - log_info("\tPlatform has %d devices.\n", (int)num_devices); - for (int d = 0; d < (int)num_devices; d++) - { - size_t returned_size; - cl_platform_id returned_platform; - cl_context context; - cl_context_properties properties[] = { - CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[p], 0 - }; - - err = clGetDeviceInfo(devices[d], CL_DEVICE_PLATFORM, - sizeof(cl_platform_id), &returned_platform, - &returned_size); - test_error(err, "clGetDeviceInfo failed for CL_DEVICE_PLATFORM\n"); - if (returned_size != sizeof(cl_platform_id)) + memset(string_returned, 0, 8192); + err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VERSION, 8192, + string_returned, &size); + test_error(err, "clGetPlatformInfo for CL_PLATFORM_VERSION failed"); + log_info("\tCL_PLATFORM_VERSION: %s\n", string_returned); + if (strlen(string_returned) + 1 != size) { - log_error("Reported return size (%zu) does not match expected size " - "(%zu).\n", - returned_size, sizeof(cl_platform_id)); + log_error( + "Returned string length %zu does not equal reported one %zu.\n", + strlen(string_returned) + 1, size); total_errors++; } memset(string_returned, 0, 8192); - err = clGetDeviceInfo(devices[d], CL_DEVICE_NAME, 8192, string_returned, - NULL); - test_error(err, "clGetDeviceInfo failed for CL_DEVICE_NAME\n"); - - log_info("\t\tPlatform for device %d (%s) is %p.\n", d, string_returned, - returned_platform); - - log_info("\t\t\tTesting clCreateContext for the platform/device...\n"); - // Try creating a context for the platform - context = clCreateContext(properties, 1, &devices[d], NULL, NULL, &err); - test_error( - err, - "\t\tclCreateContext failed for device with platform properties\n"); - - memset(properties, 0, sizeof(cl_context_properties) * 3); - - err = clGetContextInfo(context, CL_CONTEXT_PROPERTIES, - sizeof(cl_context_properties) * 3, properties, - &returned_size); - test_error(err, "clGetContextInfo for CL_CONTEXT_PROPERTIES failed"); - if (returned_size != sizeof(cl_context_properties) * 3) + err = clGetPlatformInfo(platforms[p], CL_PLATFORM_NAME, 8192, + string_returned, &size); + test_error(err, "clGetPlatformInfo for CL_PLATFORM_NAME failed"); + log_info("\tCL_PLATFORM_NAME: %s\n", string_returned); + if (strlen(string_returned) + 1 != size) { - log_error("Invalid size returned from clGetContextInfo for " - "CL_CONTEXT_PROPERTIES. Got %zu, expected %zu.\n", - returned_size, sizeof(cl_context_properties) * 3); + log_error( + "Returned string length %zu does not equal reported one %zu.\n", + strlen(string_returned) + 1, size); total_errors++; } - if (properties[0] != (cl_context_properties)CL_CONTEXT_PLATFORM - || properties[1] != (cl_context_properties)platforms[p]) + memset(string_returned, 0, 8192); + err = clGetPlatformInfo(platforms[p], CL_PLATFORM_VENDOR, 8192, + string_returned, &size); + test_error(err, "clGetPlatformInfo for CL_PLATFORM_VENDOR failed"); + log_info("\tCL_PLATFORM_VENDOR: %s\n", string_returned); + if (strlen(string_returned) + 1 != size) { log_error( - "Wrong properties returned. Expected: [%p %p], got [%p %p]\n", - (void *)CL_CONTEXT_PLATFORM, platforms[p], - (void *)properties[0], (void *)properties[1]); + "Returned string length %zu does not equal reported one %zu.\n", + strlen(string_returned) + 1, size); total_errors++; } - err = clReleaseContext(context); - test_error(err, "clReleaseContext failed"); - } - free(devices); + memset(string_returned, 0, 8192); + err = clGetPlatformInfo(platforms[p], CL_PLATFORM_EXTENSIONS, 8192, + string_returned, &size); + test_error(err, "clGetPlatformInfo for CL_PLATFORM_EXTENSIONS failed"); + log_info("\tCL_PLATFORM_EXTENSIONS: %s\n", string_returned); + if (strlen(string_returned) + 1 != size) + { + log_error( + "Returned string length %zu does not equal reported one %zu.\n", + strlen(string_returned) + 1, size); + total_errors++; + } - err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_DEFAULT, 0, NULL, - &num_devices); - test_error(err, "clGetDeviceIDs failed.\n"); - if (num_devices != 1) - { - log_error("clGetDeviceIDs must return exactly one device\n"); - total_errors++; + err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, 0, NULL, + &num_devices); + test_error(err, "clGetDeviceIDs failed.\n"); + if (num_devices == 0) + { + log_error("clGetDeviceIDs must return at least one device\n"); + total_errors++; + } + + devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id)); + memset(devices, 0, sizeof(cl_device_id) * num_devices); + err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, num_devices, + devices, NULL); + test_error(err, "clGetDeviceIDs failed.\n"); + + log_info("\tPlatform has %d devices.\n", (int)num_devices); + for (int d = 0; d < (int)num_devices; d++) + { + size_t returned_size; + cl_platform_id returned_platform; + cl_context context; + cl_context_properties properties[] = { + CL_CONTEXT_PLATFORM, (cl_context_properties)platforms[p], 0 + }; + + err = clGetDeviceInfo(devices[d], CL_DEVICE_PLATFORM, + sizeof(cl_platform_id), &returned_platform, + &returned_size); + test_error(err, "clGetDeviceInfo failed for CL_DEVICE_PLATFORM\n"); + if (returned_size != sizeof(cl_platform_id)) + { + log_error( + "Reported return size (%zu) does not match expected size " + "(%zu).\n", + returned_size, sizeof(cl_platform_id)); + total_errors++; + } + + memset(string_returned, 0, 8192); + err = clGetDeviceInfo(devices[d], CL_DEVICE_NAME, 8192, + string_returned, NULL); + test_error(err, "clGetDeviceInfo failed for CL_DEVICE_NAME\n"); + + log_info("\t\tPlatform for device %d (%s) is %p.\n", d, + string_returned, returned_platform); + + log_info( + "\t\t\tTesting clCreateContext for the platform/device...\n"); + // Try creating a context for the platform + context = + clCreateContext(properties, 1, &devices[d], NULL, NULL, &err); + test_error(err, + "\t\tclCreateContext failed for device with platform " + "properties\n"); + + memset(properties, 0, sizeof(cl_context_properties) * 3); + + err = clGetContextInfo(context, CL_CONTEXT_PROPERTIES, + sizeof(cl_context_properties) * 3, + properties, &returned_size); + test_error(err, + "clGetContextInfo for CL_CONTEXT_PROPERTIES failed"); + if (returned_size != sizeof(cl_context_properties) * 3) + { + log_error("Invalid size returned from clGetContextInfo for " + "CL_CONTEXT_PROPERTIES. Got %zu, expected %zu.\n", + returned_size, sizeof(cl_context_properties) * 3); + total_errors++; + } + + if (properties[0] != (cl_context_properties)CL_CONTEXT_PLATFORM + || properties[1] != (cl_context_properties)platforms[p]) + { + log_error("Wrong properties returned. Expected: [%p %p], got " + "[%p %p]\n", + (void *)CL_CONTEXT_PLATFORM, platforms[p], + (void *)properties[0], (void *)properties[1]); + total_errors++; + } + + err = clReleaseContext(context); + test_error(err, "clReleaseContext failed"); + } + free(devices); + + err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_DEFAULT, 0, NULL, + &num_devices); + test_error(err, "clGetDeviceIDs failed.\n"); + if (num_devices != 1) + { + log_error("clGetDeviceIDs must return exactly one device\n"); + total_errors++; + } } - } - free(string_returned); + free(string_returned); - return total_errors; + return total_errors; } diff --git a/test_conformance/api/test_queries.cpp b/test_conformance/api/test_queries.cpp index 2c4bdb1072..92eff9c12d 100644 --- a/test_conformance/api/test_queries.cpp +++ b/test_conformance/api/test_queries.cpp @@ -22,7 +22,7 @@ #include #include -int test_get_platform_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(get_platform_info) { cl_platform_id platform; cl_int error; @@ -162,7 +162,7 @@ static cl_addressing_mode addressing_mode_values[] = { static cl_filter_mode filter_mode_values[] = { CL_FILTER_NEAREST, CL_FILTER_LINEAR }; -int test_sampler_params(cl_device_id deviceID, cl_context context, +int test_sampler_params(cl_device_id device, cl_context context, bool is_compatibility, size_t norm_coord_num, size_t addr_mod_num, size_t filt_mod_num) { @@ -218,7 +218,7 @@ int test_sampler_params(cl_device_id deviceID, cl_context context, "normalized coords"); test_error(error, "param checking failed"); - Version version = get_device_cl_version(deviceID); + Version version = get_device_cl_version(device); if (version >= Version(3, 0)) { std::vector test_properties( @@ -270,7 +270,7 @@ int test_sampler_params(cl_device_id deviceID, cl_context context, return 0; } -int get_sampler_info_params(cl_device_id deviceID, cl_context context, +int get_sampler_info_params(cl_device_id device, cl_context context, bool is_compatibility) { for (size_t norm_coord_num = 0; @@ -289,36 +289,32 @@ int get_sampler_info_params(cl_device_id deviceID, cl_context context, for (size_t filt_mod_num = 0; filt_mod_num < ARRAY_SIZE(filter_mode_values); filt_mod_num++) { - int err = test_sampler_params(deviceID, context, - is_compatibility, norm_coord_num, - addr_mod_num, filt_mod_num); + int err = test_sampler_params(device, context, is_compatibility, + norm_coord_num, addr_mod_num, + filt_mod_num); test_error(err, "testing clGetSamplerInfo params failed"); } } } return 0; } -int test_get_sampler_info(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(get_sampler_info, Version(2, 0)) { int error; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) - error = get_sampler_info_params(deviceID, context, false); + error = get_sampler_info_params(device, context, false); test_error(error, "Test Failed"); return 0; } -int test_get_sampler_info_compatibility(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements) +REGISTER_TEST(get_sampler_info_compatibility) { int error; - PASSIVE_REQUIRE_IMAGE_SUPPORT(deviceID) + PASSIVE_REQUIRE_IMAGE_SUPPORT(device) - error = get_sampler_info_params(deviceID, context, true); + error = get_sampler_info_params(device, context, true); test_error(error, "Test Failed"); return 0; @@ -347,8 +343,7 @@ int command_queue_param_test(cl_command_queue queue, return 0; } -int check_get_command_queue_info_params(cl_device_id deviceID, - cl_context context, +int check_get_command_queue_info_params(cl_device_id device, cl_context context, bool is_compatibility) { const cl_command_queue_properties host_optional[] = { @@ -370,7 +365,7 @@ int check_get_command_queue_info_params(cl_device_id deviceID, const size_t host_optional_size = ARRAY_SIZE(host_optional); const size_t device_required_size = ARRAY_SIZE(device_required); - Version version = get_device_cl_version(deviceID); + Version version = get_device_cl_version(device); const cl_device_info host_queue_query = version >= Version(2, 0) ? CL_DEVICE_QUEUE_ON_HOST_PROPERTIES @@ -378,7 +373,7 @@ int check_get_command_queue_info_params(cl_device_id deviceID, cl_queue_properties host_queue_props = 0; int error = - clGetDeviceInfo(deviceID, host_queue_query, sizeof(host_queue_props), + clGetDeviceInfo(device, host_queue_query, sizeof(host_queue_props), &host_queue_props, NULL); test_error(error, "clGetDeviceInfo failed"); log_info("CL_DEVICE_QUEUE_ON_HOST_PROPERTIES is %" PRIu64 "\n", @@ -387,7 +382,7 @@ int check_get_command_queue_info_params(cl_device_id deviceID, cl_queue_properties device_queue_props = 0; if (version >= Version(2, 0)) { - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, sizeof(device_queue_props), &device_queue_props, NULL); test_error(error, "clGetDeviceInfo failed"); @@ -430,12 +425,12 @@ int check_get_command_queue_info_params(cl_device_id deviceID, clCommandQueueWrapper queue; if (is_compatibility) { - queue = clCreateCommandQueue(context, deviceID, props, &error); + queue = clCreateCommandQueue(context, device, props, &error); test_error(error, "Unable to create command queue to test with"); } else { - queue = clCreateCommandQueueWithProperties(context, deviceID, + queue = clCreateCommandQueueWithProperties(context, device, queue_props_arg, &error); test_error(error, "Unable to create command queue to test with"); } @@ -453,8 +448,8 @@ int check_get_command_queue_info_params(cl_device_id deviceID, "context"); test_error(error, "param checking failed"); - error = command_queue_param_test(queue, CL_QUEUE_DEVICE, deviceID, - "deviceID"); + error = + command_queue_param_test(queue, CL_QUEUE_DEVICE, device, "device"); test_error(error, "param checking failed"); error = command_queue_param_test(queue, CL_QUEUE_PROPERTIES, @@ -464,25 +459,21 @@ int check_get_command_queue_info_params(cl_device_id deviceID, return 0; } -int test_get_command_queue_info(cl_device_id deviceID, cl_context context, - cl_command_queue ignoreQueue, int num_elements) +REGISTER_TEST_VERSION(get_command_queue_info, Version(2, 0)) { - int error = check_get_command_queue_info_params(deviceID, context, false); + int error = check_get_command_queue_info_params(device, context, false); test_error(error, "Test Failed"); return 0; } -int test_get_command_queue_info_compatibility(cl_device_id deviceID, - cl_context context, - cl_command_queue ignoreQueue, - int num_elements) +REGISTER_TEST(get_command_queue_info_compatibility) { - int error = check_get_command_queue_info_params(deviceID, context, true); + int error = check_get_command_queue_info_params(device, context, true); test_error(error, "Test Failed"); return 0; } -int test_get_context_info(cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements) +REGISTER_TEST(get_context_info) { int error; size_t size; @@ -534,16 +525,18 @@ return -1; \ } \ log_info( "\tReported device " name " : " type "\n", (int)( val / div ) ); -int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_queue ignoreQueue, int num_elements) +REGISTER_TEST(get_device_info) { int error; size_t size; cl_uint vendorID; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_VENDOR_ID, vendorID, "vendor ID", "0x%08x", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_VENDOR_ID, vendorID, "vendor ID", + "0x%08x", int) char extensions[ 10240 ]; - error = clGetDeviceInfo( deviceID, CL_DEVICE_EXTENSIONS, sizeof( extensions ), &extensions, &size ); + error = clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(extensions), + &extensions, &size); test_error( error, "Unable to get device extensions" ); if( size != strlen( extensions ) + 1 ) { @@ -553,25 +546,33 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q log_info( "\tReported device extensions: %s \n", extensions ); cl_uint preferred; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, preferred, "preferred vector char width", "%d", int ) - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, preferred, "preferred vector short width", "%d", int ) - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, preferred, "preferred vector int width", "%d", int ) - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, preferred, "preferred vector long width", "%d", int ) - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, preferred, "preferred vector float width", "%d", int ) - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, preferred, "preferred vector double width", "%d", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, preferred, + "preferred vector char width", "%d", int) + TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, preferred, + "preferred vector short width", "%d", int) + TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, preferred, + "preferred vector int width", "%d", int) + TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, preferred, + "preferred vector long width", "%d", int) + TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, preferred, + "preferred vector float width", "%d", int) + TEST_DEVICE_PARAM(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, + preferred, "preferred vector double width", "%d", int) // Note that even if cl_khr_fp64, the preferred width for double can be non-zero. For example, vendors // extensions can support double but may not support cl_khr_fp64, which implies math library support. cl_uint baseAddrAlign; - TEST_DEVICE_PARAM(deviceID, CL_DEVICE_MEM_BASE_ADDR_ALIGN, baseAddrAlign, + TEST_DEVICE_PARAM(device, CL_DEVICE_MEM_BASE_ADDR_ALIGN, baseAddrAlign, "base address alignment", "%d bits", int) cl_uint maxDataAlign; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, maxDataAlign, "min data type alignment", "%d bytes", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, maxDataAlign, + "min data type alignment", "%d bytes", int) cl_device_mem_cache_type cacheType; - error = clGetDeviceInfo( deviceID, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, sizeof( cacheType ), &cacheType, &size ); + error = clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, + sizeof(cacheType), &cacheType, &size); test_error( error, "Unable to get device global mem cache type" ); if( size != sizeof( cacheType ) ) { @@ -582,16 +583,21 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q log_info( "\tReported device global mem cache type: %s \n", cacheTypeName ); cl_uint cachelineSize; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cachelineSize, "global mem cacheline size", "%d bytes", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, + cachelineSize, "global mem cacheline size", "%d bytes", + int) cl_ulong cacheSize; - TEST_DEVICE_PARAM_MEM( deviceID, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cacheSize, "global mem cache size", "%d KB", 1024 ) + TEST_DEVICE_PARAM_MEM(device, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cacheSize, + "global mem cache size", "%d KB", 1024) cl_ulong memSize; - TEST_DEVICE_PARAM_MEM( deviceID, CL_DEVICE_GLOBAL_MEM_SIZE, memSize, "global mem size", "%d MB", ( 1024 * 1024 ) ) + TEST_DEVICE_PARAM_MEM(device, CL_DEVICE_GLOBAL_MEM_SIZE, memSize, + "global mem size", "%d MB", (1024 * 1024)) cl_device_local_mem_type localMemType; - error = clGetDeviceInfo( deviceID, CL_DEVICE_LOCAL_MEM_TYPE, sizeof( localMemType ), &localMemType, &size ); + error = clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_TYPE, + sizeof(localMemType), &localMemType, &size); test_error( error, "Unable to get device local mem type" ); if( size != sizeof( cacheType ) ) { @@ -603,22 +609,29 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q cl_bool errSupport; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_ERROR_CORRECTION_SUPPORT, errSupport, "error correction support", "%d", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_ERROR_CORRECTION_SUPPORT, errSupport, + "error correction support", "%d", int) size_t timerResolution; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_PROFILING_TIMER_RESOLUTION, timerResolution, "profiling timer resolution", "%ld nanoseconds", long ) + TEST_DEVICE_PARAM(device, CL_DEVICE_PROFILING_TIMER_RESOLUTION, + timerResolution, "profiling timer resolution", + "%ld nanoseconds", long) cl_bool endian; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_ENDIAN_LITTLE, endian, "little endian flag", "%d", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_ENDIAN_LITTLE, endian, + "little endian flag", "%d", int) cl_bool avail; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_AVAILABLE, avail, "available flag", "%d", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_AVAILABLE, avail, "available flag", + "%d", int) cl_bool compilerAvail; - TEST_DEVICE_PARAM( deviceID, CL_DEVICE_COMPILER_AVAILABLE, compilerAvail, "compiler available flag", "%d", int ) + TEST_DEVICE_PARAM(device, CL_DEVICE_COMPILER_AVAILABLE, compilerAvail, + "compiler available flag", "%d", int) char profile[ 1024 ]; - error = clGetDeviceInfo( deviceID, CL_DEVICE_PROFILE, sizeof( profile ), &profile, &size ); + error = clGetDeviceInfo(device, CL_DEVICE_PROFILE, sizeof(profile), + &profile, &size); test_error( error, "Unable to get device profile" ); if( size != strlen( profile ) + 1 ) { @@ -644,8 +657,6 @@ int test_get_device_info(cl_device_id deviceID, cl_context context, cl_command_q } - - static const char *sample_compile_size[2] = { "__kernel void sample_test(__global int *src, __global int *dst)\n" "{\n" @@ -660,7 +671,7 @@ static const char *sample_compile_size[2] = { "\n" "}\n" }; -int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(kernel_required_group_size) { int error; size_t realSize; @@ -670,7 +681,8 @@ int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, c cl_uint max_dimensions; - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(max_dimensions), &max_dimensions, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, + sizeof(max_dimensions), &max_dimensions, NULL); test_error(error, "clGetDeviceInfo failed for CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS"); log_info("Device reported CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = %d.\n", (int)max_dimensions); @@ -682,12 +694,17 @@ int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, c if( error != 0 ) return error; - error = clGetKernelWorkGroupInfo(kernel, deviceID, CL_KERNEL_WORK_GROUP_SIZE, sizeof(kernel_max_workgroup_size), &kernel_max_workgroup_size, NULL); + error = + clGetKernelWorkGroupInfo(kernel, device, CL_KERNEL_WORK_GROUP_SIZE, + sizeof(kernel_max_workgroup_size), + &kernel_max_workgroup_size, NULL); test_error( error, "clGetKernelWorkGroupInfo failed for CL_KERNEL_WORK_GROUP_SIZE"); log_info("The CL_KERNEL_WORK_GROUP_SIZE for the kernel is %d.\n", (int)kernel_max_workgroup_size); size_t size[ 3 ]; - error = clGetKernelWorkGroupInfo( kernel, deviceID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, sizeof( size ), size, &realSize ); + error = clGetKernelWorkGroupInfo(kernel, device, + CL_KERNEL_COMPILE_WORK_GROUP_SIZE, + sizeof(size), size, &realSize); test_error( error, "Unable to get work group info" ); if( size[ 0 ] != 0 || size[ 1 ] != 0 || size[ 2 ] != 0 ) @@ -735,7 +752,9 @@ int test_kernel_required_group_size(cl_device_id deviceID, cl_context context, c return error; size_t size[ 3 ]; - error = clGetKernelWorkGroupInfo( kernel, deviceID, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, sizeof( size ), size, &realSize ); + error = clGetKernelWorkGroupInfo(kernel, device, + CL_KERNEL_COMPILE_WORK_GROUP_SIZE, + sizeof(size), size, &realSize); test_error( error, "Unable to get work group info" ); if( size[ 0 ] != local[0] || size[ 1 ] != local[1] || size[ 2 ] != local[2] ) diff --git a/test_conformance/api/test_queue.cpp b/test_conformance/api/test_queue.cpp index 27ed5f05b4..1023c1f835 100644 --- a/test_conformance/api/test_queue.cpp +++ b/test_conformance/api/test_queue.cpp @@ -18,13 +18,12 @@ #include "testBase.h" #include "harness/typeWrappers.h" -int test_queue_flush_on_release(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) +REGISTER_TEST(queue_flush_on_release) { cl_int err; // Create a command queue - cl_command_queue queue = clCreateCommandQueue(context, deviceID, 0, &err); + cl_command_queue cmd_queue = clCreateCommandQueue(context, device, 0, &err); test_error(err, "Could not create command queue"); // Create a kernel @@ -38,12 +37,12 @@ int test_queue_flush_on_release(cl_device_id deviceID, cl_context context, // Enqueue the kernel size_t gws = 1; clEventWrapper event; - err = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &gws, nullptr, 0, - nullptr, &event); + err = clEnqueueNDRangeKernel(cmd_queue, kernel, 1, nullptr, &gws, nullptr, + 0, nullptr, &event); test_error(err, "Could not enqueue kernel"); // Release the queue - err = clReleaseCommandQueue(queue); + err = clReleaseCommandQueue(cmd_queue); // Wait for kernel to execute since the queue must flush on release bool success = poll_until(2000, 50, [&event]() { diff --git a/test_conformance/api/test_queue_hint.cpp b/test_conformance/api/test_queue_hint.cpp index 8e9b686980..89769d7e32 100644 --- a/test_conformance/api/test_queue_hint.cpp +++ b/test_conformance/api/test_queue_hint.cpp @@ -73,9 +73,7 @@ int test_enqueue(cl_context context, clCommandQueueWrapper& queue, clKernelWrapp } - - -int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(queue_hint) { if (num_elements <= 0) { @@ -94,7 +92,7 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue return err; } - if (is_extension_available(deviceID, "cl_khr_priority_hints")) + if (is_extension_available(device, "cl_khr_priority_hints")) { log_info("Testing cl_khr_priority_hints...\n"); @@ -116,7 +114,8 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue for (int i = 0; i < 3; ++i) { - clCommandQueueWrapper q = clCreateCommandQueueWithProperties(context, deviceID, queue_prop[i], &err); + clCommandQueueWrapper q = clCreateCommandQueueWithProperties( + context, device, queue_prop[i], &err); test_error(err, "clCreateCommandQueueWithProperties failed"); err = test_enqueue(context, q, kernel, (size_t)num_elements); @@ -131,7 +130,7 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue log_info("cl_khr_priority_hints is not supported.\n"); } - if (is_extension_available(deviceID, "cl_khr_throttle_hints")) + if (is_extension_available(device, "cl_khr_throttle_hints")) { log_info("Testing cl_khr_throttle_hints...\n"); cl_queue_properties queue_prop[][3] = @@ -152,7 +151,8 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue for (int i = 0; i < 3; ++i) { - clCommandQueueWrapper q = clCreateCommandQueueWithProperties(context, deviceID, queue_prop[i], &err); + clCommandQueueWrapper q = clCreateCommandQueueWithProperties( + context, device, queue_prop[i], &err); test_error(err, "clCreateCommandQueueWithProperties failed"); err = test_enqueue(context, q, kernel, (size_t)num_elements); @@ -170,4 +170,3 @@ int test_queue_hint(cl_device_id deviceID, cl_context context, cl_command_queue return 0; } - diff --git a/test_conformance/api/test_queue_properties.cpp b/test_conformance/api/test_queue_properties.cpp index a60211a2ec..674e9881fe 100644 --- a/test_conformance/api/test_queue_properties.cpp +++ b/test_conformance/api/test_queue_properties.cpp @@ -37,7 +37,10 @@ const char *queue_test_kernel[] = { "\n" "}\n" }; -int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop_def, cl_device_id deviceID, clKernelWrapper& kernel, size_t num_elements) +int enqueue_kernel(cl_context context, + const cl_queue_properties_khr *queue_prop_def, + cl_device_id device, clKernelWrapper &kernel, + size_t num_elements) { clMemWrapper streams[2]; int error; @@ -46,7 +49,8 @@ int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop cl_platform_id platform; clEventWrapper event; - error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &platform, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), + &platform, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); clCreateCommandQueueWithPropertiesKHR = (clCreateCommandQueueWithPropertiesKHR_fn) clGetExtensionFunctionAddressForPlatform(platform, "clCreateCommandQueueWithPropertiesKHR"); @@ -56,7 +60,8 @@ int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop return -1; } - clCommandQueueWrapper queue = clCreateCommandQueueWithPropertiesKHR(context, deviceID, queue_prop_def, &error); + clCommandQueueWrapper queue = clCreateCommandQueueWithPropertiesKHR( + context, device, queue_prop_def, &error); test_error(error, "clCreateCommandQueueWithPropertiesKHR failed"); for (size_t i = 0; i < num_elements; ++i) @@ -96,7 +101,7 @@ int enqueue_kernel(cl_context context, const cl_queue_properties_khr *queue_prop return 0; } -int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(queue_properties) { if (num_elements <= 0) { @@ -111,7 +116,7 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_ 0 }; // Query extension - if (!is_extension_available(deviceID, "cl_khr_create_command_queue")) + if (!is_extension_available(device, "cl_khr_create_command_queue")) { log_info("extension cl_khr_create_command_queue is not supported.\n"); return 0; @@ -121,17 +126,19 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_ test_error(error, "create_single_kernel_helper failed"); log_info("Queue property NULL. Testing ... \n"); - error = enqueue_kernel(context, NULL,deviceID, kernel, (size_t)num_elements); + error = enqueue_kernel(context, NULL, device, kernel, (size_t)num_elements); test_error(error, "enqueue_kernel failed"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, sizeof(device_props), &device_props, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES, + sizeof(device_props), &device_props, NULL); test_error(error, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed"); if (device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { log_info("Queue property CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE supported. Testing ... \n"); queue_prop_def[1] = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; - error = enqueue_kernel(context, queue_prop_def, deviceID, kernel, (size_t)num_elements); + error = enqueue_kernel(context, queue_prop_def, device, kernel, + (size_t)num_elements); test_error(error, "enqueue_kernel failed"); } else { @@ -142,7 +149,8 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_ { log_info("Queue property CL_QUEUE_PROFILING_ENABLE supported. Testing ... \n"); queue_prop_def[1] = CL_QUEUE_PROFILING_ENABLE; - error = enqueue_kernel(context, queue_prop_def, deviceID, kernel, (size_t)num_elements); + error = enqueue_kernel(context, queue_prop_def, device, kernel, + (size_t)num_elements); test_error(error, "enqueue_kernel failed"); } else { @@ -153,7 +161,8 @@ int test_queue_properties(cl_device_id deviceID, cl_context context, cl_command_ { log_info("Queue property CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE & CL_QUEUE_PROFILING_ENABLE supported. Testing ... \n"); queue_prop_def[1] = CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE|CL_QUEUE_PROFILING_ENABLE; - error = enqueue_kernel(context, queue_prop_def, deviceID, kernel, (size_t)num_elements); + error = enqueue_kernel(context, queue_prop_def, device, kernel, + (size_t)num_elements); test_error(error, "enqueue_kernel failed"); } else diff --git a/test_conformance/api/test_queue_properties_queries.cpp b/test_conformance/api/test_queue_properties_queries.cpp index 6d9b438027..a16bee9c7e 100644 --- a/test_conformance/api/test_queue_properties_queries.cpp +++ b/test_conformance/api/test_queue_properties_queries.cpp @@ -26,7 +26,7 @@ struct test_queue_array_properties_data }; int verify_if_properties_supported( - cl_device_id deviceID, cl_command_queue_properties requested_bitfield, + cl_device_id device, cl_command_queue_properties requested_bitfield, cl_uint requested_size) { int error = CL_SUCCESS; @@ -40,7 +40,7 @@ int verify_if_properties_supported( { cl_uint max_queue_size = 0; error = - clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, + clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE, sizeof(max_queue_size), &max_queue_size, NULL); test_error(error, "clGetDeviceInfo for " @@ -71,7 +71,7 @@ int verify_if_properties_supported( if (on_host_queue) { - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, sizeof(supported_properties), &supported_properties, NULL); test_error(error, @@ -80,7 +80,7 @@ int verify_if_properties_supported( } else { - error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, + error = clGetDeviceInfo(device, CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, sizeof(supported_properties), &supported_properties, NULL); test_error(error, @@ -107,7 +107,7 @@ int verify_if_properties_supported( } static int create_queue_and_check_array_properties( - cl_context context, cl_device_id deviceID, + cl_context context, cl_device_id device, test_queue_array_properties_data test_case) { cl_int error = CL_SUCCESS; @@ -117,13 +117,13 @@ static int create_queue_and_check_array_properties( if (test_case.properties.size() > 0) { test_queue = clCreateCommandQueueWithProperties( - context, deviceID, test_case.properties.data(), &error); + context, device, test_case.properties.data(), &error); test_error(error, "clCreateCommandQueueWithProperties failed"); } else { test_queue = - clCreateCommandQueueWithProperties(context, deviceID, NULL, &error); + clCreateCommandQueueWithProperties(context, device, NULL, &error); test_error(error, "clCreateCommandQueueWithProperties failed"); } @@ -162,7 +162,7 @@ static int create_queue_and_check_array_properties( } static int -run_test_queue_array_properties(cl_context context, cl_device_id deviceID, +run_test_queue_array_properties(cl_context context, cl_device_id device, test_queue_array_properties_data test_case) { int error = TEST_PASS; @@ -189,7 +189,7 @@ run_test_queue_array_properties(cl_context context, cl_device_id deviceID, } } - error = verify_if_properties_supported(deviceID, requested_bitfield, + error = verify_if_properties_supported(device, requested_bitfield, requested_size); if (error == TEST_SKIPPED_ITSELF) { @@ -201,16 +201,14 @@ run_test_queue_array_properties(cl_context context, cl_device_id deviceID, } // continue testing if supported user properties - error = - create_queue_and_check_array_properties(context, deviceID, test_case); + error = create_queue_and_check_array_properties(context, device, test_case); test_error(error, "create_queue_and_check_array_properties failed.\n"); log_info("TC result: passed\n"); return TEST_PASS; } -int test_queue_properties_queries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(queue_properties_queries, Version(3, 0)) { int error = TEST_PASS; std::vector test_cases; @@ -264,13 +262,12 @@ int test_queue_properties_queries(cl_device_id deviceID, cl_context context, for (auto test_case : test_cases) { - error |= run_test_queue_array_properties(context, deviceID, test_case); + error |= run_test_queue_array_properties(context, device, test_case); } return error; } -int test_set_command_queue_property(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(set_command_queue_property) { int err; @@ -281,7 +278,7 @@ int test_set_command_queue_property(cl_device_id deviceID, cl_context context, // Add other supported properties combinations cl_command_queue_properties supported_queue_props; - clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, + clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES, sizeof(supported_queue_props), &supported_queue_props, NULL); if (supported_queue_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) @@ -297,7 +294,7 @@ int test_set_command_queue_property(cl_device_id deviceID, cl_context context, queue_property_options) { clCommandQueueWrapper test_queue = - clCreateCommandQueue(context, deviceID, initial_properties, &err); + clCreateCommandQueue(context, device, initial_properties, &err); test_error(err, "clCreateCommandQueue failed"); cl_command_queue_properties old_properties, set_properties, diff --git a/test_conformance/api/test_retain.cpp b/test_conformance/api/test_retain.cpp index 6e66c7dabc..4cedef7312 100644 --- a/test_conformance/api/test_retain.cpp +++ b/test_conformance/api/test_retain.cpp @@ -30,28 +30,28 @@ log_error( "ERROR: Instance count for test object is not valid! (should be %d, really is %d)\n", rightValue, c ); \ return -1; } -int test_retain_queue_single(cl_device_id deviceID, cl_context context, cl_command_queue queueNotUsed, int num_elements) +REGISTER_TEST(retain_queue_single) { - cl_command_queue queue; + cl_command_queue cmd_queue; cl_uint numInstances; int err; /* Create a test queue */ - queue = clCreateCommandQueue( context, deviceID, 0, &err ); + cmd_queue = clCreateCommandQueue(context, device, 0, &err); test_error( err, "Unable to create command queue to test with" ); /* Test the instance count */ - GET_QUEUE_INSTANCE_COUNT( queue ); + GET_QUEUE_INSTANCE_COUNT(cmd_queue); test_error( err, "Unable to get queue instance count" ); VERIFY_INSTANCE_COUNT( numInstances, 1 ); /* Now release the program */ - clReleaseCommandQueue( queue ); + clReleaseCommandQueue(cmd_queue); #ifdef VERIFY_AFTER_RELEASE /* We're not allowed to get the instance count after the object has been completely released. But that's exactly how we can tell the release worked--by making sure getting the instance count fails! */ - GET_QUEUE_INSTANCE_COUNT( queue ); + GET_QUEUE_INSTANCE_COUNT(cmd_queue); if( err != CL_INVALID_COMMAND_QUEUE ) { print_error( err, "Command queue was not properly released" ); @@ -62,65 +62,65 @@ int test_retain_queue_single(cl_device_id deviceID, cl_context context, cl_comma return 0; } -int test_retain_queue_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queueNotUsed, int num_elements) +REGISTER_TEST(retain_queue_multiple) { - cl_command_queue queue; + cl_command_queue cmd_queue; unsigned int numInstances, i; int err; /* Create a test program */ - queue = clCreateCommandQueue( context, deviceID, 0, &err ); + cmd_queue = clCreateCommandQueue(context, device, 0, &err); test_error( err, "Unable to create command queue to test with" ); /* Increment 9 times, which should bring the count to 10 */ for( i = 0; i < 9; i++ ) { - clRetainCommandQueue( queue ); + clRetainCommandQueue(cmd_queue); } /* Test the instance count */ - GET_QUEUE_INSTANCE_COUNT( queue ); + GET_QUEUE_INSTANCE_COUNT(cmd_queue); test_error( err, "Unable to get queue instance count" ); VERIFY_INSTANCE_COUNT( numInstances, 10 ); /* Now release 5 times, which should take us to 5 */ for( i = 0; i < 5; i++ ) { - clReleaseCommandQueue( queue ); + clReleaseCommandQueue(cmd_queue); } - GET_QUEUE_INSTANCE_COUNT( queue ); + GET_QUEUE_INSTANCE_COUNT(cmd_queue); test_error( err, "Unable to get queue instance count" ); VERIFY_INSTANCE_COUNT( numInstances, 5 ); /* Retain again three times, which should take us to 8 */ for( i = 0; i < 3; i++ ) { - clRetainCommandQueue( queue ); + clRetainCommandQueue(cmd_queue); } - GET_QUEUE_INSTANCE_COUNT( queue ); + GET_QUEUE_INSTANCE_COUNT(cmd_queue); test_error( err, "Unable to get queue instance count" ); VERIFY_INSTANCE_COUNT( numInstances, 8 ); /* Release 7 times, which should take it to 1 */ for( i = 0; i < 7; i++ ) { - clReleaseCommandQueue( queue ); + clReleaseCommandQueue(cmd_queue); } - GET_QUEUE_INSTANCE_COUNT( queue ); + GET_QUEUE_INSTANCE_COUNT(cmd_queue); test_error( err, "Unable to get queue instance count" ); VERIFY_INSTANCE_COUNT( numInstances, 1 ); /* And one last one */ - clReleaseCommandQueue( queue ); + clReleaseCommandQueue(cmd_queue); #ifdef VERIFY_AFTER_RELEASE /* We're not allowed to get the instance count after the object has been completely released. But that's exactly how we can tell the release worked--by making sure getting the instance count fails! */ - GET_QUEUE_INSTANCE_COUNT( queue ); + GET_QUEUE_INSTANCE_COUNT(cmd_queue); if( err != CL_INVALID_COMMAND_QUEUE ) { print_error( err, "Command queue was not properly released" ); @@ -131,7 +131,7 @@ int test_retain_queue_multiple(cl_device_id deviceID, cl_context context, cl_com return 0; } -int test_retain_mem_object_single(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(retain_mem_object_single) { cl_mem object; cl_uint numInstances; @@ -163,7 +163,7 @@ int test_retain_mem_object_single(cl_device_id deviceID, cl_context context, cl_ return 0; } -int test_retain_mem_object_multiple(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(retain_mem_object_multiple) { cl_mem object; unsigned int numInstances, i; @@ -232,7 +232,7 @@ int test_retain_mem_object_multiple(cl_device_id deviceID, cl_context context, c return 0; } -int test_retain_mem_object_set_kernel_arg(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(retain_mem_object_set_kernel_arg) { int err; cl_mem buffer = nullptr; diff --git a/test_conformance/api/test_retain_program.cpp b/test_conformance/api/test_retain_program.cpp index b9fc8b7e24..ac2ea5b852 100644 --- a/test_conformance/api/test_retain_program.cpp +++ b/test_conformance/api/test_retain_program.cpp @@ -21,7 +21,7 @@ #include "harness/compat.h" -int test_release_kernel_order(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(release_kernel_order) { cl_program program; cl_kernel kernel; @@ -50,7 +50,7 @@ const char *sample_delay_kernel[] = { "\n" "}\n" }; -int test_release_during_execute( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(release_during_execute) { int error; cl_program program; @@ -100,5 +100,3 @@ int test_release_during_execute( cl_device_id deviceID, cl_context context, cl_c return 0; } - - diff --git a/test_conformance/api/test_sub_group_dispatch.cpp b/test_conformance/api/test_sub_group_dispatch.cpp index 3375990b25..fb0401cf99 100644 --- a/test_conformance/api/test_sub_group_dispatch.cpp +++ b/test_conformance/api/test_sub_group_dispatch.cpp @@ -54,7 +54,7 @@ cl_int get_sub_group_num(cl_command_queue queue, cl_kernel kernel, clMemWrapper& return error; } -int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(sub_group_dispatch, Version(2, 1)) { int error; size_t realSize; @@ -73,12 +73,12 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman size_t ret_ndrange2d_flattened; size_t ret_ndrange3d_flattened; - if (get_device_cl_version(deviceID) >= Version(3, 0)) + if (get_device_cl_version(device) >= Version(3, 0)) { int error; cl_uint max_num_sub_groups; - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_NUM_SUB_GROUPS, + error = clGetDeviceInfo(device, CL_DEVICE_MAX_NUM_SUB_GROUPS, sizeof(max_num_sub_groups), &max_num_sub_groups, NULL); if (error != CL_SUCCESS) @@ -102,16 +102,20 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman out = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR, sizeof(size_t), NULL, &error); test_error(error, "clCreateBuffer failed"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t), &max_local, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, + sizeof(size_t), &max_local, NULL); test_error(error, "clGetDeviceInfo failed"); - error = clGetDeviceInfo(deviceID, CL_DEVICE_PLATFORM, sizeof(platform), (void *)&platform, NULL); + error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, sizeof(platform), + (void *)&platform, NULL); test_error(error, "clDeviceInfo failed for CL_DEVICE_PLATFORM"); // Get the max subgroup size - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, - sizeof(max_local), &max_local, sizeof(kernel_max_subgroup_size), (void *)&kernel_max_subgroup_size, &realSize); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, + sizeof(max_local), &max_local, sizeof(kernel_max_subgroup_size), + (void *)&kernel_max_subgroup_size, &realSize); test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE"); log_info("The CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE for the kernel is %d.\n", (int)kernel_max_subgroup_size); @@ -121,8 +125,10 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman } // Get the number of subgroup for max local size - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, - sizeof(max_local), &max_local, sizeof(kernel_subgroup_count), (void *)&kernel_subgroup_count, &realSize); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE, + sizeof(max_local), &max_local, sizeof(kernel_subgroup_count), + (void *)&kernel_subgroup_count, &realSize); test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE"); log_info("The CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE for the kernel is %d.\n", (int)kernel_subgroup_count); @@ -138,7 +144,9 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman { // test all 3 different dimention of requested local size size_t kernel_ret_size = 0; - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), &i, sizeof(ret_ndrange1d), &ret_ndrange1d, &realSize); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), + &i, sizeof(ret_ndrange1d), &ret_ndrange1d, &realSize); test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); if (realSize != sizeof(ret_ndrange1d)) { log_error( "ERROR: Returned size of sub group count not valid! (Expected %d, got %d)\n", (int)sizeof(kernel_subgroup_count), (int)realSize ); @@ -153,7 +161,9 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman return -1; } - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), &i, sizeof(ret_ndrange2d), ret_ndrange2d, &realSize); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), + &i, sizeof(ret_ndrange2d), ret_ndrange2d, &realSize); test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); if (realSize != sizeof(ret_ndrange2d)) { log_error( "ERROR: Returned size of sub group count not valid! (Expected %d, got %d)\n", (int)sizeof(kernel_subgroup_count), (int)realSize ); @@ -170,7 +180,9 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman return -1; } - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), &i, sizeof(ret_ndrange3d), ret_ndrange3d, &realSize); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(i), + &i, sizeof(ret_ndrange3d), ret_ndrange3d, &realSize); test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); if (realSize != sizeof(ret_ndrange3d)) { log_error( "ERROR: Returned size of sub group count not valid! (Expected %d, got %d)\n", (int)sizeof(kernel_subgroup_count), (int)realSize ); @@ -191,16 +203,26 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman // test when input subgroup count exceeds max wg size: // there can be at most the local size of (1 WI) subgroups size_t large_sg_size = max_local + 1; - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(size_t), &large_sg_size, sizeof(ret_ndrange1d), &ret_ndrange1d, &realSize); - test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, + sizeof(size_t), &large_sg_size, sizeof(ret_ndrange1d), &ret_ndrange1d, + &realSize); + test_error(error, + "clGetKernelSubGroupInfo failed for " + "CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); if (ret_ndrange1d != 0) { log_error( "ERROR: Incorrect value returned for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT! (Expected %d, got %d)\n", 0, (int)ret_ndrange1d ); return -1; } - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(size_t), &large_sg_size, sizeof(ret_ndrange2d), ret_ndrange2d, &realSize); - test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, + sizeof(size_t), &large_sg_size, sizeof(ret_ndrange2d), ret_ndrange2d, + &realSize); + test_error(error, + "clGetKernelSubGroupInfo failed for " + "CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); if (ret_ndrange2d[0] != 0 || ret_ndrange2d[1] != 0) { @@ -208,8 +230,13 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman return -1; } - error = clGetKernelSubGroupInfo(kernel, deviceID, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, sizeof(size_t), &large_sg_size, sizeof(ret_ndrange3d), ret_ndrange3d, &realSize); - test_error(error, "clGetKernelSubGroupInfo failed for CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, + sizeof(size_t), &large_sg_size, sizeof(ret_ndrange3d), ret_ndrange3d, + &realSize); + test_error(error, + "clGetKernelSubGroupInfo failed for " + "CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"); if (ret_ndrange3d[0] != 0 || ret_ndrange3d[1] != 0 || ret_ndrange3d[2] != 0) diff --git a/test_conformance/api/test_wg_suggested_local_work_size.cpp b/test_conformance/api/test_wg_suggested_local_work_size.cpp index 6667ffda9a..f84646380c 100644 --- a/test_conformance/api/test_wg_suggested_local_work_size.cpp +++ b/test_conformance/api/test_wg_suggested_local_work_size.cpp @@ -14,6 +14,7 @@ // limitations under the License. // #include "harness/compat.h" +#include "harness/typeWrappers.h" #include #include @@ -21,7 +22,7 @@ #include #include -#include "procs.h" + #include const char* wg_scan_local_work_group_size = R"( @@ -276,9 +277,7 @@ int do_test_work_group_suggested_local_size( return err; } -int test_work_group_suggested_local_size_1D(cl_device_id device, - cl_context context, - cl_command_queue queue, int n_elems) +REGISTER_TEST(work_group_suggested_local_size_1D) { if (!is_extension_available(device, "cl_khr_suggested_local_work_size")) { @@ -380,9 +379,7 @@ int test_work_group_suggested_local_size_1D(cl_device_id device, return err; } -int test_work_group_suggested_local_size_2D(cl_device_id device, - cl_context context, - cl_command_queue queue, int n_elems) +REGISTER_TEST(work_group_suggested_local_size_2D) { if (!is_extension_available(device, "cl_khr_suggested_local_work_size")) { @@ -485,9 +482,7 @@ int test_work_group_suggested_local_size_2D(cl_device_id device, return err; } -int test_work_group_suggested_local_size_3D(cl_device_id device, - cl_context context, - cl_command_queue queue, int n_elems) +REGISTER_TEST(work_group_suggested_local_size_3D) { if (!is_extension_available(device, "cl_khr_suggested_local_work_size")) { diff --git a/test_conformance/api/test_zero_sized_enqueue.cpp b/test_conformance/api/test_zero_sized_enqueue.cpp index 7efb32c7b6..52b6f4a88e 100644 --- a/test_conformance/api/test_zero_sized_enqueue.cpp +++ b/test_conformance/api/test_zero_sized_enqueue.cpp @@ -58,7 +58,8 @@ cl_int test_zero_sized_enqueue_and_test_output_buffer(cl_command_queue queue, cl return clEnqueueUnmapMemObject(queue, buf, output, 0, NULL, NULL); } -int test_zero_sized_enqueue_helper(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_zero_sized_enqueue_helper(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) { int error; clProgramWrapper program; @@ -185,9 +186,10 @@ int test_zero_sized_enqueue_helper(cl_device_id deviceID, cl_context context, cl } -int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST_VERSION(zero_sized_enqueue, Version(2, 1)) { - int res = test_zero_sized_enqueue_helper(deviceID, context, queue, num_elements); + int res = + test_zero_sized_enqueue_helper(device, context, queue, num_elements); if (res != 0) { return res; @@ -195,7 +197,9 @@ int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_comman // now test out of order queue cl_command_queue_properties props; - cl_int error = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, sizeof(cl_command_queue_properties), &props, NULL); + cl_int error = + clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES, + sizeof(cl_command_queue_properties), &props, NULL); test_error( error, "clGetDeviceInfo failed."); if (props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) @@ -207,10 +211,12 @@ int test_zero_sized_enqueue(cl_device_id deviceID, cl_context context, cl_comman 0 }; - clCommandQueueWrapper ooqueue = clCreateCommandQueueWithProperties(context, deviceID, queue_prop_def, &error); + clCommandQueueWrapper ooqueue = clCreateCommandQueueWithProperties( + context, device, queue_prop_def, &error); test_error( error, "clCreateCommandQueueWithProperties failed."); - res = test_zero_sized_enqueue_helper(deviceID, context, ooqueue, num_elements); + res = test_zero_sized_enqueue_helper(device, context, ooqueue, + num_elements); } return res; From baed1566996056e34560c10db44e6f8b8d5920aa Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:29:16 +0000 Subject: [PATCH 16/39] Migrate the select suite to the new test registration framework (#2198) Contirbutes to #2181 Signed-off-by: Ahmed Hesham --- test_conformance/select/test_select.cpp | 114 ++++++++++-------------- 1 file changed, 49 insertions(+), 65 deletions(-) diff --git a/test_conformance/select/test_select.cpp b/test_conformance/select/test_select.cpp index 72be08c7a1..9cf4727ade 100644 --- a/test_conformance/select/test_select.cpp +++ b/test_conformance/select/test_select.cpp @@ -478,113 +478,95 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c return err; } -int test_select_uchar_uchar(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_uchar_uchar) { - return doTest(queue, context, kuchar, kuchar, deviceID); + return doTest(queue, context, kuchar, kuchar, device); } -int test_select_uchar_char(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_uchar_char) { - return doTest(queue, context, kuchar, kchar, deviceID); + return doTest(queue, context, kuchar, kchar, device); } -int test_select_char_uchar(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_char_uchar) { - return doTest(queue, context, kchar, kuchar, deviceID); + return doTest(queue, context, kchar, kuchar, device); } -int test_select_char_char(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_char_char) { - return doTest(queue, context, kchar, kchar, deviceID); + return doTest(queue, context, kchar, kchar, device); } -int test_select_ushort_ushort(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_ushort_ushort) { - return doTest(queue, context, kushort, kushort, deviceID); + return doTest(queue, context, kushort, kushort, device); } -int test_select_ushort_short(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_ushort_short) { - return doTest(queue, context, kushort, kshort, deviceID); + return doTest(queue, context, kushort, kshort, device); } -int test_select_short_ushort(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_short_ushort) { - return doTest(queue, context, kshort, kushort, deviceID); + return doTest(queue, context, kshort, kushort, device); } -int test_select_short_short(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_short_short) { - return doTest(queue, context, kshort, kshort, deviceID); + return doTest(queue, context, kshort, kshort, device); } -int test_select_half_ushort(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(select_half_ushort) { - return doTest(queue, context, khalf, kushort, deviceID); + return doTest(queue, context, khalf, kushort, device); } -int test_select_half_short(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements) +REGISTER_TEST(select_half_short) { - return doTest(queue, context, khalf, kshort, deviceID); + return doTest(queue, context, khalf, kshort, device); } -int test_select_uint_uint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_uint_uint) { - return doTest(queue, context, kuint, kuint, deviceID); + return doTest(queue, context, kuint, kuint, device); } -int test_select_uint_int(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_uint_int) { - return doTest(queue, context, kuint, kint, deviceID); + return doTest(queue, context, kuint, kint, device); } -int test_select_int_uint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_int_uint) { - return doTest(queue, context, kint, kuint, deviceID); + return doTest(queue, context, kint, kuint, device); } -int test_select_int_int(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_int_int) { - return doTest(queue, context, kint, kint, deviceID); + return doTest(queue, context, kint, kint, device); } -int test_select_float_uint(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_float_uint) { - return doTest(queue, context, kfloat, kuint, deviceID); + return doTest(queue, context, kfloat, kuint, device); } -int test_select_float_int(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_float_int) { - return doTest(queue, context, kfloat, kint, deviceID); + return doTest(queue, context, kfloat, kint, device); } -int test_select_ulong_ulong(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_ulong_ulong) { - return doTest(queue, context, kulong, kulong, deviceID); + return doTest(queue, context, kulong, kulong, device); } -int test_select_ulong_long(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_ulong_long) { - return doTest(queue, context, kulong, klong, deviceID); + return doTest(queue, context, kulong, klong, device); } -int test_select_long_ulong(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_long_ulong) { - return doTest(queue, context, klong, kulong, deviceID); + return doTest(queue, context, klong, kulong, device); } -int test_select_long_long(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_long_long) { - return doTest(queue, context, klong, klong, deviceID); + return doTest(queue, context, klong, klong, device); } -int test_select_double_ulong(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_double_ulong) { - return doTest(queue, context, kdouble, kulong, deviceID); + return doTest(queue, context, kdouble, kulong, device); } -int test_select_double_long(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(select_double_long) { - return doTest(queue, context, kdouble, klong, deviceID); + return doTest(queue, context, kdouble, klong, device); } -test_definition test_list[] = { - ADD_TEST(select_uchar_uchar), ADD_TEST(select_uchar_char), - ADD_TEST(select_char_uchar), ADD_TEST(select_char_char), - ADD_TEST(select_ushort_ushort), ADD_TEST(select_ushort_short), - ADD_TEST(select_short_ushort), ADD_TEST(select_short_short), - ADD_TEST(select_half_ushort), ADD_TEST(select_half_short), - ADD_TEST(select_uint_uint), ADD_TEST(select_uint_int), - ADD_TEST(select_int_uint), ADD_TEST(select_int_int), - ADD_TEST(select_float_uint), ADD_TEST(select_float_int), - ADD_TEST(select_ulong_ulong), ADD_TEST(select_ulong_long), - ADD_TEST(select_long_ulong), ADD_TEST(select_long_long), - ADD_TEST(select_double_ulong), ADD_TEST(select_double_long), -}; - -const int test_num = ARRAY_SIZE( test_list ); - int main(int argc, const char* argv[]) { test_start(); @@ -652,7 +634,9 @@ int main(int argc, const char* argv[]) log_info("*** Wimpy Reduction Factor: %-27u ***\n\n", s_wimpy_reduction_factor); } - int err = runTestHarness(argCount, argList, test_num, test_list, false, 0); + int err = runTestHarness( + argCount, argList, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0); free( argList ); @@ -667,8 +651,8 @@ static void printUsage( void ) log_info("\t-[2^n] Set wimpy reduction factor, recommended range of n is 1-12, default factor(%u)\n", s_wimpy_reduction_factor); log_info("\n"); log_info("Test names:\n"); - for( int i = 0; i < test_num; i++ ) + for (size_t i = 0; i < test_registry::getInstance().num_tests(); i++) { - log_info( "\t%s\n", test_list[i].name ); + log_info("\t%s\n", test_registry::getInstance().definitions()[i].name); } } From 2ea4d165d5242e6f642151538436bc47295f2773 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 24 Dec 2024 14:49:31 +0100 Subject: [PATCH 17/39] cmake: remove global -Wno-format (#2195) Move the global `-Wno-format` compiler option to the individual tests that still trigger Wformat warnings. The majority of the tests now compile cleanly with `-Wformat` enabled. Signed-off-by: Sven van Haastregt --- CMakeLists.txt | 1 - test_conformance/basic/CMakeLists.txt | 2 +- test_conformance/c11_atomics/CMakeLists.txt | 2 +- test_conformance/commonfns/CMakeLists.txt | 2 ++ test_conformance/conversions/CMakeLists.txt | 2 +- test_conformance/relationals/CMakeLists.txt | 2 ++ 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4c3181848..40deed8cd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,6 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang" # Enable more warnings if not doing a release build. add_cxx_flag_if_supported(-Wall) endif() - add_cxx_flag_if_supported(-Wno-format) add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785 add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784 diff --git a/test_conformance/basic/CMakeLists.txt b/test_conformance/basic/CMakeLists.txt index 7292bc9d37..a2b47402c4 100644 --- a/test_conformance/basic/CMakeLists.txt +++ b/test_conformance/basic/CMakeLists.txt @@ -71,6 +71,6 @@ if(APPLE) list(APPEND ${MODULE_NAME}_SOURCES test_queue_priority.cpp) endif(APPLE) -set_gnulike_module_compile_flags("-Wno-sign-compare") +set_gnulike_module_compile_flags("-Wno-sign-compare -Wno-format") include(../CMakeCommon.txt) diff --git a/test_conformance/c11_atomics/CMakeLists.txt b/test_conformance/c11_atomics/CMakeLists.txt index 0d389bce3c..29e224ffe8 100644 --- a/test_conformance/c11_atomics/CMakeLists.txt +++ b/test_conformance/c11_atomics/CMakeLists.txt @@ -7,6 +7,6 @@ set(${MODULE_NAME}_SOURCES test_atomics.cpp ) -set_gnulike_module_compile_flags("-Wno-sign-compare") +set_gnulike_module_compile_flags("-Wno-sign-compare -Wno-format") include(../CMakeCommon.txt) diff --git a/test_conformance/commonfns/CMakeLists.txt b/test_conformance/commonfns/CMakeLists.txt index bea20cf5e0..e77524740e 100644 --- a/test_conformance/commonfns/CMakeLists.txt +++ b/test_conformance/commonfns/CMakeLists.txt @@ -10,4 +10,6 @@ set(${MODULE_NAME}_SOURCES test_binary_fn.cpp ) +set_gnulike_module_compile_flags("-Wno-format") + include(../CMakeCommon.txt) diff --git a/test_conformance/conversions/CMakeLists.txt b/test_conformance/conversions/CMakeLists.txt index 32990ebae4..037430efe0 100644 --- a/test_conformance/conversions/CMakeLists.txt +++ b/test_conformance/conversions/CMakeLists.txt @@ -12,6 +12,6 @@ if("${CLConform_TARGET_ARCH}" STREQUAL "ARM" OR "${CLConform_TARGET_ARCH}" STREQ list(APPEND ${MODULE_NAME}_SOURCES fplib.cpp) endif() -set_gnulike_module_compile_flags("-Wno-sign-compare") +set_gnulike_module_compile_flags("-Wno-sign-compare -Wno-format") include(../CMakeCommon.txt) diff --git a/test_conformance/relationals/CMakeLists.txt b/test_conformance/relationals/CMakeLists.txt index aa5dd6a1ec..183fdd1de6 100644 --- a/test_conformance/relationals/CMakeLists.txt +++ b/test_conformance/relationals/CMakeLists.txt @@ -7,5 +7,7 @@ set(${MODULE_NAME}_SOURCES test_shuffles.cpp ) +set_gnulike_module_compile_flags("-Wno-format") + include(../CMakeCommon.txt) From 28da01788d4193c1ca84df66f6dfeb126bb5cf62 Mon Sep 17 00:00:00 2001 From: Kamil-Goras-Mobica <141216953+kamil-goras-mobica@users.noreply.github.com> Date: Tue, 7 Jan 2025 18:29:28 +0100 Subject: [PATCH 18/39] Removed checking for supporting half (#2175) Fixes https://github.com/KhronosGroup/OpenCL-CTS/issues/1982 according to description --- test_conformance/gl/test_images_getinfo_common.cpp | 5 ----- test_conformance/gl/test_images_read_common.cpp | 5 ----- test_conformance/gl/test_renderbuffer.cpp | 1 - 3 files changed, 11 deletions(-) diff --git a/test_conformance/gl/test_images_getinfo_common.cpp b/test_conformance/gl/test_images_getinfo_common.cpp index 836eb067cb..1d1b0542a6 100644 --- a/test_conformance/gl/test_images_getinfo_common.cpp +++ b/test_conformance/gl/test_images_getinfo_common.cpp @@ -23,7 +23,6 @@ #include #endif -extern int supportsHalf(cl_context context, bool *supports_half); static int test_image_info(cl_context context, cl_command_queue queue, GLenum glTarget, GLuint glTexture, size_t imageWidth, @@ -97,10 +96,6 @@ static int test_image_format_get_info(cl_context context, if (fmt->type == kHalf) { if (DetectFloatToHalfRoundingMode(queue)) return 0; - bool supports_half = false; - error = supportsHalf(context, &supports_half); - if (error != 0) return error; - if (!supports_half) return 0; } size_t w = width, h = height, d = depth; diff --git a/test_conformance/gl/test_images_read_common.cpp b/test_conformance/gl/test_images_read_common.cpp index d12936e885..3b76745aff 100644 --- a/test_conformance/gl/test_images_read_common.cpp +++ b/test_conformance/gl/test_images_read_common.cpp @@ -23,7 +23,6 @@ #include #endif -extern int supportsHalf(cl_context context, bool *supports_half); extern int supportsMsaa(cl_context context, bool *supports_msaa); extern int supportsDepth(cl_context context, bool *supports_depth); @@ -441,10 +440,6 @@ static int test_image_format_read(cl_context context, cl_command_queue queue, if (fmt->type == kHalf) { if (DetectFloatToHalfRoundingMode(queue)) return 1; - bool supports_half = false; - error = supportsHalf(context, &supports_half); - if (error != 0) return error; - if (!supports_half) return 0; } #ifdef GL_VERSION_3_2 if (get_base_gl_target(target) == GL_TEXTURE_2D_MULTISAMPLE diff --git a/test_conformance/gl/test_renderbuffer.cpp b/test_conformance/gl/test_renderbuffer.cpp index 1b5709d4b5..25807abeab 100644 --- a/test_conformance/gl/test_renderbuffer.cpp +++ b/test_conformance/gl/test_renderbuffer.cpp @@ -63,7 +63,6 @@ extern int test_cl_image_read(cl_context context, cl_command_queue queue, cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer); -extern int supportsHalf(cl_context context, bool *supports_half); static int test_attach_renderbuffer_read_image( cl_context context, cl_command_queue queue, GLenum glTarget, From 4486241540ba8ff131fdeb810fdd7d10322b0671 Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:30:27 +0000 Subject: [PATCH 19/39] Generate the Vulkan shaders at build time (#2199) Use `add_custom_command` and `add_custom_target` instead of `execute_process` so the generation of the Vulkan shader is done at build time and not configuration time. Use `configure_file` instead of string replacement. Fixes #2179 Signed-off-by: Ahmed Hesham --- test_conformance/vulkan/CMakeLists.txt | 2 + .../vulkan/shaders/CMakeLists.txt | 72 +++++++++---------- .../shaders/{image2D.comp => image2D.comp.in} | 24 ++++--- 3 files changed, 50 insertions(+), 48 deletions(-) rename test_conformance/vulkan/shaders/{image2D.comp => image2D.comp.in} (67%) diff --git a/test_conformance/vulkan/CMakeLists.txt b/test_conformance/vulkan/CMakeLists.txt index 61a6014923..7b9bcc1801 100644 --- a/test_conformance/vulkan/CMakeLists.txt +++ b/test_conformance/vulkan/CMakeLists.txt @@ -32,3 +32,5 @@ include_directories("../common/vulkan_wrapper") add_subdirectory(shaders) include(../CMakeCommon.txt) + +add_dependencies(${${MODULE_NAME}_OUT} vulkan_shaders) diff --git a/test_conformance/vulkan/shaders/CMakeLists.txt b/test_conformance/vulkan/shaders/CMakeLists.txt index 258075504b..002ab9bf5c 100644 --- a/test_conformance/vulkan/shaders/CMakeLists.txt +++ b/test_conformance/vulkan/shaders/CMakeLists.txt @@ -1,5 +1,3 @@ -# CMP0007:NEW - Don't ignore empty elements in a list -cmake_policy(SET CMP0007 NEW) find_program( Vulkan_glslang_binary NAMES glslang @@ -10,40 +8,36 @@ if(${Vulkan_glslang_binary} STREQUAL "Vulkan_glslang_binary-NOTFOUND") else() message(STATUS "Found glslang: ${Vulkan_glslang_binary}") - set(IMAGE2D_SHADER_IN_FILE "image2D.comp") - set(IMAGE2D_SHADER_TMP_OUT_FILE "tmp_image2D.comp") - set(BUFFER_SHADER_IN_FILE "buffer") - set(IMAGE2D_FORMATS_LIST_IN_FILE "image2D_test_formats.txt") - - file(READ ${IMAGE2D_SHADER_IN_FILE} IMAGE2D_SHADER_UNFORMAT_CONTENT) - file(STRINGS ${IMAGE2D_FORMATS_LIST_IN_FILE} IMAGE2D_FORMATS_LIST) - - if(NOT DEFINED VULKAN_TEST_RESOURCES) - set(VULKAN_TEST_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}) - endif() - - foreach(IMAGE2D_FORMAT ${IMAGE2D_FORMATS_LIST}) - list(GET IMAGE2D_FORMAT 1 GLSL_FORMAT) - list(GET IMAGE2D_FORMAT 2 GLSL_TYPE_PREFIX) - string(REPLACE "GLSL_FORMAT" "${GLSL_FORMAT}" IMAGE2D_SHADER_CONTENT "${IMAGE2D_SHADER_UNFORMAT_CONTENT}") - string(REPLACE "GLSL_TYPE_PREFIX" "${GLSL_TYPE_PREFIX}" IMAGE2D_SHADER_CONTENT "${IMAGE2D_SHADER_CONTENT}") - file(WRITE ${IMAGE2D_SHADER_TMP_OUT_FILE} "${IMAGE2D_SHADER_CONTENT}") - execute_process( - COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv ${IMAGE2D_SHADER_TMP_OUT_FILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE commandStatus - OUTPUT_QUIET) - if(commandStatus AND NOT commandStatus EQUAL 0) - message(FATAL_ERROR "shader -> spir-v compilation failed") - endif() - endforeach(IMAGE2D_FORMAT) - execute_process( - COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${VULKAN_TEST_RESOURCES}/${BUFFER_SHADER_IN_FILE}.spv ${BUFFER_SHADER_IN_FILE}.comp - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE commandStatus - OUTPUT_QUIET) - if(commandStatus AND NOT commandStatus EQUAL 0) - message(FATAL_ERROR "shader -> spir-v compilation failed") - endif() - file(REMOVE ${IMAGE2D_SHADER_TMP_OUT_FILE}) -endif() \ No newline at end of file + set(vulkan_spirv_files "") + + add_custom_command( + OUTPUT buffer.spv + COMMAND ${Vulkan_glslang_binary} + --target-env vulkan1.0 + -o ${CMAKE_CURRENT_BINARY_DIR}/buffer.spv + ${CMAKE_CURRENT_SOURCE_DIR}/buffer.comp + DEPENDS buffer.comp + VERBATIM) + list(APPEND vulkan_spirv_files ${CMAKE_CURRENT_BINARY_DIR}/buffer.spv) + + file(STRINGS "image2D_test_formats.txt" image2D_formats) + + foreach(format ${image2D_formats}) + list(GET format 1 GLSL_FORMAT) + list(GET format 2 GLSL_TYPE_PREFIX) + + configure_file(image2D.comp.in image2D_${GLSL_FORMAT}.comp) + + add_custom_command( + OUTPUT image2D_${GLSL_FORMAT}.spv + COMMAND ${Vulkan_glslang_binary} + --target-env vulkan1.0 + -o ${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.spv + ${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.comp + DEPENDS image2D_${GLSL_FORMAT}.comp + VERBATIM) + list(APPEND vulkan_spirv_files ${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.spv) + endforeach() + + add_custom_target(vulkan_shaders DEPENDS ${vulkan_spirv_files}) +endif() diff --git a/test_conformance/vulkan/shaders/image2D.comp b/test_conformance/vulkan/shaders/image2D.comp.in similarity index 67% rename from test_conformance/vulkan/shaders/image2D.comp rename to test_conformance/vulkan/shaders/image2D.comp.in index 6c0f6f26b3..0ad70a63d2 100644 --- a/test_conformance/vulkan/shaders/image2D.comp +++ b/test_conformance/vulkan/shaders/image2D.comp.in @@ -1,6 +1,6 @@ #version 450 #extension GL_ARB_separate_shader_objects : enable -#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable +#extension GL_EXT_shader_explicit_arithmetic_types_int32 : enable #define MAX_2D_IMAGES 5 #define MAX_2D_IMAGE_MIP_LEVELS 11 @@ -10,22 +10,28 @@ layout(binding = 0) buffer Params { uint32_t numImage2DDescriptors; }; -layout(binding = 1, GLSL_FORMAT ) uniform GLSL_TYPE_PREFIXimage2D image2DList[ MAX_2D_IMAGE_DESCRIPTORS ]; + +layout(binding = 1, ${GLSL_FORMAT}) uniform ${GLSL_TYPE_PREFIX}image2D image2DList[MAX_2D_IMAGE_DESCRIPTORS]; layout(local_size_x = 32, local_size_y = 32) in; -void main() { + +void main() +{ uvec3 numThreads = gl_NumWorkGroups * gl_WorkGroupSize; - for (uint32_t image2DIdx = 0; image2DIdx < numImage2DDescriptors; image2DIdx++) { + for (uint32_t image2DIdx = 0; image2DIdx < numImage2DDescriptors; image2DIdx++) + { ivec2 imageDim = imageSize(image2DList[image2DIdx]); uint32_t heightBy2 = imageDim.y / 2; - for (uint32_t row = gl_GlobalInvocationID.y; row < heightBy2; row += numThreads.y) { - for (uint32_t col = gl_GlobalInvocationID.x; col < imageDim.x; col += numThreads.x) { + for (uint32_t row = gl_GlobalInvocationID.y; row < heightBy2; row += numThreads.y) + { + for (uint32_t col = gl_GlobalInvocationID.x; col < imageDim.x; col += numThreads.x) + { ivec2 coordsA = ivec2(col, row); ivec2 coordsB = ivec2(col, imageDim.y - row - 1); - GLSL_TYPE_PREFIXvec4 dataA = imageLoad(image2DList[image2DIdx], coordsA); - GLSL_TYPE_PREFIXvec4 dataB = imageLoad(image2DList[image2DIdx], coordsB); + ${GLSL_TYPE_PREFIX}vec4 dataA = imageLoad(image2DList[image2DIdx], coordsA); + ${GLSL_TYPE_PREFIX}vec4 dataB = imageLoad(image2DList[image2DIdx], coordsB); imageStore(image2DList[image2DIdx], coordsA, dataB); imageStore(image2DList[image2DIdx], coordsB, dataA); } } } -} \ No newline at end of file +} From 435db66a3ac8bd41e663dbd1d863ede589227bdb Mon Sep 17 00:00:00 2001 From: Romaric Jodin Date: Tue, 7 Jan 2025 18:32:36 +0100 Subject: [PATCH 20/39] fix negative_command_buffer_enqueue_with_different_context (#2206) negative_command_buffer_enqueue_with_different_context does not need to use CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE Fix #2205 --- .../cl_khr_command_buffer/negative_command_buffer_enqueue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_enqueue.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_enqueue.cpp index bb393267c8..f13836fb99 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_enqueue.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_enqueue.cpp @@ -395,8 +395,8 @@ struct EnqueueCommandBufferQueueWithDifferentContext clCreateContext(0, 1, &device, nullptr, nullptr, &error); test_error(error, "Failed to create context"); - queue_different_context = clCreateCommandQueue( - context1, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &error); + queue_different_context = + clCreateCommandQueue(context1, device, 0, &error); test_error(error, "clCreateCommandQueue failed"); return CL_SUCCESS; From 86e0c236a144c46161c8113d3301f6f238dd5236 Mon Sep 17 00:00:00 2001 From: Romaric Jodin Date: Tue, 7 Jan 2025 18:33:29 +0100 Subject: [PATCH 21/39] =?UTF-8?q?fix=20negative=5Fcreate=5Fcommand=5Fbuffe?= =?UTF-8?q?r=5Fdevice=5Fdoes=5Fnot=5Fsupport=5Fout=5Fof=5Ford=E2=80=A6=20(?= =?UTF-8?q?#2207)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …er_queue Test should be skipped if device does not support out of order queue or if device supports out of order command buffer. Fix #2204 --- .../cl_khr_command_buffer/basic_command_buffer.cpp | 5 +++-- .../extensions/cl_khr_command_buffer/basic_command_buffer.h | 1 + .../cl_khr_command_buffer/negative_command_buffer_create.cpp | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp index 97dcb9da41..c5dc9010c1 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp @@ -27,7 +27,7 @@ BasicCommandBufferTest::BasicCommandBufferTest(cl_device_id device, cl_command_queue queue) : CommandBufferTestBase(device), context(context), queue(nullptr), num_elements(0), simultaneous_use_support(false), - out_of_order_support(false), + out_of_order_support(false), queue_out_of_order_support(false), // try to use simultaneous path by default simultaneous_use_requested(true), // due to simultaneous cases extend buffer size @@ -57,7 +57,8 @@ bool BasicCommandBufferTest::Skip() sizeof(queue_properties), &queue_properties, NULL); test_error(error, "Unable to query CL_QUEUE_PROPERTIES"); - + queue_out_of_order_support = + queue_properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; // Query if device supports simultaneous use cl_device_command_buffer_capabilities_khr capabilities; diff --git a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h index efe5bb14fd..8c2e273613 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h +++ b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h @@ -75,6 +75,7 @@ struct BasicCommandBufferTest : CommandBufferTestBase // Device support query results bool simultaneous_use_support; bool out_of_order_support; + bool queue_out_of_order_support; bool device_side_enqueue_support; // user request for simultaneous use diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp index f6401cead6..538a9eef46 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp @@ -289,8 +289,9 @@ struct CreateCommandBufferDeviceDoesNotSupportOutOfOderQueue { BasicCommandBufferTest::Skip(); - // If device supports out of order queues test should be skipped - return out_of_order_support != 0; + // If device does not support out of order queue or if device supports + // out of order command buffer test should be skipped + return !queue_out_of_order_support || out_of_order_support; } clCommandQueueWrapper out_of_order_queue; From 34feb6e0082b6890f57a91523dac18d28131bb34 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Tue, 7 Jan 2025 18:35:46 +0100 Subject: [PATCH 22/39] svm: finish all queues in svm_pointer_passing (#2209) The `svm_pointer_passing` test has unflushed buffer unmap commands queued, which a runtime might process after the `clSVMFree` calls at the end of the test (through implicit flushing when destroying the queues at e.g. program exit handlers). This is only an issue when running the test with multiple devices. However I think this was caused by a simple typo given the `clFinish` was simply in the wrong block. --- test_conformance/SVM/test_pointer_passing.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test_conformance/SVM/test_pointer_passing.cpp b/test_conformance/SVM/test_pointer_passing.cpp index d1aa5005dd..aa1df4eb58 100644 --- a/test_conformance/SVM/test_pointer_passing.cpp +++ b/test_conformance/SVM/test_pointer_passing.cpp @@ -127,10 +127,10 @@ REGISTER_TEST(svm_pointer_passing) return -1; } } - } - error = clFinish(cmdq); - test_error(error, "clFinish failed"); + error = clFinish(cmdq); + test_error(error, "clFinish failed"); + } } From 6fc38707280747ed66555115b48af774a8f326e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 7 Jan 2025 18:00:12 +0000 Subject: [PATCH 23/39] Delete read_array_half and write_array_half tests (#2212) These tests are broken, have been disabled for the longest time, and don't add significant value. Signed-off-by: Kevin Petit --- test_conformance/profiling/readArray.cpp | 63 ---------------- test_conformance/profiling/writeArray.cpp | 89 ----------------------- 2 files changed, 152 deletions(-) diff --git a/test_conformance/profiling/readArray.cpp b/test_conformance/profiling/readArray.cpp index 021c3ff43b..a5946d0cbc 100644 --- a/test_conformance/profiling/readArray.cpp +++ b/test_conformance/profiling/readArray.cpp @@ -322,45 +322,6 @@ const char *stream_read_float_kernel_code[] = { const char *float_kernel_name[] = { "test_stream_read_float", "test_stream_read_float2", "test_stream_read_float4", "test_stream_read_float8", "test_stream_read_float16" }; -const char *stream_read_half_kernel_code[] = { -"__kernel void test_stream_read_half(__global half *dst)\n" -"{\n" -" int tid = get_global_id(0);\n" -"\n" -" dst[tid] = (half)119;\n" -"}\n", - -"__kernel void test_stream_read_half2(__global half2 *dst)\n" -"{\n" -" int tid = get_global_id(0);\n" -"\n" -" dst[tid] = (half)119;\n" -"}\n", - -"__kernel void test_stream_read_half4(__global half4 *dst)\n" -"{\n" -" int tid = get_global_id(0);\n" -"\n" -" dst[tid] = (half)119;\n" -"}\n", - -"__kernel void test_stream_read_half8(__global half8 *dst)\n" -"{\n" -" int tid = get_global_id(0);\n" -"\n" -" dst[tid] = (half)119;\n" -"}\n", - -"__kernel void test_stream_read_half16(__global half16 *dst)\n" -"{\n" -" int tid = get_global_id(0);\n" -"\n" -" dst[tid] = (half)119;\n" -"}\n" }; - -const char *half_kernel_name[] = { "test_stream_read_half", "test_stream_read_half2", "test_stream_read_half4", "test_stream_read_half8", "test_stream_read_half16" }; - - const char *stream_read_char_kernel_code[] = { "__kernel void test_stream_read_char(__global char *dst)\n" "{\n" @@ -555,20 +516,6 @@ static int verify_read_float( void *ptr, int n ) } -static int verify_read_half( void *ptr, int n ) -{ - int i; - float *outptr = (float *)ptr; - - for( i = 0; i < n / 2; i++ ){ - if( outptr[i] != TEST_PRIME_HALF ) - return -1; - } - - return 0; -} - - static int verify_read_char(void *ptr, int n) { int i; @@ -840,16 +787,6 @@ REGISTER_TEST(read_array_float) } -REGISTER_TEST(read_array_half) -{ - int (*foo)(void *,int); - foo = verify_read_half; - - return test_stream_read( device, context, queue, num_elements, sizeof( cl_half ), "half", 5, - stream_read_half_kernel_code, half_kernel_name, foo ); -} - - REGISTER_TEST(read_array_char) { int (*foo)(void *,int); diff --git a/test_conformance/profiling/writeArray.cpp b/test_conformance/profiling/writeArray.cpp index f6028273dc..80fd455761 100644 --- a/test_conformance/profiling/writeArray.cpp +++ b/test_conformance/profiling/writeArray.cpp @@ -310,45 +310,6 @@ const char *stream_write_float_kernel_code[] = { static const char *float_kernel_name[] = { "test_stream_write_float", "test_stream_write_float2", "test_stream_write_float4", "test_stream_write_float8", "test_stream_write_float16" }; -const char *stream_write_half_kernel_code[] = { - "__kernel void test_stream_write_half(__global half *src, __global float *dst)\n" - "{\n" - " int tid = get_global_id(0);\n" - "\n" - " dst[tid] = vload_half( tid * 2, src );\n" - "}\n", - - "__kernel void test_stream_write_half2(__global half2 *src, __global float2 *dst)\n" - "{\n" - " int tid = get_global_id(0);\n" - "\n" - " dst[tid] = vload_half2( tid * 2, src );\n" - "}\n", - - "__kernel void test_stream_write_half4(__global half4 *src, __global float4 *dst)\n" - "{\n" - " int tid = get_global_id(0);\n" - "\n" - " dst[tid] = vload_half4( tid * 2, src );\n" - "}\n", - - "__kernel void test_stream_write_half8(__global half8 *src, __global float8 *dst)\n" - "{\n" - " int tid = get_global_id(0);\n" - "\n" - " dst[tid] = vload_half8( tid * 2, src );\n" - "}\n", - - "__kernel void test_stream_write_half16(__global half16 *src, __global float16 *dst)\n" - "{\n" - " int tid = get_global_id(0);\n" - "\n" - " dst[tid] = vload_half16( tid * 2, src );\n" - "}\n" }; - -static const char *half_kernel_name[] = { "test_stream_write_half", "test_stream_write_half2", "test_stream_write_half4", "test_stream_write_half8", "test_stream_write_half16" }; - - const char *stream_write_long_kernel_code[] = { "__kernel void test_stream_write_long(__global long *src, __global long *dst)\n" "{\n" @@ -548,21 +509,6 @@ static int verify_write_float( void *ptr1, void *ptr2, int n ) } -static int verify_write_half( void *ptr1, void *ptr2, int n ) -{ - int i; - cl_half *inptr = (cl_half *)ptr1; - cl_half *outptr = (cl_half *)ptr2; - - for( i = 0; i < n; i++ ){ - if( outptr[i] != inptr[i] ) - return -1; - } - - return 0; -} - - static int verify_write_long( void *ptr1, void *ptr2, int n ) { int i; @@ -1067,41 +1013,6 @@ REGISTER_TEST(write_array_float) } // end write_float_array() -REGISTER_TEST(write_array_half) -{ - float *inptr[5]; - size_t ptrSizes[5]; - int i, j, err; - int (*foo)(void *,void *,int); - MTdata d = init_genrand( gRandomSeed ); - foo = verify_write_half; - - ptrSizes[0] = sizeof( cl_half ); - ptrSizes[1] = ptrSizes[0] << 1; - ptrSizes[2] = ptrSizes[1] << 1; - ptrSizes[3] = ptrSizes[2] << 1; - ptrSizes[4] = ptrSizes[3] << 1; - - for( i = 0; i < 5; i++ ){ - inptr[i] = (float *)malloc(ptrSizes[i] * num_elements); - - for( j = 0; (unsigned int)j < ptrSizes[i] * num_elements / ( ptrSizes[0] * 2 ); j++ ) - inptr[i][j] = get_random_float( -FLT_MAX, FLT_MAX, d ); - } - - err = test_stream_write( device, context, queue, num_elements, sizeof( cl_half ), "half", 5, (void **)inptr, - stream_write_half_kernel_code, half_kernel_name, foo, d ); - - for( i = 0; i < 5; i++ ){ - free( (void *)inptr[i] ); - } - - free_mtdata(d); - return err; - -} // end write_half_array() - - REGISTER_TEST(write_array_long) { cl_long *inptr[5]; From 4c70fecad7d41a5218fd40804a798fed04d40846 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 7 Jan 2025 19:06:20 +0100 Subject: [PATCH 24/39] Moved sub-test external_semaphores_import_export_fd to test_external_semaphore executable (#2110) Fixes #1989 according to task description. Moreover, fixes #1876 as well. --- .../cl_khr_external_semaphore/CMakeLists.txt | 1 + .../cl_khr_external_semaphore/main.cpp | 23 +-- .../cl_khr_external_semaphore/procs.h | 2 +- .../test_external_semaphore.cpp | 31 ++-- .../test_external_semaphore_sync_fd.cpp | 134 ++++++++++++++++++ .../extensions/cl_khr_semaphore/main.cpp | 1 - .../cl_khr_semaphore/test_semaphores.cpp | 99 ------------- 7 files changed, 164 insertions(+), 127 deletions(-) create mode 100644 test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore_sync_fd.cpp diff --git a/test_conformance/extensions/cl_khr_external_semaphore/CMakeLists.txt b/test_conformance/extensions/cl_khr_external_semaphore/CMakeLists.txt index df136004cd..633dea33c9 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/CMakeLists.txt +++ b/test_conformance/extensions/cl_khr_external_semaphore/CMakeLists.txt @@ -3,6 +3,7 @@ set(MODULE_NAME CL_KHR_EXTERNAL_SEMAPHORE) set(${MODULE_NAME}_SOURCES main.cpp test_external_semaphore.cpp + test_external_semaphore_sync_fd.cpp ) set (CLConform_VULKAN_LIBRARIES_DIR "${VULKAN_LIB_DIR}") diff --git a/test_conformance/extensions/cl_khr_external_semaphore/main.cpp b/test_conformance/extensions/cl_khr_external_semaphore/main.cpp index f3ead65e92..4693ec1623 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/main.cpp +++ b/test_conformance/extensions/cl_khr_external_semaphore/main.cpp @@ -16,16 +16,17 @@ #include "harness/testHarness.h" test_definition test_list[] = { - ADD_TEST(external_semaphores_queries), - ADD_TEST(external_semaphores_cross_context), - ADD_TEST(external_semaphores_simple_1), - ADD_TEST(external_semaphores_simple_2), - ADD_TEST(external_semaphores_reuse), - ADD_TEST(external_semaphores_cross_queues_ooo), - ADD_TEST(external_semaphores_cross_queues_io), - ADD_TEST(external_semaphores_cross_queues_io2), - ADD_TEST(external_semaphores_multi_signal), - ADD_TEST(external_semaphores_multi_wait), + ADD_TEST_VERSION(external_semaphores_queries, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_cross_context, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_simple_1, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_simple_2, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_reuse, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_cross_queues_ooo, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_cross_queues_io, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_cross_queues_io2, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_multi_signal, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_multi_wait, Version(1, 2)), + ADD_TEST_VERSION(external_semaphores_import_export_fd, Version(1, 2)), }; @@ -39,4 +40,4 @@ int main(int argc, const char *argv[]) const cl_command_queue_properties queue_properties = 0; return runTestHarnessWithCheck(argc, argv, ARRAY_SIZE(test_list), test_list, false, queue_properties, nullptr); -} \ No newline at end of file +} diff --git a/test_conformance/extensions/cl_khr_external_semaphore/procs.h b/test_conformance/extensions/cl_khr_external_semaphore/procs.h index f9b7a4ce90..fec89f7502 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/procs.h +++ b/test_conformance/extensions/cl_khr_external_semaphore/procs.h @@ -63,4 +63,4 @@ extern int test_external_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -#endif // CL_KHR_EXTERNAL_SEMAPHORE_PROCS_H \ No newline at end of file +#endif // CL_KHR_EXTERNAL_SEMAPHORE_PROCS_H diff --git a/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp index 1d3010e73a..849d1c7c2c 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp +++ b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #define SEMAPHORE_PARAM_TEST(param_name, param_type, expected) \ do \ @@ -16,9 +17,9 @@ test_error(error, "Unable to get " #param_name " from semaphore"); \ if (value != expected) \ { \ - test_fail("ERROR: Parameter %s did not validate! (expected %d, " \ - "got %d)\n", \ - #param_name, expected, value); \ + test_fail("ERROR: Parameter %s did not validate! " \ + "(expected %" PRIuPTR " got %" PRIuPTR ")\n", \ + #param_name, (uintptr_t)expected, (uintptr_t)value); \ } \ if (size != sizeof(value)) \ { \ @@ -51,7 +52,7 @@ } \ } while (false) -static const char* source = "__kernel void empty() {}"; +static const char *source = "__kernel void empty() {}"; static void log_info_semaphore_type( VulkanExternalSemaphoreHandleType vkExternalSemaphoreHandleType) @@ -63,7 +64,7 @@ static void log_info_semaphore_type( log_info("%s", semaphore_type_description.str().c_str()); } -static int init_vuikan_device(cl_uint num_devices, cl_device_id* deviceIds) +static int init_vulkan_device(cl_uint num_devices, cl_device_id *deviceIds) { cl_platform_id platform = nullptr; @@ -83,7 +84,7 @@ static int init_vuikan_device(cl_uint num_devices, cl_device_id* deviceIds) static cl_int get_device_semaphore_handle_types( cl_device_id deviceID, cl_device_info param, - std::vector& handle_types) + std::vector &handle_types) { int err = CL_SUCCESS; // Query for export support @@ -125,7 +126,7 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, REQUIRE_EXTENSION("cl_khr_semaphore"); REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -330,7 +331,7 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -405,7 +406,7 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -512,7 +513,7 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -632,7 +633,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -682,7 +683,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, nullptr, 0, nullptr, &wait_event); test_error(err, "Could not wait semaphore"); - // Finish queue_1 and queue_2 + // Finish queue_1 and queue_2 err = clFinish(queue_1); test_error(err, "Could not finish queue"); @@ -747,7 +748,7 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -856,7 +857,7 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -947,7 +948,7 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, { REQUIRE_EXTENSION("cl_khr_external_semaphore"); - if (init_vuikan_device(1, &deviceID)) + if (init_vulkan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); diff --git a/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore_sync_fd.cpp b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore_sync_fd.cpp new file mode 100644 index 0000000000..0419c6157f --- /dev/null +++ b/test_conformance/extensions/cl_khr_external_semaphore/test_external_semaphore_sync_fd.cpp @@ -0,0 +1,134 @@ +// +// 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 "harness/typeWrappers.h" +#include "harness/extensionHelpers.h" +#include "harness/errorHelpers.h" + +// Test it is possible to export a semaphore to a sync fd and import the same +// sync fd to a new semaphore +int test_external_semaphores_import_export_fd(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + cl_int err = CL_SUCCESS; + + if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) + { + log_info( + "cl_khr_external_semaphore is not supported on this platoform. " + "Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + if (!is_extension_available(deviceID, "cl_khr_external_semaphore_sync_fd")) + { + log_info("cl_khr_external_semaphore_sync_fd is not supported on this " + "platoform. Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_command_queue_properties device_props = 0; + err = clGetDeviceInfo(deviceID, CL_DEVICE_QUEUE_PROPERTIES, + sizeof(device_props), &device_props, NULL); + test_error(err, "clGetDeviceInfo for CL_DEVICE_QUEUE_PROPERTIES failed"); + + if ((device_props & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) == 0) + { + log_info("Queue property CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE not " + "supported. Skipping test.\n"); + return TEST_SKIPPED_ITSELF; + } + + // Obtain pointers to semaphore's API + GET_PFN(deviceID, clCreateSemaphoreWithPropertiesKHR); + GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); + GET_PFN(deviceID, clEnqueueWaitSemaphoresKHR); + GET_PFN(deviceID, clGetSemaphoreHandleForTypeKHR); + GET_PFN(deviceID, clReleaseSemaphoreKHR); + + // Create ooo queue + clCommandQueueWrapper queue = clCreateCommandQueue( + context, deviceID, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + test_error(err, "Could not create command queue"); + + // Create semaphore + cl_semaphore_properties_khr sema_1_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast(CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), + static_cast( + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), + static_cast( + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), + 0 + }; + cl_semaphore_khr sema_1 = + clCreateSemaphoreWithPropertiesKHR(context, sema_1_props, &err); + test_error(err, "Could not create semaphore"); + + // Signal semaphore + clEventWrapper signal_event; + err = clEnqueueSignalSemaphoresKHR(queue, 1, &sema_1, nullptr, 0, nullptr, + &signal_event); + test_error(err, "Could not signal semaphore"); + + // Extract sync fd + int handle = -1; + size_t handle_size; + err = clGetSemaphoreHandleForTypeKHR(sema_1, deviceID, + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, + sizeof(handle), &handle, &handle_size); + test_error(err, "Could not extract semaphore handle"); + test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); + test_assert_error(handle >= 0, "Invalid handle"); + + // Create semaphore from sync fd + cl_semaphore_properties_khr sema_2_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast(CL_SEMAPHORE_TYPE_BINARY_KHR), + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, + static_cast(handle), 0 + }; + + cl_semaphore_khr sema_2 = + clCreateSemaphoreWithPropertiesKHR(context, sema_2_props, &err); + test_error(err, "Could not create semaphore"); + + // Wait semaphore + clEventWrapper wait_event; + err = clEnqueueWaitSemaphoresKHR(queue, 1, &sema_2, nullptr, 0, nullptr, + &wait_event); + test_error(err, "Could not wait semaphore"); + + // Finish + err = clFinish(queue); + test_error(err, "Could not finish queue"); + + // Check all events are completed + test_assert_event_complete(signal_event); + test_assert_event_complete(wait_event); + + // Release semaphore + err = clReleaseSemaphoreKHR(sema_1); + test_error(err, "Could not release semaphore"); + + err = clReleaseSemaphoreKHR(sema_2); + test_error(err, "Could not release semaphore"); + return TEST_PASS; +} diff --git a/test_conformance/extensions/cl_khr_semaphore/main.cpp b/test_conformance/extensions/cl_khr_semaphore/main.cpp index 00732d547b..0952729b90 100644 --- a/test_conformance/extensions/cl_khr_semaphore/main.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/main.cpp @@ -36,7 +36,6 @@ test_definition test_list[] = { ADD_TEST_VERSION(semaphores_device_list_queries, Version(1, 2)), ADD_TEST_VERSION(semaphores_no_device_list_queries, Version(1, 2)), ADD_TEST_VERSION(semaphores_multi_device_context_queries, Version(1, 2)), - ADD_TEST_VERSION(semaphores_import_export_fd, Version(1, 2)), ADD_TEST_VERSION(semaphores_ooo_ops_single_queue, Version(1, 2)), ADD_TEST_VERSION(semaphores_ooo_ops_cross_queue, Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_create_invalid_context, Version(1, 2)), diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index dc896cbe58..1ec7a551a3 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -378,95 +378,6 @@ struct SemaphoreMultiWait : public SemaphoreTestBase clSemaphoreWrapper semaphore_second = nullptr; }; -struct SemaphoreImportExportFD : public SemaphoreTestBase -{ - SemaphoreImportExportFD(cl_device_id device, cl_context context, - cl_command_queue queue, cl_int nelems) - : SemaphoreTestBase(device, context, queue, nelems), - semaphore_second(this) - {} - - cl_int Run() override - { - cl_int err = CL_SUCCESS; - if (!is_extension_available(device, - "cl_khr_external_semaphore_sync_fd")) - { - log_info( - "cl_khr_external_semaphore_sync_fd is not supported on this " - "platform. Skipping test.\n"); - return TEST_SKIPPED_ITSELF; - } - - // Create ooo queue - clCommandQueueWrapper queue = clCreateCommandQueue( - context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); - test_error(err, "Could not create command queue"); - - // Create semaphore - cl_semaphore_properties_khr sema_1_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), - static_cast( - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR), - static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR), - 0 - }; - semaphore = - clCreateSemaphoreWithPropertiesKHR(context, sema_1_props, &err); - test_error(err, "Could not create semaphore"); - - // Signal semaphore - clEventWrapper signal_event; - err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, - nullptr, &signal_event); - test_error(err, "Could not signal semaphore"); - - // Extract sync fd - int handle = -1; - size_t handle_size; - err = clGetSemaphoreHandleForTypeKHR( - semaphore, device, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, sizeof(handle), - &handle, &handle_size); - test_error(err, "Could not extract semaphore handle"); - test_assert_error(sizeof(handle) == handle_size, "Invalid handle size"); - test_assert_error(handle >= 0, "Invalid handle"); - - // Create semaphore from sync fd - cl_semaphore_properties_khr sema_2_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR, - static_cast(handle), 0 - }; - - semaphore_second = - clCreateSemaphoreWithPropertiesKHR(context, sema_2_props, &err); - test_error(err, "Could not create semaphore"); - - // Wait semaphore - clEventWrapper wait_event; - err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore_second, nullptr, 0, - nullptr, &wait_event); - test_error(err, "Could not wait semaphore"); - - // Finish - err = clFinish(queue); - test_error(err, "Could not finish queue"); - - // Check all events are completed - test_assert_event_complete(signal_event); - test_assert_event_complete(wait_event); - - return CL_SUCCESS; - } - clSemaphoreWrapper semaphore_second = nullptr; -}; } // anonymous namespace // Confirm that a signal followed by a wait will complete successfully @@ -510,13 +421,3 @@ int test_semaphores_multi_wait(cl_device_id deviceID, cl_context context, return MakeAndRunTest(deviceID, context, defaultQueue, num_elements); } - -// Test it is possible to export a semaphore to a sync fd and import the same -// sync fd to a new semaphore -int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) -{ - return MakeAndRunTest(deviceID, context, - defaultQueue, num_elements); -} From d058dfdeef5a56278cf1e5b2321abb3f41873fea Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 7 Jan 2025 19:09:38 +0100 Subject: [PATCH 25/39] Corrected test_vulkan to use specific platform/device from harness (#2154) Fixes #1926 according to task description --- .../vulkan_wrapper/opencl_vulkan_wrapper.cpp | 5 +- .../common/vulkan_wrapper/vulkan_utility.cpp | 86 +- .../common/vulkan_wrapper/vulkan_utility.hpp | 11 +- .../common/vulkan_wrapper/vulkan_wrapper.hpp | 2 +- test_conformance/vulkan/CMakeLists.txt | 1 + test_conformance/vulkan/main.cpp | 232 +--- test_conformance/vulkan/procs.h | 33 + .../vulkan/test_vulkan_api_consistency.cpp | 911 ++++++------ ...st_vulkan_api_consistency_for_1dimages.cpp | 345 ++--- ...st_vulkan_api_consistency_for_3dimages.cpp | 349 ++--- .../vulkan/test_vulkan_interop_buffer.cpp | 1232 +++++++++-------- .../vulkan/test_vulkan_interop_image.cpp | 402 +++--- .../test_vulkan_platform_device_info.cpp | 309 +++-- test_conformance/vulkan/vulkan_test_base.h | 129 ++ 14 files changed, 2026 insertions(+), 2021 deletions(-) create mode 100644 test_conformance/vulkan/vulkan_test_base.h diff --git a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp index b4330e9235..ded1e7092b 100644 --- a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp @@ -464,7 +464,7 @@ getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *VulkanImageCreateInfo, memcpy(img_fmt, &clImgFormat, sizeof(cl_image_format)); img_desc->image_type = getImageTypeFromVk(VulkanImageCreateInfo->imageType); - if (CL_INVALID_VALUE == img_desc->image_type) + if (CL_INVALID_VALUE == static_cast(img_desc->image_type)) { return CL_INVALID_VALUE; } @@ -503,6 +503,8 @@ cl_int check_external_memory_handle_type( errNum = clGetDeviceInfo(deviceID, CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR, 0, NULL, &handle_type_size); + test_error(errNum, "clGetDeviceInfo failed"); + handle_type = (cl_external_memory_handle_type_khr *)malloc(handle_type_size); @@ -539,6 +541,7 @@ cl_int check_external_semaphore_handle_type( errNum = clGetDeviceInfo(deviceID, queryParamName, 0, NULL, &handle_type_size); + test_error(errNum, "clGetDeviceInfo failed"); if (handle_type_size == 0) { diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp index 1c433a7176..e4796bc9d0 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2022 The Khronos Group Inc. +// 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. @@ -40,13 +40,10 @@ const VulkanInstance &getVulkanInstance() const VulkanPhysicalDevice &getVulkanPhysicalDevice() { - size_t pdIdx; + size_t pdIdx = 0; cl_int errNum = 0; - cl_platform_id platform = NULL; + cl_platform_id platform = nullptr; cl_uchar uuid[CL_UUID_SIZE_KHR]; - cl_device_id *devices; - char *extensions = NULL; - size_t extensionSize = 0; cl_uint num_devices = 0; cl_uint device_no = 0; const size_t bufsize = BUFFERSIZE; @@ -69,14 +66,9 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice() throw std::runtime_error( "Error: clGetDeviceIDs failed in returning of devices\n"); } - devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id)); - if (NULL == devices) - { - throw std::runtime_error( - "Error: Unable to allocate memory for devices\n"); - } - errNum = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices, devices, - NULL); + std::vector devices(num_devices); + errNum = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices, + devices.data(), NULL); if (CL_SUCCESS != errNum) { throw std::runtime_error("Error: Failed to get deviceID.\n"); @@ -84,34 +76,14 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice() bool is_selected = false; for (device_no = 0; device_no < num_devices; device_no++) { - errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS, 0, - NULL, &extensionSize); - if (CL_SUCCESS != errNum) - { - throw std::runtime_error("Error in clGetDeviceInfo for getting " - "device_extension size....\n"); - } - extensions = (char *)malloc(extensionSize); - if (NULL == extensions) - { - throw std::runtime_error( - "Unable to allocate memory for extensions\n"); - } - errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS, - extensionSize, extensions, NULL); - if (CL_SUCCESS != errNum) - { - throw std::runtime_error("Error: Error in clGetDeviceInfo for " - "getting device_extension\n"); - } errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_UUID_KHR, - CL_UUID_SIZE_KHR, uuid, &extensionSize); + CL_UUID_SIZE_KHR, uuid, nullptr); if (CL_SUCCESS != errNum) { throw std::runtime_error( "Error: clGetDeviceInfo failed with error\n"); } - free(extensions); + for (pdIdx = 0; pdIdx < physicalDeviceList.size(); pdIdx++) { if (!memcmp(&uuid, physicalDeviceList[pdIdx].getUUID(), @@ -139,10 +111,48 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice() return physicalDeviceList[pdIdx]; } -const VulkanQueueFamily &getVulkanQueueFamily(uint32_t queueFlags) +const VulkanPhysicalDevice & +getAssociatedVulkanPhysicalDevice(cl_device_id deviceId) +{ + size_t pdIdx; + cl_int errNum = 0; + cl_uchar uuid[CL_UUID_SIZE_KHR]; + const VulkanInstance &instance = getVulkanInstance(); + const VulkanPhysicalDeviceList &physicalDeviceList = + instance.getPhysicalDeviceList(); + + errNum = clGetDeviceInfo(deviceId, CL_DEVICE_UUID_KHR, CL_UUID_SIZE_KHR, + uuid, nullptr); + if (CL_SUCCESS != errNum) + { + throw std::runtime_error("Error: clGetDeviceInfo failed with error\n"); + } + for (pdIdx = 0; pdIdx < physicalDeviceList.size(); pdIdx++) + { + if (!memcmp(&uuid, physicalDeviceList[pdIdx].getUUID(), VK_UUID_SIZE)) + { + std::cout << "Selected physical device = " + << physicalDeviceList[pdIdx] << std::endl; + break; + } + } + + if ((pdIdx >= physicalDeviceList.size()) + || (physicalDeviceList[pdIdx] == (VkPhysicalDevice)VK_NULL_HANDLE)) + { + throw std::runtime_error("failed to find a suitable GPU!"); + } + std::cout << "Selected physical device is: " << physicalDeviceList[pdIdx] + << std::endl; + return physicalDeviceList[pdIdx]; +} + + +const VulkanQueueFamily & +getVulkanQueueFamily(const VulkanPhysicalDevice &physicalDevice, + uint32_t queueFlags) { size_t qfIdx; - const VulkanPhysicalDevice &physicalDevice = getVulkanPhysicalDevice(); const VulkanQueueFamilyList &queueFamilyList = physicalDevice.getQueueFamilyList(); diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp index d2f4b7bf91..486ad97c80 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2022 The Khronos Group Inc. +// 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. @@ -32,9 +32,12 @@ const VulkanInstance& getVulkanInstance(); const VulkanPhysicalDevice& getVulkanPhysicalDevice(); -const VulkanQueueFamily& -getVulkanQueueFamily(uint32_t queueFlags = VULKAN_QUEUE_FLAG_GRAPHICS - | VULKAN_QUEUE_FLAG_COMPUTE); +const VulkanPhysicalDevice& +getAssociatedVulkanPhysicalDevice(cl_device_id deviceId); +const VulkanQueueFamily& getVulkanQueueFamily( + const VulkanPhysicalDevice& physicalDevice = getVulkanPhysicalDevice(), + uint32_t queueFlags = VULKAN_QUEUE_FLAG_GRAPHICS + | VULKAN_QUEUE_FLAG_COMPUTE); const VulkanMemoryType& getVulkanMemoryType(const VulkanDevice& device, VulkanMemoryTypeProperty memoryTypeProperty); diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp index b528f4aade..a536d140a8 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp @@ -145,7 +145,7 @@ class VulkanDevice { virtual ~VulkanDevice(); const VulkanPhysicalDevice &getPhysicalDevice() const; VulkanQueue & - getQueue(const VulkanQueueFamily &queueFamily = getVulkanQueueFamily(), + getQueue(const VulkanQueueFamily &queueFamily /* = getVulkanQueueFamily()*/, uint32_t queueIndex = 0); operator VkDevice() const; }; diff --git a/test_conformance/vulkan/CMakeLists.txt b/test_conformance/vulkan/CMakeLists.txt index 7b9bcc1801..85313c39b6 100644 --- a/test_conformance/vulkan/CMakeLists.txt +++ b/test_conformance/vulkan/CMakeLists.txt @@ -25,6 +25,7 @@ set (${MODULE_NAME}_SOURCES test_vulkan_api_consistency_for_1dimages.cpp test_vulkan_platform_device_info.cpp vulkan_interop_common.cpp + vulkan_test_base.h ) include_directories("../common/vulkan_wrapper") diff --git a/test_conformance/vulkan/main.cpp b/test_conformance/vulkan/main.cpp index 7b1cf01c70..7be31b231a 100644 --- a/test_conformance/vulkan/main.cpp +++ b/test_conformance/vulkan/main.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2022 The Khronos Group Inc. +// 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. @@ -30,121 +30,15 @@ #include #endif - #include "procs.h" #include "harness/testHarness.h" -#include "harness/parseParameters.h" -#include "harness/deviceInfo.h" #if !defined(_WIN32) #include #endif -#include -#include #define BUFFERSIZE 3000 -static void params_reset() -{ - numCQ = 1; - multiImport = false; - multiCtx = false; -} - -extern int test_buffer_common(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_, - bool use_fence); -extern int test_image_common(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_); - -int test_buffer_single_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, false); -} -int test_buffer_multiple_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - numCQ = 2; - log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, false); -} -int test_buffer_multiImport_sameCtx(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - multiImport = true; - log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " - "IN SAME CONTEXT...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, false); -} -int test_buffer_multiImport_diffCtx(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - multiImport = true; - multiCtx = true; - log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " - "IN DIFFERENT CONTEXT...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, false); -} -int test_buffer_single_queue_fence(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, true); -} -int test_buffer_multiple_queue_fence(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - numCQ = 2; - log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, true); -} -int test_buffer_multiImport_sameCtx_fence(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_) -{ - params_reset(); - multiImport = true; - log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " - "IN SAME CONTEXT...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, true); -} -int test_buffer_multiImport_diffCtx_fence(cl_device_id device_, - cl_context context_, - cl_command_queue queue_, - int numElements_) -{ - params_reset(); - multiImport = true; - multiCtx = true; - log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " - "IN DIFFERENT CONTEXT...... \n\n"); - return test_buffer_common(device_, context_, queue_, numElements_, true); -} -int test_image_single_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); - return test_image_common(device_, context_, queue_, numElements_); -} -int test_image_multiple_queue(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) -{ - params_reset(); - numCQ = 2; - log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); - return test_image_common(device_, context_, queue_, numElements_); -} - test_definition test_list[] = { ADD_TEST(buffer_single_queue), ADD_TEST(buffer_multiple_queue), ADD_TEST(buffer_multiImport_sameCtx), @@ -165,20 +59,6 @@ test_definition test_list[] = { ADD_TEST(buffer_single_queue), const int test_num = ARRAY_SIZE(test_list); -cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT; -char *choosen_platform_name = NULL; -cl_platform_id platform = NULL; -cl_int choosen_platform_index = -1; -char platform_name[1024] = ""; -cl_platform_id select_platform = NULL; -char *extensions = NULL; -size_t extensionSize = 0; -cl_uint num_devices = 0; -cl_uint device_no = 0; -cl_device_id *devices; -const size_t bufsize = BUFFERSIZE; -char buf[BUFFERSIZE]; -cl_uchar uuid[CL_UUID_SIZE_KHR]; unsigned int numCQ; bool multiImport; bool multiCtx; @@ -269,19 +149,7 @@ size_t parseParams(int argc, const char *argv[], const char **argList) int main(int argc, const char *argv[]) { - int errNum = 0; - test_start(); - params_reset(); - - if (!checkVkSupport()) - { - log_info("Vulkan supported GPU not found \n"); - log_info("TEST SKIPPED \n"); - return 0; - } - - VulkanDevice vkDevice; cl_device_type requestedDeviceType = CL_DEVICE_TYPE_GPU; char *force_cpu = getenv("CL_DEVICE_TYPE"); @@ -305,104 +173,10 @@ int main(int argc, const char *argv[]) log_info("Vulkan tests can only run on a GPU device.\n"); return 0; } - gDeviceType = CL_DEVICE_TYPE_GPU; const char **argList = (const char **)calloc(argc, sizeof(char *)); size_t argCount = parseParams(argc, argv, argList); if (argCount == 0) return 0; - // get the platform ID - errNum = clGetPlatformIDs(1, &platform, NULL); - if (errNum != CL_SUCCESS) - { - print_error(errNum, "Error: Failed to get platform\n"); - return errNum; - } - errNum = - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); - if (CL_SUCCESS != errNum) - { - print_error(errNum, "clGetDeviceIDs failed in returning of devices\n"); - return errNum; - } - devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id)); - if (NULL == devices) - { - print_error(errNum, "Unable to allocate memory for devices\n"); - return CL_OUT_OF_HOST_MEMORY; - } - errNum = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices, devices, - NULL); - if (CL_SUCCESS != errNum) - { - print_error(errNum, "Failed to get deviceID.\n"); - return errNum; - } - for (device_no = 0; device_no < num_devices; device_no++) - { - errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS, 0, - NULL, &extensionSize); - if (CL_SUCCESS != errNum) - { - log_error("Error in clGetDeviceInfo for getting " - "device_extension size....\n"); - return errNum; - } - extensions = (char *)malloc(extensionSize); - if (NULL == extensions) - { - log_error("Unable to allocate memory for extensions\n"); - return CL_OUT_OF_HOST_MEMORY; - } - errNum = - clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS, - extensionSize, extensions, NULL /*&extensionSize*/); - if (CL_SUCCESS != errNum) - { - print_error(errNum, - "Error in clGetDeviceInfo for getting " - "device_extension\n"); - return errNum; - } - errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_UUID_KHR, - CL_UUID_SIZE_KHR, uuid, &extensionSize); - if (CL_SUCCESS != errNum) - { - print_error(errNum, "clGetDeviceInfo failed with error\n "); - return errNum; - } - errNum = - memcmp(uuid, vkDevice.getPhysicalDevice().getUUID(), VK_UUID_SIZE); - if (errNum == 0) - { - break; - } - } - if (device_no >= num_devices) - { - fprintf(stderr, - "OpenCL error: " - "No Vulkan-OpenCL Interop capable GPU found.\n"); - } - if (!(is_extension_available(devices[device_no], "cl_khr_external_memory") - && is_extension_available(devices[device_no], - "cl_khr_external_semaphore"))) - { - log_info("Device does not support cl_khr_external_memory " - "or cl_khr_external_semaphore\n"); - log_info(" TEST SKIPPED\n"); - return CL_SUCCESS; - } - init_cl_vk_ext(platform, num_devices, devices); - - // Execute tests. - // Note: don't use the entire harness, because we have a different way of - // obtaining the device (via the context) - test_harness_config config{}; - config.forceNoContextCreation = true; - config.numElementsToUse = 1024; - config.queueProps = 0; - errNum = parseAndCallCommandLineTests(argCount, argList, devices[device_no], - test_num, test_list, config); - return errNum; -} \ No newline at end of file + return runTestHarness(argc, argv, test_num, test_list, false, 0); +} diff --git a/test_conformance/vulkan/procs.h b/test_conformance/vulkan/procs.h index d5465d7a28..71fad68f1e 100644 --- a/test_conformance/vulkan/procs.h +++ b/test_conformance/vulkan/procs.h @@ -44,3 +44,36 @@ extern int test_platform_info(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); extern int test_device_info(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); +extern int test_buffer_single_queue(cl_device_id device_, cl_context context_, + cl_command_queue queue_, int numElements_); +extern int test_buffer_multiple_queue(cl_device_id device_, cl_context context_, + cl_command_queue queue_, + int numElements_); +extern int test_buffer_multiImport_sameCtx(cl_device_id device_, + cl_context context_, + cl_command_queue queue_, + int numElements_); +extern int test_buffer_multiImport_diffCtx(cl_device_id device_, + cl_context context_, + cl_command_queue queue_, + int numElements_); +extern int test_buffer_single_queue_fence(cl_device_id device_, + cl_context context_, + cl_command_queue queue_, + int numElements_); +extern int test_buffer_multiple_queue_fence(cl_device_id device_, + cl_context context_, + cl_command_queue queue_, + int numElements_); +extern int test_buffer_multiImport_sameCtx_fence(cl_device_id device_, + cl_context context_, + cl_command_queue queue_, + int numElements_); +extern int test_buffer_multiImport_diffCtx_fence(cl_device_id device_, + cl_context context_, + cl_command_queue queue_, + int numElements_); +extern int test_image_single_queue(cl_device_id device_, cl_context context_, + cl_command_queue queue_, int numElements_); +extern int test_image_multiple_queue(cl_device_id device_, cl_context context_, + cl_command_queue queue_, int numElements_); diff --git a/test_conformance/vulkan/test_vulkan_api_consistency.cpp b/test_conformance/vulkan/test_vulkan_api_consistency.cpp index 09e02981a6..b27a3c74c5 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2022 The Khronos Group Inc. +// 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. @@ -33,502 +33,525 @@ #include "harness/typeWrappers.h" #include "harness/deviceInfo.h" -int test_consistency_external_buffer(cl_device_id deviceID, cl_context _context, - cl_command_queue _queue, int num_elements) -{ - cl_int errNum; - VulkanDevice vkDevice; - // Context and command queue creation - cl_platform_id platform = NULL; - cl_context context = NULL; - cl_command_queue cmd_queue = NULL; - - cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, 0, 0 }; - errNum = clGetPlatformIDs(1, &platform, NULL); - test_error(errNum, "Failed to get platform Id"); +#include "vulkan_test_base.h" +#include "opencl_vulkan_wrapper.hpp" - contextProperties[1] = (cl_context_properties)platform; +namespace { - context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, - NULL, NULL, &errNum); - test_error(errNum, "Unable to create context with properties"); +struct ConsistencyExternalBufferTest : public VulkanTestBase +{ + ConsistencyExternalBufferTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - cmd_queue = clCreateCommandQueue(context, deviceID, 0, &errNum); - test_error(errNum, "Unable to create command queue"); + cl_int Run() override + { - uint32_t bufferSize = 32; - cl_device_id devList[] = { deviceID, NULL }; + cl_int errNum = CL_SUCCESS; + uint32_t bufferSize = 32; #ifdef _WIN32 - if (!is_extension_available(devList[0], "cl_khr_external_memory_win32")) - { - throw std::runtime_error("Device does not support " - "cl_khr_external_memory_win32 extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_win32")) + { + throw std::runtime_error( + "Device does not support " + "cl_khr_external_memory_win32 extension \n"); + } #else - if (!is_extension_available(devList[0], "cl_khr_external_memory_opaque_fd")) - { - throw std::runtime_error( - "Device does not support " - "cl_khr_external_memory_opaque_fd extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) + { + throw std::runtime_error( + "Device does not support " + "cl_khr_external_memory_opaque_fd extension \n"); + } #endif - VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; + VulkanExternalMemoryHandleType vkExternalMemoryHandleType = + getSupportedVulkanExternalMemoryHandleTypeList()[0]; - VulkanBuffer vkDummyBuffer(vkDevice, 4 * 1024, vkExternalMemoryHandleType); - const VulkanMemoryTypeList& memoryTypeList = - vkDummyBuffer.getMemoryTypeList(); + VulkanBuffer vkDummyBuffer(*vkDevice, 4 * 1024, + vkExternalMemoryHandleType); + const VulkanMemoryTypeList& memoryTypeList = + vkDummyBuffer.getMemoryTypeList(); - VulkanBufferList vkBufferList(1, vkDevice, bufferSize, - vkExternalMemoryHandleType); - VulkanDeviceMemory* vkDeviceMem = - new VulkanDeviceMemory(vkDevice, vkBufferList[0], memoryTypeList[0], - vkExternalMemoryHandleType); + VulkanBufferList vkBufferList(1, *vkDevice, bufferSize, + vkExternalMemoryHandleType); + VulkanDeviceMemory* vkDeviceMem = new VulkanDeviceMemory( + *vkDevice, vkBufferList[0], memoryTypeList[0], + vkExternalMemoryHandleType); - vkDeviceMem->bindBuffer(vkBufferList[0], 0); + vkDeviceMem->bindBuffer(vkBufferList[0], 0); - void* handle = NULL; - int fd; + void* handle = NULL; + int fd; - std::vector extMemProperties{ - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, - (cl_mem_properties)devList[0], - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, - }; - cl_external_memory_handle_type_khr type; - switch (vkExternalMemoryHandleType) - { + std::vector extMemProperties{ + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, + (cl_mem_properties)device, + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, + }; + cl_external_memory_handle_type_khr type; + switch (vkExternalMemoryHandleType) + { #ifdef _WIN32 - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - type = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR; - errNum = check_external_memory_handle_type(devList[0], type); - extMemProperties.push_back((cl_mem_properties)type); - extMemProperties.push_back((cl_mem_properties)handle); - break; - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - type = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR; - errNum = check_external_memory_handle_type(devList[0], type); - extMemProperties.push_back((cl_mem_properties)type); - extMemProperties.push_back((cl_mem_properties)handle); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + type = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR; + errNum = check_external_memory_handle_type(device, type); + extMemProperties.push_back((cl_mem_properties)type); + extMemProperties.push_back((cl_mem_properties)handle); + break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + type = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR; + errNum = check_external_memory_handle_type(device, type); + extMemProperties.push_back((cl_mem_properties)type); + extMemProperties.push_back((cl_mem_properties)handle); + break; #else - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: - fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); - type = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR; - errNum = check_external_memory_handle_type(devList[0], type); - extMemProperties.push_back((cl_mem_properties)type); - extMemProperties.push_back((cl_mem_properties)fd); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: + fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); + type = CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR; + errNum = check_external_memory_handle_type(device, type); + extMemProperties.push_back((cl_mem_properties)type); + extMemProperties.push_back((cl_mem_properties)fd); + break; #endif - default: - errNum = TEST_FAIL; - log_error("Unsupported external memory handle type \n"); - break; - } - if (errNum != CL_SUCCESS) - { - log_error("Checks failed for " - "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); - return TEST_FAIL; - } - extMemProperties.push_back(0); + default: + errNum = TEST_FAIL; + log_error("Unsupported external memory handle type \n"); + break; + } + if (errNum != CL_SUCCESS) + { + log_error("Checks failed for " + "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); + return TEST_FAIL; + } + extMemProperties.push_back(0); - clMemWrapper buffer; + clMemWrapper buffer; - // Passing NULL properties and a valid extMem_desc size - buffer = clCreateBufferWithProperties(context, NULL, 1, bufferSize, NULL, - &errNum); - test_error(errNum, "Unable to create buffer with NULL properties"); + // Passing NULL properties and a valid extMem_desc size + buffer = clCreateBufferWithProperties(context, NULL, 1, bufferSize, + NULL, &errNum); + test_error(errNum, "Unable to create buffer with NULL properties"); - buffer.reset(); + buffer.reset(); - // Passing valid extMemProperties and buffersize - buffer = clCreateBufferWithProperties(context, extMemProperties.data(), 1, - bufferSize, NULL, &errNum); - test_error(errNum, "Unable to create buffer with Properties"); + // Passing valid extMemProperties and buffersize + buffer = clCreateBufferWithProperties(context, extMemProperties.data(), + 1, bufferSize, NULL, &errNum); + test_error(errNum, "Unable to create buffer with Properties"); - buffer.reset(); + buffer.reset(); - // Not passing external memory handle - std::vector extMemProperties2{ + // Not passing external memory handle + std::vector extMemProperties2{ #ifdef _WIN32 - (cl_mem_properties)type, - NULL, // Passing NULL handle + (cl_mem_properties)type, + NULL, // Passing NULL handle #else - (cl_mem_properties)type, - (cl_mem_properties)-64, // Passing random invalid fd + (cl_mem_properties)type, + (cl_mem_properties)-64, // Passing random invalid fd #endif - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, - (cl_mem_properties)devList[0], - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, - 0 - }; - buffer = clCreateBufferWithProperties(context, extMemProperties2.data(), 1, - bufferSize, NULL, &errNum); - test_failure_error(errNum, CL_INVALID_VALUE, - "Should return CL_INVALID_VALUE "); - - buffer.reset(); - - // Passing extMem_desc size = 0 but valid memProperties, CL_INVALID_SIZE - // should be returned. - buffer = clCreateBufferWithProperties(context, extMemProperties.data(), 1, - 0, NULL, &errNum); - test_failure_error(errNum, CL_INVALID_BUFFER_SIZE, - "Should return CL_INVALID_BUFFER_SIZE"); - - return TEST_PASS; -} - -int test_consistency_external_image(cl_device_id deviceID, cl_context _context, - cl_command_queue _queue, int num_elements) -{ - cl_int errNum; - VulkanDevice vkDevice; - - // Context and command queue creation - cl_platform_id platform = NULL; - cl_context context = NULL; - cl_command_queue cmd_queue = NULL; + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, + (cl_mem_properties)device, + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, + 0 + }; + buffer = clCreateBufferWithProperties(context, extMemProperties2.data(), + 1, bufferSize, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_VALUE, + "Should return CL_INVALID_VALUE "); - cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, 0, 0 }; - errNum = clGetPlatformIDs(1, &platform, NULL); - test_error(errNum, "Failed to get platform id"); + buffer.reset(); - contextProperties[1] = (cl_context_properties)platform; + // Passing extMem_desc size = 0 but valid memProperties, CL_INVALID_SIZE + // should be returned. + buffer = clCreateBufferWithProperties(context, extMemProperties.data(), + 1, 0, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_BUFFER_SIZE, + "Should return CL_INVALID_BUFFER_SIZE"); - context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, - NULL, NULL, &errNum); - test_error(errNum, "Unable to create context with properties"); + return TEST_PASS; + } +}; - cmd_queue = clCreateCommandQueue(context, deviceID, 0, &errNum); - test_error(errNum, "Unable to create command queue"); +struct ConsistencyExternalImageTest : public VulkanTestBase +{ + ConsistencyExternalImageTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - cl_device_id devList[] = { deviceID, NULL }; + cl_int Run() override + { + cl_int errNum = CL_SUCCESS; #ifdef _WIN32 - if (!is_extension_available(devList[0], "cl_khr_external_memory_win32")) - { - throw std::runtime_error("Device does not support" - "cl_khr_external_memory_win32 extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_win32")) + { + throw std::runtime_error( + "Device does not support" + "cl_khr_external_memory_win32 extension \n"); + } #else - if (!is_extension_available(devList[0], "cl_khr_external_memory_opaque_fd")) - { - test_fail("Device does not support cl_khr_external_memory_opaque_fd " - "extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) + { + test_fail( + "Device does not support cl_khr_external_memory_opaque_fd " + "extension \n"); + } #endif - uint32_t width = 256; - uint32_t height = 16; - cl_image_desc image_desc; - memset(&image_desc, 0x0, sizeof(cl_image_desc)); - cl_image_format img_format = { 0 }; - - VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; - - VulkanImageTiling vulkanImageTiling = - vkClExternalMemoryHandleTilingAssumption( - deviceID, vkExternalMemoryHandleType, &errNum); - ASSERT_SUCCESS(errNum, "Failed to query OpenCL tiling mode"); - - VulkanImage2D vkImage2D = - VulkanImage2D(vkDevice, VULKAN_FORMAT_R8G8B8A8_UNORM, width, height, - vulkanImageTiling, 1, vkExternalMemoryHandleType); - - const VulkanMemoryTypeList& memoryTypeList = vkImage2D.getMemoryTypeList(); - uint64_t totalImageMemSize = vkImage2D.getSize(); - - log_info("Memory type index: %lu\n", (uint32_t)memoryTypeList[0]); - log_info("Memory type property: %d\n", - memoryTypeList[0].getMemoryTypeProperty()); - log_info("Image size : %d\n", totalImageMemSize); - - VulkanDeviceMemory* vkDeviceMem = new VulkanDeviceMemory( - vkDevice, vkImage2D, memoryTypeList[0], vkExternalMemoryHandleType); - vkDeviceMem->bindImage(vkImage2D, 0); - - void* handle = NULL; - int fd; - std::vector extMemProperties{ - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, - (cl_mem_properties)devList[0], - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, - }; - switch (vkExternalMemoryHandleType) - { + uint32_t width = 256; + uint32_t height = 16; + cl_image_desc image_desc; + memset(&image_desc, 0x0, sizeof(cl_image_desc)); + cl_image_format img_format = { 0 }; + + VulkanExternalMemoryHandleType vkExternalMemoryHandleType = + getSupportedVulkanExternalMemoryHandleTypeList()[0]; + + VulkanImageTiling vulkanImageTiling = + vkClExternalMemoryHandleTilingAssumption( + device, vkExternalMemoryHandleType, &errNum); + ASSERT_SUCCESS(errNum, "Failed to query OpenCL tiling mode"); + + VulkanImage2D vkImage2D = VulkanImage2D( + *vkDevice, VULKAN_FORMAT_R8G8B8A8_UNORM, width, height, + vulkanImageTiling, 1, vkExternalMemoryHandleType); + + const VulkanMemoryTypeList& memoryTypeList = + vkImage2D.getMemoryTypeList(); + uint64_t totalImageMemSize = vkImage2D.getSize(); + + log_info("Memory type index: %u\n", (uint32_t)memoryTypeList[0]); + log_info("Memory type property: %d\n", + memoryTypeList[0].getMemoryTypeProperty()); + log_info("Image size : %ld\n", totalImageMemSize); + + VulkanDeviceMemory* vkDeviceMem = + new VulkanDeviceMemory(*vkDevice, vkImage2D, memoryTypeList[0], + vkExternalMemoryHandleType); + vkDeviceMem->bindImage(vkImage2D, 0); + + void* handle = NULL; + int fd; + std::vector extMemProperties{ + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, + (cl_mem_properties)device, + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, + }; + switch (vkExternalMemoryHandleType) + { #ifdef _WIN32 - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); - extMemProperties.push_back( - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); - extMemProperties.push_back((cl_mem_properties)handle); - break; - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); - extMemProperties.push_back( - (cl_mem_properties) - CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); - extMemProperties.push_back((cl_mem_properties)handle); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); + extMemProperties.push_back((cl_mem_properties)handle); + break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); + extMemProperties.push_back((cl_mem_properties)handle); + break; #else - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: - fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); - extMemProperties.push_back( - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); - extMemProperties.push_back((cl_mem_properties)fd); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: + fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); + extMemProperties.push_back( + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); + extMemProperties.push_back((cl_mem_properties)fd); + break; #endif - default: - errNum = TEST_FAIL; - log_error("Unsupported external memory handle type \n"); - break; - } - if (errNum != CL_SUCCESS) - { - log_error("Checks failed for " - "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); - return TEST_FAIL; - } - extMemProperties.push_back(0); + default: + errNum = TEST_FAIL; + log_error("Unsupported external memory handle type \n"); + break; + } + if (errNum != CL_SUCCESS) + { + log_error("Checks failed for " + "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); + return TEST_FAIL; + } + extMemProperties.push_back(0); - const VkImageCreateInfo VulkanImageCreateInfo = - vkImage2D.getVkImageCreateInfo(); + const VkImageCreateInfo VulkanImageCreateInfo = + vkImage2D.getVkImageCreateInfo(); - errNum = getCLImageInfoFromVkImageInfo( - &VulkanImageCreateInfo, totalImageMemSize, &img_format, &image_desc); - if (errNum != CL_SUCCESS) - { - log_error("getCLImageInfoFromVkImageInfo failed!!!"); - return TEST_FAIL; - } + errNum = getCLImageInfoFromVkImageInfo(&VulkanImageCreateInfo, + totalImageMemSize, &img_format, + &image_desc); + if (errNum != CL_SUCCESS) + { + log_error("getCLImageInfoFromVkImageInfo failed!!!"); + return TEST_FAIL; + } - clMemWrapper image; - - // Pass valid properties, image_desc and image_format - image = clCreateImageWithProperties( - context, extMemProperties.data(), CL_MEM_READ_WRITE, &img_format, - &image_desc, NULL /* host_ptr */, &errNum); - test_error(errNum, "Unable to create Image with Properties"); - image.reset(); - - // Passing image_format as NULL - image = clCreateImageWithProperties(context, extMemProperties.data(), - CL_MEM_READ_WRITE, NULL, &image_desc, - NULL, &errNum); - test_failure_error(errNum, CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, - "Image creation must fail with " - "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" - "when image desc passed as NULL"); - - image.reset(); - - // Passing image_desc as NULL - image = clCreateImageWithProperties(context, extMemProperties.data(), - CL_MEM_READ_WRITE, &img_format, NULL, - NULL, &errNum); - test_failure_error(errNum, CL_INVALID_IMAGE_DESCRIPTOR, - "Image creation must fail with " - "CL_INVALID_IMAGE_DESCRIPTOR " - "when image desc passed as NULL"); - image.reset(); - - return TEST_PASS; -} + clMemWrapper image; + + // Pass valid properties, image_desc and image_format + image = clCreateImageWithProperties( + context, extMemProperties.data(), CL_MEM_READ_WRITE, &img_format, + &image_desc, NULL /* host_ptr */, &errNum); + test_error(errNum, "Unable to create Image with Properties"); + image.reset(); + + // Passing image_format as NULL + image = clCreateImageWithProperties(context, extMemProperties.data(), + CL_MEM_READ_WRITE, NULL, + &image_desc, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, + "Image creation must fail with " + "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" + "when image desc passed as NULL"); + + image.reset(); + + // Passing image_desc as NULL + image = clCreateImageWithProperties(context, extMemProperties.data(), + CL_MEM_READ_WRITE, &img_format, + NULL, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_IMAGE_DESCRIPTOR, + "Image creation must fail with " + "CL_INVALID_IMAGE_DESCRIPTOR " + "when image desc passed as NULL"); + image.reset(); + + return TEST_PASS; + } +}; -int test_consistency_external_semaphore(cl_device_id deviceID, - cl_context _context, - cl_command_queue _queue, - int num_elements) +struct ConsistencyExternalSemaphoreTest : public VulkanTestBase { - cl_int errNum; - VulkanDevice vkDevice; - // Context and command queue creation - cl_platform_id platform = NULL; - cl_context context = NULL; - cl_command_queue cmd_queue = NULL; + ConsistencyExternalSemaphoreTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - errNum = clGetPlatformIDs(1, &platform, NULL); - test_error(errNum, "Failed to get platform Id"); - - cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, 0, 0 }; - - contextProperties[1] = (cl_context_properties)platform; - - context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, - NULL, NULL, &errNum); - test_error(errNum, "Unable to create context with properties"); - - cmd_queue = clCreateCommandQueue(context, deviceID, 0, &errNum); - test_error(errNum, "Unable to create command queue"); + cl_int Run() override + { + cl_int errNum = CL_SUCCESS; - cl_device_id devList[] = { deviceID, NULL }; +#ifdef _WIN32 + if (!is_extension_available(device, "cl_khr_external_memory_win32")) + { + throw std::runtime_error( + "Device does not support" + "cl_khr_external_memory_win32 extension \n"); + } +#else + if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) + { + test_fail( + "Device does not support cl_khr_external_memory_opaque_fd " + "extension \n"); + } +#endif - std::vector supportedExternalSemaphores = - getSupportedInteropExternalSemaphoreHandleTypes(devList[0], vkDevice); + std::vector + supportedExternalSemaphores = + getSupportedInteropExternalSemaphoreHandleTypes(device, + *vkDevice); - if (supportedExternalSemaphores.empty()) - { - test_fail("No supported external semaphore types found\n"); - } + if (supportedExternalSemaphores.empty()) + { + test_fail("No supported external semaphore types found\n"); + } - for (VulkanExternalSemaphoreHandleType semaphoreHandleType : - supportedExternalSemaphores) - { - VulkanSemaphore vkVk2Clsemaphore(vkDevice, semaphoreHandleType); - VulkanSemaphore vkCl2Vksemaphore(vkDevice, semaphoreHandleType); - cl_semaphore_khr clCl2Vksemaphore; - cl_semaphore_khr clVk2Clsemaphore; - void* handle1 = NULL; - void* handle2 = NULL; - int fd1, fd2; - std::vector sema_props1{ - (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, - (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, - }; - std::vector sema_props2{ - (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, - (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, - }; - switch (semaphoreHandleType) + for (VulkanExternalSemaphoreHandleType semaphoreHandleType : + supportedExternalSemaphores) { + VulkanSemaphore vkVk2Clsemaphore(*vkDevice, semaphoreHandleType); + VulkanSemaphore vkCl2Vksemaphore(*vkDevice, semaphoreHandleType); + cl_semaphore_khr clCl2Vksemaphore; + cl_semaphore_khr clVk2Clsemaphore; + void* handle1 = NULL; + void* handle2 = NULL; + int fd1, fd2; + std::vector sema_props1{ + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + }; + std::vector sema_props2{ + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + }; + switch (semaphoreHandleType) + { #ifdef _WIN32 - case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT: - log_info(" Opaque NT handles are only supported on Windows\n"); - handle1 = vkVk2Clsemaphore.getHandle(semaphoreHandleType); - handle2 = vkCl2Vksemaphore.getHandle(semaphoreHandleType); - errNum = check_external_semaphore_handle_type( - devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); - sema_props1.push_back((cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); - sema_props1.push_back((cl_semaphore_properties_khr)handle1); - sema_props2.push_back((cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); - sema_props2.push_back((cl_semaphore_properties_khr)handle2); - break; - case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT: - log_info( - " Opaque D3DKMT handles are only supported on Windows\n"); - handle1 = vkVk2Clsemaphore.getHandle(semaphoreHandleType); - handle2 = vkCl2Vksemaphore.getHandle(semaphoreHandleType); - errNum = check_external_semaphore_handle_type( - devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); - sema_props1.push_back( - (cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); - sema_props1.push_back((cl_semaphore_properties_khr)handle1); - sema_props2.push_back( - (cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); - sema_props2.push_back((cl_semaphore_properties_khr)handle2); - break; + case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT: + log_info( + " Opaque NT handles are only supported on Windows\n"); + handle1 = vkVk2Clsemaphore.getHandle(semaphoreHandleType); + handle2 = vkCl2Vksemaphore.getHandle(semaphoreHandleType); + errNum = check_external_semaphore_handle_type( + device, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); + sema_props1.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); + sema_props1.push_back((cl_semaphore_properties_khr)handle1); + sema_props2.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); + sema_props2.push_back((cl_semaphore_properties_khr)handle2); + break; + case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT: + log_info(" Opaque D3DKMT handles are only supported on " + "Windows\n"); + handle1 = vkVk2Clsemaphore.getHandle(semaphoreHandleType); + handle2 = vkCl2Vksemaphore.getHandle(semaphoreHandleType); + errNum = check_external_semaphore_handle_type( + device, CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); + sema_props1.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); + sema_props1.push_back((cl_semaphore_properties_khr)handle1); + sema_props2.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); + sema_props2.push_back((cl_semaphore_properties_khr)handle2); + break; #else - case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD: - fd1 = (int)vkVk2Clsemaphore.getHandle(semaphoreHandleType); - fd2 = (int)vkCl2Vksemaphore.getHandle(semaphoreHandleType); - errNum = check_external_semaphore_handle_type( - devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); - sema_props1.push_back((cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); - sema_props1.push_back((cl_semaphore_properties_khr)fd1); - sema_props2.push_back((cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); - sema_props2.push_back((cl_semaphore_properties_khr)fd2); - break; - case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD: - fd1 = -1; - fd2 = -1; - errNum = check_external_semaphore_handle_type( - devList[0], CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); - sema_props1.push_back((cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); - sema_props1.push_back((cl_semaphore_properties_khr)fd1); - sema_props2.push_back((cl_semaphore_properties_khr) - CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); - sema_props2.push_back((cl_semaphore_properties_khr)fd2); - break; + case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD: + fd1 = (int)vkVk2Clsemaphore.getHandle(semaphoreHandleType); + fd2 = (int)vkCl2Vksemaphore.getHandle(semaphoreHandleType); + errNum = check_external_semaphore_handle_type( + device, CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); + sema_props1.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); + sema_props1.push_back((cl_semaphore_properties_khr)fd1); + sema_props2.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); + sema_props2.push_back((cl_semaphore_properties_khr)fd2); + break; + case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD: + fd1 = -1; + fd2 = -1; + errNum = check_external_semaphore_handle_type( + device, CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); + sema_props1.push_back((cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); + sema_props1.push_back((cl_semaphore_properties_khr)fd1); + sema_props2.push_back((cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); + sema_props2.push_back((cl_semaphore_properties_khr)fd2); + break; #endif - default: log_error("Unsupported external memory handle type\n"); break; + default: + log_error("Unsupported external memory handle type\n"); + break; + } + if (CL_SUCCESS != errNum) + { + throw std::runtime_error( + "Unsupported external sempahore handle type\n "); + } + sema_props1.push_back((cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR); + sema_props1.push_back((cl_semaphore_properties_khr)device); + sema_props1.push_back((cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR); + sema_props2.push_back((cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR); + sema_props2.push_back((cl_semaphore_properties_khr)device); + sema_props2.push_back((cl_semaphore_properties_khr) + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR); + sema_props1.push_back(0); + sema_props2.push_back(0); + + // Pass NULL properties + clCreateSemaphoreWithPropertiesKHRptr(context, NULL, &errNum); + test_failure_error( + errNum, CL_INVALID_VALUE, + "Semaphore creation must fail with CL_INVALID_VALUE " + " when properties are passed as NULL"); + + // Pass invalid semaphore object to wait + errNum = clEnqueueWaitSemaphoresKHRptr(queue, 1, NULL, NULL, 0, + NULL, NULL); + test_failure_error( + errNum, CL_INVALID_VALUE, + "clEnqueueWaitSemaphoresKHR fails with CL_INVALID_VALUE " + "when invalid semaphore object is passed"); + + // Pass invalid semaphore object to signal + errNum = clEnqueueSignalSemaphoresKHRptr(queue, 1, NULL, NULL, 0, + NULL, NULL); + test_failure_error( + errNum, CL_INVALID_VALUE, + "clEnqueueSignalSemaphoresKHR fails with CL_INVALID_VALUE" + "when invalid semaphore object is passed"); + + // Create two semaphore objects + clVk2Clsemaphore = clCreateSemaphoreWithPropertiesKHRptr( + context, sema_props1.data(), &errNum); + test_error( + errNum, + "Unable to create semaphore with valid semaphore properties"); + + clCl2Vksemaphore = clCreateSemaphoreWithPropertiesKHRptr( + context, sema_props2.data(), &errNum); + test_error( + errNum, + "Unable to create semaphore with valid semaphore properties"); + + // Pass invalid object to release call + errNum = clReleaseSemaphoreKHRptr(NULL); + test_failure_error(errNum, CL_INVALID_SEMAPHORE_KHR, + "clReleaseSemaphoreKHRptr fails with " + "CL_INVALID_SEMAPHORE_KHR when NULL semaphore " + "object is passed"); + + // Release both semaphore objects + errNum = clReleaseSemaphoreKHRptr(clVk2Clsemaphore); + test_error(errNum, "clReleaseSemaphoreKHRptr failed"); + + errNum = clReleaseSemaphoreKHRptr(clCl2Vksemaphore); + test_error(errNum, "clReleaseSemaphoreKHRptr failed"); } - if (CL_SUCCESS != errNum) - { - throw std::runtime_error( - "Unsupported external sempahore handle type\n "); - } - sema_props1.push_back( - (cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR); - sema_props1.push_back((cl_semaphore_properties_khr)devList[0]); - sema_props1.push_back( - (cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR); - sema_props2.push_back( - (cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR); - sema_props2.push_back((cl_semaphore_properties_khr)devList[0]); - sema_props2.push_back( - (cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR); - sema_props1.push_back(0); - sema_props2.push_back(0); - - // Pass NULL properties - cl_semaphore_khr cl_ext_semaphore = - clCreateSemaphoreWithPropertiesKHRptr(context, NULL, &errNum); - test_failure_error(errNum, CL_INVALID_VALUE, - "Semaphore creation must fail with CL_INVALID_VALUE " - " when properties are passed as NULL"); - - - // Pass invalid semaphore object to wait - errNum = - clEnqueueWaitSemaphoresKHRptr(cmd_queue, 1, NULL, NULL, 0, NULL, NULL); - test_failure_error(errNum, CL_INVALID_VALUE, - "clEnqueueWaitSemaphoresKHR fails with CL_INVALID_VALUE " - "when invalid semaphore object is passed"); - - - // Pass invalid semaphore object to signal - errNum = clEnqueueSignalSemaphoresKHRptr(cmd_queue, 1, NULL, NULL, 0, NULL, - NULL); - test_failure_error( - errNum, CL_INVALID_VALUE, - "clEnqueueSignalSemaphoresKHR fails with CL_INVALID_VALUE" - "when invalid semaphore object is passed"); - - - // Create two semaphore objects - clVk2Clsemaphore = clCreateSemaphoreWithPropertiesKHRptr( - context, sema_props1.data(), &errNum); - test_error(errNum, - "Unable to create semaphore with valid semaphore properties"); - - clCl2Vksemaphore = clCreateSemaphoreWithPropertiesKHRptr( - context, sema_props2.data(), &errNum); - test_error(errNum, - "Unable to create semaphore with valid semaphore properties"); - - // Pass invalid object to release call - errNum = clReleaseSemaphoreKHRptr(NULL); - test_failure_error( - errNum, CL_INVALID_SEMAPHORE_KHR, - "clReleaseSemaphoreKHRptr fails with " - "CL_INVALID_SEMAPHORE_KHR when NULL semaphore object is passed"); - - // Release both semaphore objects - errNum = clReleaseSemaphoreKHRptr(clVk2Clsemaphore); - test_error(errNum, "clReleaseSemaphoreKHRptr failed"); - - errNum = clReleaseSemaphoreKHRptr(clCl2Vksemaphore); - test_error(errNum, "clReleaseSemaphoreKHRptr failed"); + + return TEST_PASS; } +}; + +} // anonymous namespace + +int test_consistency_external_buffer(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); +} - return TEST_PASS; +int test_consistency_external_image(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); +} + +int test_consistency_external_semaphore(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp index aefdb41457..799a73f05b 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp @@ -1,3 +1,19 @@ +// +// 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 #include #include @@ -17,180 +33,181 @@ #include "harness/typeWrappers.h" #include "harness/deviceInfo.h" -int test_consistency_external_for_1dimage(cl_device_id deviceID, - cl_context _context, - cl_command_queue _queue, - int num_elements) -{ - cl_int errNum; - VulkanDevice vkDevice; - - // Context and command queue creation - cl_platform_id platform = NULL; - cl_context context = NULL; - cl_command_queue cmd_queue = NULL; - - cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, 0, 0 }; - errNum = clGetPlatformIDs(1, &platform, NULL); - test_error(errNum, "Failed to get platform id"); +#include "vulkan_test_base.h" +#include "opencl_vulkan_wrapper.hpp" - contextProperties[1] = (cl_context_properties)platform; +namespace { - context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, - NULL, NULL, &errNum); - test_error(errNum, "Unable to create context with properties"); - - cmd_queue = clCreateCommandQueue(context, deviceID, 0, &errNum); - test_error(errNum, "Unable to create command queue"); +struct ConsistencyExternalImage1DTest : public VulkanTestBase +{ + ConsistencyExternalImage1DTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - cl_device_id devList[] = { deviceID, NULL }; + cl_int Run() override + { + cl_int errNum = CL_SUCCESS; #ifdef _WIN32 - if (!is_extension_available(devList[0], "cl_khr_external_memory_win32")) - { - throw std::runtime_error("Device does not support" - "cl_khr_external_memory_win32 extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_win32")) + { + throw std::runtime_error( + "Device does not support" + "cl_khr_external_memory_win32 extension \n"); + } #else - if (!is_extension_available(devList[0], "cl_khr_external_memory_opaque_fd")) - { - throw std::runtime_error( - "Device does not support cl_khr_external_memory_opaque_fd " - "extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) + { + throw std::runtime_error( + "Device does not support cl_khr_external_memory_opaque_fd " + "extension \n"); + } #endif - uint32_t width = 256; - cl_image_desc image_desc; - memset(&image_desc, 0x0, sizeof(cl_image_desc)); - cl_image_format img_format = { 0 }; - - VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; - - VulkanImageTiling vulkanImageTiling = - vkClExternalMemoryHandleTilingAssumption( - deviceID, vkExternalMemoryHandleType, &errNum); - ASSERT_SUCCESS(errNum, "Failed to query OpenCL tiling mode"); - - VulkanImage1D vkImage1D = - VulkanImage1D(vkDevice, VULKAN_FORMAT_R8G8B8A8_UNORM, width, - vulkanImageTiling, 1, vkExternalMemoryHandleType); - - const VulkanMemoryTypeList& memoryTypeList = vkImage1D.getMemoryTypeList(); - uint64_t totalImageMemSize = vkImage1D.getSize(); - - log_info("Memory type index: %u\n", (uint32_t)memoryTypeList[0]); - log_info("Memory type property: %d\n", - memoryTypeList[0].getMemoryTypeProperty()); - log_info("Image size : %lu\n", totalImageMemSize); - - VulkanDeviceMemory* vkDeviceMem = new VulkanDeviceMemory( - vkDevice, vkImage1D, memoryTypeList[0], vkExternalMemoryHandleType); - vkDeviceMem->bindImage(vkImage1D, 0); - - void* handle = NULL; - int fd; - std::vector extMemProperties{ - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, - (cl_mem_properties)devList[0], - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, - }; - switch (vkExternalMemoryHandleType) - { + uint32_t width = 256; + cl_image_desc image_desc; + memset(&image_desc, 0x0, sizeof(cl_image_desc)); + cl_image_format img_format = { 0 }; + + VulkanExternalMemoryHandleType vkExternalMemoryHandleType = + getSupportedVulkanExternalMemoryHandleTypeList()[0]; + + VulkanImageTiling vulkanImageTiling = + vkClExternalMemoryHandleTilingAssumption( + device, vkExternalMemoryHandleType, &errNum); + ASSERT_SUCCESS(errNum, "Failed to query OpenCL tiling mode"); + + VulkanImage1D vkImage1D = + VulkanImage1D(*vkDevice, VULKAN_FORMAT_R8G8B8A8_UNORM, width, + vulkanImageTiling, 1, vkExternalMemoryHandleType); + + const VulkanMemoryTypeList& memoryTypeList = + vkImage1D.getMemoryTypeList(); + uint64_t totalImageMemSize = vkImage1D.getSize(); + + log_info("Memory type index: %u\n", (uint32_t)memoryTypeList[0]); + log_info("Memory type property: %d\n", + memoryTypeList[0].getMemoryTypeProperty()); + log_info("Image size : %lu\n", totalImageMemSize); + + VulkanDeviceMemory* vkDeviceMem = + new VulkanDeviceMemory(*vkDevice, vkImage1D, memoryTypeList[0], + vkExternalMemoryHandleType); + vkDeviceMem->bindImage(vkImage1D, 0); + + void* handle = NULL; + int fd; + std::vector extMemProperties{ + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, + (cl_mem_properties)device, + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, + }; + switch (vkExternalMemoryHandleType) + { #ifdef _WIN32 - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); - extMemProperties.push_back( - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); - extMemProperties.push_back((cl_mem_properties)handle); - break; - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); - extMemProperties.push_back( - (cl_mem_properties) - CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); - extMemProperties.push_back((cl_mem_properties)handle); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); + extMemProperties.push_back((cl_mem_properties)handle); + break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); + extMemProperties.push_back((cl_mem_properties)handle); + break; #else - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: - fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); - extMemProperties.push_back( - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); - extMemProperties.push_back((cl_mem_properties)fd); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: + fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); + extMemProperties.push_back( + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); + extMemProperties.push_back((cl_mem_properties)fd); + break; #endif - default: - errNum = TEST_FAIL; - log_error("Unsupported external memory handle type \n"); - break; - } - if (errNum != CL_SUCCESS) - { - log_error("Checks failed for " - "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); - return TEST_FAIL; - } - extMemProperties.push_back(0); - - const VkImageCreateInfo VulkanImageCreateInfo = - vkImage1D.getVkImageCreateInfo(); - - errNum = getCLImageInfoFromVkImageInfo( - &VulkanImageCreateInfo, totalImageMemSize, &img_format, &image_desc); - if (errNum != CL_SUCCESS) - { - log_error("getCLImageInfoFromVkImageInfo failed!!!"); - return TEST_FAIL; + default: + errNum = TEST_FAIL; + log_error("Unsupported external memory handle type \n"); + break; + } + if (errNum != CL_SUCCESS) + { + log_error("Checks failed for " + "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); + return TEST_FAIL; + } + extMemProperties.push_back(0); + + const VkImageCreateInfo VulkanImageCreateInfo = + vkImage1D.getVkImageCreateInfo(); + + errNum = getCLImageInfoFromVkImageInfo(&VulkanImageCreateInfo, + totalImageMemSize, &img_format, + &image_desc); + if (errNum != CL_SUCCESS) + { + log_error("getCLImageInfoFromVkImageInfo failed!!!"); + return TEST_FAIL; + } + + clMemWrapper image; + + // Pass valid properties, image_desc and image_format + image = clCreateImageWithProperties( + context, extMemProperties.data(), CL_MEM_READ_WRITE, &img_format, + &image_desc, NULL /* host_ptr */, &errNum); + test_error(errNum, "Unable to create Image with Properties"); + image.reset(); + + // Passing NULL properties and a valid image_format and image_desc + image = clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, + &img_format, &image_desc, NULL, + &errNum); + test_error(errNum, + "Unable to create image with NULL properties " + "with valid image format and image desc"); + + image.reset(); + + // Passing image_format as NULL + image = clCreateImageWithProperties(context, extMemProperties.data(), + CL_MEM_READ_WRITE, NULL, + &image_desc, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, + "Image creation must fail with " + "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" + "when image desc passed as NULL"); + + image.reset(); + + // Passing image_desc as NULL + image = clCreateImageWithProperties(context, extMemProperties.data(), + CL_MEM_READ_WRITE, &img_format, + NULL, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_IMAGE_DESCRIPTOR, + "Image creation must fail with " + "CL_INVALID_IMAGE_DESCRIPTOR " + "when image desc passed as NULL"); + image.reset(); + + return TEST_PASS; } +}; +} - clMemWrapper image; - - // Pass valid properties, image_desc and image_format - image = clCreateImageWithProperties( - context, extMemProperties.data(), CL_MEM_READ_WRITE, &img_format, - &image_desc, NULL /* host_ptr */, &errNum); - test_error(errNum, "Unable to create Image with Properties"); - image.reset(); - - // Passing NULL properties and a valid image_format and image_desc - image = - clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, - &img_format, &image_desc, NULL, &errNum); - test_error(errNum, - "Unable to create image with NULL properties " - "with valid image format and image desc"); - - image.reset(); - - // Passing image_format as NULL - image = clCreateImageWithProperties(context, extMemProperties.data(), - CL_MEM_READ_WRITE, NULL, &image_desc, - NULL, &errNum); - test_failure_error(errNum, CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, - "Image creation must fail with " - "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" - "when image desc passed as NULL"); - - image.reset(); - - // Passing image_desc as NULL - image = clCreateImageWithProperties(context, extMemProperties.data(), - CL_MEM_READ_WRITE, &img_format, NULL, - NULL, &errNum); - test_failure_error(errNum, CL_INVALID_IMAGE_DESCRIPTOR, - "Image creation must fail with " - "CL_INVALID_IMAGE_DESCRIPTOR " - "when image desc passed as NULL"); - image.reset(); - - if (cmd_queue) clReleaseCommandQueue(cmd_queue); - if (context) clReleaseContext(context); - - return TEST_PASS; +int test_consistency_external_for_1dimage(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp index a71fb9453d..b30f37477f 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp @@ -1,3 +1,19 @@ +// +// 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 #include #include @@ -18,183 +34,184 @@ #include "harness/deviceInfo.h" #include +#include "vulkan_test_base.h" +#include "opencl_vulkan_wrapper.hpp" -int test_consistency_external_for_3dimage(cl_device_id deviceID, - cl_context _context, - cl_command_queue _queue, - int num_elements) -{ - cl_int errNum; - VulkanDevice vkDevice; - - // Context and command queue creation - cl_platform_id platform = NULL; - cl_context context = NULL; - cl_command_queue cmd_queue = NULL; - - cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, 0, 0 }; - errNum = clGetPlatformIDs(1, &platform, NULL); - test_error(errNum, "Failed to get platform id"); +namespace { - contextProperties[1] = (cl_context_properties)platform; - - context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, - NULL, NULL, &errNum); - test_error(errNum, "Unable to create context with properties"); - - cmd_queue = clCreateCommandQueue(context, deviceID, 0, &errNum); - test_error(errNum, "Unable to create command queue"); +struct ConsistencyExternalImage3DTest : public VulkanTestBase +{ + ConsistencyExternalImage3DTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - cl_device_id devList[] = { deviceID, NULL }; + cl_int Run() override + { + cl_int errNum; #ifdef _WIN32 - if (!is_extension_available(devList[0], "cl_khr_external_memory_win32")) - { - throw std::runtime_error("Device does not support" - "cl_khr_external_memory_win32 extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_win32")) + { + throw std::runtime_error( + "Device does not support" + "cl_khr_external_memory_win32 extension \n"); + } #else - if (!is_extension_available(devList[0], "cl_khr_external_memory_opaque_fd")) - { - throw std::runtime_error( - "Device does not support cl_khr_external_memory_opaque_fd " - "extension \n"); - } + if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) + { + throw std::runtime_error( + "Device does not support cl_khr_external_memory_opaque_fd " + "extension \n"); + } #endif - uint32_t width = 256; - uint32_t height = 16; - uint32_t depth = 10; - cl_image_desc image_desc; - memset(&image_desc, 0x0, sizeof(cl_image_desc)); - cl_image_format img_format = { 0 }; - - VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; - - VulkanImageTiling vulkanImageTiling = - vkClExternalMemoryHandleTilingAssumption( - deviceID, vkExternalMemoryHandleType, &errNum); - ASSERT_SUCCESS(errNum, "Failed to query OpenCL tiling mode"); - - VulkanImage3D vkImage3D = - VulkanImage3D(vkDevice, VULKAN_FORMAT_R8G8B8A8_UNORM, width, height, - depth, vulkanImageTiling, 1, vkExternalMemoryHandleType); - - const VulkanMemoryTypeList& memoryTypeList = vkImage3D.getMemoryTypeList(); - uint64_t totalImageMemSize = vkImage3D.getSize(); - - log_info("Memory type index: %u\n", (uint32_t)memoryTypeList[0]); - log_info("Memory type property: %d\n", - memoryTypeList[0].getMemoryTypeProperty()); - log_info("Image size : %lu\n", totalImageMemSize); - - VulkanDeviceMemory* vkDeviceMem = new VulkanDeviceMemory( - vkDevice, vkImage3D, memoryTypeList[0], vkExternalMemoryHandleType); - vkDeviceMem->bindImage(vkImage3D, 0); - - void* handle = NULL; - int fd; - std::vector extMemProperties{ - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, - (cl_mem_properties)devList[0], - (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, - }; - switch (vkExternalMemoryHandleType) - { + uint32_t width = 256; + uint32_t height = 16; + uint32_t depth = 10; + cl_image_desc image_desc; + memset(&image_desc, 0x0, sizeof(cl_image_desc)); + cl_image_format img_format = { 0 }; + + VulkanExternalMemoryHandleType vkExternalMemoryHandleType = + getSupportedVulkanExternalMemoryHandleTypeList()[0]; + + VulkanImageTiling vulkanImageTiling = + vkClExternalMemoryHandleTilingAssumption( + device, vkExternalMemoryHandleType, &errNum); + ASSERT_SUCCESS(errNum, "Failed to query OpenCL tiling mode"); + + VulkanImage3D vkImage3D = VulkanImage3D( + *vkDevice, VULKAN_FORMAT_R8G8B8A8_UNORM, width, height, depth, + vulkanImageTiling, 1, vkExternalMemoryHandleType); + + const VulkanMemoryTypeList& memoryTypeList = + vkImage3D.getMemoryTypeList(); + uint64_t totalImageMemSize = vkImage3D.getSize(); + + log_info("Memory type index: %u\n", (uint32_t)memoryTypeList[0]); + log_info("Memory type property: %d\n", + memoryTypeList[0].getMemoryTypeProperty()); + log_info("Image size : %lu\n", totalImageMemSize); + + VulkanDeviceMemory* vkDeviceMem = + new VulkanDeviceMemory(*vkDevice, vkImage3D, memoryTypeList[0], + vkExternalMemoryHandleType); + vkDeviceMem->bindImage(vkImage3D, 0); + + void* handle = NULL; + int fd; + std::vector extMemProperties{ + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_KHR, + (cl_mem_properties)device, + (cl_mem_properties)CL_MEM_DEVICE_HANDLE_LIST_END_KHR, + }; + switch (vkExternalMemoryHandleType) + { #ifdef _WIN32 - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); - extMemProperties.push_back( - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); - extMemProperties.push_back((cl_mem_properties)handle); - break; - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: - handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); - extMemProperties.push_back( - (cl_mem_properties) - CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); - extMemProperties.push_back((cl_mem_properties)handle); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); + extMemProperties.push_back((cl_mem_properties)handle); + break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: + handle = vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); + extMemProperties.push_back((cl_mem_properties)handle); + break; #else - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: - fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); - errNum = check_external_memory_handle_type( - devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); - extMemProperties.push_back( - (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); - extMemProperties.push_back((cl_mem_properties)fd); - break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: + fd = (int)vkDeviceMem->getHandle(vkExternalMemoryHandleType); + errNum = check_external_memory_handle_type( + device, CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); + extMemProperties.push_back( + (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); + extMemProperties.push_back((cl_mem_properties)fd); + break; #endif - default: - errNum = TEST_FAIL; - log_error("Unsupported external memory handle type \n"); - break; + default: + errNum = TEST_FAIL; + log_error("Unsupported external memory handle type \n"); + break; + } + if (errNum != CL_SUCCESS) + { + log_error("Checks failed for " + "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); + return TEST_FAIL; + } + extMemProperties.push_back(0); + + const VkImageCreateInfo VulkanImageCreateInfo = + vkImage3D.getVkImageCreateInfo(); + + errNum = getCLImageInfoFromVkImageInfo(&VulkanImageCreateInfo, + totalImageMemSize, &img_format, + &image_desc); + if (errNum != CL_SUCCESS) + { + log_error("getCLImageInfoFromVkImageInfo failed!!!"); + return TEST_FAIL; + } + + clMemWrapper image; + + // Pass valid properties, image_desc and image_format + image = clCreateImageWithProperties( + context, extMemProperties.data(), CL_MEM_READ_WRITE, &img_format, + &image_desc, NULL /* host_ptr */, &errNum); + test_error(errNum, "Unable to create Image with Properties"); + image.reset(); + + // Passing NULL properties and a valid image_format and image_desc + image = clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, + &img_format, &image_desc, NULL, + &errNum); + test_error(errNum, + "Unable to create image with NULL properties " + "with valid image format and image desc"); + + image.reset(); + + // Passing image_format as NULL + image = clCreateImageWithProperties(context, extMemProperties.data(), + CL_MEM_READ_WRITE, NULL, + &image_desc, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, + "Image creation must fail with " + "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" + "when image desc passed as NULL"); + + image.reset(); + + // Passing image_desc as NULL + image = clCreateImageWithProperties(context, extMemProperties.data(), + CL_MEM_READ_WRITE, &img_format, + NULL, NULL, &errNum); + test_failure_error(errNum, CL_INVALID_IMAGE_DESCRIPTOR, + "Image creation must fail with " + "CL_INVALID_IMAGE_DESCRIPTOR " + "when image desc passed as NULL"); + image.reset(); + + return TEST_PASS; } - if (errNum != CL_SUCCESS) - { - log_error("Checks failed for " - "CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR\n"); - return TEST_FAIL; - } - extMemProperties.push_back(0); +}; - const VkImageCreateInfo VulkanImageCreateInfo = - vkImage3D.getVkImageCreateInfo(); +} // anonymous namespace - errNum = getCLImageInfoFromVkImageInfo( - &VulkanImageCreateInfo, totalImageMemSize, &img_format, &image_desc); - if (errNum != CL_SUCCESS) - { - log_error("getCLImageInfoFromVkImageInfo failed!!!"); - return TEST_FAIL; - } - - clMemWrapper image; - - // Pass valid properties, image_desc and image_format - image = clCreateImageWithProperties( - context, extMemProperties.data(), CL_MEM_READ_WRITE, &img_format, - &image_desc, NULL /* host_ptr */, &errNum); - test_error(errNum, "Unable to create Image with Properties"); - image.reset(); - - // Passing NULL properties and a valid image_format and image_desc - image = - clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, - &img_format, &image_desc, NULL, &errNum); - test_error(errNum, - "Unable to create image with NULL properties " - "with valid image format and image desc"); - - image.reset(); - - // Passing image_format as NULL - image = clCreateImageWithProperties(context, extMemProperties.data(), - CL_MEM_READ_WRITE, NULL, &image_desc, - NULL, &errNum); - test_failure_error(errNum, CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, - "Image creation must fail with " - "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" - "when image desc passed as NULL"); - - image.reset(); - - // Passing image_desc as NULL - image = clCreateImageWithProperties(context, extMemProperties.data(), - CL_MEM_READ_WRITE, &img_format, NULL, - NULL, &errNum); - test_failure_error(errNum, CL_INVALID_IMAGE_DESCRIPTOR, - "Image creation must fail with " - "CL_INVALID_IMAGE_DESCRIPTOR " - "when image desc passed as NULL"); - image.reset(); - - if (cmd_queue) clReleaseCommandQueue(cmd_queue); - if (context) clReleaseContext(context); - - return TEST_PASS; +int test_consistency_external_for_3dimage(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); } diff --git a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp index 56fd485c77..e5f1a72800 100644 --- a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2022 The Khronos Group Inc. +// 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. @@ -24,62 +24,66 @@ #include #include "harness/errorHelpers.h" #include "harness/os_helpers.h" -#include "deviceInfo.h" + +#include "vulkan_test_base.h" +#include "opencl_vulkan_wrapper.hpp" #define MAX_BUFFERS 5 #define MAX_IMPORTS 5 #define BUFFERSIZE 3000 -static cl_uchar uuid[CL_UUID_SIZE_KHR]; -static cl_device_id deviceId = NULL; namespace { + +cl_uchar uuid[CL_UUID_SIZE_KHR]; +cl_device_id deviceId = nullptr; + struct Params { uint32_t numBuffers; uint32_t bufferSize; uint32_t interBufferOffset; }; -} const char *kernel_text_numbuffer_1 = " \ -__kernel void clUpdateBuffer(int bufferSize, __global unsigned char *a) { \n\ - int gid = get_global_id(0); \n\ - if (gid < bufferSize) { \n\ - a[gid]++; \n\ - } \n\ -}"; + __kernel void clUpdateBuffer(int bufferSize, __global unsigned char *a) { \n\ + int gid = get_global_id(0); \n\ + if (gid < bufferSize) { \n\ + a[gid]++; \n\ + } \n\ + }"; const char *kernel_text_numbuffer_2 = " \ -__kernel void clUpdateBuffer(int bufferSize, __global unsigned char *a, __global unsigned char *b) { \n\ - int gid = get_global_id(0); \n\ - if (gid < bufferSize) { \n\ - a[gid]++; \n\ - b[gid]++;\n\ - } \n\ -}"; + __kernel void clUpdateBuffer(int bufferSize, __global unsigned char *a, __global unsigned char *b) { \n\ + int gid = get_global_id(0); \n\ + if (gid < bufferSize) { \n\ + a[gid]++; \n\ + b[gid]++;\n\ + } \n\ + }"; const char *kernel_text_numbuffer_4 = " \ -__kernel void clUpdateBuffer(int bufferSize, __global unsigned char *a, __global unsigned char *b, __global unsigned char *c, __global unsigned char *d) { \n\ - int gid = get_global_id(0); \n\ - if (gid < bufferSize) { \n\ - a[gid]++;\n\ - b[gid]++; \n\ - c[gid]++; \n\ - d[gid]++; \n\ - } \n\ -}"; + __kernel void clUpdateBuffer(int bufferSize, __global unsigned char *a, __global unsigned char *b, __global unsigned char *c, __global unsigned char *d) { \n\ + int gid = get_global_id(0); \n\ + if (gid < bufferSize) { \n\ + a[gid]++;\n\ + b[gid]++; \n\ + c[gid]++; \n\ + d[gid]++; \n\ + } \n\ + }"; const char *kernel_text_verify = " \ -__kernel void checkKernel(__global unsigned char *ptr, int size, int expVal, __global unsigned char *err) \n\ -{ \n\ - int idx = get_global_id(0); \n\ - if ((idx < size) && (*err == 0)) { \n\ - if (ptr[idx] != expVal){ \n\ - *err = 1; \n\ - } \n\ - } \n\ -}"; + __kernel void checkKernel(__global unsigned char *ptr, int size, int expVal, __global unsigned char *err) \n\ + { \n\ + int idx = get_global_id(0); \n\ + if ((idx < size) && (*err == 0)) { \n\ + if (ptr[idx] != expVal){ \n\ + *err = 1; \n\ + } \n\ + } \n\ + }"; + int run_test_with_two_queue( cl_context &context, cl_command_queue &cmd_queue1, @@ -114,7 +118,8 @@ int run_test_with_two_queue( VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; - VulkanQueue &vkQueue = vkDevice.getQueue(); + VulkanQueue &vkQueue = + vkDevice.getQueue(getVulkanQueueFamily(vkDevice.getPhysicalDevice())); std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); @@ -150,6 +155,7 @@ int run_test_with_two_queue( } const uint32_t maxIter = innerIterations; + VulkanCommandPool vkCommandPool(vkDevice); VulkanCommandBuffer vkCommandBuffer(vkDevice, vkCommandPool); @@ -446,7 +452,8 @@ int run_test_with_one_queue( VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; - VulkanQueue &vkQueue = vkDevice.getQueue(); + VulkanQueue &vkQueue = + vkDevice.getQueue(getVulkanQueueFamily(vkDevice.getPhysicalDevice())); std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); @@ -482,6 +489,7 @@ int run_test_with_one_queue( } const uint32_t maxIter = innerIterations; + VulkanCommandPool vkCommandPool(vkDevice); VulkanCommandBuffer vkCommandBuffer(vkDevice, vkCommandPool); @@ -749,7 +757,7 @@ int run_test_with_multi_import_same_ctx( VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; - VulkanQueue &vkQueue = vkDevice.getQueue(); + VulkanQueue &vkQueue = vkDevice.getQueue(getVulkanQueueFamily()); std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); @@ -820,221 +828,213 @@ int run_test_with_multi_import_same_ctx( memoryType.getMemoryTypeProperty()); - cl_mem buffers[MAX_BUFFERS][MAX_IMPORTS]; - VulkanBufferList vkBufferList(numBuffers, vkDevice, bufferSize, - vkExternalMemoryHandleType); + cl_mem buffers[MAX_BUFFERS][MAX_IMPORTS]; + VulkanBufferList vkBufferList(numBuffers, vkDevice, bufferSize, + vkExternalMemoryHandleType); + + for (size_t bIdx = 0; bIdx < numBuffers; bIdx++) + { + vkBufferListDeviceMemory.push_back(new VulkanDeviceMemory( + vkDevice, vkBufferList[bIdx], memoryType, + vkExternalMemoryHandleType)); - for (size_t bIdx = 0; bIdx < numBuffers; bIdx++) + std::vector pExternalMemory; + for (size_t cl_bIdx = 0; cl_bIdx < numImports; cl_bIdx++) { - vkBufferListDeviceMemory.push_back(new VulkanDeviceMemory( - vkDevice, vkBufferList[bIdx], memoryType, - vkExternalMemoryHandleType)); + pExternalMemory.push_back( + new clExternalMemory(vkBufferListDeviceMemory[bIdx], + vkExternalMemoryHandleType, + bufferSize, context, deviceId)); + } + externalMemory.push_back(pExternalMemory); + } - std::vector pExternalMemory; - for (size_t cl_bIdx = 0; cl_bIdx < numImports; cl_bIdx++) - { - pExternalMemory.push_back(new clExternalMemory( - vkBufferListDeviceMemory[bIdx], - vkExternalMemoryHandleType, bufferSize, context, - deviceId)); - } - externalMemory.push_back(pExternalMemory); + clFinish(cmd_queue1); + Params *params = (Params *)vkParamsDeviceMemory.map(); + params->numBuffers = numBuffers; + params->bufferSize = bufferSize; + params->interBufferOffset = 0; + vkParamsDeviceMemory.unmap(); + vkDescriptorSet.update(0, vkParamsBuffer); + for (size_t bIdx = 0; bIdx < vkBufferList.size(); bIdx++) + { + size_t buffer_size = vkBufferList[bIdx].getSize(); + vkBufferListDeviceMemory[bIdx]->bindBuffer(vkBufferList[bIdx], + 0); + for (size_t cl_bIdx = 0; cl_bIdx < numImports; cl_bIdx++) + { + buffers[bIdx][cl_bIdx] = externalMemory[bIdx][cl_bIdx] + ->getExternalMemoryBuffer(); } + } + vkDescriptorSet.updateArray(1, numBuffers, vkBufferList); + vkCommandBuffer.begin(); + vkCommandBuffer.bindPipeline(vkComputePipeline); + vkCommandBuffer.bindDescriptorSets( + vkComputePipeline, vkPipelineLayout, vkDescriptorSet); + vkCommandBuffer.dispatch(512, 1, 1); + vkCommandBuffer.end(); + + update_buffer_kernel = (numBuffers == 1) + ? kernel[0] + : ((numBuffers == 2) ? kernel[1] : kernel[2]); + // global work size should be less than or equal to + // bufferSizeList[i] + global_work_size[0] = bufferSize; - clFinish(cmd_queue1); - Params *params = (Params *)vkParamsDeviceMemory.map(); - params->numBuffers = numBuffers; - params->bufferSize = bufferSize; - params->interBufferOffset = 0; - vkParamsDeviceMemory.unmap(); - vkDescriptorSet.update(0, vkParamsBuffer); - for (size_t bIdx = 0; bIdx < vkBufferList.size(); bIdx++) + for (uint32_t iter = 0; iter < maxIter; iter++) + { + if (use_fence) { - size_t buffer_size = vkBufferList[bIdx].getSize(); - vkBufferListDeviceMemory[bIdx]->bindBuffer( - vkBufferList[bIdx], 0); - for (size_t cl_bIdx = 0; cl_bIdx < numImports; cl_bIdx++) - { - buffers[bIdx][cl_bIdx] = - externalMemory[bIdx][cl_bIdx] - ->getExternalMemoryBuffer(); - } + fence->reset(); + vkQueue.submit(vkCommandBuffer, fence); + fence->wait(); } - vkDescriptorSet.updateArray(1, numBuffers, vkBufferList); - vkCommandBuffer.begin(); - vkCommandBuffer.bindPipeline(vkComputePipeline); - vkCommandBuffer.bindDescriptorSets( - vkComputePipeline, vkPipelineLayout, vkDescriptorSet); - vkCommandBuffer.dispatch(512, 1, 1); - vkCommandBuffer.end(); - - update_buffer_kernel = (numBuffers == 1) - ? kernel[0] - : ((numBuffers == 2) ? kernel[1] : kernel[2]); - // global work size should be less than or equal to - // bufferSizeList[i] - global_work_size[0] = bufferSize; - - for (uint32_t iter = 0; iter < maxIter; iter++) + else { - if (use_fence) - { - fence->reset(); - vkQueue.submit(vkCommandBuffer, fence); - fence->wait(); - } - else - { - if (iter == 0) - { - vkQueue.submit(vkCommandBuffer, vkVk2CLSemaphore); - } - else - { - vkQueue.submit(vkCl2VkSemaphore, vkCommandBuffer, - vkVk2CLSemaphore); - } - } - - if (use_fence) + if (iter == 0) { - fence->wait(); + vkQueue.submit(vkCommandBuffer, vkVk2CLSemaphore); } else { - err = clVk2CLExternalSemaphore->wait(cmd_queue1); - test_error_and_cleanup( - err, CLEANUP, - "Error: failed to wait on CL external semaphore\n"); - } - - for (uint8_t launchIter = 0; launchIter < numImports; - launchIter++) - { - err = clSetKernelArg(update_buffer_kernel, 0, - sizeof(uint32_t), - (void *)&bufferSize); - for (int i = 0; i < numBuffers; i++) - { - err |= clSetKernelArg( - update_buffer_kernel, i + 1, sizeof(cl_mem), - (void *)&(buffers[i][launchIter])); - err = clEnqueueAcquireExternalMemObjectsKHRptr( - cmd_queue1, 1, &buffers[i][launchIter], 0, - nullptr, nullptr); - test_error_and_cleanup(err, CLEANUP, - "Failed to acquire buffers"); - } - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to set arg values for " - "kernel\n "); - - err = clEnqueueNDRangeKernel( - cmd_queue1, update_buffer_kernel, 1, NULL, - global_work_size, NULL, 0, NULL, NULL); - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to launch " - "update_buffer_kernel, error\n "); - - for (int i = 0; i < numBuffers; i++) - { - err = clEnqueueReleaseExternalMemObjectsKHRptr( - cmd_queue1, 1, &buffers[i][launchIter], 0, - nullptr, nullptr); - test_error_and_cleanup(err, CLEANUP, - "Failed to release buffers"); - } - } - if (use_fence) - { - clFinish(cmd_queue1); - } - else if (!use_fence && iter != (maxIter - 1)) - { - err = clCl2VkExternalSemaphore->signal(cmd_queue1); - test_error_and_cleanup( - err, CLEANUP, "Failed to signal CL semaphore\n"); + vkQueue.submit(vkCl2VkSemaphore, vkCommandBuffer, + vkVk2CLSemaphore); } } - error_2 = (uint8_t *)malloc(sizeof(uint8_t)); - if (NULL == error_2) + if (use_fence) + { + fence->wait(); + } + else { - test_fail_and_cleanup(err, CLEANUP, - "Not able to allocate memory\n"); + err = clVk2CLExternalSemaphore->wait(cmd_queue1); + test_error_and_cleanup(err, CLEANUP, + "Error: failed to wait on " + "CL external semaphore\n"); } - error_1 = clCreateBuffer(context, CL_MEM_WRITE_ONLY, - sizeof(uint8_t), NULL, &err); - test_error_and_cleanup(err, CLEANUP, - "Error: clCreateBuffer \n"); - - uint8_t val = 0; - err = - clEnqueueWriteBuffer(cmd_queue1, error_1, CL_TRUE, 0, - sizeof(uint8_t), &val, 0, NULL, NULL); - test_error_and_cleanup(err, CLEANUP, - "Error: clEnqueueWriteBuffer \n"); - - calc_max_iter = maxIter * (numImports + 1); - - for (int i = 0; i < vkBufferList.size(); i++) + for (uint8_t launchIter = 0; launchIter < numImports; + launchIter++) { - err = clSetKernelArg(verify_kernel, 0, sizeof(cl_mem), - (void *)&(buffers[i][0])); - err |= clSetKernelArg(verify_kernel, 1, sizeof(int), - &bufferSize); - err |= clSetKernelArg(verify_kernel, 2, sizeof(int), - &calc_max_iter); - err |= clSetKernelArg(verify_kernel, 3, sizeof(cl_mem), - (void *)&error_1); + err = clSetKernelArg(update_buffer_kernel, 0, + sizeof(uint32_t), (void *)&bufferSize); + for (int i = 0; i < numBuffers; i++) + { + err |= clSetKernelArg( + update_buffer_kernel, i + 1, sizeof(cl_mem), + (void *)&(buffers[i][launchIter])); + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers[i][launchIter], 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to acquire buffers"); + } test_error_and_cleanup( err, CLEANUP, "Error: Failed to set arg values for " - "verify_kernel \n"); - - err = clEnqueueNDRangeKernel(cmd_queue1, verify_kernel, 1, - NULL, global_work_size, NULL, - 0, NULL, NULL); - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to launch verify_kernel, error\n"); + "kernel\n "); - err = clEnqueueReadBuffer(cmd_queue1, error_1, CL_TRUE, 0, - sizeof(uint8_t), error_2, 0, NULL, - NULL); - test_error_and_cleanup( - err, CLEANUP, "Error: Failed read output, error \n"); + err = clEnqueueNDRangeKernel( + cmd_queue1, update_buffer_kernel, 1, NULL, + global_work_size, NULL, 0, NULL, NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed to launch " + "update_buffer_kernel, error\n "); - if (*error_2 == 1) + for (int i = 0; i < numBuffers; i++) { - test_fail_and_cleanup( - err, CLEANUP, - " vulkan_opencl_buffer test FAILED\n"); + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue1, 1, &buffers[i][launchIter], 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to release buffers"); } } - for (size_t i = 0; i < vkBufferList.size(); i++) + if (use_fence) { - for (size_t j = 0; j < numImports; j++) - { - delete externalMemory[i][j]; - } + clFinish(cmd_queue1); } - for (size_t i = 0; i < vkBufferListDeviceMemory.size(); i++) + else if (!use_fence && iter != (maxIter - 1)) { - delete vkBufferListDeviceMemory[i]; + err = clCl2VkExternalSemaphore->signal(cmd_queue1); + test_error_and_cleanup(err, CLEANUP, + "Failed to signal CL semaphore\n"); } - vkBufferListDeviceMemory.erase(vkBufferListDeviceMemory.begin(), - vkBufferListDeviceMemory.end()); - for (size_t i = 0; i < externalMemory.size(); i++) + } + + error_2 = (uint8_t *)malloc(sizeof(uint8_t)); + if (NULL == error_2) + { + test_fail_and_cleanup(err, CLEANUP, + "Not able to allocate memory\n"); + } + + error_1 = clCreateBuffer(context, CL_MEM_WRITE_ONLY, + sizeof(uint8_t), NULL, &err); + test_error_and_cleanup(err, CLEANUP, "Error: clCreateBuffer \n"); + + uint8_t val = 0; + err = clEnqueueWriteBuffer(cmd_queue1, error_1, CL_TRUE, 0, + sizeof(uint8_t), &val, 0, NULL, NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: clEnqueueWriteBuffer \n"); + + calc_max_iter = maxIter * (numImports + 1); + + for (int i = 0; i < vkBufferList.size(); i++) + { + err = clSetKernelArg(verify_kernel, 0, sizeof(cl_mem), + (void *)&(buffers[i][0])); + err |= + clSetKernelArg(verify_kernel, 1, sizeof(int), &bufferSize); + err |= clSetKernelArg(verify_kernel, 2, sizeof(int), + &calc_max_iter); + err |= clSetKernelArg(verify_kernel, 3, sizeof(cl_mem), + (void *)&error_1); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed to set arg values for " + "verify_kernel \n"); + + err = clEnqueueNDRangeKernel(cmd_queue1, verify_kernel, 1, NULL, + global_work_size, NULL, 0, NULL, + NULL); + test_error_and_cleanup( + err, CLEANUP, + "Error: Failed to launch verify_kernel, error\n"); + + err = clEnqueueReadBuffer(cmd_queue1, error_1, CL_TRUE, 0, + sizeof(uint8_t), error_2, 0, NULL, + NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed read output, error \n"); + + if (*error_2 == 1) { - externalMemory[i].erase(externalMemory[i].begin(), - externalMemory[i].begin() - + numBuffers); + test_fail_and_cleanup( + err, CLEANUP, " vulkan_opencl_buffer test FAILED\n"); + } + } + for (size_t i = 0; i < vkBufferList.size(); i++) + { + for (size_t j = 0; j < numImports; j++) + { + delete externalMemory[i][j]; } - externalMemory.clear(); + } + for (size_t i = 0; i < vkBufferListDeviceMemory.size(); i++) + { + delete vkBufferListDeviceMemory[i]; + } + vkBufferListDeviceMemory.erase(vkBufferListDeviceMemory.begin(), + vkBufferListDeviceMemory.end()); + for (size_t i = 0; i < externalMemory.size(); i++) + { + externalMemory[i].erase(externalMemory[i].begin(), + externalMemory[i].begin() + numBuffers); + } + externalMemory.clear(); } } CLEANUP: @@ -1097,7 +1097,7 @@ int run_test_with_multi_import_diff_ctx( VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; - VulkanQueue &vkQueue = vkDevice.getQueue(); + VulkanQueue &vkQueue = vkDevice.getQueue(getVulkanQueueFamily()); std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); @@ -1273,9 +1273,9 @@ int run_test_with_multi_import_diff_ctx( else { err = clVk2CLExternalSemaphore->wait(cmd_queue1); - test_error_and_cleanup( - err, CLEANUP, - "Error: failed to wait on CL external semaphore\n"); + test_error_and_cleanup(err, CLEANUP, + "Error: failed to wait on " + "CL external semaphore\n"); } for (uint8_t launchIter = 0; launchIter < numImports; @@ -1354,204 +1354,193 @@ int run_test_with_multi_import_diff_ctx( } } - if (use_fence) - { - fence->wait(); - } - else - { - err = clVk2CLExternalSemaphore2->wait(cmd_queue2); - test_error_and_cleanup( - err, CLEANUP, - "Error: failed to wait on CL external semaphore\n"); - } + if (use_fence) + { + fence->wait(); + } + else + { + err = clVk2CLExternalSemaphore2->wait(cmd_queue2); + test_error_and_cleanup(err, CLEANUP, + "Error: failed to wait on " + "CL external semaphore\n"); + } + + for (uint8_t launchIter = 0; launchIter < numImports; + launchIter++) + { + err = clSetKernelArg(update_buffer_kernel2[launchIter], 0, + sizeof(uint32_t), (void *)&bufferSize); + test_error_and_cleanup(err, CLEANUP, + "Failed to set kernel arg"); - for (uint8_t launchIter = 0; launchIter < numImports; - launchIter++) + for (int i = 0; i < numBuffers; i++) { - err = clSetKernelArg(update_buffer_kernel2[launchIter], - 0, sizeof(uint32_t), - (void *)&bufferSize); + err = clSetKernelArg( + update_buffer_kernel2[launchIter], i + 1, + sizeof(cl_mem), (void *)&(buffers2[i][launchIter])); test_error_and_cleanup(err, CLEANUP, "Failed to set kernel arg"); - for (int i = 0; i < numBuffers; i++) - { - err = clSetKernelArg( - update_buffer_kernel2[launchIter], i + 1, - sizeof(cl_mem), - (void *)&(buffers2[i][launchIter])); - test_error_and_cleanup(err, CLEANUP, - "Failed to set kernel arg"); - - err = clEnqueueAcquireExternalMemObjectsKHRptr( - cmd_queue2, 1, &buffers2[i][launchIter], 0, - nullptr, nullptr); - test_error_and_cleanup(err, CLEANUP, - "Failed to acquire buffers"); - } - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to set arg values for " - "kernel\n "); - - err = clEnqueueNDRangeKernel( - cmd_queue2, update_buffer_kernel2[launchIter], 1, - NULL, global_work_size, NULL, 0, NULL, NULL); - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to launch " - "update_buffer_kernel, error\n "); - for (int i = 0; i < numBuffers; i++) - { - err = clEnqueueReleaseExternalMemObjectsKHRptr( - cmd_queue2, 1, &buffers2[i][launchIter], 0, - nullptr, nullptr); - test_error_and_cleanup(err, CLEANUP, - "Failed to release buffers"); - } - } - if (use_fence) - { - clFinish(cmd_queue2); + err = clEnqueueAcquireExternalMemObjectsKHRptr( + cmd_queue2, 1, &buffers2[i][launchIter], 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to acquire buffers"); } - else if (!use_fence && iter != (maxIter - 1)) + test_error_and_cleanup( + err, CLEANUP, + "Error: Failed to set arg values for " + "kernel\n "); + + err = clEnqueueNDRangeKernel( + cmd_queue2, update_buffer_kernel2[launchIter], 1, NULL, + global_work_size, NULL, 0, NULL, NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed to launch " + "update_buffer_kernel, error\n "); + for (int i = 0; i < numBuffers; i++) { - err = clCl2VkExternalSemaphore2->signal(cmd_queue2); - test_error_and_cleanup( - err, CLEANUP, "Failed to signal CL semaphore\n"); + err = clEnqueueReleaseExternalMemObjectsKHRptr( + cmd_queue2, 1, &buffers2[i][launchIter], 0, nullptr, + nullptr); + test_error_and_cleanup(err, CLEANUP, + "Failed to release buffers"); } - } - clFinish(cmd_queue2); - error_3 = (uint8_t *)malloc(sizeof(uint8_t)); - if (NULL == error_3) + } + if (use_fence) { - test_fail_and_cleanup(err, CLEANUP, - "Not able to allocate memory\n"); + clFinish(cmd_queue2); } + else if (!use_fence && iter != (maxIter - 1)) + { + err = clCl2VkExternalSemaphore2->signal(cmd_queue2); + test_error_and_cleanup(err, CLEANUP, + "Failed to signal CL semaphore\n"); + } + } + clFinish(cmd_queue2); + error_3 = (uint8_t *)malloc(sizeof(uint8_t)); + if (NULL == error_3) + { + test_fail_and_cleanup(err, CLEANUP, + "Not able to allocate memory\n"); + } - error_1 = clCreateBuffer(context, CL_MEM_WRITE_ONLY, - sizeof(uint8_t), NULL, &err); - test_error_and_cleanup(err, CLEANUP, - "Error: clCreateBuffer \n"); + error_1 = clCreateBuffer(context, CL_MEM_WRITE_ONLY, + sizeof(uint8_t), NULL, &err); + test_error_and_cleanup(err, CLEANUP, "Error: clCreateBuffer \n"); + + error_2 = clCreateBuffer(context2, CL_MEM_WRITE_ONLY, + sizeof(uint8_t), NULL, &err); + test_error_and_cleanup(err, CLEANUP, "Error: clCreateBuffer \n"); + + uint8_t val = 0; + err = clEnqueueWriteBuffer(cmd_queue1, error_1, CL_TRUE, 0, + sizeof(uint8_t), &val, 0, NULL, NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed read output, error \n"); + + err = clEnqueueWriteBuffer(cmd_queue2, error_2, CL_TRUE, 0, + sizeof(uint8_t), &val, 0, NULL, NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed read output, error \n"); - error_2 = clCreateBuffer(context2, CL_MEM_WRITE_ONLY, - sizeof(uint8_t), NULL, &err); + calc_max_iter = maxIter * 2 * (numBuffers + 1); + for (int i = 0; i < numBuffers; i++) + { + err = clSetKernelArg(verify_kernel, 0, sizeof(cl_mem), + (void *)&(buffers1[i][0])); + err |= + clSetKernelArg(verify_kernel, 1, sizeof(int), &pBufferSize); + err |= clSetKernelArg(verify_kernel, 2, sizeof(int), + &calc_max_iter); + err |= clSetKernelArg(verify_kernel, 3, sizeof(cl_mem), + (void *)&error_1); test_error_and_cleanup(err, CLEANUP, - "Error: clCreateBuffer \n"); + "Error: Failed to set arg values for " + "verify_kernel \n"); - uint8_t val = 0; - err = - clEnqueueWriteBuffer(cmd_queue1, error_1, CL_TRUE, 0, - sizeof(uint8_t), &val, 0, NULL, NULL); + err = clEnqueueNDRangeKernel(cmd_queue1, verify_kernel, 1, NULL, + global_work_size, NULL, 0, NULL, + NULL); test_error_and_cleanup(err, CLEANUP, - "Error: Failed read output, error \n"); + "Error: Failed to launch verify_kernel," + "error\n"); - err = - clEnqueueWriteBuffer(cmd_queue2, error_2, CL_TRUE, 0, - sizeof(uint8_t), &val, 0, NULL, NULL); + err = clEnqueueReadBuffer(cmd_queue1, error_1, CL_TRUE, 0, + sizeof(uint8_t), error_3, 0, NULL, + NULL); test_error_and_cleanup(err, CLEANUP, - "Error: Failed read output, error \n"); + "Error: Failed read output, error\n"); - calc_max_iter = maxIter * 2 * (numBuffers + 1); - for (int i = 0; i < numBuffers; i++) + if (*error_3 == 1) { - err = clSetKernelArg(verify_kernel, 0, sizeof(cl_mem), - (void *)&(buffers1[i][0])); - err |= clSetKernelArg(verify_kernel, 1, sizeof(int), - &pBufferSize); - err |= clSetKernelArg(verify_kernel, 2, sizeof(int), - &calc_max_iter); - err |= clSetKernelArg(verify_kernel, 3, sizeof(cl_mem), - (void *)&error_1); - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to set arg values for " - "verify_kernel \n"); - - err = clEnqueueNDRangeKernel(cmd_queue1, verify_kernel, 1, - NULL, global_work_size, NULL, - 0, NULL, NULL); - test_error_and_cleanup( + test_fail_and_cleanup( err, CLEANUP, - "Error: Failed to launch verify_kernel," - "error\n"); - - err = clEnqueueReadBuffer(cmd_queue1, error_1, CL_TRUE, 0, - sizeof(uint8_t), error_3, 0, NULL, - NULL); - test_error_and_cleanup( - err, CLEANUP, "Error: Failed read output, error\n"); - - if (*error_3 == 1) - { - test_fail_and_cleanup( - err, CLEANUP, - "&&&& vulkan_opencl_buffer test FAILED\n"); - } + "&&&& vulkan_opencl_buffer test FAILED\n"); } - *error_3 = 0; - for (int i = 0; i < vkBufferList.size(); i++) - { - err = clSetKernelArg(verify_kernel2, 0, sizeof(cl_mem), - (void *)&(buffers2[i][0])); - err |= clSetKernelArg(verify_kernel2, 1, sizeof(int), - &pBufferSize); - err |= clSetKernelArg(verify_kernel2, 2, sizeof(int), - &calc_max_iter); - err |= clSetKernelArg(verify_kernel2, 3, sizeof(cl_mem), - (void *)&error_2); - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to set arg values for " - "verify_kernel \n"); + } + *error_3 = 0; + for (int i = 0; i < vkBufferList.size(); i++) + { + err = clSetKernelArg(verify_kernel2, 0, sizeof(cl_mem), + (void *)&(buffers2[i][0])); + err |= clSetKernelArg(verify_kernel2, 1, sizeof(int), + &pBufferSize); + err |= clSetKernelArg(verify_kernel2, 2, sizeof(int), + &calc_max_iter); + err |= clSetKernelArg(verify_kernel2, 3, sizeof(cl_mem), + (void *)&error_2); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed to set arg values for " + "verify_kernel \n"); - err = clEnqueueNDRangeKernel(cmd_queue2, verify_kernel2, 1, - NULL, global_work_size, NULL, - 0, NULL, NULL); - test_error_and_cleanup( - err, CLEANUP, - "Error: Failed to launch verify_kernel," - "error\n"); + err = clEnqueueNDRangeKernel(cmd_queue2, verify_kernel2, 1, + NULL, global_work_size, NULL, 0, + NULL, NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed to launch verify_kernel," + "error\n"); - err = clEnqueueReadBuffer(cmd_queue2, error_2, CL_TRUE, 0, - sizeof(uint8_t), error_3, 0, NULL, - NULL); - test_error_and_cleanup( - err, CLEANUP, "Error: Failed read output, error\n"); + err = clEnqueueReadBuffer(cmd_queue2, error_2, CL_TRUE, 0, + sizeof(uint8_t), error_3, 0, NULL, + NULL); + test_error_and_cleanup(err, CLEANUP, + "Error: Failed read output, error\n"); - if (*error_3 == 1) - { - test_fail_and_cleanup( - err, CLEANUP, - "&&&& vulkan_opencl_buffer test FAILED\n"); - } - } - for (size_t i = 0; i < vkBufferList.size(); i++) + if (*error_3 == 1) { - for (size_t j = 0; j < numImports; j++) - { - delete externalMemory1[i][j]; - delete externalMemory2[i][j]; - } - } - for (size_t i = 0; i < vkBufferListDeviceMemory.size(); i++) - { - delete vkBufferListDeviceMemory[i]; + test_fail_and_cleanup( + err, CLEANUP, + "&&&& vulkan_opencl_buffer test FAILED\n"); } - vkBufferListDeviceMemory.erase(vkBufferListDeviceMemory.begin(), - vkBufferListDeviceMemory.end()); - for (size_t i = 0; i < externalMemory1.size(); i++) + } + for (size_t i = 0; i < vkBufferList.size(); i++) + { + for (size_t j = 0; j < numImports; j++) { - externalMemory1[i].erase(externalMemory1[i].begin(), - externalMemory1[i].begin() - + numBuffers); - externalMemory2[i].erase(externalMemory2[i].begin(), - externalMemory2[i].begin() - + numBuffers); + delete externalMemory1[i][j]; + delete externalMemory2[i][j]; } - externalMemory1.clear(); - externalMemory2.clear(); + } + for (size_t i = 0; i < vkBufferListDeviceMemory.size(); i++) + { + delete vkBufferListDeviceMemory[i]; + } + vkBufferListDeviceMemory.erase(vkBufferListDeviceMemory.begin(), + vkBufferListDeviceMemory.end()); + for (size_t i = 0; i < externalMemory1.size(); i++) + { + externalMemory1[i].erase(externalMemory1[i].begin(), + externalMemory1[i].begin() + + numBuffers); + externalMemory2[i].erase(externalMemory2[i].begin(), + externalMemory2[i].begin() + + numBuffers); + } + externalMemory1.clear(); + externalMemory2.clear(); } } CLEANUP: @@ -1597,80 +1586,52 @@ int run_test_with_multi_import_diff_ctx( return err; } -int test_buffer_common(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_, - bool use_fence) -{ - int current_device = 0; - int device_count = 0; - int devices_prohibited = 0; - cl_int errNum = CL_SUCCESS; - cl_platform_id platform = NULL; - size_t extensionSize = 0; - cl_uint num_devices = 0; - cl_uint device_no = 0; - const size_t bufsize = BUFFERSIZE; - char buf[BUFFERSIZE]; - cl_device_id *devices; - char *extensions = NULL; - cl_kernel verify_kernel; - cl_kernel verify_kernel2; - cl_kernel kernel[3] = { NULL, NULL, NULL }; - cl_kernel kernel2[3] = { NULL, NULL, NULL }; - const char *program_source_const[3] = { kernel_text_numbuffer_1, - kernel_text_numbuffer_2, - kernel_text_numbuffer_4 }; - const char *program_source_const_verify; - size_t program_source_length; - cl_command_queue cmd_queue1 = NULL; - cl_command_queue cmd_queue2 = NULL; - cl_command_queue cmd_queue3 = NULL; - cl_context context = NULL; - cl_program program[3] = { NULL, NULL, NULL }; - cl_program program_verify, program_verify2; - cl_context context2 = NULL; - - - VulkanDevice vkDevice; - uint32_t numBuffersList[] = { 1, 2, 4 }; - uint32_t bufferSizeList[] = { 4 * 1024, 64 * 1024, 2 * 1024 * 1024 }; - uint32_t bufferSizeListforOffset[] = { 256, 512, 1024 }; - - cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, 0, 0 }; - std::vector supportedSemaphoreTypes; - - errNum = clGetPlatformIDs(1, &platform, NULL); - test_error_and_cleanup(errNum, CLEANUP, "Error: Failed to get platform\n"); - - errNum = - clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); - test_error_and_cleanup(errNum, CLEANUP, - "clGetDeviceIDs failed in returning of devices\n"); - - devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id)); - if (NULL == devices) - { - test_fail_and_cleanup(errNum, CLEANUP, - "Unable to allocate memory for devices\n"); - } - errNum = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices, devices, - NULL); - test_error_and_cleanup(errNum, CLEANUP, "Failed to get deviceID.\n"); +struct BufferTestBase : public VulkanTestBase +{ + BufferTestBase(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - contextProperties[1] = (cl_context_properties)platform; - log_info("Assigned contextproperties for platform\n"); - for (device_no = 0; device_no < num_devices; device_no++) + int test_buffer_common(bool use_fence) { - errNum = clGetDeviceInfo(devices[device_no], CL_DEVICE_UUID_KHR, - CL_UUID_SIZE_KHR, uuid, NULL); - test_error_and_cleanup(errNum, CLEANUP, "clGetDeviceInfo failed\n"); + int current_device = 0; + int device_count = 0; + int devices_prohibited = 0; + cl_int errNum = CL_SUCCESS; + size_t extensionSize = 0; + const size_t bufsize = BUFFERSIZE; + char buf[BUFFERSIZE]; + char *extensions = NULL; + clKernelWrapper verify_kernel; + clKernelWrapper verify_kernel2; + clKernelWrapper kernel[3] = { NULL, NULL, NULL }; + clKernelWrapper kernel2[3] = { NULL, NULL, NULL }; + const char *program_source_const[3] = { kernel_text_numbuffer_1, + kernel_text_numbuffer_2, + kernel_text_numbuffer_4 }; + const char *program_source_const_verify; + size_t program_source_length; + clCommandQueueWrapper cmd_queue1; + clCommandQueueWrapper cmd_queue2; + clCommandQueueWrapper cmd_queue3; + + clProgramWrapper program[3] = { NULL, NULL, NULL }; + clProgramWrapper program_verify, program_verify2; + clContextWrapper context2; + + uint32_t numBuffersList[] = { 1, 2, 4 }; + uint32_t bufferSizeList[] = { 4 * 1024, 64 * 1024, 2 * 1024 * 1024 }; + uint32_t bufferSizeListforOffset[] = { 256, 512, 1024 }; + + std::vector supportedSemaphoreTypes; if (!use_fence) { supportedSemaphoreTypes = - getSupportedInteropExternalSemaphoreHandleTypes( - devices[device_no], vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, + *vkDevice); } else { @@ -1678,176 +1639,247 @@ int test_buffer_common(cl_device_id device_, cl_context context_, VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_NONE); } - // If device does not support any semaphores, try the next one if (!use_fence && supportedSemaphoreTypes.empty()) { - continue; + return TEST_FAIL; } - errNum = - memcmp(uuid, vkDevice.getPhysicalDevice().getUUID(), VK_UUID_SIZE); - if (errNum == 0) + if (!use_fence && supportedSemaphoreTypes.empty()) { - break; + test_error_fail( + errNum, "No devices found that support OpenCL semaphores\n"); } - } - if (!use_fence && supportedSemaphoreTypes.empty()) - { - test_fail_and_cleanup( - errNum, CLEANUP, - "No devices found that support OpenCL semaphores\n"); - } - - if (device_no >= num_devices) - { - test_fail_and_cleanup(errNum, CLEANUP, - "OpenCL error: " - "No Vulkan-OpenCL Interop capable GPU found.\n"); - } - deviceId = devices[device_no]; - context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, - NULL, NULL, &errNum); - test_error_and_cleanup(errNum, CLEANUP, "error creating context\n"); - - log_info("Successfully created context !!!\n"); - - cmd_queue1 = clCreateCommandQueue(context, devices[device_no], 0, &errNum); - test_error_and_cleanup(errNum, CLEANUP, - "Error: Failed to create command queue!\n"); - - cmd_queue2 = clCreateCommandQueue(context, devices[device_no], 0, &errNum); - test_error_and_cleanup(errNum, CLEANUP, - "Error: Failed to create command queue!\n"); - - log_info("clCreateCommandQueue successful\n"); - for (int i = 0; i < 3; i++) - { - program_source_length = strlen(program_source_const[i]); - program[i] = - clCreateProgramWithSource(context, 1, &program_source_const[i], - &program_source_length, &errNum); - errNum = clBuildProgram(program[i], 0, NULL, NULL, NULL, NULL); - test_error_and_cleanup(errNum, CLEANUP, - "Error: Failed to build program \n"); - - // create the kernel - kernel[i] = clCreateKernel(program[i], "clUpdateBuffer", &errNum); - test_error_and_cleanup(errNum, CLEANUP, "clCreateKernel failed \n"); - } + deviceId = device; + cmd_queue1 = clCreateCommandQueue(context, device, 0, &errNum); + test_error(errNum, "Error: Failed to create command queue!\n"); - program_source_const_verify = kernel_text_verify; - program_source_length = strlen(program_source_const_verify); - program_verify = - clCreateProgramWithSource(context, 1, &program_source_const_verify, - &program_source_length, &errNum); - errNum = clBuildProgram(program_verify, 0, NULL, NULL, NULL, NULL); - test_error_and_cleanup(errNum, CLEANUP, - "Error: Failed to build program2\n"); - - verify_kernel = clCreateKernel(program_verify, "checkKernel", &errNum); - test_error_and_cleanup(errNum, CLEANUP, "clCreateKernel failed \n"); - - if (multiCtx) // different context guard - { - context2 = clCreateContextFromType( - contextProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &errNum); - test_error_and_cleanup(errNum, CLEANUP, "error creating context\n"); - - cmd_queue3 = - clCreateCommandQueue(context2, devices[device_no], 0, &errNum); - test_error_and_cleanup(errNum, CLEANUP, - "Error: Failed to create command queue!\n"); + cmd_queue2 = clCreateCommandQueue(context, device, 0, &errNum); + test_error(errNum, "Error: Failed to create command queue!\n"); + log_info("clCreateCommandQueue successful\n"); for (int i = 0; i < 3; i++) { program_source_length = strlen(program_source_const[i]); program[i] = - clCreateProgramWithSource(context2, 1, &program_source_const[i], + clCreateProgramWithSource(context, 1, &program_source_const[i], &program_source_length, &errNum); errNum = clBuildProgram(program[i], 0, NULL, NULL, NULL, NULL); - test_error_and_cleanup(errNum, CLEANUP, - "Error: Failed to build program \n"); + test_error(errNum, "Error: Failed to build program \n"); // create the kernel - kernel2[i] = clCreateKernel(program[i], "clUpdateBuffer", &errNum); - test_error_and_cleanup(errNum, CLEANUP, "clCreateKernel failed \n"); + kernel[i] = clCreateKernel(program[i], "clUpdateBuffer", &errNum); + test_error(errNum, "clCreateKernel failed \n"); } + + program_source_const_verify = kernel_text_verify; program_source_length = strlen(program_source_const_verify); program_verify = - clCreateProgramWithSource(context2, 1, &program_source_const_verify, + clCreateProgramWithSource(context, 1, &program_source_const_verify, &program_source_length, &errNum); errNum = clBuildProgram(program_verify, 0, NULL, NULL, NULL, NULL); - test_error_and_cleanup(errNum, CLEANUP, - "Error: Failed to build program2\n"); + test_error(errNum, "Error: Failed to build program2\n"); - verify_kernel2 = clCreateKernel(program_verify, "checkKernel", &errNum); - test_error_and_cleanup(errNum, CLEANUP, "clCreateKernel failed \n"); - } + verify_kernel = clCreateKernel(program_verify, "checkKernel", &errNum); + test_error(errNum, "clCreateKernel failed \n"); - // TODO: Add support for empty list if use_fence enabled - for (VulkanExternalSemaphoreHandleType semaphoreType : - supportedSemaphoreTypes) - { - for (size_t numBuffersIdx = 0; - numBuffersIdx < ARRAY_SIZE(numBuffersList); numBuffersIdx++) + if (multiCtx) // different context guard { - uint32_t numBuffers = numBuffersList[numBuffersIdx]; - log_info("Number of buffers: %d\n", numBuffers); - for (size_t sizeIdx = 0; sizeIdx < ARRAY_SIZE(bufferSizeList); - sizeIdx++) + context2 = + clCreateContext(0, 1, &device, nullptr, nullptr, &errNum); + test_error(errNum, "error creating context\n"); + + cmd_queue3 = clCreateCommandQueue(context2, device, 0, &errNum); + test_error(errNum, "Error: Failed to create command queue!\n"); + + for (int i = 0; i < 3; i++) { - uint32_t bufferSize = bufferSizeList[sizeIdx]; - log_info( - "&&&& RUNNING vulkan_opencl_buffer test for Buffer size: " - "%d\n", - bufferSize); - if (multiImport && !multiCtx) - { - errNum = run_test_with_multi_import_same_ctx( - context, cmd_queue1, kernel, verify_kernel, vkDevice, - numBuffers, bufferSize, use_fence, semaphoreType); - } - else if (multiImport && multiCtx) - { - errNum = run_test_with_multi_import_diff_ctx( - context, context2, cmd_queue1, cmd_queue3, kernel, - kernel2, verify_kernel, verify_kernel2, vkDevice, - numBuffers, bufferSize, use_fence, semaphoreType); - } - else if (numCQ == 2) - { - errNum = run_test_with_two_queue( - context, cmd_queue1, cmd_queue2, kernel, verify_kernel, - vkDevice, numBuffers + 1, bufferSize, use_fence, - semaphoreType); - } - else + program_source_length = strlen(program_source_const[i]); + program[i] = clCreateProgramWithSource( + context2, 1, &program_source_const[i], + &program_source_length, &errNum); + errNum = clBuildProgram(program[i], 0, NULL, NULL, NULL, NULL); + test_error(errNum, "Error: Failed to build program \n"); + + // create the kernel + kernel2[i] = + clCreateKernel(program[i], "clUpdateBuffer", &errNum); + test_error(errNum, "clCreateKernel failed \n"); + } + program_source_length = strlen(program_source_const_verify); + program_verify = clCreateProgramWithSource( + context2, 1, &program_source_const_verify, + &program_source_length, &errNum); + errNum = clBuildProgram(program_verify, 0, NULL, NULL, NULL, NULL); + test_error(errNum, "Error: Failed to build program2\n"); + + verify_kernel2 = + clCreateKernel(program_verify, "checkKernel", &errNum); + test_error(errNum, "clCreateKernel failed \n"); + } + + // TODO: Add support for empty list if use_fence enabled + for (VulkanExternalSemaphoreHandleType semaphoreType : + supportedSemaphoreTypes) + { + for (size_t numBuffersIdx = 0; + numBuffersIdx < ARRAY_SIZE(numBuffersList); numBuffersIdx++) + { + uint32_t numBuffers = numBuffersList[numBuffersIdx]; + log_info("Number of buffers: %d\n", numBuffers); + for (size_t sizeIdx = 0; sizeIdx < ARRAY_SIZE(bufferSizeList); + sizeIdx++) { - errNum = run_test_with_one_queue( - context, cmd_queue1, kernel, verify_kernel, vkDevice, - numBuffers, bufferSize, semaphoreType, use_fence); + uint32_t bufferSize = bufferSizeList[sizeIdx]; + log_info("&&&& RUNNING vulkan_opencl_buffer test " + "for Buffer size: " + "%d\n", + bufferSize); + if (multiImport && !multiCtx) + { + errNum = run_test_with_multi_import_same_ctx( + context, (cl_command_queue &)cmd_queue1, + (cl_kernel *)&kernel, (cl_kernel &)verify_kernel, + *vkDevice, numBuffers, bufferSize, use_fence, + semaphoreType); + } + else if (multiImport && multiCtx) + { + errNum = run_test_with_multi_import_diff_ctx( + context, (cl_context &)context2, + (cl_command_queue &)cmd_queue1, + (cl_command_queue &)cmd_queue3, + (cl_kernel *)&kernel, (cl_kernel *)&kernel2, + (cl_kernel &)verify_kernel, verify_kernel2, + *vkDevice, numBuffers, bufferSize, use_fence, + semaphoreType); + } + else if (numCQ == 2) + { + errNum = run_test_with_two_queue( + context, (cl_command_queue &)cmd_queue1, + (cl_command_queue &)cmd_queue2, + (cl_kernel *)&kernel, (cl_kernel &)verify_kernel, + *vkDevice, numBuffers + 1, bufferSize, use_fence, + semaphoreType); + } + else + { + errNum = run_test_with_one_queue( + context, (cl_command_queue &)cmd_queue1, + (cl_kernel *)&kernel, (cl_kernel &)verify_kernel, + *vkDevice, numBuffers, bufferSize, semaphoreType, + use_fence); + } + test_error(errNum, "func_name failed \n"); } - test_error_and_cleanup(errNum, CLEANUP, "func_name failed \n"); } } - } -CLEANUP: - for (int i = 0; i < 3; i++) - { - if (program[i]) clReleaseProgram(program[i]); - if (kernel[i]) clReleaseKernel(kernel[i]); + return errNum; } - if (cmd_queue1) clReleaseCommandQueue(cmd_queue1); - if (cmd_queue2) clReleaseCommandQueue(cmd_queue2); - if (cmd_queue3) clReleaseCommandQueue(cmd_queue3); - if (context) clReleaseContext(context); - if (context2) clReleaseContext(context2); +}; + +template struct BufferCommonBufferTest : public BufferTestBase +{ + BufferCommonBufferTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : BufferTestBase(device, context, queue, nelems) + {} + + cl_int Run() override { return test_buffer_common(use_fence); } +}; - if (devices) free(devices); - if (extensions) free(extensions); +} // anonymous namespace - return errNum; -} \ No newline at end of file +int test_buffer_single_queue(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, int num_elements) +{ + params_reset(); + log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +int test_buffer_multiple_queue(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, int num_elements) +{ + params_reset(); + numCQ = 2; + log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +int test_buffer_multiImport_sameCtx(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + params_reset(); + multiImport = true; + log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " + "IN SAME CONTEXT...... \n\n"); + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} +int test_buffer_multiImport_diffCtx(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + params_reset(); + multiImport = true; + multiCtx = true; + log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " + "IN DIFFERENT CONTEXT...... \n\n"); + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} +int test_buffer_single_queue_fence(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + params_reset(); + log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); + + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +int test_buffer_multiple_queue_fence(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + params_reset(); + numCQ = 2; + log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +int test_buffer_multiImport_sameCtx_fence(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + params_reset(); + multiImport = true; + log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " + "IN SAME CONTEXT...... \n\n"); + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +int test_buffer_multiImport_diffCtx_fence(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + params_reset(); + multiImport = true; + multiCtx = true; + log_info("RUNNING TEST WITH MULTIPLE DEVICE MEMORY IMPORT " + "IN DIFFERENT CONTEXT...... \n\n"); + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} diff --git a/test_conformance/vulkan/test_vulkan_interop_image.cpp b/test_conformance/vulkan/test_vulkan_interop_image.cpp index a3c8de993c..7808ef64dc 100644 --- a/test_conformance/vulkan/test_vulkan_interop_image.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_image.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2022 The Khronos Group Inc. +// 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. @@ -19,7 +19,11 @@ #include "harness/errorHelpers.h" #include "harness/os_helpers.h" #include -#include "deviceInfo.h" + +#include "vulkan_test_base.h" +#include "opencl_vulkan_wrapper.hpp" + +namespace { #define MAX_2D_IMAGES 5 #define MAX_2D_IMAGE_WIDTH 1024 @@ -46,14 +50,13 @@ ASSERT(0); \ } -namespace { struct Params { uint32_t numImage2DDescriptors; }; -} -static cl_uchar uuid[CL_UUID_SIZE_KHR]; -static cl_device_id deviceId = NULL; + +cl_uchar uuid[CL_UUID_SIZE_KHR]; +cl_device_id deviceId = NULL; size_t max_width = MAX_2D_IMAGE_WIDTH; size_t max_height = MAX_2D_IMAGE_HEIGHT; @@ -245,7 +248,7 @@ int run_test_with_two_queue( VulkanCommandPool vkCommandPool(vkDevice); VulkanCommandBuffer vkCopyCommandBuffer(vkDevice, vkCommandPool); VulkanCommandBuffer vkShaderCommandBuffer(vkDevice, vkCommandPool); - VulkanQueue &vkQueue = vkDevice.getQueue(); + VulkanQueue &vkQueue = vkDevice.getQueue(getVulkanQueueFamily()); VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); @@ -857,7 +860,7 @@ int run_test_with_one_queue( VulkanCommandPool vkCommandPool(vkDevice); VulkanCommandBuffer vkCopyCommandBuffer(vkDevice, vkCommandPool); VulkanCommandBuffer vkShaderCommandBuffer(vkDevice, vkCommandPool); - VulkanQueue &vkQueue = vkDevice.getQueue(); + VulkanQueue &vkQueue = vkDevice.getQueue(getVulkanQueueFamily()); VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); @@ -1352,262 +1355,185 @@ int run_test_with_one_queue( return err; } -int test_image_common(cl_device_id device_, cl_context context_, - cl_command_queue queue_, int numElements_) +struct ImageCommonTest : public VulkanTestBase { - int current_device = 0; - int device_count = 0; - int devices_prohibited = 0; - cl_int err = CL_SUCCESS; - cl_platform_id platform = NULL; - size_t extensionSize = 0; - cl_uint num_devices = 0; - cl_uint device_no = 0; - cl_device_id *devices; - char *extensions = NULL; - const char *program_source_const; - cl_command_queue cmd_queue1 = NULL; - cl_command_queue cmd_queue2 = NULL; - cl_context context = NULL; - const uint32_t num_kernels = ARRAY_SIZE(num2DImagesList) + 1; - // One kernel for Cross-CQ case - const uint32_t num_kernel_types = 3; - const char *kernel_source[num_kernels] = { kernel_text_numImage_1, - kernel_text_numImage_2, - kernel_text_numImage_4 }; - char source_1[4096]; - char source_2[4096]; - char source_3[4096]; - size_t program_source_length; - cl_program program[num_kernel_types] = { NULL }; - cl_kernel kernel_float[num_kernels] = { NULL }; - cl_kernel kernel_signed[num_kernels] = { NULL }; - cl_kernel kernel_unsigned[num_kernels] = { NULL }; - cl_mem external_mem_image1; - cl_mem external_mem_image2; - std::vector supportedSemaphoreTypes; - - VulkanDevice vkDevice; - - cl_context_properties contextProperties[] = { CL_CONTEXT_PLATFORM, 0, 0 }; - // get the platform ID - err = clGetPlatformIDs(1, &platform, NULL); - test_error_and_cleanup(err, CLEANUP, "Error: Failed to get platform\n"); - - err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); - test_error_and_cleanup( - err, CLEANUP, "clGetDeviceIDs failed in returning no. of devices\n"); - - devices = (cl_device_id *)malloc(num_devices * sizeof(cl_device_id)); - if (NULL == devices) - { - test_fail_and_cleanup(err, CLEANUP, - "Unable to allocate memory for devices\n"); - } - err = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices, devices, - NULL); - test_error_and_cleanup(err, CLEANUP, "Failed to get deviceID.\n"); + ImageCommonTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - contextProperties[1] = (cl_context_properties)platform; - log_info("Assigned contextproperties for platform\n"); - for (device_no = 0; device_no < num_devices; device_no++) + int test_image_common() { - err = clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS, 0, NULL, - &extensionSize); - if (CL_SUCCESS != err) - { - print_error( - err, - "Error in clGetDeviceInfo for getting device_extension size\n"); - goto CLEANUP; - } - extensions = (char *)malloc(extensionSize); - if (NULL == extensions) - { - err = CL_OUT_OF_HOST_MEMORY; - print_error(err, "Unable to allocate memory for extensions\n"); - goto CLEANUP; - } - err = clGetDeviceInfo(devices[device_no], CL_DEVICE_EXTENSIONS, - extensionSize, extensions, NULL); - if (CL_SUCCESS != err) - { - print_error( - err, "Error in clGetDeviceInfo for getting device_extension\n"); - goto CLEANUP; - } - err = clGetDeviceInfo(devices[device_no], CL_DEVICE_UUID_KHR, - CL_UUID_SIZE_KHR, uuid, NULL); - test_error_and_cleanup(err, CLEANUP, - "clGetDeviceInfo failed with error"); + cl_int err = CL_SUCCESS; + clCommandQueueWrapper cmd_queue1; + clCommandQueueWrapper cmd_queue2; + const uint32_t num_kernels = ARRAY_SIZE(num2DImagesList) + 1; + // One kernel for Cross-CQ case + const uint32_t num_kernel_types = 3; + const char *kernel_source[num_kernels] = { kernel_text_numImage_1, + kernel_text_numImage_2, + kernel_text_numImage_4 }; + char source_1[4096]; + char source_2[4096]; + char source_3[4096]; + size_t program_source_length; + clProgramWrapper program[num_kernel_types] = { NULL }; + clKernelWrapper kernel_float[num_kernels] = { NULL }; + clKernelWrapper kernel_signed[num_kernels] = { NULL }; + clKernelWrapper kernel_unsigned[num_kernels] = { NULL }; + clMemWrapper external_mem_image1; + clMemWrapper external_mem_image2; + std::vector supportedSemaphoreTypes; supportedSemaphoreTypes = - getSupportedInteropExternalSemaphoreHandleTypes(devices[device_no], - vkDevice); + getSupportedInteropExternalSemaphoreHandleTypes(device, *vkDevice); // If device does not support any semaphores, try the next one if (supportedSemaphoreTypes.empty()) { - continue; + log_info("Device does not support any semaphores!\n"); + return TEST_SKIPPED_ITSELF; } - err = - memcmp(uuid, vkDevice.getPhysicalDevice().getUUID(), VK_UUID_SIZE); - if (err == 0) - { - break; - } - } - - if (supportedSemaphoreTypes.empty()) - { - test_fail_and_cleanup( - err, CLEANUP, "No devices found that support OpenCL semaphores\n"); - } + deviceId = device; - if (device_no >= num_devices) - { - test_fail_and_cleanup(err, CLEANUP, - "OpenCL error:" - "No Vulkan-OpenCL Interop capable GPU found.\n"); - } - deviceId = devices[device_no]; - err = setMaxImageDimensions(deviceId, max_width, max_height); - test_error_and_cleanup(err, CLEANUP, "error setting max image dimensions"); + err = setMaxImageDimensions(deviceId, max_width, max_height); + test_error(err, "error setting max image dimensions"); - log_info("Set max_width to %zu and max_height to %zu\n", max_width, - max_height); - context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, - NULL, NULL, &err); - test_error_and_cleanup(err, CLEANUP, "error creating context"); + log_info("Set max_width to %zu and max_height to %zu\n", max_width, + max_height); - log_info("Successfully created context !!!\n"); + log_info("Successfully created context !!!\n"); - cmd_queue1 = clCreateCommandQueue(context, devices[device_no], 0, &err); - test_error_and_cleanup(err, CLEANUP, - "Error: Failed to create command queue!\n"); + cmd_queue1 = clCreateCommandQueue(context, deviceId, 0, &err); + test_error(err, "Error: Failed to create command queue!\n"); - log_info("clCreateCommandQueue successfull \n"); + log_info("clCreateCommandQueue successfull \n"); - cmd_queue2 = clCreateCommandQueue(context, devices[device_no], 0, &err); - test_error_and_cleanup(err, CLEANUP, - "Error: Failed to create command queue!\n"); + cmd_queue2 = clCreateCommandQueue(context, deviceId, 0, &err); + test_error(err, "Error: Failed to create command queue!\n"); - log_info("clCreateCommandQueue2 successful \n"); + log_info("clCreateCommandQueue2 successful \n"); - for (int i = 0; i < num_kernels; i++) - { - switch (i) - { - case 0: - sprintf(source_1, kernel_source[i], "float4", "f", "float4", - "f", "f", "f"); - sprintf(source_2, kernel_source[i], "int4", "i", "int4", "i", - "i", "i"); - sprintf(source_3, kernel_source[i], "uint4", "ui", "uint4", - "ui", "ui", "ui"); - break; - case 1: - sprintf(source_1, kernel_source[i], "float4", "f", "float4", - "f", "float4", "f", "float4", "f", "f", "f", "f", "f"); - sprintf(source_2, kernel_source[i], "int4", "i", "int4", "i", - "int4", "i", "int4", "i", "i", "i", "i", "i"); - sprintf(source_3, kernel_source[i], "uint4", "ui", "uint4", - "ui", "uint4", "ui", "uint4", "ui", "ui", "ui", "ui", - "ui"); - break; - case 2: - sprintf(source_1, kernel_source[i], "float4", "f", "float4", - "f", "float4", "f", "float4", "f", "float4", "f", - "float4", "f", "float4", "f", "float4", "f", "f", "f", - "f", "f", "f", "f", "f", "f"); - sprintf(source_2, kernel_source[i], "int4", "i", "int4", "i", - "int4", "i", "int4", "i", "int4", "i", "int4", "i", - "int4", "i", "int4", "i", "i", "i", "i", "i", "i", "i", - "i", "i"); - sprintf(source_3, kernel_source[i], "uint4", "ui", "uint4", - "ui", "uint4", "ui", "uint4", "ui", "uint4", "ui", - "uint4", "ui", "uint4", "ui", "uint4", "ui", "ui", "ui", - "ui", "ui", "ui", "ui", "ui", "ui"); - break; - case 3: - // Addtional case for creating updateKernelCQ2 which takes two - // images - sprintf(source_1, kernel_source[1], "float4", "f", "float4", - "f", "float4", "f", "float4", "f", "f", "f", "f", "f"); - sprintf(source_2, kernel_source[1], "int4", "i", "int4", "i", - "int4", "i", "int4", "i", "i", "i", "i", "i"); - sprintf(source_3, kernel_source[1], "uint4", "ui", "uint4", - "ui", "uint4", "ui", "uint4", "ui", "ui", "ui", "ui", - "ui"); - break; - } - const char *sourceTexts[num_kernel_types] = { source_1, source_2, - source_3 }; - for (int k = 0; k < num_kernel_types; k++) + for (int i = 0; i < num_kernels; i++) { - program_source_length = strlen(sourceTexts[k]); - program[k] = clCreateProgramWithSource( - context, 1, &sourceTexts[k], &program_source_length, &err); - err |= clBuildProgram(program[k], 0, NULL, NULL, NULL, NULL); - } - test_error_and_cleanup(err, CLEANUP, "Error: Failed to build program"); + switch (i) + { + case 0: + sprintf(source_1, kernel_source[i], "float4", "f", "float4", + "f", "f", "f"); + sprintf(source_2, kernel_source[i], "int4", "i", "int4", + "i", "i", "i"); + sprintf(source_3, kernel_source[i], "uint4", "ui", "uint4", + "ui", "ui", "ui"); + break; + case 1: + sprintf(source_1, kernel_source[i], "float4", "f", "float4", + "f", "float4", "f", "float4", "f", "f", "f", "f", + "f"); + sprintf(source_2, kernel_source[i], "int4", "i", "int4", + "i", "int4", "i", "int4", "i", "i", "i", "i", "i"); + sprintf(source_3, kernel_source[i], "uint4", "ui", "uint4", + "ui", "uint4", "ui", "uint4", "ui", "ui", "ui", + "ui", "ui"); + break; + case 2: + sprintf(source_1, kernel_source[i], "float4", "f", "float4", + "f", "float4", "f", "float4", "f", "float4", "f", + "float4", "f", "float4", "f", "float4", "f", "f", + "f", "f", "f", "f", "f", "f", "f"); + sprintf(source_2, kernel_source[i], "int4", "i", "int4", + "i", "int4", "i", "int4", "i", "int4", "i", "int4", + "i", "int4", "i", "int4", "i", "i", "i", "i", "i", + "i", "i", "i", "i"); + sprintf(source_3, kernel_source[i], "uint4", "ui", "uint4", + "ui", "uint4", "ui", "uint4", "ui", "uint4", "ui", + "uint4", "ui", "uint4", "ui", "uint4", "ui", "ui", + "ui", "ui", "ui", "ui", "ui", "ui", "ui"); + break; + case 3: + // Addtional case for creating updateKernelCQ2 which takes + // two images + sprintf(source_1, kernel_source[1], "float4", "f", "float4", + "f", "float4", "f", "float4", "f", "f", "f", "f", + "f"); + sprintf(source_2, kernel_source[1], "int4", "i", "int4", + "i", "int4", "i", "int4", "i", "i", "i", "i", "i"); + sprintf(source_3, kernel_source[1], "uint4", "ui", "uint4", + "ui", "uint4", "ui", "uint4", "ui", "ui", "ui", + "ui", "ui"); + break; + } + const char *sourceTexts[num_kernel_types] = { source_1, source_2, + source_3 }; + for (int k = 0; k < num_kernel_types; k++) + { + program_source_length = strlen(sourceTexts[k]); + program[k] = clCreateProgramWithSource( + context, 1, &sourceTexts[k], &program_source_length, &err); + err |= clBuildProgram(program[k], 0, NULL, NULL, NULL, NULL); + } + test_error(err, "Error: Failed to build program"); - // create the kernel - kernel_float[i] = clCreateKernel(program[0], "image2DKernel", &err); - test_error_and_cleanup(err, CLEANUP, "clCreateKernel failed"); + // create the kernel + kernel_float[i] = clCreateKernel(program[0], "image2DKernel", &err); + test_error(err, "clCreateKernel failed"); - kernel_signed[i] = clCreateKernel(program[1], "image2DKernel", &err); - test_error_and_cleanup(err, CLEANUP, "clCreateKernel failed"); + kernel_signed[i] = + clCreateKernel(program[1], "image2DKernel", &err); + test_error(err, "clCreateKernel failed"); - kernel_unsigned[i] = clCreateKernel(program[2], "image2DKernel", &err); - test_error_and_cleanup(err, CLEANUP, "clCreateKernel failed "); - } - for (VulkanExternalSemaphoreHandleType externalSemaphoreType : - supportedSemaphoreTypes) - { - if (numCQ == 2) - { - err = run_test_with_two_queue( - context, cmd_queue1, cmd_queue2, kernel_unsigned, kernel_signed, - kernel_float, vkDevice, externalSemaphoreType); - } - else - { - err = run_test_with_one_queue(context, cmd_queue1, kernel_unsigned, - kernel_signed, kernel_float, vkDevice, - externalSemaphoreType); - } - } -CLEANUP: - for (int i = 0; i < num_kernels; i++) - { - if (kernel_float[i]) - { - clReleaseKernel(kernel_float[i]); - } - if (kernel_unsigned[i]) - { - clReleaseKernel(kernel_unsigned[i]); + kernel_unsigned[i] = + clCreateKernel(program[2], "image2DKernel", &err); + test_error(err, "clCreateKernel failed "); } - if (kernel_signed[i]) + for (VulkanExternalSemaphoreHandleType externalSemaphoreType : + supportedSemaphoreTypes) { - clReleaseKernel(kernel_signed[i]); - } - } - for (int i = 0; i < num_kernel_types; i++) - { - if (program[i]) - { - clReleaseProgram(program[i]); + if (numCQ == 2) + { + err = run_test_with_two_queue( + context, (cl_command_queue &)cmd_queue1, + (cl_command_queue &)cmd_queue2, + (cl_kernel *)kernel_unsigned, (cl_kernel *)kernel_signed, + (cl_kernel *)kernel_float, *vkDevice, + externalSemaphoreType); + } + else + { + err = run_test_with_one_queue( + context, (cl_command_queue &)cmd_queue1, + (cl_kernel *)kernel_unsigned, (cl_kernel *)kernel_signed, + (cl_kernel *)kernel_float, *vkDevice, + externalSemaphoreType); + } + test_error(err, "func_name failed \n"); } + + return err; } - if (cmd_queue1) clReleaseCommandQueue(cmd_queue1); - if (cmd_queue2) clReleaseCommandQueue(cmd_queue2); - if (context) clReleaseContext(context); - if (extensions) free(extensions); - if (devices) free(devices); + cl_int Run() override { return test_image_common(); } +}; - return err; -} \ No newline at end of file +} // anonymous namespace + +int test_image_single_queue(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, int num_elements) +{ + params_reset(); + log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); + + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); +} + +int test_image_multiple_queue(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, int num_elements) +{ + params_reset(); + numCQ = 2; + log_info("RUNNING TEST WITH TWO QUEUE...... \n\n"); + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); +} diff --git a/test_conformance/vulkan/test_vulkan_platform_device_info.cpp b/test_conformance/vulkan/test_vulkan_platform_device_info.cpp index 1c25c0f58a..eaf963c9f8 100644 --- a/test_conformance/vulkan/test_vulkan_platform_device_info.cpp +++ b/test_conformance/vulkan/test_vulkan_platform_device_info.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2022 The Khronos Group Inc. +// 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. @@ -22,6 +22,10 @@ #include #include +#include "vulkan_test_base.h" + +namespace { + typedef struct { cl_uint info; @@ -29,183 +33,216 @@ typedef struct } _info; _info platform_info_table[] = { -#define STRING(x) \ +#define PLATFORM_INFO_STRING(x) \ { \ x, #x \ } - STRING(CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR), - STRING(CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), - STRING(CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR) -#undef STRING + PLATFORM_INFO_STRING(CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR), + PLATFORM_INFO_STRING(CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), + PLATFORM_INFO_STRING(CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR) +#undef PLATFORM_INFO_STRING }; _info device_info_table[] = { -#define STRING(x) \ +#define DEVICE_INFO_STRING(x) \ { \ x, #x \ } - STRING(CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR), - STRING(CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), - STRING(CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR) -#undef STRING + DEVICE_INFO_STRING(CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR), + DEVICE_INFO_STRING(CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR), + DEVICE_INFO_STRING(CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR) +#undef DEVICE_INFO_STRING }; -int test_platform_info(cl_device_id deviceID, cl_context _context, - cl_command_queue _queue, int num_elements) +struct PlatformInfoTest : public VulkanTestBase { - cl_uint i; - cl_platform_id platform = getPlatformFromDevice(deviceID); - cl_int errNum; - cl_uint *handle_type; - size_t handle_type_size = 0; - cl_uint num_handles = 0; - cl_bool external_mem_extn_available = - is_platform_extension_available(platform, "cl_khr_external_semaphore"); - cl_bool external_sema_extn_available = - is_platform_extension_available(platform, "cl_khr_external_memory"); - cl_bool supports_atleast_one_sema_query = false; - - if (!external_mem_extn_available && !external_sema_extn_available) - { - log_info("Platform does not support 'cl_khr_external_semaphore' " - "and 'cl_khr_external_memory'. Skipping the test.\n"); - return TEST_SKIPPED_ITSELF; - } + PlatformInfoTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - log_info("Platform (id %lu) info:\n", (unsigned long)platform); - - for (i = 0; - i < sizeof(platform_info_table) / sizeof(platform_info_table[0]); i++) + cl_int Run() override { - errNum = clGetPlatformInfo(platform, platform_info_table[i].info, 0, - NULL, &handle_type_size); - test_error(errNum, "clGetPlatformInfo failed"); + cl_uint i; + cl_platform_id platform = getPlatformFromDevice(device); + cl_int errNum; + cl_uint *handle_type; + size_t handle_type_size = 0; + cl_uint num_handles = 0; + cl_bool external_mem_extn_available = is_platform_extension_available( + platform, "cl_khr_external_semaphore"); + cl_bool external_sema_extn_available = + is_platform_extension_available(platform, "cl_khr_external_memory"); + cl_bool supports_atleast_one_sema_query = false; + + if (!external_mem_extn_available && !external_sema_extn_available) + { + log_info("Platform does not support 'cl_khr_external_semaphore' " + "and 'cl_khr_external_memory'. Skipping the test.\n"); + return TEST_SKIPPED_ITSELF; + } - if (handle_type_size == 0) + log_info("Platform (id %lu) info:\n", (unsigned long)platform); + + for (i = 0; + i < sizeof(platform_info_table) / sizeof(platform_info_table[0]); + i++) { - if (platform_info_table[i].info - == CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR - && external_mem_extn_available) + errNum = clGetPlatformInfo(platform, platform_info_table[i].info, 0, + NULL, &handle_type_size); + test_error(errNum, "clGetPlatformInfo failed"); + + if (handle_type_size == 0) { - test_fail( - "External memory import handle types should be reported if " - "cl_khr_external_memory is available.\n"); + if (platform_info_table[i].info + == CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR + && external_mem_extn_available) + { + test_fail("External memory import handle types should be " + "reported if " + "cl_khr_external_memory is available.\n"); + } + log_info("%s not supported. Skipping the query.\n", + platform_info_table[i].name); + continue; } - log_info("%s not supported. Skipping the query.\n", - platform_info_table[i].name); - continue; - } - if ((platform_info_table[i].info - == CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) - || (platform_info_table[i].info - == CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) - { - supports_atleast_one_sema_query = true; - } + if ((platform_info_table[i].info + == CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) + || (platform_info_table[i].info + == CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) + { + supports_atleast_one_sema_query = true; + } - num_handles = handle_type_size / sizeof(cl_uint); - handle_type = (cl_uint *)malloc(handle_type_size); - errNum = clGetPlatformInfo(platform, platform_info_table[i].info, - handle_type_size, handle_type, NULL); - test_error(errNum, "clGetPlatformInfo failed"); + num_handles = handle_type_size / sizeof(cl_uint); + handle_type = (cl_uint *)malloc(handle_type_size); + errNum = clGetPlatformInfo(platform, platform_info_table[i].info, + handle_type_size, handle_type, NULL); + test_error(errNum, "clGetPlatformInfo failed"); - log_info("%s: \n", platform_info_table[i].name); - while (num_handles--) - { - log_info("%x \n", handle_type[num_handles]); + log_info("%s: \n", platform_info_table[i].name); + while (num_handles--) + { + log_info("%x \n", handle_type[num_handles]); + } + if (handle_type) + { + free(handle_type); + } } - if (handle_type) + + if (external_sema_extn_available && !supports_atleast_one_sema_query) { - free(handle_type); + log_info( + "External semaphore import/export or both should be supported " + "if cl_khr_external_semaphore is available.\n"); + return TEST_FAIL; } - } - if (external_sema_extn_available && !supports_atleast_one_sema_query) - { - log_info("External semaphore import/export or both should be supported " - "if cl_khr_external_semaphore is available.\n"); - return TEST_FAIL; + return TEST_PASS; } +}; - return TEST_PASS; -} - -int test_device_info(cl_device_id deviceID, cl_context _context, - cl_command_queue _queue, int num_elements) +struct DeviceInfoTest : public VulkanTestBase { - cl_uint j; - cl_uint *handle_type; - size_t handle_type_size = 0; - cl_uint num_handles = 0; - cl_int errNum = CL_SUCCESS; - cl_bool external_mem_extn_available = - is_extension_available(deviceID, "cl_khr_external_memory"); - cl_bool external_sema_extn_available = - is_extension_available(deviceID, "cl_khr_external_semaphore"); - cl_bool supports_atleast_one_sema_query = false; - - if (!external_mem_extn_available && !external_sema_extn_available) - { - log_info("Device does not support 'cl_khr_external_semaphore' " - "and 'cl_khr_external_memory'. Skipping the test.\n"); - return TEST_SKIPPED_ITSELF; - } + DeviceInfoTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : VulkanTestBase(device, context, queue, nelems) + {} - for (j = 0; j < sizeof(device_info_table) / sizeof(device_info_table[0]); - j++) + cl_int Run() override { - errNum = clGetDeviceInfo(deviceID, device_info_table[j].info, 0, NULL, - &handle_type_size); - test_error(errNum, "clGetDeviceInfo failed"); + cl_uint j; + cl_uint *handle_type; + size_t handle_type_size = 0; + cl_uint num_handles = 0; + cl_int errNum = CL_SUCCESS; + cl_bool external_mem_extn_available = + is_extension_available(device, "cl_khr_external_memory"); + cl_bool external_sema_extn_available = + is_extension_available(device, "cl_khr_external_semaphore"); + cl_bool supports_atleast_one_sema_query = false; + + if (!external_mem_extn_available && !external_sema_extn_available) + { + log_info("Device does not support 'cl_khr_external_semaphore' " + "and 'cl_khr_external_memory'. Skipping the test.\n"); + return TEST_SKIPPED_ITSELF; + } - if (handle_type_size == 0) + for (j = 0; + j < sizeof(device_info_table) / sizeof(device_info_table[0]); j++) { - if (device_info_table[j].info - == CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR - && external_mem_extn_available) + errNum = clGetDeviceInfo(device, device_info_table[j].info, 0, NULL, + &handle_type_size); + test_error(errNum, "clGetDeviceInfo failed"); + + if (handle_type_size == 0) { - test_fail( - "External memory import handle types should be reported if " - "cl_khr_external_memory is available.\n"); + if (device_info_table[j].info + == CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR + && external_mem_extn_available) + { + test_fail("External memory import handle types should be " + "reported if " + "cl_khr_external_memory is available.\n"); + } + log_info("%s not supported. Skipping the query.\n", + device_info_table[j].name); + continue; } - log_info("%s not supported. Skipping the query.\n", - device_info_table[j].name); - continue; - } - if ((device_info_table[j].info - == CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) - || (device_info_table[j].info - == CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) - { - supports_atleast_one_sema_query = true; - } + if ((device_info_table[j].info + == CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) + || (device_info_table[j].info + == CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) + { + supports_atleast_one_sema_query = true; + } - num_handles = handle_type_size / sizeof(cl_uint); - handle_type = (cl_uint *)malloc(handle_type_size); + num_handles = handle_type_size / sizeof(cl_uint); + handle_type = (cl_uint *)malloc(handle_type_size); - errNum = clGetDeviceInfo(deviceID, device_info_table[j].info, - handle_type_size, handle_type, NULL); - test_error(errNum, "clGetDeviceInfo failed"); + errNum = clGetDeviceInfo(device, device_info_table[j].info, + handle_type_size, handle_type, NULL); + test_error(errNum, "clGetDeviceInfo failed"); - log_info("%s: \n", device_info_table[j].name); - while (num_handles--) - { - log_info("%x \n", handle_type[num_handles]); + log_info("%s: \n", device_info_table[j].name); + while (num_handles--) + { + log_info("%x \n", handle_type[num_handles]); + } + if (handle_type) + { + free(handle_type); + } } - if (handle_type) + + if (external_sema_extn_available && !supports_atleast_one_sema_query) { - free(handle_type); + log_info( + "External semaphore import/export or both should be supported " + "if cl_khr_external_semaphore is available.\n"); + return TEST_FAIL; } - } - if (external_sema_extn_available && !supports_atleast_one_sema_query) - { - log_info("External semaphore import/export or both should be supported " - "if cl_khr_external_semaphore is available.\n"); - return TEST_FAIL; + return TEST_PASS; } +}; + +} // anonymous namespace + +int test_platform_info(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, int num_elements) +{ + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); +} - return TEST_PASS; +int test_device_info(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, int num_elements) +{ + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); } diff --git a/test_conformance/vulkan/vulkan_test_base.h b/test_conformance/vulkan/vulkan_test_base.h new file mode 100644 index 0000000000..d4cfa68446 --- /dev/null +++ b/test_conformance/vulkan/vulkan_test_base.h @@ -0,0 +1,129 @@ +// +// 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. + +#ifndef CL_VULKAN_TEST_BASE_H +#define CL_VULKAN_TEST_BASE_H + +#include + +#include +#include + +#include "vulkan_interop_common.hpp" + +#include "harness/deviceInfo.h" +#include "harness/testHarness.h" +#include "harness/typeWrappers.h" + +inline void params_reset() +{ + numCQ = 1; + multiImport = false; + multiCtx = false; +} + +struct VulkanTestBase +{ + VulkanTestBase(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : device(device), context(context), num_elems(nelems) + { + vkDevice.reset( + new VulkanDevice(getAssociatedVulkanPhysicalDevice(device))); + + if (!(is_extension_available(device, "cl_khr_external_memory") + && is_extension_available(device, "cl_khr_external_semaphore"))) + { + log_info("Device does not support cl_khr_external_memory " + "or cl_khr_external_semaphore\n"); + log_info(" TEST SKIPPED\n"); + throw std::runtime_error("VulkanTestBase not supported"); + } + + cl_platform_id platform; + cl_int error = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, + sizeof(cl_platform_id), &platform, NULL); + if (error != CL_SUCCESS) + throw std::runtime_error( + "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); + + + // verify whether selected device is one of the type CL_DEVICE_TYPE_GPU + cl_uint num_devices = 0; + error = + clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &num_devices); + if (CL_SUCCESS != error) + throw std::runtime_error( + "clGetDeviceIDs failed in returning of devices"); + + std::vector devices(num_devices); + error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, num_devices, + devices.data(), NULL); + + bool found_gpu_match = false; + for (cl_uint i = 0; i < num_devices; i++) + if (devices[i] == device) + { + found_gpu_match = true; + break; + } + + if (!found_gpu_match) + throw std::runtime_error( + "Vulkan tests can only run on a GPU device."); + + init_cl_vk_ext(platform, 1, &device); + } + + virtual cl_int Run() = 0; + +protected: + cl_device_id device = nullptr; + cl_context context = nullptr; + clCommandQueueWrapper queue = nullptr; + cl_int num_elems = 0; + std::unique_ptr vkDevice; +}; + +template +int MakeAndRunTest(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) +{ + if (!checkVkSupport()) + { + log_info("Vulkan supported GPU not found \n"); + log_info("TEST SKIPPED \n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int status = TEST_PASS; + try + { + // moved from original test - do we want to stick to that ? + cl_int numElementsToUse = 1024; + + auto test_fixture = + T(device, context, queue, /*nelems*/ numElementsToUse); + status = test_fixture.Run(); + } catch (const std::runtime_error &e) + { + log_error("%s", e.what()); + return TEST_FAIL; + } + + return status; +} + +#endif // CL_VULKAN_TEST_BASE_H From 74cb5cd60875168fdf1d203fd0f738c9b36e600c Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Fri, 10 Jan 2025 04:55:37 +0000 Subject: [PATCH 26/39] [NFC] Add .gitignore file (#2216) Introduce a `.gitignore` file to the repository matching a build folder `[Bb]uild/` pattern. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..e939c62808 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Build dir +[Bb]uild/ From 4fd42150bcf6140d7dfa233eb7be924f02baeeac Mon Sep 17 00:00:00 2001 From: Ben Ashbaugh Date: Tue, 14 Jan 2025 09:05:47 -0800 Subject: [PATCH 27/39] add testing for SPIR-V 1.5 (#2208) fixes #2140 Adds testing for SPIR-V 1.5 features: * Adds a test for bitcasts between pointers and vectors of integers. Note, SPIR-V 1.5 only supports bitcasts to vectors of two 32-bit integers. Therefore, the SPIR-V 1.5 behavior will only be exercised on devices with 64-bit pointers. The test will run on devices with 32-bit pointers, but will instead bitcast to scalars. * Adds a test for OpGroupNonUniformBroadcast with a dynamic index. Note, this is not an exhaustive test, and only unsigned integer types are tested, to avoid duplicating testing for cl_khr_subgroup_ballot. --- test_conformance/spirv_new/CMakeLists.txt | 1 + ...n_uniform_broadcast_dynamic_index.spvasm32 | 37 ++++ ...n_uniform_broadcast_dynamic_index.spvasm64 | 41 +++++ .../spirv_asm/spv1.5/ptr_bitcast.spvasm32 | 22 +++ .../spirv_asm/spv1.5/ptr_bitcast.spvasm64 | 27 +++ test_conformance/spirv_new/test_spirv_15.cpp | 162 ++++++++++++++++++ 6 files changed, 290 insertions(+) create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm32 create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm64 create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm32 create mode 100644 test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm64 create mode 100644 test_conformance/spirv_new/test_spirv_15.cpp diff --git a/test_conformance/spirv_new/CMakeLists.txt b/test_conformance/spirv_new/CMakeLists.txt index 67faecf895..828d417f26 100644 --- a/test_conformance/spirv_new/CMakeLists.txt +++ b/test_conformance/spirv_new/CMakeLists.txt @@ -28,6 +28,7 @@ set(${MODULE_NAME}_SOURCES test_op_vector_insert.cpp test_op_vector_times_scalar.cpp test_spirv_14.cpp + test_spirv_15.cpp ) set(TEST_HARNESS_SOURCES diff --git a/test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm32 new file mode 100644 index 0000000000..66ed035099 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm32 @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.5 +; Reference: +; kernel void non_uniform_broadcast_dynamic_index_test(global uint* dst_base) { +; uint id = get_global_id(0); +; uint index = get_group_id(0); +; uint value = sub_group_non_uniform_broadcast(id, index); +; dst_base[id] = value; +; } + OpCapability Addresses + OpCapability Kernel + OpCapability GroupNonUniformBallot + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "non_uniform_broadcast_dynamic_index_test" %pglobalid %pgroupid + OpDecorate %pglobalid BuiltIn GlobalInvocationId + OpDecorate %pgroupid BuiltIn WorkgroupId + %uint = OpTypeInt 32 0 + %sg_scope = OpConstant %uint 3 + %uint3 = OpTypeVector %uint 3 + %void = OpTypeVoid +%iptr_uint3 = OpTypePointer Input %uint3 + %gptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %gptr_uint + %pglobalid = OpVariable %iptr_uint3 Input + %pgroupid = OpVariable %iptr_uint3 Input + %kernel = OpFunction %void None %kernel_sig + %dst_base = OpFunctionParameter %gptr_uint + %entry = OpLabel + %globalid = OpLoad %uint3 %pglobalid Aligned 32 + %id = OpCompositeExtract %uint %globalid 0 + %groupid = OpLoad %uint3 %pgroupid Aligned 32 + %index = OpCompositeExtract %uint %groupid 0 + %value = OpGroupNonUniformBroadcast %uint %sg_scope %id %index + %dst = OpInBoundsPtrAccessChain %gptr_uint %dst_base %id + OpStore %dst %value + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm64 new file mode 100644 index 0000000000..f97d50d927 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.5/non_uniform_broadcast_dynamic_index.spvasm64 @@ -0,0 +1,41 @@ +; SPIR-V +; Version: 1.5 +; Reference: +; kernel void non_uniform_broadcast_dynamic_index_test(global uint* dst_base) { +; uint id = get_global_id(0); +; uint index = get_group_id(0); +; uint value = sub_group_non_uniform_broadcast(id, index); +; dst_base[id] = value; +; } + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpCapability GroupNonUniformBallot + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "non_uniform_broadcast_dynamic_index_test" %pglobalid %pgroupid + OpDecorate %pglobalid BuiltIn GlobalInvocationId + OpDecorate %pgroupid BuiltIn WorkgroupId + %uint = OpTypeInt 32 0 + %sg_scope = OpConstant %uint 3 + %ulong = OpTypeInt 64 0 + %ulong3 = OpTypeVector %ulong 3 + %void = OpTypeVoid +%iptr_ulong3 = OpTypePointer Input %ulong3 + %gptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %gptr_uint + %pglobalid = OpVariable %iptr_ulong3 Input + %pgroupid = OpVariable %iptr_ulong3 Input + %kernel = OpFunction %void None %kernel_sig + %dst_base = OpFunctionParameter %gptr_uint + %entry = OpLabel + %globalid = OpLoad %ulong3 %pglobalid Aligned 32 + %globalid0 = OpCompositeExtract %ulong %globalid 0 + %id = OpUConvert %uint %globalid0 + %groupid = OpLoad %ulong3 %pgroupid Aligned 32 + %groupid0 = OpCompositeExtract %ulong %groupid 0 + %index = OpUConvert %uint %groupid0 + %value = OpGroupNonUniformBroadcast %uint %sg_scope %id %index + %dst = OpInBoundsPtrAccessChain %gptr_uint %dst_base %globalid0 + OpStore %dst %value + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm32 new file mode 100644 index 0000000000..3707c432f9 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm32 @@ -0,0 +1,22 @@ +; SPIR-V +; Version: 1.5 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "ptr_bitcast_test" + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %pptr_int = OpTypePointer Function %uint + %gptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %gptr_uint %gptr_uint + %uint_42 = OpConstant %uint 42 + %kernel = OpFunction %void None %kernel_sig + %dst_uint0 = OpFunctionParameter %gptr_uint + %dst_uint1 = OpFunctionParameter %gptr_uint + %entry = OpLabel + %pvalue = OpVariable %pptr_int Function %uint_42 + %uint_ptr = OpBitcast %uint %pvalue + OpStore %dst_uint0 %uint_ptr + OpStore %dst_uint1 %uint_ptr + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm64 new file mode 100644 index 0000000000..76f38c4100 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.5/ptr_bitcast.spvasm64 @@ -0,0 +1,27 @@ +; SPIR-V +; Version: 1.5 + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "ptr_bitcast_test" + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint2 = OpTypeVector %uint 2 + %void = OpTypeVoid + %pptr_int = OpTypePointer Function %uint + %gptr_ulong = OpTypePointer CrossWorkgroup %ulong + %gptr_uint2 = OpTypePointer CrossWorkgroup %uint2 + %kernel_sig = OpTypeFunction %void %gptr_ulong %gptr_uint2 + %uint_42 = OpConstant %uint 42 + %kernel = OpFunction %void None %kernel_sig + %dst_ulong = OpFunctionParameter %gptr_ulong + %dst_uint2 = OpFunctionParameter %gptr_uint2 + %entry = OpLabel + %pvalue = OpVariable %pptr_int Function %uint_42 + %ulong_ptr = OpBitcast %ulong %pvalue + OpStore %dst_ulong %ulong_ptr + %uint2_ptr = OpBitcast %uint2 %pvalue + OpStore %dst_uint2 %uint2_ptr + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/test_spirv_15.cpp b/test_conformance/spirv_new/test_spirv_15.cpp new file mode 100644 index 0000000000..dfab7e9a4c --- /dev/null +++ b/test_conformance/spirv_new/test_spirv_15.cpp @@ -0,0 +1,162 @@ +// +// 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 "spirvInfo.hpp" +#include "types.hpp" + +#include +#include +#include + +REGISTER_TEST(spirv15_ptr_bitcast) +{ + if (!is_spirv_version_supported(device, "SPIR-V_1.5")) + { + log_info("SPIR-V 1.5 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + + cl_uint address_bits; + error = clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(cl_uint), + &address_bits, NULL); + SPIRV_CHECK_ERROR(error, "Failed to get address bits"); + + clProgramWrapper prog; + error = get_program_with_il(prog, device, context, "spv1.5/ptr_bitcast"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "ptr_bitcast_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + cl_ulong result_ulong = + address_bits == 32 ? 0xAAAAAAAAUL : 0xAAAAAAAAAAAAAAAAUL; + cl_ulong result_uint2 = + address_bits == 32 ? 0x55555555UL : 0x5555555555555555UL; + + clMemWrapper dst_ulong = + clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, + sizeof(result_ulong), &result_ulong, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst_ulong buffer"); + + clMemWrapper dst_uint2 = + clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, + sizeof(result_uint2), &result_uint2, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst_uint2 buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst_ulong), &dst_ulong); + error |= clSetKernelArg(kernel, 1, sizeof(dst_uint2), &dst_uint2); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = + clEnqueueReadBuffer(queue, dst_ulong, CL_TRUE, 0, sizeof(result_ulong), + &result_ulong, 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read dst_ulong buffer"); + + error = + clEnqueueReadBuffer(queue, dst_uint2, CL_TRUE, 0, sizeof(result_uint2), + &result_uint2, 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read dst_uint2 buffer"); + + if (result_ulong != result_uint2) + { + log_error("Results mismatch! ulong = 0x%016" PRIx64 + " vs. uint2 = 0x%016" PRIx64 "\n", + result_ulong, result_uint2); + return TEST_FAIL; + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv15_non_uniform_broadcast) +{ + if (!is_spirv_version_supported(device, "SPIR-V_1.5")) + { + log_info("SPIR-V 1.5 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + if (!is_extension_available(device, "cl_khr_subgroup_ballot")) + { + log_info("cl_khr_subgroup_ballot is not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + error = get_program_with_il(prog, device, context, + "spv1.5/non_uniform_broadcast_dynamic_index"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel( + prog, "non_uniform_broadcast_dynamic_index_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + // Get the local work-group size for one sub-group per work-group. + size_t lws = 0; + size_t one = 1; + error = clGetKernelSubGroupInfo( + kernel, device, CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT, + sizeof(size_t), &one, sizeof(size_t), &lws, NULL); + SPIRV_CHECK_ERROR(error, "Failed to get local work size for one sub-group"); + + // Use four work-groups, unless the local-group size is less than four. + size_t wgcount = std::min(lws, 4); + size_t gws = wgcount * lws; + clMemWrapper dst = clCreateBuffer(context, CL_MEM_READ_WRITE, + sizeof(cl_int) * gws, NULL, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &gws, &lws, 0, NULL, + NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + std::vector results(gws); + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, sizeof(cl_int) * gws, + results.data(), 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + // Remember: the test kernel did: + // sub_group_non_uniform_broadcast(get_global_id(0), get_group_id(0)) + for (size_t g = 0; g < wgcount; g++) + { + for (size_t l = 0; l < lws; l++) + { + size_t index = g * lws + l; + size_t check = g * lws + g; + if (results[index] != static_cast(check)) + { + log_error("Result mismatch at index %zu! Got %d, Wanted %zu\n", + index, results[index], check); + return TEST_FAIL; + } + } + } + + return TEST_PASS; +} From 98d52d0d5663a5b9244beb50388792d921c0562d Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Tue, 14 Jan 2025 17:06:30 +0000 Subject: [PATCH 28/39] Check command-buffer extension version for equality (#2215) As described in Issue https://github.com/KhronosGroup/OpenCL-CTS/issues/2152 we currently check the provisional extension version supported by a vendor is the same or older than a test specified version. However, it was discussed in the WG that this should be a check for equality to avoid hitting issues when a implementation tests against an older version of the CTS using a lower extension version, with API breaking changes having occurred since. The tests for the command-buffer family of extensions are the only provisional KHR tests using this versioning check, so this PR updates all those cases to equality. --- .../basic_command_buffer.h | 5 ++- .../mutable_command_basic.h | 32 +++++++++++-------- .../mutable_command_info.cpp | 4 ++- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h index 8c2e273613..b1171def8f 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h +++ b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h @@ -104,11 +104,10 @@ int MakeAndRunTest(cl_device_id device, cl_context context, cl_version extension_version = get_extension_version(device, "cl_khr_command_buffer"); - if (extension_version < CL_MAKE_VERSION(0, 9, 5)) + if (extension_version != CL_MAKE_VERSION(0, 9, 5)) { - log_info("cl_khr_command_buffer version 0.9.5 or later is required " - "to run " + log_info("cl_khr_command_buffer version 0.9.5 is required to run " "the test, skipping.\n "); return TEST_SKIPPED_ITSELF; } diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_basic.h b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_basic.h index 51938dce02..b0bd31d2fc 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_basic.h +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_basic.h @@ -80,20 +80,24 @@ struct BasicMutableCommandBufferTest : BasicCommandBufferTest "cl_khr_command_buffer_mutable_dispatch") == true; - if (extension_avaliable) { - // API breaking changes occur at revision 0.9.2, check implementation - // matches tested API - Version device_version = get_device_cl_version(device); - if ((device_version >= Version(3, 0)) - || is_extension_available(device, "cl_khr_extended_versioning")) { - - cl_version extension_version = - get_extension_version(device, "cl_khr_command_buffer_mutable_dispatch"); - - if (extension_version < CL_MAKE_VERSION(0, 9, 2)) { - extension_avaliable = false; - } - } + if (extension_avaliable) + { + Version device_version = get_device_cl_version(device); + if ((device_version >= Version(3, 0)) + || is_extension_available(device, "cl_khr_extended_versioning")) + { + + cl_version extension_version = get_extension_version( + device, "cl_khr_command_buffer_mutable_dispatch"); + + if (extension_version != CL_MAKE_VERSION(0, 9, 3)) + { + log_info("cl_khr_command_buffer_mutable_dispatch version " + "0.9.3 is " + "required to run the test, skipping.\n "); + extension_avaliable = false; + } + } } cl_mutable_dispatch_fields_khr mutable_capabilities; diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_info.cpp b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_info.cpp index 2b5b3b42e8..12a982fa6a 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_info.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_info.cpp @@ -127,8 +127,10 @@ struct PropertiesArray : public InfoMutableCommandBufferTest cl_version extension_version = get_extension_version( device, "cl_khr_command_buffer_mutable_dispatch"); - if (extension_version < CL_MAKE_VERSION(0, 9, 3)) + if (extension_version != CL_MAKE_VERSION(0, 9, 3)) { + log_info("cl_khr_command_buffer_mutable_dispatch version 0.9.3 " + "is required to run the test, skipping.\n "); return true; } } From bc5b0215eead35ba21bccf0a39b1cb6d25b840d9 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Tue, 14 Jan 2025 17:07:41 +0000 Subject: [PATCH 29/39] Fix derived command-buffer Skip() checks (#2217) It was noticed during another PR review https://github.com/KhronosGroup/OpenCL-CTS/pull/2207/files#r1903921283 that there was a case where the return value of a `Skip()` check was ignored, this is fixed in this PR. I've also tracking down occurrences of derived class overriding the `Skip()` test fixture method, but not calling the parents class `Skip()` check inside of the method. I believe omitting this parent skip check wasn't intentional, it's clearer to explicitly respect the parent classes skip conditions, even if we've got away with not needing too due to the way the derived class skip conditions have been defined. --- .../negative_command_buffer_create.cpp | 10 +++++++--- .../negative_command_nd_range_kernel.cpp | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp index 538a9eef46..eaece77657 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp @@ -129,8 +129,9 @@ struct CreateCommandBufferRepeatedProperties : public BasicCommandBufferTest bool Skip() override { - bool skip = true; + if (BasicCommandBufferTest::Skip()) return true; + bool skip = true; if (simultaneous_use_support) { rep_prop = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR; @@ -181,8 +182,9 @@ struct CreateCommandBufferNotSupportedProperties : public BasicCommandBufferTest bool Skip() override { - bool skip = true; + if (BasicCommandBufferTest::Skip()) return true; + bool skip = true; if (!simultaneous_use_support) { unsupported_prop = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR; @@ -223,6 +225,8 @@ struct CreateCommandBufferQueueWithoutMinProperties bool Skip() override { + if (BasicCommandBufferTest::Skip()) return true; + cl_command_queue_properties required_properties; cl_int error = clGetDeviceInfo( device, CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR, @@ -287,7 +291,7 @@ struct CreateCommandBufferDeviceDoesNotSupportOutOfOderQueue bool Skip() override { - BasicCommandBufferTest::Skip(); + if (BasicCommandBufferTest::Skip()) return true; // If device does not support out of order queue or if device supports // out of order command buffer test should be skipped diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp index 05774bc00f..cb2bc62b4d 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp @@ -273,6 +273,8 @@ struct CommandNDRangeKernelNotSupportPrintf : public BasicCommandBufferTest bool Skip() override { + if (BasicCommandBufferTest::Skip()) return true; + cl_device_command_buffer_capabilities_khr capabilities; cl_int error = clGetDeviceInfo(device, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, @@ -353,6 +355,8 @@ struct CommandNDRangeKernelWithKernelEnqueueCall : public BasicCommandBufferTest bool Skip() override { + if (BasicCommandBufferTest::Skip()) return true; + bool has_device_enqueue = false; bool cl_version_2_0_or_higher = false; From a2d6cadec1fe90f51ba2009c8f96d79ec25081d7 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 14 Jan 2025 18:08:32 +0100 Subject: [PATCH 30/39] relationals: fix -Wformat warnings (#2218) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid a ``` ‘%zu’ directive writing between 1 and 20 bytes into a region of size 16 ``` warning by using `std::string` for `generate_shuffle_mask`. As this fixes the last remaining Wformat warning in the relationals suite, drop the local `-Wno-format` compiler option. Signed-off-by: Sven van Haastregt --- test_conformance/relationals/CMakeLists.txt | 2 - .../relationals/test_shuffles.cpp | 61 +++++++++++-------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/test_conformance/relationals/CMakeLists.txt b/test_conformance/relationals/CMakeLists.txt index 183fdd1de6..aa5dd6a1ec 100644 --- a/test_conformance/relationals/CMakeLists.txt +++ b/test_conformance/relationals/CMakeLists.txt @@ -7,7 +7,5 @@ set(${MODULE_NAME}_SOURCES test_shuffles.cpp ) -set_gnulike_module_compile_flags("-Wno-format") - include(../CMakeCommon.txt) diff --git a/test_conformance/relationals/test_shuffles.cpp b/test_conformance/relationals/test_shuffles.cpp index ba6a0aec1e..149243744e 100644 --- a/test_conformance/relationals/test_shuffles.cpp +++ b/test_conformance/relationals/test_shuffles.cpp @@ -307,27 +307,24 @@ void print_hex_mem_dump(const unsigned char *inDataPtr, log_info("%s\n", error.str().c_str()); } -void generate_shuffle_mask( char *outMaskString, size_t maskSize, const ShuffleOrder *order ) +std::string generate_shuffle_mask(size_t maskSize, const ShuffleOrder *order) { - outMaskString[ 0 ] = 0; + std::ostringstream outMaskString; if( order != NULL ) { for( size_t jj = 0; jj < maskSize; jj++ ) { - char thisMask[ 16 ]; - sprintf( thisMask, "%s%d", ( jj == 0 ) ? "" : ", ", (*order)[ jj ] ); - strcat( outMaskString, thisMask ); + outMaskString << (jj == 0 ? "" : ", ") << +((*order)[jj]); } } else { for( size_t jj = 0; jj < maskSize; jj++ ) { - char thisMask[ 16 ]; - sprintf(thisMask, "%s%zu", (jj == 0) ? "" : ", ", jj); - strcat( outMaskString, thisMask ); + outMaskString << (jj == 0 ? "" : ", ") << jj; } } + return outMaskString.str(); } static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl_kernel *outKernel, @@ -520,9 +517,9 @@ static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl maskType = kULong; } - char maskString[ 1024 ] = ""; size_t maskSize = outVecSize;// ( shuffleMode == kBuiltInDualInputFnMode ) ? ( outVecSize << 1 ) : outVecSize; - generate_shuffle_mask( maskString, maskSize, ( outOrders != NULL ) ? &outOrders[ i ] : NULL ); + std::string maskString = generate_shuffle_mask( + maskSize, (outOrders != NULL) ? &outOrders[i] : NULL); // Set up a quick prefix, so mask gets unsigned type regardless of the input/output type char maskPrefix[ 2 ] = "u"; @@ -532,13 +529,21 @@ static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl char progLine2[ 10240 ]; if( shuffleMode == kBuiltInDualInputFnMode ) { - sprintf( progLine2, shuffleBuiltInDualPattern, get_explicit_type_name( vecType ), inSizeName, - ( inVecSize == 3 ) ? "vload3( %ld, (__global %s *)source )" : "source[ %ld ]", - get_explicit_type_name( vecType ), inSizeName, - ( inVecSize == 3 ) ? "vload3( %ld, (__global %s *)secondSource )" : "secondSource[ %ld ]", - maskPrefix, get_explicit_type_name( maskType ), outSizeName, maskPrefix, get_explicit_type_name( maskType ), outSizeName, - maskString, - ( outVecSize == 3 ) ? "vstore3( tmp, %ld, (__global %s *)dest )" : "dest[ %ld ] = tmp" ); + sprintf( + progLine2, shuffleBuiltInDualPattern, + get_explicit_type_name(vecType), inSizeName, + (inVecSize == 3) ? "vload3( %ld, (__global %s *)source )" + : "source[ %ld ]", + get_explicit_type_name(vecType), inSizeName, + (inVecSize == 3) + ? "vload3( %ld, (__global %s *)secondSource )" + : "secondSource[ %ld ]", + maskPrefix, get_explicit_type_name(maskType), outSizeName, + maskPrefix, get_explicit_type_name(maskType), outSizeName, + maskString.c_str(), + (outVecSize == 3) + ? "vstore3( tmp, %ld, (__global %s *)dest )" + : "dest[ %ld ] = tmp"); if( outVecSize == 3 ) { @@ -557,11 +562,17 @@ static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl } else { - sprintf( progLine2, shuffleBuiltInPattern, get_explicit_type_name( vecType ), inSizeName, - ( inVecSize == 3 ) ? "vload3( %ld, (__global %s *)source )" : "source[ %ld ]", - maskPrefix, get_explicit_type_name( maskType ), outSizeName, maskPrefix, get_explicit_type_name( maskType ), outSizeName, - maskString, - ( outVecSize == 3 ) ? "vstore3( tmp, %ld, (__global %s *)dest )" : "dest[ %ld ] = tmp" ); + sprintf( + progLine2, shuffleBuiltInPattern, + get_explicit_type_name(vecType), inSizeName, + (inVecSize == 3) ? "vload3( %ld, (__global %s *)source )" + : "source[ %ld ]", + maskPrefix, get_explicit_type_name(maskType), outSizeName, + maskPrefix, get_explicit_type_name(maskType), outSizeName, + maskString.c_str(), + (outVecSize == 3) + ? "vstore3( tmp, %ld, (__global %s *)dest )" + : "dest[ %ld ] = tmp"); if( outVecSize == 3 ) { @@ -705,9 +716,9 @@ int test_shuffle_dual_kernel(cl_context context, cl_command_queue queue, if( ( shuffleMode == kBuiltInFnMode ) || ( shuffleMode == kBuiltInDualInputFnMode ) ) { // Mask would've been different for every shuffle done, so we have to regen it to print it - char maskString[ 1024 ]; - generate_shuffle_mask( maskString, outVecSize, ( outOrderIdx != NULL ) ? &outOrderIdx[ i ] : NULL ); - log_error( " Mask: %s\n", maskString ); + std::string maskString = generate_shuffle_mask( + outVecSize, (outOrderIdx != NULL) ? &outOrderIdx[i] : NULL); + log_error(" Mask: %s\n", maskString.c_str()); } ret++; From f6611ec912bc1c434a3b8251bf4683e299fc91b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Petit?= Date: Tue, 14 Jan 2025 17:11:31 +0000 Subject: [PATCH 31/39] Migrate commonfns suite to new test registration framework (#2197) Signed-off-by: Kevin Petit --- test_conformance/commonfns/main.cpp | 17 ++----- test_conformance/commonfns/procs.h | 49 ------------------- test_conformance/commonfns/test_base.h | 8 +++ test_conformance/commonfns/test_binary_fn.cpp | 41 ++++++---------- test_conformance/commonfns/test_clamp.cpp | 6 +-- test_conformance/commonfns/test_mix.cpp | 11 ++--- .../commonfns/test_smoothstep.cpp | 11 ++--- test_conformance/commonfns/test_step.cpp | 15 +++--- test_conformance/commonfns/test_unary_fn.cpp | 17 +++---- 9 files changed, 50 insertions(+), 125 deletions(-) delete mode 100644 test_conformance/commonfns/procs.h diff --git a/test_conformance/commonfns/main.cpp b/test_conformance/commonfns/main.cpp index 645d3f703c..8b16bf96b1 100644 --- a/test_conformance/commonfns/main.cpp +++ b/test_conformance/commonfns/main.cpp @@ -16,7 +16,6 @@ #include #include -#include "procs.h" #include "test_base.h" #include "harness/kernelHelpers.h" @@ -36,17 +35,6 @@ static void initVecSizes() { } } -test_definition test_list[] = { - ADD_TEST(clamp), ADD_TEST(degrees), ADD_TEST(fmax), - ADD_TEST(fmaxf), ADD_TEST(fmin), ADD_TEST(fminf), - ADD_TEST(max), ADD_TEST(maxf), ADD_TEST(min), - ADD_TEST(minf), ADD_TEST(mix), ADD_TEST(mixf), - ADD_TEST(radians), ADD_TEST(step), ADD_TEST(stepf), - ADD_TEST(smoothstep), ADD_TEST(smoothstepf), ADD_TEST(sign), -}; - -const int test_num = ARRAY_SIZE( test_list ); - test_status InitCL(cl_device_id device) { if (is_extension_available(device, "cl_khr_fp16")) @@ -79,6 +67,7 @@ int main(int argc, const char *argv[]) BaseFunctionTest::type2name[sizeof(float)] = "float"; BaseFunctionTest::type2name[sizeof(double)] = "double"; - return runTestHarnessWithCheck(argc, argv, test_num, test_list, false, 0, - InitCL); + return runTestHarnessWithCheck( + argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0, InitCL); } diff --git a/test_conformance/commonfns/procs.h b/test_conformance/commonfns/procs.h deleted file mode 100644 index c1115ee7cd..0000000000 --- a/test_conformance/commonfns/procs.h +++ /dev/null @@ -1,49 +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. -// -#include "harness/testHarness.h" -#include "harness/kernelHelpers.h" -#include "harness/errorHelpers.h" -#include "harness/conversions.h" -#include "harness/mt19937.h" - -#define kVectorSizeCount 5 -#define kStrangeVectorSizeCount 1 -#define kTotalVecCount (kVectorSizeCount + kStrangeVectorSizeCount) - -extern int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount]; -// int g_arrStrangeVectorSizes[kStrangeVectorSizeCount] = {3}; - -extern int test_clamp(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_degrees(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_fmax(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_fmaxf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_fmin(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_fminf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_max(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_maxf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_min(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_minf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_mix(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_mixf(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_radians(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_step(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_stepf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_smoothstep(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_smoothstepf(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_sign(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); - - diff --git a/test_conformance/commonfns/test_base.h b/test_conformance/commonfns/test_base.h index c7286a92f5..bcce3ba408 100644 --- a/test_conformance/commonfns/test_base.h +++ b/test_conformance/commonfns/test_base.h @@ -24,9 +24,17 @@ #include #include +#include "harness/conversions.h" +#include "harness/mt19937.h" #include "harness/testHarness.h" #include "harness/typeWrappers.h" +#define kVectorSizeCount 5 +#define kStrangeVectorSizeCount 1 +#define kTotalVecCount (kVectorSizeCount + kStrangeVectorSizeCount) + +extern int g_arrVecSizes[kVectorSizeCount + kStrangeVectorSizeCount]; + template using VerifyFuncBinary = int (*)(const T *const, const T *const, const T *const, const int num, const int vs, const int vp); diff --git a/test_conformance/commonfns/test_binary_fn.cpp b/test_conformance/commonfns/test_binary_fn.cpp index a6c75647d0..8ad347aafb 100644 --- a/test_conformance/commonfns/test_binary_fn.cpp +++ b/test_conformance/commonfns/test_binary_fn.cpp @@ -24,7 +24,6 @@ #include "harness/typeWrappers.h" #include "harness/stringHelpers.h" -#include "procs.h" #include "test_base.h" const char *binary_fn_code_pattern = @@ -319,58 +318,50 @@ cl_int MinTest::Run() return error; } -int test_min(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(min) { - return MakeAndRunTest(device, context, queue, n_elems, "min", + return MakeAndRunTest(device, context, queue, num_elements, "min", true); } -int test_minf(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(minf) { - return MakeAndRunTest(device, context, queue, n_elems, "min", + return MakeAndRunTest(device, context, queue, num_elements, "min", false); } -int test_fmin(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(fmin) { - return MakeAndRunTest(device, context, queue, n_elems, "fmin", + return MakeAndRunTest(device, context, queue, num_elements, "fmin", true); } -int test_fminf(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(fminf) { - return MakeAndRunTest(device, context, queue, n_elems, "fmin", + return MakeAndRunTest(device, context, queue, num_elements, "fmin", false); } -int test_max(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(max) { - return MakeAndRunTest(device, context, queue, n_elems, "max", + return MakeAndRunTest(device, context, queue, num_elements, "max", true); } -int test_maxf(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(maxf) { - return MakeAndRunTest(device, context, queue, n_elems, "max", + return MakeAndRunTest(device, context, queue, num_elements, "max", false); } -int test_fmax(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(fmax) { - return MakeAndRunTest(device, context, queue, n_elems, "fmax", + return MakeAndRunTest(device, context, queue, num_elements, "fmax", true); } -int test_fmaxf(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(fmaxf) { - return MakeAndRunTest(device, context, queue, n_elems, "fmax", + return MakeAndRunTest(device, context, queue, num_elements, "fmax", false); } diff --git a/test_conformance/commonfns/test_clamp.cpp b/test_conformance/commonfns/test_clamp.cpp index 1bf4067705..298811e245 100644 --- a/test_conformance/commonfns/test_clamp.cpp +++ b/test_conformance/commonfns/test_clamp.cpp @@ -23,7 +23,6 @@ #include "harness/deviceInfo.h" #include "harness/typeWrappers.h" -#include "procs.h" #include "test_base.h" #ifndef M_PI @@ -308,8 +307,7 @@ cl_int ClampTest::Run() return error; } -int test_clamp(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(clamp) { - return MakeAndRunTest(device, context, queue, n_elems); + return MakeAndRunTest(device, context, queue, num_elements); } diff --git a/test_conformance/commonfns/test_mix.cpp b/test_conformance/commonfns/test_mix.cpp index 2a06e43df6..ae543d0d89 100644 --- a/test_conformance/commonfns/test_mix.cpp +++ b/test_conformance/commonfns/test_mix.cpp @@ -20,7 +20,6 @@ #include "harness/stringHelpers.h" -#include "procs.h" #include "test_base.h" @@ -302,16 +301,14 @@ cl_int MixTest::Run() return error; } -int test_mix(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(mix) { - return MakeAndRunTest(device, context, queue, n_elems, "mix", + return MakeAndRunTest(device, context, queue, num_elements, "mix", true); } -int test_mixf(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(mixf) { - return MakeAndRunTest(device, context, queue, n_elems, "mix", + return MakeAndRunTest(device, context, queue, num_elements, "mix", false); } diff --git a/test_conformance/commonfns/test_smoothstep.cpp b/test_conformance/commonfns/test_smoothstep.cpp index 5afc2d0f22..6aaa800dfb 100644 --- a/test_conformance/commonfns/test_smoothstep.cpp +++ b/test_conformance/commonfns/test_smoothstep.cpp @@ -20,7 +20,6 @@ #include "harness/stringHelpers.h" -#include "procs.h" #include "test_base.h" const char *smoothstep_fn_code_pattern = @@ -317,16 +316,14 @@ cl_int SmoothstepTest::Run() return error; } -int test_smoothstep(cl_device_id device, cl_context context, - cl_command_queue queue, int n_elems) +REGISTER_TEST(smoothstep) { - return MakeAndRunTest(device, context, queue, n_elems, + return MakeAndRunTest(device, context, queue, num_elements, "smoothstep", true); } -int test_smoothstepf(cl_device_id device, cl_context context, - cl_command_queue queue, int n_elems) +REGISTER_TEST(smoothstepf) { - return MakeAndRunTest(device, context, queue, n_elems, + return MakeAndRunTest(device, context, queue, num_elements, "smoothstep", false); } diff --git a/test_conformance/commonfns/test_step.cpp b/test_conformance/commonfns/test_step.cpp index 1cfa96eabd..e3a6fdf695 100644 --- a/test_conformance/commonfns/test_step.cpp +++ b/test_conformance/commonfns/test_step.cpp @@ -20,7 +20,6 @@ #include "harness/stringHelpers.h" -#include "procs.h" #include "test_base.h" const char *step_fn_code_pattern = "%s\n" /* optional pragma */ @@ -268,16 +267,14 @@ cl_int StepTest::Run() return error; } -int test_step(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(step) { - return MakeAndRunTest(device, context, queue, n_elems, "step", - true); + return MakeAndRunTest(device, context, queue, num_elements, + "step", true); } -int test_stepf(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(stepf) { - return MakeAndRunTest(device, context, queue, n_elems, "step", - false); + return MakeAndRunTest(device, context, queue, num_elements, + "step", false); } diff --git a/test_conformance/commonfns/test_unary_fn.cpp b/test_conformance/commonfns/test_unary_fn.cpp index 91b5c215bf..23b665a45f 100644 --- a/test_conformance/commonfns/test_unary_fn.cpp +++ b/test_conformance/commonfns/test_unary_fn.cpp @@ -24,7 +24,6 @@ #include "harness/stringHelpers.h" #include "harness/typeWrappers.h" -#include "procs.h" #include "test_base.h" #ifndef M_PI @@ -385,22 +384,20 @@ cl_int SignTest::Run() return error; } -int test_degrees(cl_device_id device, cl_context context, - cl_command_queue queue, int n_elems) +REGISTER_TEST(degrees) { - return MakeAndRunTest(device, context, queue, n_elems, + return MakeAndRunTest(device, context, queue, num_elements, "degrees"); } -int test_radians(cl_device_id device, cl_context context, - cl_command_queue queue, int n_elems) +REGISTER_TEST(radians) { - return MakeAndRunTest(device, context, queue, n_elems, + return MakeAndRunTest(device, context, queue, num_elements, "radians"); } -int test_sign(cl_device_id device, cl_context context, cl_command_queue queue, - int n_elems) +REGISTER_TEST(sign) { - return MakeAndRunTest(device, context, queue, n_elems, "sign"); + return MakeAndRunTest(device, context, queue, num_elements, + "sign"); } From a7db9a49f96b0b5da14eafcde3670332cea38801 Mon Sep 17 00:00:00 2001 From: joshqti <127994991+joshqti@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:12:02 -0800 Subject: [PATCH 32/39] vulkan: Choose where Shaders are generated (#2226) - generate spv files into VULKAN_TEST_RESOURCES directory - works with change that generates spv at build time Co-authored-by: dcrawley --- test_conformance/vulkan/shaders/CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test_conformance/vulkan/shaders/CMakeLists.txt b/test_conformance/vulkan/shaders/CMakeLists.txt index 002ab9bf5c..f09dc51cac 100644 --- a/test_conformance/vulkan/shaders/CMakeLists.txt +++ b/test_conformance/vulkan/shaders/CMakeLists.txt @@ -8,17 +8,21 @@ if(${Vulkan_glslang_binary} STREQUAL "Vulkan_glslang_binary-NOTFOUND") else() message(STATUS "Found glslang: ${Vulkan_glslang_binary}") + if(NOT DEFINED VULKAN_TEST_RESOURCES) + set(VULKAN_TEST_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}) + endif() + set(vulkan_spirv_files "") add_custom_command( - OUTPUT buffer.spv + OUTPUT ${VULKAN_TEST_RESOURCES}/buffer.spv COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 - -o ${CMAKE_CURRENT_BINARY_DIR}/buffer.spv + -o ${VULKAN_TEST_RESOURCES}/buffer.spv ${CMAKE_CURRENT_SOURCE_DIR}/buffer.comp DEPENDS buffer.comp VERBATIM) - list(APPEND vulkan_spirv_files ${CMAKE_CURRENT_BINARY_DIR}/buffer.spv) + list(APPEND vulkan_spirv_files ${VULKAN_TEST_RESOURCES}/buffer.spv) file(STRINGS "image2D_test_formats.txt" image2D_formats) @@ -29,14 +33,14 @@ else() configure_file(image2D.comp.in image2D_${GLSL_FORMAT}.comp) add_custom_command( - OUTPUT image2D_${GLSL_FORMAT}.spv + OUTPUT ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 - -o ${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.spv + -o ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv ${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.comp DEPENDS image2D_${GLSL_FORMAT}.comp VERBATIM) - list(APPEND vulkan_spirv_files ${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.spv) + list(APPEND vulkan_spirv_files ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv) endforeach() add_custom_target(vulkan_shaders DEPENDS ${vulkan_spirv_files}) From 2ff5cdaf7dea7f3ea7ab9d811f9207112e523712 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Tue, 14 Jan 2025 20:37:38 +0000 Subject: [PATCH 33/39] Command-buffer query for supported queue properties (#2101) CTS test update to match OpenCL-Doc & OpenCL-Header PRs: * https://github.com/KhronosGroup/OpenCL-Headers/pull/265 * https://github.com/KhronosGroup/OpenCL-Docs/pull/850 Tested with https://github.com/bashbaug/SimpleOpenCLSamples/pull/126 locally using a checkout of the linked OpenCL-Headers branch --- .../basic_command_buffer.cpp | 10 +++++++++- .../basic_command_buffer.h | 5 ++--- .../command_buffer_profiling.cpp | 17 ++++++++++++++++- .../negative_command_buffer_create.cpp | 4 ++-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp index c5dc9010c1..803daf6bcf 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp @@ -52,6 +52,14 @@ bool BasicCommandBufferTest::Skip() "Unable to query " "CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR"); + cl_command_queue_properties supported_properties; + error = clGetDeviceInfo( + device, CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR, + sizeof(supported_properties), &supported_properties, NULL); + test_error(error, + "Unable to query " + "CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR"); + cl_command_queue_properties queue_properties; error = clGetCommandQueueInfo(queue, CL_QUEUE_PROPERTIES, sizeof(queue_properties), &queue_properties, @@ -70,7 +78,7 @@ bool BasicCommandBufferTest::Skip() && (capabilities & CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR) != 0; out_of_order_support = - capabilities & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR; + supported_properties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; device_side_enqueue_support = (capabilities & CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR) != 0; diff --git a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h index b1171def8f..aa90201340 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h +++ b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h @@ -104,10 +104,9 @@ int MakeAndRunTest(cl_device_id device, cl_context context, cl_version extension_version = get_extension_version(device, "cl_khr_command_buffer"); - if (extension_version != CL_MAKE_VERSION(0, 9, 5)) + if (extension_version != CL_MAKE_VERSION(0, 9, 6)) { - - log_info("cl_khr_command_buffer version 0.9.5 is required to run " + log_info("cl_khr_command_buffer version 0.9.6 is required to run " "the test, skipping.\n "); return TEST_SKIPPED_ITSELF; } diff --git a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_profiling.cpp b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_profiling.cpp index c06bbf762e..e715ddc9da 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_profiling.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_profiling.cpp @@ -70,7 +70,22 @@ struct CommandBufferProfiling : public BasicCommandBufferTest //-------------------------------------------------------------------------- cl_int SetUp(int elements) override { - cl_int error = CL_SUCCESS; + + cl_command_queue_properties supported_properties; + cl_int error = clGetDeviceInfo( + device, CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR, + sizeof(supported_properties), &supported_properties, NULL); + test_error(error, + "Unable to query " + "CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR"); + + // CL_QUEUE_PROFILING_ENABLE is mandated minimum property returned by + // CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR + if (!(supported_properties & CL_QUEUE_PROFILING_ENABLE)) + { + return TEST_FAIL; + } + queue = clCreateCommandQueue(context, device, CL_QUEUE_PROFILING_ENABLE, &error); test_error(error, "clCreateCommandQueue failed"); diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp index eaece77657..72e50e6643 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp @@ -248,8 +248,8 @@ struct CreateCommandBufferQueueWithoutMinProperties // CL_INCOMPATIBLE_COMMAND_QUEUE_KHR if any command-queue in queues is an // out-of-order command-queue and the device associated with the command-queue -// does not support the CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR -// capability. +// does not return CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE from +// CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR struct CreateCommandBufferDeviceDoesNotSupportOutOfOderQueue : public BasicCommandBufferTest { From 98c3fe4f161e7708bd7e4246cd9841cfd69aa912 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 21 Jan 2025 17:39:28 +0100 Subject: [PATCH 34/39] Added test for work-item functions with out-of-range arguments (#2099) Fixes #2005 according to task description. --- test_conformance/basic/main.cpp | 2 + test_conformance/basic/procs.h | 7 + .../basic/test_work_item_functions.cpp | 621 ++++++++++++++---- 3 files changed, 519 insertions(+), 111 deletions(-) diff --git a/test_conformance/basic/main.cpp b/test_conformance/basic/main.cpp index f66089587e..e89b2747a3 100644 --- a/test_conformance/basic/main.cpp +++ b/test_conformance/basic/main.cpp @@ -99,6 +99,8 @@ test_definition test_list[] = { ADD_TEST(enqueue_map_image), ADD_TEST(work_item_functions), + ADD_TEST(work_item_functions_out_of_range), + ADD_TEST(work_item_functions_out_of_range_hardcoded), ADD_TEST(astype), diff --git a/test_conformance/basic/procs.h b/test_conformance/basic/procs.h index cf3e8c6316..69529b1f28 100644 --- a/test_conformance/basic/procs.h +++ b/test_conformance/basic/procs.h @@ -98,6 +98,13 @@ extern int test_enqueue_map_buffer(cl_device_id deviceID, cl_context contex extern int test_enqueue_map_image(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); extern int test_work_item_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_work_item_functions_out_of_range(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_work_item_functions_out_of_range_hardcoded( + cl_device_id deviceID, cl_context context, cl_command_queue queue, + int num_elements); extern int test_astype(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); diff --git a/test_conformance/basic/test_work_item_functions.cpp b/test_conformance/basic/test_work_item_functions.cpp index d326bb8bbc..6c2b436f4e 100644 --- a/test_conformance/basic/test_work_item_functions.cpp +++ b/test_conformance/basic/test_work_item_functions.cpp @@ -15,6 +15,7 @@ // #include "harness/compat.h" +#include #include #include #include @@ -26,6 +27,8 @@ #include "harness/conversions.h" #include "harness/typeWrappers.h" +namespace { + struct work_item_data { cl_uint workDim; @@ -35,146 +38,542 @@ struct work_item_data cl_uint localID[ 3 ]; cl_uint numGroups[ 3 ]; cl_uint groupID[ 3 ]; + cl_uint globalOffset[3]; + cl_uint enqueuedLocalSize[3]; }; -static const char *workItemKernelCode = -"typedef struct {\n" -" uint workDim;\n" -" uint globalSize[ 3 ];\n" -" uint globalID[ 3 ];\n" -" uint localSize[ 3 ];\n" -" uint localID[ 3 ];\n" -" uint numGroups[ 3 ];\n" -" uint groupID[ 3 ];\n" -" } work_item_data;\n" -"\n" -"__kernel void sample_kernel( __global work_item_data *outData )\n" -"{\n" -" int id = get_global_id(0);\n" -" outData[ id ].workDim = (uint)get_work_dim();\n" -" for( uint i = 0; i < get_work_dim(); i++ )\n" -" {\n" -" outData[ id ].globalSize[ i ] = (uint)get_global_size( i );\n" -" outData[ id ].globalID[ i ] = (uint)get_global_id( i );\n" -" outData[ id ].localSize[ i ] = (uint)get_local_size( i );\n" -" outData[ id ].localID[ i ] = (uint)get_local_id( i );\n" -" outData[ id ].numGroups[ i ] = (uint)get_num_groups( i );\n" -" outData[ id ].groupID[ i ] = (uint)get_group_id( i );\n" -" }\n" -"}"; +const char *workItemKernelCode = + R"(typedef struct { + uint workDim; + uint globalSize[ 3 ]; + uint globalID[ 3 ]; + uint localSize[ 3 ]; + uint localID[ 3 ]; + uint numGroups[ 3 ]; + uint groupID[ 3 ]; + uint globalOffset[ 3 ]; + uint enqueuedLocalSize[ 3 ]; + } work_item_data; + +__kernel void sample_kernel( __global work_item_data *outData ) +{ + int id = get_global_id(0); + outData[ id ].workDim = (uint)get_work_dim(); + for( uint i = 0; i < get_work_dim(); i++ ) + { + outData[ id ].globalSize[ i ] = (uint)get_global_size( i ); + outData[ id ].globalID[ i ] = (uint)get_global_id( i ); + outData[ id ].localSize[ i ] = (uint)get_local_size( i ); + outData[ id ].localID[ i ] = (uint)get_local_id( i ); + outData[ id ].numGroups[ i ] = (uint)get_num_groups( i ); + outData[ id ].groupID[ i ] = (uint)get_group_id( i ); + } +})"; + +struct work_item_data_out_of_range +{ + cl_uint workDim; + cl_uint globalSize; + cl_uint globalID; + cl_uint localSize; + cl_uint localID; + cl_uint numGroups; + cl_uint groupID; + cl_uint globalOffset; + cl_uint enqueuedLocalSize; +}; + +const char *outOfRangeWorkItemKernelCode = + R"(typedef struct { + uint workDim; + uint globalSize; + uint globalID; + uint localSize; + uint localID; + uint numGroups; + uint groupID; + uint globalOffset; + uint enqueuedLocalSize; + } work_item_data; + +__kernel void sample_kernel( __global work_item_data *outData, int dim_param ) +{ + int ind_mul=1; + int ind=0; + for( uint i = 0; i < get_work_dim(); i++ ) + { + ind += (uint)get_global_id(i) * ind_mul; + ind_mul *= get_global_size(i); + } + outData[ind].workDim = (uint)get_work_dim(); + + uint dimindx=dim_param; + outData[ind].globalSize = (uint)get_global_size(dimindx); + outData[ind].globalID = (uint)get_global_id(dimindx); + outData[ind].localSize = (uint)get_local_size(dimindx); + outData[ind].localID = (uint)get_local_id(dimindx); + outData[ind].numGroups = (uint)get_num_groups(dimindx); + outData[ind].groupID = (uint)get_group_id(dimindx); +#if __OPENCL_VERSION__ >= CL_VERSION_2_0 + outData[ind].enqueuedLocalSize = (uint)get_enqueued_local_size(dimindx); + outData[ind].globalOffset = (uint)get_global_offset(dimindx); +#elif __OPENCL_VERSION__ >= CL_VERSION_1_1 + outData[ind].globalOffset = (uint)get_global_offset(dimindx); +#endif +})"; + +const char *outOfRangeWorkItemHardcodedKernelCode = + R"(typedef struct { + uint workDim; + uint globalSize; + uint globalID; + uint localSize; + uint localID; + uint numGroups; + uint groupID; + uint globalOffset; + uint enqueuedLocalSize; + } work_item_data; + +__kernel void sample_kernel( __global work_item_data *outData, int dim_param ) +{ + int ind_mul=1; + int ind=0; + for( uint i = 0; i < get_work_dim(); i++ ) + { + ind += (uint)get_global_id(i) * ind_mul; + ind_mul *= get_global_size(i); + } + outData[ind].workDim = (uint)get_work_dim(); + outData[ind].globalSize = (uint)get_global_size(4); + outData[ind].globalID = (uint)get_global_id(4); + outData[ind].localSize = (uint)get_local_size(4); + outData[ind].localID = (uint)get_local_id(4); + outData[ind].numGroups = (uint)get_num_groups(4); + outData[ind].groupID = (uint)get_group_id(4); +#if __OPENCL_VERSION__ >= CL_VERSION_2_0 + outData[ind].enqueuedLocalSize = (uint)get_enqueued_local_size(4); + outData[ind].globalOffset = (uint)get_global_offset(4); +#elif __OPENCL_VERSION__ >= CL_VERSION_1_1 + outData[ind].globalOffset = (uint)get_global_offset(4); +#endif +})"; #define NUM_TESTS 1 -int test_work_item_functions(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +struct TestWorkItemFns { - int error; + TestWorkItemFns(cl_device_id deviceID, cl_context context, + cl_command_queue queue) + : device(deviceID), context(context), queue(queue), program(nullptr), + kernel(nullptr), outData(nullptr), d_holder(gRandomSeed), + testData(10240) + {} + + cl_int SetUp(const char *src) + { + cl_int error = create_single_kernel_helper(context, &program, &kernel, + 1, &src, "sample_kernel"); + test_error(error, "Unable to create testing kernel"); + + outData = clCreateBuffer(context, CL_MEM_READ_WRITE, + sizeof(work_item_data) * testData.size(), NULL, + &error); + test_error(error, "Unable to create output buffer"); + + error = clSetKernelArg(kernel, 0, sizeof(outData), &outData); + test_error(error, "Unable to set kernel arg"); + + return CL_SUCCESS; + } + + cl_int Run() + { + cl_int error = SetUp(workItemKernelCode); + test_error(error, "SetUp failed"); + + size_t threads[3] = { 0, 0, 0 }; + size_t localThreads[3] = { 0, 0, 0 }; + for (size_t dim = 1; dim <= 3; dim++) + { + for (int i = 0; i < NUM_TESTS; i++) + { + for (size_t j = 0; j < dim; j++) + { + // All of our thread sizes should be within the max local + // sizes, since they're all <= 20 + threads[j] = (size_t)random_in_range(1, 20, d_holder); + localThreads[j] = threads[j] + / (size_t)random_in_range(1, (int)threads[j], d_holder); + while (localThreads[j] > 1 + && (threads[j] % localThreads[j] != 0)) + localThreads[j]--; + + // Hack for now: localThreads > 1 are iffy + localThreads[j] = 1; + } + error = clEnqueueNDRangeKernel(queue, kernel, (cl_uint)dim, + NULL, threads, localThreads, 0, + NULL, NULL); + test_error(error, "Unable to run kernel"); + + error = clEnqueueReadBuffer(queue, outData, CL_TRUE, 0, + sizeof(work_item_data) + * testData.size(), + testData.data(), 0, NULL, NULL); + test_error(error, "Unable to read results"); + // Validate + for (size_t q = 0; q < threads[0]; q++) + { + // We can't really validate the actual value of each one, + // but we can validate that they're within a sane range + if (testData[q].workDim != (cl_uint)dim) + { + log_error( + "ERROR: get_work_dim() did not return proper value " + "for %d dimensions (expected %d, got %d)\n", + (int)dim, (int)dim, (int)testData[q].workDim); + return -1; + } + for (size_t j = 0; j < dim; j++) + { + if (testData[q].globalSize[j] != (cl_uint)threads[j]) + { + log_error("ERROR: get_global_size(%d) did not " + "return proper value for %d dimensions " + "(expected %d, got %d)\n", + (int)j, (int)dim, (int)threads[j], + (int)testData[q].globalSize[j]); + return -1; + } + if (testData[q].globalID[j] >= (cl_uint)threads[j]) + { + log_error("ERROR: get_global_id(%d) did not return " + "proper value for %d dimensions (max %d, " + "got %d)\n", + (int)j, (int)dim, (int)threads[j], + (int)testData[q].globalID[j]); + return -1; + } + if (testData[q].localSize[j] + != (cl_uint)localThreads[j]) + { + log_error("ERROR: get_local_size(%d) did not " + "return proper value for %d dimensions " + "(expected %d, got %d)\n", + (int)j, (int)dim, (int)localThreads[j], + (int)testData[q].localSize[j]); + return -1; + } + if (testData[q].localID[j] >= (cl_uint)localThreads[j]) + { + log_error( + "ERROR: get_local_id(%d) did not return proper " + "value for %d dimensions (max %d, got %d)\n", + (int)j, (int)dim, (int)localThreads[j], + (int)testData[q].localID[j]); + return -1; + } + size_t groupCount = (threads[j] + localThreads[j] - 1) + / localThreads[j]; + if (testData[q].numGroups[j] != (cl_uint)groupCount) + { + log_error("ERROR: get_num_groups(%d) did not " + "return proper value for %d dimensions " + "(expected %d with global dim %d and " + "local dim %d, got %d)\n", + (int)j, (int)dim, (int)groupCount, + (int)threads[j], (int)localThreads[j], + (int)testData[q].numGroups[j]); + return -1; + } + if (testData[q].groupID[j] >= (cl_uint)groupCount) + { + log_error( + "ERROR: get_group_id(%d) did not return proper " + "value for %d dimensions (max %d, got %d)\n", + (int)j, (int)dim, (int)groupCount, + (int)testData[q].groupID[j]); + return -1; + } + } + } + } + } + return 0; + } + + cl_device_id device; + cl_context context; + cl_command_queue queue; clProgramWrapper program; clKernelWrapper kernel; clMemWrapper outData; - std::vector testData(10240); - size_t threads[3], localThreads[3]; - MTdata d; + MTdataHolder d_holder; + + std::vector testData; +}; +struct TestWorkItemFnsOutOfRange +{ + size_t threads[3] = { 0, 0, 0 }; + + TestWorkItemFnsOutOfRange(cl_device_id deviceID, cl_context context, + cl_command_queue queue, const char *ksrc) + : device(deviceID), context(context), queue(queue), program(nullptr), + kernel(nullptr), outData(nullptr), d_holder(gRandomSeed), + testData(10240), max_workgroup_size(0), kernel_src(ksrc) + {} + + virtual cl_int SetUp(const char *src) + { + cl_int error = create_single_kernel_helper(context, &program, &kernel, + 1, &src, "sample_kernel"); + test_error(error, "Unable to create testing kernel"); - error = create_single_kernel_helper( context, &program, &kernel, 1, &workItemKernelCode, "sample_kernel" ); - test_error( error, "Unable to create testing kernel" ); + outData = clCreateBuffer(context, CL_MEM_READ_WRITE, + sizeof(work_item_data_out_of_range) + * testData.size(), + NULL, &error); + test_error(error, "Unable to create output buffer"); - outData = - clCreateBuffer(context, CL_MEM_READ_WRITE, - sizeof(work_item_data) * testData.size(), NULL, &error); - test_error( error, "Unable to create output buffer" ); + error = clSetKernelArg(kernel, 0, sizeof(outData), &outData); + test_error(error, "Unable to set kernel arg"); - error = clSetKernelArg( kernel, 0, sizeof( outData ), &outData ); - test_error( error, "Unable to set kernel arg" ); + error = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, + sizeof(size_t) * maxWorkItemSizes.size(), + maxWorkItemSizes.data(), NULL); + test_error(error, + "clDeviceInfo for CL_DEVICE_MAX_WORK_ITEM_SIZES failed"); - d = init_genrand( gRandomSeed ); - for( size_t dim = 1; dim <= 3; dim++ ) + error = clGetKernelWorkGroupInfo( + kernel, device, CL_KERNEL_WORK_GROUP_SIZE, + sizeof(max_workgroup_size), &max_workgroup_size, NULL); + test_error(error, "clGetKernelWorkgroupInfo failed."); + + return CL_SUCCESS; + } + + bool Validate(const cl_uint dim) { - for( int i = 0; i < NUM_TESTS; i++ ) + cl_uint threads_to_verify = 1; + for (size_t j = 0; j < dim; j++) threads_to_verify *= threads[j]; + + for (size_t q = 0; q < threads_to_verify; q++) { - for( size_t j = 0; j < dim; j++ ) + if (testData[q].workDim != (cl_uint)dim) { - // All of our thread sizes should be within the max local sizes, since they're all <= 20 - threads[ j ] = (size_t)random_in_range( 1, 20, d ); - localThreads[ j ] = threads[ j ] / (size_t)random_in_range( 1, (int)threads[ j ], d ); - while( localThreads[ j ] > 1 && ( threads[ j ] % localThreads[ j ] != 0 ) ) - localThreads[ j ]--; - - // Hack for now: localThreads > 1 are iffy - localThreads[ j ] = 1; + log_error("ERROR: get_work_dim() did not return proper value " + "for %d dimensions (expected %d, got %d)\n", + (int)dim, (int)dim, (int)testData[q].workDim); + return false; } - error = clEnqueueNDRangeKernel( queue, kernel, (cl_uint)dim, NULL, threads, localThreads, 0, NULL, NULL ); - test_error( error, "Unable to run kernel" ); - - error = - clEnqueueReadBuffer(queue, outData, CL_TRUE, 0, - sizeof(work_item_data) * testData.size(), - testData.data(), 0, NULL, NULL); - test_error( error, "Unable to read results" ); + if (testData[q].globalSize != 1) + { + log_error("ERROR: get_global_size(%d) did not return " + "proper value for the argument out of range " + "(expected 1, got %d)\n", + (int)dim, (int)testData[q].globalSize); + return false; + } + if (testData[q].globalID != 0) + { + log_error("ERROR: get_global_id(%d) did not return " + "proper value for the argument out of range " + "(expected 0, got %d)\n", + (int)dim, (int)testData[q].globalID); + return false; + } + if (testData[q].localSize != 1) + { + log_error("ERROR: get_local_size(%d) did not return " + "proper value for the argument out of range " + "(expected 1, got %d)\n", + (int)dim, (int)testData[q].localSize); + return false; + } + if (testData[q].localID != 0) + { + log_error("ERROR: get_local_id(%d) did not return " + "proper value for the argument out of range " + "(expected 0, got %d)\n", + (int)dim, (int)testData[q].localID); + return false; + } + if (testData[q].numGroups != 1) + { + log_error("ERROR: get_num_groups(%d) did not return " + "proper value for the argument out of range " + "(expected 1, got %d)\n", + (int)dim, (int)testData[q].numGroups); + return false; + } + if (testData[q].groupID != 0) + { + log_error("ERROR: get_group_id(%d) did not return " + "proper value for the argument out of range " + "(expected 0, got %d)\n", + (int)dim, (int)testData[q].groupID); + return false; + } + } - // Validate - for( size_t q = 0; q < threads[0]; q++ ) + const Version version = get_device_cl_version(device); + if (version >= Version(2, 0)) + { + for (size_t q = 0; q < threads_to_verify; q++) { - // We can't really validate the actual value of each one, but we can validate that they're within a sane range - if( testData[ q ].workDim != (cl_uint)dim ) + if (testData[q].globalOffset != 0) { - log_error( "ERROR: get_work_dim() did not return proper value for %d dimensions (expected %d, got %d)\n", (int)dim, (int)dim, (int)testData[ q ].workDim ); - free_mtdata(d); - return -1; + log_error( + "ERROR: get_global_offset(%d) did not return " + "proper value " + "for the argument out of range (expected 0, got %d)\n", + (int)dim, (int)testData[q].globalOffset); + return false; } - for( size_t j = 0; j < dim; j++ ) + if (testData[q].enqueuedLocalSize != 1) { - if( testData[ q ].globalSize[ j ] != (cl_uint)threads[ j ] ) - { - log_error( "ERROR: get_global_size(%d) did not return proper value for %d dimensions (expected %d, got %d)\n", - (int)j, (int)dim, (int)threads[ j ], (int)testData[ q ].globalSize[ j ] ); - free_mtdata(d); - return -1; - } - if (testData[q].globalID[j] >= (cl_uint)threads[j]) - { - log_error( "ERROR: get_global_id(%d) did not return proper value for %d dimensions (max %d, got %d)\n", - (int)j, (int)dim, (int)threads[ j ], (int)testData[ q ].globalID[ j ] ); - free_mtdata(d); - return -1; - } - if( testData[ q ].localSize[ j ] != (cl_uint)localThreads[ j ] ) - { - log_error( "ERROR: get_local_size(%d) did not return proper value for %d dimensions (expected %d, got %d)\n", - (int)j, (int)dim, (int)localThreads[ j ], (int)testData[ q ].localSize[ j ] ); - free_mtdata(d); - return -1; - } - if (testData[q].localID[j] >= (cl_uint)localThreads[j]) - { - log_error( "ERROR: get_local_id(%d) did not return proper value for %d dimensions (max %d, got %d)\n", - (int)j, (int)dim, (int)localThreads[ j ], (int)testData[ q ].localID[ j ] ); - free_mtdata(d); - return -1; - } - size_t groupCount = ( threads[ j ] + localThreads[ j ] - 1 ) / localThreads[ j ]; - if( testData[ q ].numGroups[ j ] != (cl_uint)groupCount ) - { - log_error( "ERROR: get_num_groups(%d) did not return proper value for %d dimensions (expected %d with global dim %d and local dim %d, got %d)\n", - (int)j, (int)dim, (int)groupCount, (int)threads[ j ], (int)localThreads[ j ], (int)testData[ q ].numGroups[ j ] ); - free_mtdata(d); - return -1; - } - if (testData[q].groupID[j] >= (cl_uint)groupCount) - { - log_error( "ERROR: get_group_id(%d) did not return proper value for %d dimensions (max %d, got %d)\n", - (int)j, (int)dim, (int)groupCount, (int)testData[ q ].groupID[ j ] ); - free_mtdata(d); - return -1; - } + log_error( + "ERROR: get_enqueued_local_size(%d) did not return " + "proper value for the argument out of range " + "(expected 1, got %d)\n", + (int)dim, (int)testData[q].globalSize); + return false; + } + } + } + else if (version >= Version(1, 1)) + { + for (size_t q = 0; q < threads_to_verify; q++) + { + if (testData[q].globalOffset != 0) + { + log_error( + "ERROR: get_global_offset(%d) did not return " + "proper value " + "for the argument out of range (expected 0, got %d)\n", + (int)dim, (int)testData[q].globalOffset); + return false; + } + } + } + + return true; + } + + cl_int Run() + { + cl_int error = SetUp(kernel_src); + test_error(error, "SetUp failed"); + + size_t localThreads[3] = { 0, 0, 0 }; + + for (size_t dim = 1; dim <= 3; dim++) + { + size_t local_workgroup_size[3] = { maxWorkItemSizes[0], + maxWorkItemSizes[1], + maxWorkItemSizes[2] }; + // check if maximum work group size for current dimention is not + // exceeded + cl_uint work_group_size = max_workgroup_size + 1; + while (max_workgroup_size < work_group_size && work_group_size != 1) + { + work_group_size = 1; + for (size_t j = 0; j < dim; j++) + work_group_size *= local_workgroup_size[j]; + if (max_workgroup_size < work_group_size) + { + for (size_t j = 0; j < dim; j++) + local_workgroup_size[j] = + std::max(1, (int)local_workgroup_size[j] / 2); } + }; + + // compute max number of work groups based on buffer size and max + // group size + cl_uint max_work_groups = testData.size() / work_group_size; + // take into account number of dimentions + cl_uint work_groups_per_dim = + std::max(1, (int)pow(max_work_groups, 1.f / dim)); + + for (size_t j = 0; j < dim; j++) + { + // generate ranges for uniform work group size + localThreads[j] = + random_in_range(1, (int)local_workgroup_size[j], d_holder); + size_t num_groups = + (size_t)random_in_range(1, work_groups_per_dim, d_holder); + threads[j] = num_groups * localThreads[j]; + } + + cl_int dim_param = dim + 1; + error = clSetKernelArg(kernel, 1, sizeof(cl_int), &dim_param); + test_error(error, "Unable to set kernel arg"); + + error = + clEnqueueNDRangeKernel(queue, kernel, (cl_uint)dim, NULL, + threads, localThreads, 0, NULL, NULL); + test_error(error, "Unable to run kernel"); + + error = clEnqueueReadBuffer(queue, outData, CL_TRUE, 0, + sizeof(work_item_data_out_of_range) + * testData.size(), + testData.data(), 0, NULL, NULL); + test_error(error, "Unable to read results"); + + // Validate + if (!Validate(dim)) + { + log_error("Validation failed"); + return TEST_FAIL; } } + return TEST_PASS; } - free_mtdata(d); - return 0; + cl_device_id device; + cl_context context; + cl_command_queue queue; + clProgramWrapper program; + clKernelWrapper kernel; + clMemWrapper outData; + MTdataHolder d_holder; + + std::vector testData; + + std::array maxWorkItemSizes; + size_t max_workgroup_size; + + const char *kernel_src; +}; + +} // anonymous namespace + +int test_work_item_functions(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) +{ + TestWorkItemFns fnct(deviceID, context, queue); + return fnct.Run(); } +int test_work_item_functions_out_of_range(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + TestWorkItemFnsOutOfRange fnct(deviceID, context, queue, + outOfRangeWorkItemKernelCode); + return fnct.Run(); +} +int test_work_item_functions_out_of_range_hardcoded(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + TestWorkItemFnsOutOfRange fnct(deviceID, context, queue, + outOfRangeWorkItemHardcodedKernelCode); + return fnct.Run(); +} From 5b3518096ca7b82854daadb2b2fae704fe2d9cb5 Mon Sep 17 00:00:00 2001 From: Sreelakshmi Haridas Maruthur Date: Tue, 21 Jan 2025 10:44:47 -0700 Subject: [PATCH 35/39] bruteforce: Update ULP for half-precision divide to 1.0f (#2214) CTS test update to match proposed spec update https://github.com/KhronosGroup/OpenCL-Docs/issues/1278 --- test_conformance/math_brute_force/function_list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_conformance/math_brute_force/function_list.cpp b/test_conformance/math_brute_force/function_list.cpp index 5f7b8ea0e2..f06921bddb 100644 --- a/test_conformance/math_brute_force/function_list.cpp +++ b/test_conformance/math_brute_force/function_list.cpp @@ -425,7 +425,7 @@ const Func functionList[] = { { (void*)reference_relaxed_divide }, 2.5f, 0.0f, - 0.0f, + 1.0f, 3.0f, 2.5f, INFINITY, From c6cfb6800f37e61eca1503719bced065f3ec9cc1 Mon Sep 17 00:00:00 2001 From: Marcin Hajder Date: Tue, 28 Jan 2025 17:53:40 +0100 Subject: [PATCH 36/39] Added test to verify flush on clReleaseCommandQueue with multiple queues (#2134) Fixes #2087 according to task description. --- test_conformance/api/test_queue.cpp | 60 ++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/test_conformance/api/test_queue.cpp b/test_conformance/api/test_queue.cpp index 1023c1f835..0d0fa13daa 100644 --- a/test_conformance/api/test_queue.cpp +++ b/test_conformance/api/test_queue.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2020 The Khronos Group Inc. +// 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. @@ -58,3 +58,61 @@ REGISTER_TEST(queue_flush_on_release) return success ? TEST_PASS : TEST_FAIL; } + +REGISTER_TEST(multi_queue_flush_on_release) +{ + cl_int err; + + // Create A command queue + cl_command_queue queue_A = clCreateCommandQueue(context, device, 0, &err); + test_error(err, "Could not create command queue A"); + + // Create B command queue + cl_command_queue queue_B = clCreateCommandQueue(context, device, 0, &err); + test_error(err, "Could not create command queue B"); + + // Create a kernel + clProgramWrapper program; + clKernelWrapper kernel; + const char *source = "void kernel test(){}"; + err = create_single_kernel_helper(context, &program, &kernel, 1, &source, + "test"); + test_error(err, "Could not create kernel"); + + // Enqueue the kernel on queue_A and obtain event to synchronize with + // queue_B + size_t gws = num_elements; + clEventWrapper event_A; + err = clEnqueueNDRangeKernel(queue_A, kernel, 1, nullptr, &gws, nullptr, 0, + nullptr, &event_A); + test_error(err, "Could not enqueue kernel"); + + // Enqueue the kernel on queue_B using event_A for synchronization and + // create event_B to track completion + clEventWrapper event_B; + err = clEnqueueNDRangeKernel(queue_B, kernel, 1, nullptr, &gws, nullptr, 1, + &event_A, &event_B); + test_error(err, "Could not enqueue kernel"); + + // Release queue_A, which performs an implicit flush to issue any previously + // queued OpenCL commands + err = clReleaseCommandQueue(queue_A); + test_error(err, "clReleaseCommandQueue failed"); + + err = clFlush(queue_B); + test_error(err, "clFlush failed"); + + // Wait for kernel to execute since the queue must flush on release + bool success = poll_until(2000, 50, [&event_B]() { + cl_int status; + cl_int err = clGetEventInfo(event_B, CL_EVENT_COMMAND_EXECUTION_STATUS, + sizeof(cl_int), &status, nullptr); + if ((err != CL_SUCCESS) || (status != CL_COMPLETE)) + { + return false; + } + return true; + }); + + return success ? TEST_PASS : TEST_FAIL; +} From 73dd3b9af875dae322b91b00b021fa3582cb800c Mon Sep 17 00:00:00 2001 From: Ahmed Hesham <117350656+ahesham-arm@users.noreply.github.com> Date: Tue, 28 Jan 2025 18:08:24 +0000 Subject: [PATCH 37/39] Fix errors in `test_vulkan` (#2183) This fixes three problems in `test_vulkan`: 1. One negative test is violating the OpenCL specification. A call to `clEnqueue{Wait,Signal}SemaphoresKHR` with an invalid semaphore should return `CL_INVALID_SEMAPHORE_KHR` and not `CL_INVALID_VALUE`. > [CL_INVALID_SEMAPHORE_KHR](https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_INVALID_SEMAPHORE_KHR) if any of the semaphore objects specified by sema_objects is not valid. 2. When populating the list of supported external memory handle types for Vulkan, the types are unconditionally added to the list, without checking if the device supports it or not, this fix is namely for `VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD`. 3. If a device does not support an optional extension (that is required for a test), the test should skip, not throw an exception and fail. A test failure should be reserved for the cases where a device claims support for an extension but then fails to execute the test correctly. --------- Signed-off-by: Ahmed Hesham --- test_common/harness/errorHelpers.cpp | 1 + .../common/vulkan_wrapper/vulkan_api_list.hpp | 5 ++- .../common/vulkan_wrapper/vulkan_utility.cpp | 22 ++++++++-- .../common/vulkan_wrapper/vulkan_utility.hpp | 3 +- .../vulkan/test_vulkan_api_consistency.cpp | 40 ++++++++++--------- ...st_vulkan_api_consistency_for_1dimages.cpp | 9 +++-- ...st_vulkan_api_consistency_for_3dimages.cpp | 9 +++-- .../vulkan/test_vulkan_interop_buffer.cpp | 12 ++++-- .../vulkan/test_vulkan_interop_image.cpp | 7 +++- 9 files changed, 70 insertions(+), 38 deletions(-) diff --git a/test_common/harness/errorHelpers.cpp b/test_common/harness/errorHelpers.cpp index 64c730b32d..63bd107c3b 100644 --- a/test_common/harness/errorHelpers.cpp +++ b/test_common/harness/errorHelpers.cpp @@ -111,6 +111,7 @@ const char *IGetErrorString(int clErrorCode) return "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR"; case CL_INVALID_COMMAND_BUFFER_KHR: return "CL_INVALID_COMMAND_BUFFER_KHR"; + case CL_INVALID_SEMAPHORE_KHR: return "CL_INVALID_SEMAPHORE_KHR"; default: return "(unknown)"; } } diff --git a/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp b/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp index ab4acb431a..f5e7437a3c 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp @@ -101,7 +101,8 @@ VK_FUNC_DECL(vkGetPhysicalDeviceSurfaceSupportKHR) \ VK_FUNC_DECL(vkImportSemaphoreFdKHR) \ VK_FUNC_DECL(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) \ - VK_FUNC_DECL(vkGetImageSubresourceLayout) + VK_FUNC_DECL(vkGetImageSubresourceLayout) \ + VK_FUNC_DECL(vkGetPhysicalDeviceExternalBufferProperties) #define VK_WINDOWS_FUNC_LIST \ VK_FUNC_DECL(vkGetMemoryWin32HandleKHR) \ VK_FUNC_DECL(vkGetSemaphoreWin32HandleKHR) \ @@ -202,5 +203,7 @@ #define vkGetSemaphoreWin32HandleKHR _vkGetSemaphoreWin32HandleKHR #define vkImportSemaphoreWin32HandleKHR _vkImportSemaphoreWin32HandleKHR #define vkGetImageSubresourceLayout _vkGetImageSubresourceLayout +#define vkGetPhysicalDeviceExternalBufferProperties \ + _vkGetPhysicalDeviceExternalBufferProperties #endif //_vulkan_api_list_hpp_ diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp index e4796bc9d0..6391d36b1c 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp @@ -225,7 +225,8 @@ getDefaultVulkanQueueFamilyToQueueCountMap() } const std::vector -getSupportedVulkanExternalMemoryHandleTypeList() +getSupportedVulkanExternalMemoryHandleTypeList( + const VulkanPhysicalDevice &physical_device) { std::vector externalMemoryHandleTypeList; @@ -238,8 +239,23 @@ getSupportedVulkanExternalMemoryHandleTypeList() externalMemoryHandleTypeList.push_back( VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT); #else - externalMemoryHandleTypeList.push_back( - VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD); + VkPhysicalDeviceExternalBufferInfo buffer_info = {}; + buffer_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO; + buffer_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR; + + VkExternalBufferProperties buffer_properties = {}; + buffer_properties.sType = VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES; + + vkGetPhysicalDeviceExternalBufferProperties(physical_device, &buffer_info, + &buffer_properties); + + if (buffer_properties.externalMemoryProperties.externalMemoryFeatures + & VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT) + { + + externalMemoryHandleTypeList.push_back( + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD); + } #endif return externalMemoryHandleTypeList; diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp index 486ad97c80..85028662b4 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp @@ -47,7 +47,8 @@ const VulkanDescriptorSetLayoutList& getEmptyVulkanDescriptorSetLayoutList(); const VulkanQueueFamilyToQueueCountMap& getDefaultVulkanQueueFamilyToQueueCountMap(); const std::vector -getSupportedVulkanExternalMemoryHandleTypeList(); +getSupportedVulkanExternalMemoryHandleTypeList( + const VulkanPhysicalDevice& physical_device); const std::vector getSupportedVulkanExternalSemaphoreHandleTypeList(const VulkanDevice& vkDevice); std::vector diff --git a/test_conformance/vulkan/test_vulkan_api_consistency.cpp b/test_conformance/vulkan/test_vulkan_api_consistency.cpp index b27a3c74c5..f3ce4a7914 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency.cpp @@ -61,14 +61,15 @@ struct ConsistencyExternalBufferTest : public VulkanTestBase #else if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) { - throw std::runtime_error( - "Device does not support " - "cl_khr_external_memory_opaque_fd extension \n"); + log_info("Device does not support " + "cl_khr_external_memory_opaque_fd extension \n"); + return TEST_SKIPPED_ITSELF; } #endif VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice->getPhysicalDevice())[0]; VulkanBuffer vkDummyBuffer(*vkDevice, 4 * 1024, vkExternalMemoryHandleType); @@ -200,9 +201,9 @@ struct ConsistencyExternalImageTest : public VulkanTestBase #else if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) { - test_fail( - "Device does not support cl_khr_external_memory_opaque_fd " - "extension \n"); + log_info("Device does not support cl_khr_external_memory_opaque_fd " + "extension \n"); + return TEST_SKIPPED_ITSELF; } #endif uint32_t width = 256; @@ -212,7 +213,8 @@ struct ConsistencyExternalImageTest : public VulkanTestBase cl_image_format img_format = { 0 }; VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice->getPhysicalDevice())[0]; VulkanImageTiling vulkanImageTiling = vkClExternalMemoryHandleTilingAssumption( @@ -355,9 +357,9 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase #else if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) { - test_fail( - "Device does not support cl_khr_external_memory_opaque_fd " - "extension \n"); + log_info("Device does not support cl_khr_external_memory_opaque_fd " + "extension \n"); + return TEST_SKIPPED_ITSELF; } #endif @@ -484,18 +486,18 @@ struct ConsistencyExternalSemaphoreTest : public VulkanTestBase // Pass invalid semaphore object to wait errNum = clEnqueueWaitSemaphoresKHRptr(queue, 1, NULL, NULL, 0, NULL, NULL); - test_failure_error( - errNum, CL_INVALID_VALUE, - "clEnqueueWaitSemaphoresKHR fails with CL_INVALID_VALUE " - "when invalid semaphore object is passed"); + test_failure_error(errNum, CL_INVALID_SEMAPHORE_KHR, + "clEnqueueWaitSemaphoresKHR fails with " + "CL_INVALID_SEMAPHORE_KHR " + "when invalid semaphore object is passed"); // Pass invalid semaphore object to signal errNum = clEnqueueSignalSemaphoresKHRptr(queue, 1, NULL, NULL, 0, NULL, NULL); - test_failure_error( - errNum, CL_INVALID_VALUE, - "clEnqueueSignalSemaphoresKHR fails with CL_INVALID_VALUE" - "when invalid semaphore object is passed"); + test_failure_error(errNum, CL_INVALID_SEMAPHORE_KHR, + "clEnqueueSignalSemaphoresKHR fails with " + "CL_INVALID_SEMAPHORE_KHR" + "when invalid semaphore object is passed"); // Create two semaphore objects clVk2Clsemaphore = clCreateSemaphoreWithPropertiesKHRptr( diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp index 799a73f05b..346a3ce566 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp @@ -59,9 +59,9 @@ struct ConsistencyExternalImage1DTest : public VulkanTestBase #else if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) { - throw std::runtime_error( - "Device does not support cl_khr_external_memory_opaque_fd " - "extension \n"); + log_info("Device does not support " + "cl_khr_external_memory_opaque_fd extension \n"); + return TEST_SKIPPED_ITSELF; } #endif uint32_t width = 256; @@ -70,7 +70,8 @@ struct ConsistencyExternalImage1DTest : public VulkanTestBase cl_image_format img_format = { 0 }; VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice->getPhysicalDevice())[0]; VulkanImageTiling vulkanImageTiling = vkClExternalMemoryHandleTilingAssumption( diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp index b30f37477f..8dd9ae9a3e 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp @@ -60,9 +60,9 @@ struct ConsistencyExternalImage3DTest : public VulkanTestBase #else if (!is_extension_available(device, "cl_khr_external_memory_opaque_fd")) { - throw std::runtime_error( - "Device does not support cl_khr_external_memory_opaque_fd " - "extension \n"); + log_info("Device does not support " + "cl_khr_external_memory_opaque_fd extension \n"); + return TEST_SKIPPED_ITSELF; } #endif uint32_t width = 256; @@ -73,7 +73,8 @@ struct ConsistencyExternalImage3DTest : public VulkanTestBase cl_image_format img_format = { 0 }; VulkanExternalMemoryHandleType vkExternalMemoryHandleType = - getSupportedVulkanExternalMemoryHandleTypeList()[0]; + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice->getPhysicalDevice())[0]; VulkanImageTiling vulkanImageTiling = vkClExternalMemoryHandleTilingAssumption( diff --git a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp index e5f1a72800..9407803132 100644 --- a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp @@ -113,7 +113,8 @@ int run_test_with_two_queue( const std::vector vkExternalMemoryHandleTypeList = - getSupportedVulkanExternalMemoryHandleTypeList(); + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice.getPhysicalDevice()); VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; @@ -447,7 +448,8 @@ int run_test_with_one_queue( const std::vector vkExternalMemoryHandleTypeList = - getSupportedVulkanExternalMemoryHandleTypeList(); + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice.getPhysicalDevice()); VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; @@ -752,7 +754,8 @@ int run_test_with_multi_import_same_ctx( const std::vector vkExternalMemoryHandleTypeList = - getSupportedVulkanExternalMemoryHandleTypeList(); + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice.getPhysicalDevice()); VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; @@ -1092,7 +1095,8 @@ int run_test_with_multi_import_diff_ctx( const std::vector vkExternalMemoryHandleTypeList = - getSupportedVulkanExternalMemoryHandleTypeList(); + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice.getPhysicalDevice()); VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); VulkanSemaphore vkCl2VkSemaphore(vkDevice, vkExternalSemaphoreHandleType); std::shared_ptr fence = nullptr; diff --git a/test_conformance/vulkan/test_vulkan_interop_image.cpp b/test_conformance/vulkan/test_vulkan_interop_image.cpp index 7808ef64dc..d529f48211 100644 --- a/test_conformance/vulkan/test_vulkan_interop_image.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_image.cpp @@ -208,7 +208,9 @@ int run_test_with_two_queue( std::vector vkFormatList = getSupportedVulkanFormatList(); const std::vector vkExternalMemoryHandleTypeList = - getSupportedVulkanExternalMemoryHandleTypeList(); + getSupportedVulkanExternalMemoryHandleTypeList( + + vkDevice.getPhysicalDevice()); char magicValue = 0; VulkanBuffer vkParamsBuffer(vkDevice, sizeof(Params)); @@ -820,7 +822,8 @@ int run_test_with_one_queue( std::vector vkFormatList = getSupportedVulkanFormatList(); const std::vector vkExternalMemoryHandleTypeList = - getSupportedVulkanExternalMemoryHandleTypeList(); + getSupportedVulkanExternalMemoryHandleTypeList( + vkDevice.getPhysicalDevice()); char magicValue = 0; VulkanBuffer vkParamsBuffer(vkDevice, sizeof(Params)); From 5749818906f7a3c3e4237ab0ac80f4d6eb57db3f Mon Sep 17 00:00:00 2001 From: Chuang-Yu Cheng Date: Wed, 29 Jan 2025 05:33:00 +0900 Subject: [PATCH 38/39] math_brute_force: fix `fdim` to use device's rounding when converting result back to half. (#2223) In the half-precision `fdim` test, the original code used `CL_HALF_RTE` to convert the float result back to half, causing a mismatch in computation results when the hardware uses RTZ. Some of the examples: ``` fdim(0x365f, 0xdc63) = fdim( 0.398193f, -280.75f) = 281.148193f (RTE=0x5c65, RTZ=0x5c64) fdim(0xa4a3, 0xf0e9) = fdim(-0.018112f, 10056.0f) = 10055.981445f (RTE=0x70e9, RTZ=0x70e8) fdim(0x1904, 0x9ab7) = fdim( 0.002449f, -0.003279f) = 0.005728f (RTE=0x1dde, RTZ=0x1ddd) ``` Fixed this by using the hardware's default rounding mode when converting the result back to half. --- test_conformance/math_brute_force/binary_half.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test_conformance/math_brute_force/binary_half.cpp b/test_conformance/math_brute_force/binary_half.cpp index 180034ba7d..70057db5e0 100644 --- a/test_conformance/math_brute_force/binary_half.cpp +++ b/test_conformance/math_brute_force/binary_half.cpp @@ -266,6 +266,7 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) return CL_SUCCESS; } + cl_half_rounding_mode halfRoundingMode = CL_HALF_RTE; FPU_mode_type oldMode; oldRoundMode = kRoundToNearestEven; if (isFDim) @@ -275,7 +276,11 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) if (ftz) ForceFTZ(&oldMode); // Set the rounding mode to match the device - if (gIsInRTZMode) oldRoundMode = set_round(kRoundTowardZero, kfloat); + if (gIsInRTZMode) + { + oldRoundMode = set_round(kRoundTowardZero, kfloat); + halfRoundingMode = CL_HALF_RTZ; + } } if (!strcmp(name, "copysign")) copysign_test = 1; @@ -293,9 +298,9 @@ cl_int TestHalf(cl_uint job_id, cl_uint thread_id, void *data) s2[j] = cl_half_to_float(p2[j]); if (isNextafter) r[j] = cl_half_from_float(reference_nextafterh(s[j], s2[j]), - CL_HALF_RTE); + halfRoundingMode); else - r[j] = cl_half_from_float(ref_func(s[j], s2[j]), CL_HALF_RTE); + r[j] = cl_half_from_float(ref_func(s[j], s2[j]), halfRoundingMode); } if (isFDim && ftz) RestoreFPState(&oldMode); From cc9e61652fc5087dc2706908a30d701747e5e1e1 Mon Sep 17 00:00:00 2001 From: Julia Jiang <56359287+jujiang-del@users.noreply.github.com> Date: Mon, 3 Feb 2025 07:46:52 -0500 Subject: [PATCH 39/39] Fix profiling execute_multipass failure with segmentation fault (#2256) The buffer size input to the test function clEnqueueReadBuffer was incorrect, which cause segmentation fault. And it didn't match the size for the host allocation outptr --- test_conformance/profiling/execute_multipass.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test_conformance/profiling/execute_multipass.cpp b/test_conformance/profiling/execute_multipass.cpp index 921be5b994..2fd89f65a1 100644 --- a/test_conformance/profiling/execute_multipass.cpp +++ b/test_conformance/profiling/execute_multipass.cpp @@ -133,7 +133,7 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue // allocate an array memory object to load the filter weights memobjs[1] = clCreateBuffer(context, CL_MEM_READ_WRITE, - sizeof(cl_float) * w * h * d * nChannels, NULL, &err); + sizeof(cl_uchar) * w * h * d * nChannels, NULL, &err); if( memobjs[1] == (cl_mem)0 ){ log_error( " unable to create array using clCreateBuffer\n" ); clReleaseMemObject( memobjs[0] ); @@ -237,7 +237,9 @@ static int run_kernel( cl_device_id device, cl_context context, cl_command_queue } // read output image - err = clEnqueueReadBuffer(queue, memobjs[1], CL_TRUE, 0, w*h*d*nChannels*4, outptr, 0, NULL, NULL); + err = clEnqueueReadBuffer(queue, memobjs[1], CL_TRUE, 0, + sizeof(cl_uchar) * w * h * d * nChannels, outptr, + 0, NULL, NULL); if( err != CL_SUCCESS ){ print_error( err, "clReadImage failed\n" ); clReleaseKernel( kernel[0] );