diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c9bbf6f..5cfef6b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,11 @@ if( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qlong-double -Qpc80 /DWIN32 /D_WINDOWS /W3 /GR /EHsc -nologo -Od -D_CRT_NONSTDC_NO_WARNINGS -EHsc -Wall -Qdiag-disable:68,111,177,186,161,869,1028,2259,2553,181,239,265,1188 -fp:strict -fp:source") endif() +# To handle addresses larger than 2 gigabytes for 32bit targets +if(WIN32 AND ${CLConform_TARGET_ARCH} STREQUAL "x86") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") +endif() + list(APPEND CLConform_LIBRARIES ${OPENCL_LIBRARIES}) if(ANDROID) list(APPEND CLConform_LIBRARIES m) diff --git a/test_common/harness/crc32.h b/test_common/harness/crc32.h index 69587011..aa450163 100644 --- a/test_common/harness/crc32.h +++ b/test_common/harness/crc32.h @@ -1,19 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. -All Rights Reserved. This code is protected by copyright laws and -contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed -in whole or in part to third parties, and may not be reproduced, republished, -distributed, transmitted, displayed, broadcast or otherwise exploited in any -manner without the express prior written permission of Khronos Group. - -The receipt or possession of this code does not convey any rights to -reproduce, disclose, or distribute its contents, or to -manufacture, use, or sell anything that it may describe, in whole -or in part other than under the terms of the Khronos Adopters -Agreement or Khronos Conformance Test Source License Agreement as -executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 CRC32_H_ #define CRC32_H_ diff --git a/test_common/harness/imageHelpers.cpp b/test_common/harness/imageHelpers.cpp index 3e1a3442..49d5402a 100644 --- a/test_common/harness/imageHelpers.cpp +++ b/test_common/harness/imageHelpers.cpp @@ -97,23 +97,9 @@ uint32_t get_channel_data_type_size(cl_channel_type channelType) case CL_UNSIGNED_INT32: return sizeof(cl_int); case CL_UNORM_SHORT_565: - case CL_UNORM_SHORT_555: -#ifdef OBSOLETE_FORAMT - case CL_UNORM_SHORT_565_REV: - case CL_UNORM_SHORT_555_REV: -#endif - return 2; + case CL_UNORM_SHORT_555: return 2; -#ifdef OBSOLETE_FORAMT - case CL_UNORM_INT_8888: - case CL_UNORM_INT_8888_REV: return 4; -#endif - - case CL_UNORM_INT_101010: -#ifdef OBSOLETE_FORAMT - case CL_UNORM_INT_101010_REV: -#endif - return 4; + case CL_UNORM_INT_101010: return 4; case CL_FLOAT: return sizeof(cl_float); @@ -294,23 +280,9 @@ uint32_t get_pixel_size(const cl_image_format *format) return get_format_channel_count(format) * sizeof(cl_int); case CL_UNORM_SHORT_565: - case CL_UNORM_SHORT_555: -#ifdef OBSOLETE_FORAMT - case CL_UNORM_SHORT_565_REV: - case CL_UNORM_SHORT_555_REV: -#endif - return 2; + case CL_UNORM_SHORT_555: return 2; -#ifdef OBSOLETE_FORAMT - case CL_UNORM_INT_8888: - case CL_UNORM_INT_8888_REV: return 4; -#endif - - case CL_UNORM_INT_101010: -#ifdef OBSOLETE_FORAMT - case CL_UNORM_INT_101010_REV: -#endif - return 4; + case CL_UNORM_INT_101010: return 4; case CL_FLOAT: return get_format_channel_count(format) * sizeof(cl_float); diff --git a/test_common/harness/imageHelpers.h b/test_common/harness/imageHelpers.h index f8ae4fb9..455f0edb 100644 --- a/test_common/harness/imageHelpers.h +++ b/test_common/harness/imageHelpers.h @@ -347,48 +347,6 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x, break; } -#ifdef OBSOLETE_FORMAT - case CL_UNORM_SHORT_565_REV: { - unsigned short *dPtr = (unsigned short *)ptr; - tempData[2] = (T)(dPtr[0] >> 11); - tempData[1] = (T)((dPtr[0] >> 5) & 63); - tempData[0] = (T)(dPtr[0] & 31); - break; - } - - case CL_UNORM_SHORT_555_REV: { - unsigned short *dPtr = (unsigned short *)ptr; - tempData[2] = (T)((dPtr[0] >> 10) & 31); - tempData[1] = (T)((dPtr[0] >> 5) & 31); - tempData[0] = (T)(dPtr[0] & 31); - break; - } - - case CL_UNORM_INT_8888: { - unsigned int *dPtr = (unsigned int *)ptr; - tempData[3] = (T)(dPtr[0] >> 24); - tempData[2] = (T)((dPtr[0] >> 16) & 0xff); - tempData[1] = (T)((dPtr[0] >> 8) & 0xff); - tempData[0] = (T)(dPtr[0] & 0xff); - break; - } - case CL_UNORM_INT_8888_REV: { - unsigned int *dPtr = (unsigned int *)ptr; - tempData[0] = (T)(dPtr[0] >> 24); - tempData[1] = (T)((dPtr[0] >> 16) & 0xff); - tempData[2] = (T)((dPtr[0] >> 8) & 0xff); - tempData[3] = (T)(dPtr[0] & 0xff); - break; - } - - case CL_UNORM_INT_101010_REV: { - unsigned int *dPtr = (unsigned int *)ptr; - tempData[2] = (T)((dPtr[0] >> 20) & 0x3ff); - tempData[1] = (T)((dPtr[0] >> 10) & 0x3ff); - tempData[0] = (T)(dPtr[0] & 0x3ff); - break; - } -#endif case CL_UNORM_SHORT_555: { cl_ushort *dPtr = (cl_ushort *)ptr; tempData[0] = (T)((dPtr[0] >> 10) & 31); diff --git a/test_common/harness/testHarness.cpp b/test_common/harness/testHarness.cpp index 3e5d7c95..0e3c49e9 100644 --- a/test_common/harness/testHarness.cpp +++ b/test_common/harness/testHarness.cpp @@ -185,6 +185,9 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum, else if (strcmp(env_mode, "accelerator") == 0 || strcmp(env_mode, "CL_DEVICE_TYPE_ACCELERATOR") == 0) device_type = CL_DEVICE_TYPE_ACCELERATOR; + else if (strcmp(env_mode, "custom") == 0 + || strcmp(env_mode, "CL_DEVICE_TYPE_CUSTOM") == 0) + device_type = CL_DEVICE_TYPE_CUSTOM; else if (strcmp(env_mode, "default") == 0 || strcmp(env_mode, "CL_DEVICE_TYPE_DEFAULT") == 0) device_type = CL_DEVICE_TYPE_DEFAULT; @@ -314,6 +317,12 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum, device_type = CL_DEVICE_TYPE_ACCELERATOR; argc--; } + else if (strcmp(argv[argc - 1], "custom") == 0 + || strcmp(argv[argc - 1], "CL_DEVICE_TYPE_CUSTOM") == 0) + { + device_type = CL_DEVICE_TYPE_CUSTOM; + argc--; + } else if (strcmp(argv[argc - 1], "CL_DEVICE_TYPE_DEFAULT") == 0) { device_type = CL_DEVICE_TYPE_DEFAULT; @@ -351,6 +360,9 @@ int runTestHarnessWithCheck(int argc, const char *argv[], int testNum, case CL_DEVICE_TYPE_ACCELERATOR: log_info("Requesting Accelerator device "); break; + case CL_DEVICE_TYPE_CUSTOM: + log_info("Requesting Custom device "); + break; case CL_DEVICE_TYPE_DEFAULT: log_info("Requesting Default device "); break; @@ -1196,18 +1208,21 @@ Version get_device_spirv_il_version(cl_device_id device) ASSERT_SUCCESS(err, "clGetDeviceInfo"); } - if (strstr(str.data(), "SPIR-V_1.0") != NULL) - return Version(1, 0); - else if (strstr(str.data(), "SPIR-V_1.1") != NULL) - return Version(1, 1); - else if (strstr(str.data(), "SPIR-V_1.2") != NULL) - return Version(1, 2); - else if (strstr(str.data(), "SPIR-V_1.3") != NULL) - return Version(1, 3); + // Because this query returns a space-separated list of IL version strings + // we should check for SPIR-V versions in reverse order, to return the + // highest version supported. + if (strstr(str.data(), "SPIR-V_1.5") != NULL) + return Version(1, 5); else if (strstr(str.data(), "SPIR-V_1.4") != NULL) return Version(1, 4); - else if (strstr(str.data(), "SPIR-V_1.5") != NULL) - return Version(1, 5); + else if (strstr(str.data(), "SPIR-V_1.3") != NULL) + return Version(1, 3); + else if (strstr(str.data(), "SPIR-V_1.2") != NULL) + return Version(1, 2); + else if (strstr(str.data(), "SPIR-V_1.1") != NULL) + return Version(1, 1); + else if (strstr(str.data(), "SPIR-V_1.0") != NULL) + return Version(1, 0); throw std::runtime_error(std::string("Unknown SPIR-V version: ") + str.data()); diff --git a/test_conformance/SVM/test_migrate.cpp b/test_conformance/SVM/test_migrate.cpp index f624bcd9..b767a70a 100644 --- a/test_conformance/SVM/test_migrate.cpp +++ b/test_conformance/SVM/test_migrate.cpp @@ -16,6 +16,8 @@ #include "common.h" #include "harness/mt19937.h" +#include + #define GLOBAL_SIZE 65536 static const char *sources[] = { @@ -75,9 +77,9 @@ wait_and_release(const char* s, cl_event* evs, int n) int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue, int num_elements) { - cl_uint amem[GLOBAL_SIZE]; - cl_uint bmem[GLOBAL_SIZE]; - cl_uint cmem[GLOBAL_SIZE]; + std::vector amem(GLOBAL_SIZE); + std::vector bmem(GLOBAL_SIZE); + std::vector cmem(GLOBAL_SIZE); cl_event evs[20]; const size_t global_size = GLOBAL_SIZE; @@ -145,9 +147,9 @@ int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue test_error(error, "clSetKernelArgSVMPointer failed"); // Initialize host copy of data (and result) - fill_buffer(amem, global_size, seed); - fill_buffer(bmem, global_size, seed); - fill_buffer(cmem, global_size, seed); + fill_buffer(amem.data(), global_size, seed); + fill_buffer(bmem.data(), global_size, seed); + fill_buffer(cmem.data(), global_size, seed); // Now we're ready to start { @@ -218,9 +220,9 @@ int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue if (error) return -1; - memcpy((void *)asvm, (void *)amem, global_size*sizeof(cl_uint)); - memcpy((void *)bsvm, (void *)bmem, global_size*sizeof(cl_uint)); - memcpy((void *)csvm, (void *)cmem, global_size*sizeof(cl_uint)); + memcpy((void *)asvm, (void *)amem.data(), global_size * sizeof(cl_uint)); + memcpy((void *)bsvm, (void *)bmem.data(), global_size * sizeof(cl_uint)); + memcpy((void *)csvm, (void *)cmem.data(), global_size * sizeof(cl_uint)); { error = clEnqueueSVMUnmap(queues[1], (void *)asvm, 0, NULL, &evs[0]); @@ -304,9 +306,9 @@ int test_svm_migrate(cl_device_id deviceID, cl_context c, cl_command_queue queue return -1; // Check kernel results - bool ok = check("memory a", (cl_uint *)asvm, amem, global_size); - ok &= check("memory b", (cl_uint *)bsvm, bmem, global_size); - ok &= check("memory c", (cl_uint *)csvm, cmem, global_size); + bool ok = check("memory a", (cl_uint *)asvm, amem.data(), global_size); + ok &= check("memory b", (cl_uint *)bsvm, bmem.data(), global_size); + ok &= check("memory c", (cl_uint *)csvm, cmem.data(), global_size); { void *ptrs[] = { asvm, bsvm, csvm }; diff --git a/test_conformance/allocations/allocation_execute.cpp b/test_conformance/allocations/allocation_execute.cpp index fb19cccc..17627110 100644 --- a/test_conformance/allocations/allocation_execute.cpp +++ b/test_conformance/allocations/allocation_execute.cpp @@ -16,6 +16,8 @@ #include "allocation_execute.h" #include "allocation_functions.h" +#include + const char *buffer_kernel_pattern = { "__kernel void sample_test(%s __global uint *result, __global %s *array_sizes, uint per_item)\n" @@ -155,7 +157,8 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev size_t global_dims[3]; cl_uint per_item; cl_uint per_item_uint; - cl_uint returned_results[NUM_OF_WORK_ITEMS], final_result; + cl_uint final_result; + std::vector returned_results(NUM_OF_WORK_ITEMS); clEventWrapper event; cl_int event_status; @@ -236,7 +239,9 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev } // Set the result - result_mem = clCreateBuffer(context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, sizeof(cl_uint)*NUM_OF_WORK_ITEMS, &returned_results, &error); + result_mem = clCreateBuffer( + context, CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR, + sizeof(cl_uint) * NUM_OF_WORK_ITEMS, returned_results.data(), &error); test_error(error, "clCreateBuffer failed"); error = clSetKernelArg(kernel, i, sizeof(result_mem), &result_mem); test_error(error, "clSetKernelArg failed"); @@ -342,7 +347,9 @@ int execute_kernel(cl_context context, cl_command_queue *queue, cl_device_id dev // Verify the checksum. // Read back the result - error = clEnqueueReadBuffer(*queue, result_mem, CL_TRUE, 0, sizeof(cl_uint)*NUM_OF_WORK_ITEMS, &returned_results, 0, NULL, NULL); + error = clEnqueueReadBuffer(*queue, result_mem, CL_TRUE, 0, + sizeof(cl_uint) * NUM_OF_WORK_ITEMS, + returned_results.data(), 0, NULL, NULL); test_error_abort(error, "clEnqueueReadBuffer failed"); final_result = 0; if (test == BUFFER || test == IMAGE_READ || test == BUFFER_NON_BLOCKING || test == IMAGE_READ_NON_BLOCKING) { diff --git a/test_conformance/allocations/main.cpp b/test_conformance/allocations/main.cpp index 827072fc..6ef83c68 100644 --- a/test_conformance/allocations/main.cpp +++ b/test_conformance/allocations/main.cpp @@ -93,6 +93,11 @@ test_status init_cl( cl_device_id device ) { // queue, kernel code on GPU. g_global_mem_size *= 0.60; } + /* Cap the allocation size as the global size was deduced */ + if (g_max_individual_allocation_size > g_global_mem_size) + { + g_max_individual_allocation_size = g_global_mem_size; + } if( gReSeed ) { diff --git a/test_conformance/api/test_mem_object_info.cpp b/test_conformance/api/test_mem_object_info.cpp index 7eedec85..6228783a 100644 --- a/test_conformance/api/test_mem_object_info.cpp +++ b/test_conformance/api/test_mem_object_info.cpp @@ -476,7 +476,8 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec CL_MEM_HOST_NO_ACCESS | CL_MEM_WRITE_ONLY | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR, CL_MEM_HOST_NO_ACCESS | CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, }; - MTdata d; + MTdataHolder d_holder(gRandomSeed); + MTdata d = static_cast(d_holder); PASSIVE_REQUIRE_IMAGE_SUPPORT( deviceID ) @@ -495,8 +496,6 @@ int test_get_image_info( cl_device_id deviceID, cl_context context, cl_mem_objec imageInfo.buffer = NULL; #endif - d = init_genrand( gRandomSeed ); - for ( unsigned int i = 0; i < sizeof(imageFlags) / sizeof(cl_mem_flags); ++i ) { imageInfo.image_row_pitch = 0; diff --git a/test_conformance/api/test_sub_group_dispatch.cpp b/test_conformance/api/test_sub_group_dispatch.cpp index 9a3bf959..3375990b 100644 --- a/test_conformance/api/test_sub_group_dispatch.cpp +++ b/test_conformance/api/test_sub_group_dispatch.cpp @@ -188,8 +188,9 @@ int test_sub_group_dispatch(cl_device_id deviceID, cl_context context, cl_comman } } - // test when input subgroup count exceeds max wg size - size_t large_sg_size = kernel_subgroup_count + 1; + // 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"); if (ret_ndrange1d != 0) diff --git a/test_conformance/basic/test_work_item_functions.cpp b/test_conformance/basic/test_work_item_functions.cpp index 9683a834..d326bb8b 100644 --- a/test_conformance/basic/test_work_item_functions.cpp +++ b/test_conformance/basic/test_work_item_functions.cpp @@ -20,7 +20,7 @@ #include #include #include - +#include #include "procs.h" #include "harness/conversions.h" @@ -72,7 +72,7 @@ int test_work_item_functions(cl_device_id deviceID, cl_context context, cl_comma clProgramWrapper program; clKernelWrapper kernel; clMemWrapper outData; - work_item_data testData[ 10240 ]; + std::vector testData(10240); size_t threads[3], localThreads[3]; MTdata d; @@ -80,7 +80,9 @@ int test_work_item_functions(cl_device_id deviceID, cl_context context, cl_comma 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( testData ), NULL, &error ); + 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 ); @@ -105,7 +107,10 @@ int test_work_item_functions(cl_device_id deviceID, cl_context context, cl_comma 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( testData ), testData, 0, NULL, NULL ); + 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 diff --git a/test_conformance/c11_atomics/test_atomics.cpp b/test_conformance/c11_atomics/test_atomics.cpp index ca2c2242..82438a74 100644 --- a/test_conformance/c11_atomics/test_atomics.cpp +++ b/test_conformance/c11_atomics/test_atomics.cpp @@ -2827,7 +2827,7 @@ public: // value from other thread // - reads value from other thread's variable // - repeats the above steps when both values are the same (and less - // than 1000000) + // than 500000) // - stores the last value read from other thread (in additional // variable) At the end of execution at least one thread should know // the last value from other thread @@ -2846,7 +2846,7 @@ public: "memory_order_relaxed" + MemoryScopeStr() + ");\n" - " } while(myValue == hisValue && myValue < 1000000);\n" + " } while(myValue == hisValue && myValue < 500000);\n" " " + nonAtomic + "[myId] = hisValue; \n"; } @@ -2972,7 +2972,7 @@ public: host_atomic_thread_fence(MemoryOrder()); hisValue = host_atomic_load( &destMemory[hisId], MEMORY_ORDER_RELAXED); - } while (myValue == hisValue && hisValue < 1000000); + } while (myValue == hisValue && hisValue < 500000); oldValues[tid] = hisValue; } else @@ -3053,11 +3053,11 @@ public: if (myValue == hisValue) { // a draw - both threads should reach final value - // 1000000 - if (myValue != 1000000) + // 500000 + if (myValue != 500000) { log_error("ERROR: Invalid reference value #%u (%d " - "instead of 1000000)\n", + "instead of 500000)\n", workOffset + i, myValue); correct = false; return true; diff --git a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp index b69be119..c1375802 100644 --- a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp @@ -34,8 +34,10 @@ pfnclEnqueueReleaseExternalMemObjectsKHR clEnqueueReleaseExternalMemObjectsKHRptr; pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr; pfnclGetSemaphoreHandleForTypeKHR clGetSemaphoreHandleForTypeKHRptr; +pfnclReImportSemaphoreSyncFdKHR clReImportSemaphoreSyncFdKHRptr; -void init_cl_vk_ext(cl_platform_id opencl_platform) +void init_cl_vk_ext(cl_platform_id opencl_platform, cl_uint num_devices, + cl_device_id *deviceIds) { clEnqueueWaitSemaphoresKHRptr = (pfnclEnqueueWaitSemaphoresKHR)clGetExtensionFunctionAddressForPlatform( @@ -79,6 +81,21 @@ void init_cl_vk_ext(cl_platform_id opencl_platform) throw std::runtime_error("Failed to get the function pointer of " "clGetSemaphoreHandleForTypeKHRptr!"); } + + // Required only if cl_khr_external_semaphore_sync_fd is reported + clReImportSemaphoreSyncFdKHRptr = (pfnclReImportSemaphoreSyncFdKHR) + clGetExtensionFunctionAddressForPlatform( + opencl_platform, "clReImportSemaphoreSyncFdKHR"); + for (cl_uint i = 0; i < num_devices; i++) + { + if (is_extension_available(deviceIds[i], + "cl_khr_external_semaphore_sync_fd") + && (NULL == clReImportSemaphoreSyncFdKHRptr)) + { + throw std::runtime_error("Failed to get the function pointer of " + "clReImportSemaphoreSyncFdKHR!"); + } + } } cl_int setMaxImageDimensions(cl_device_id deviceID, size_t &max_width, @@ -669,7 +686,6 @@ clExternalMemoryImage::clExternalMemoryImage( break; #elif !defined(__APPLE__) case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD: - log_info(" Opaque file descriptors are not supported on Windows\n"); fd = (int)deviceMemory.getHandle(externalMemoryHandleType); errcode_ret = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); @@ -738,7 +754,9 @@ clExternalMemoryImage::clExternalMemoryImage() {} // clExternalSemaphore implementation // ////////////////////////////////////////// -clExternalSemaphore::clExternalSemaphore( +clExternalSemaphore::~clExternalSemaphore() = default; + +clExternalImportableSemaphore::clExternalImportableSemaphore( const VulkanSemaphore &semaphore, cl_context context, VulkanExternalSemaphoreHandleType externalSemaphoreHandleType, cl_device_id deviceId) @@ -759,17 +777,12 @@ clExternalSemaphore::clExternalSemaphore( switch (externalSemaphoreHandleType) { case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD: -#ifdef _WIN32 - ASSERT(0); -#else - log_info(" Opaque file descriptors are not supported on Windows\n"); fd = (int)semaphore.getHandle(externalSemaphoreHandleType); err = check_external_semaphore_handle_type( devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); sema_props.push_back( (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_OPAQUE_FD_KHR); sema_props.push_back((cl_semaphore_properties_khr)fd); -#endif break; case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT: #ifndef _WIN32 @@ -802,12 +815,10 @@ clExternalSemaphore::clExternalSemaphore( case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD: err = check_external_semaphore_handle_type( devList[0], CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); - sema_props.push_back(static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR)); + sema_props.push_back(static_cast( CL_SEMAPHORE_HANDLE_SYNC_FD_KHR)); - sema_props.push_back(static_cast( - CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR)); + sema_props.push_back(static_cast(-1)); break; default: ASSERT(0); @@ -837,7 +848,7 @@ clExternalSemaphore::clExternalSemaphore( } } -clExternalSemaphore::~clExternalSemaphore() noexcept(false) +clExternalImportableSemaphore::~clExternalImportableSemaphore() { cl_int err = clReleaseSemaphoreKHRptr(m_externalSemaphore); if (err != CL_SUCCESS) @@ -846,7 +857,89 @@ clExternalSemaphore::~clExternalSemaphore() noexcept(false) } } -int clExternalSemaphore::signal(cl_command_queue cmd_queue) +int clExternalImportableSemaphore::wait(cl_command_queue cmd_queue) +{ + int err = CL_SUCCESS; + if (m_externalHandleType == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD) + { + cl_int err = 0; + fd = (int)m_deviceSemaphore.getHandle(m_externalHandleType); + err = clReImportSemaphoreSyncFdKHRptr(m_externalSemaphore, nullptr, fd); + if (err != CL_SUCCESS) + { + return err; + } + } + + err = clEnqueueWaitSemaphoresKHRptr(cmd_queue, 1, &m_externalSemaphore, + NULL, 0, NULL, NULL); + return err; +} + +int clExternalImportableSemaphore::signal(cl_command_queue cmd_queue) +{ + return clEnqueueSignalSemaphoresKHRptr(cmd_queue, 1, &m_externalSemaphore, + NULL, 0, NULL, NULL); +} + +cl_semaphore_khr &clExternalImportableSemaphore::getCLSemaphore() +{ + return m_externalSemaphore; +} + + +clExternalExportableSemaphore::clExternalExportableSemaphore( + const VulkanSemaphore &semaphore, cl_context context, + VulkanExternalSemaphoreHandleType externalSemaphoreHandleType, + cl_device_id deviceId) + : m_deviceSemaphore(semaphore) +{ + + cl_int err = 0; + cl_device_id devList[] = { deviceId, NULL }; + m_externalHandleType = externalSemaphoreHandleType; + m_externalSemaphore = nullptr; + m_device = deviceId; + m_context = context; + + std::vector sema_props{ + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + }; + sema_props.push_back( + (cl_semaphore_properties_khr)CL_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR); + sema_props.push_back( + (cl_semaphore_properties_khr)getCLSemaphoreTypeFromVulkanType( + externalSemaphoreHandleType)); + sema_props.push_back((cl_semaphore_properties_khr) + CL_SEMAPHORE_EXPORT_HANDLE_TYPES_LIST_END_KHR); + sema_props.push_back( + (cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR); + sema_props.push_back((cl_semaphore_properties_khr)devList[0]); + sema_props.push_back( + (cl_semaphore_properties_khr)CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR); + sema_props.push_back(0); + m_externalSemaphore = + clCreateSemaphoreWithPropertiesKHRptr(context, sema_props.data(), &err); + if (CL_SUCCESS != err) + { + log_error("clCreateSemaphoreWithPropertiesKHRptr failed with %d\n", + err); + throw std::runtime_error( + "clCreateSemaphoreWithPropertiesKHRptr failed! "); + } +} + +clExternalExportableSemaphore::~clExternalExportableSemaphore() +{ + cl_int err = clReleaseSemaphoreKHRptr(m_externalSemaphore); + if (err != CL_SUCCESS) + { + throw std::runtime_error("clReleaseSemaphoreKHR failed!"); + } +} + +int clExternalExportableSemaphore::signal(cl_command_queue cmd_queue) { int err = clEnqueueSignalSemaphoresKHRptr( cmd_queue, 1, &m_externalSemaphore, NULL, 0, NULL, nullptr); @@ -886,60 +979,13 @@ int clExternalSemaphore::signal(cl_command_queue cmd_queue) return err; } -int clExternalSemaphore::wait(cl_command_queue cmd_queue) +int clExternalExportableSemaphore::wait(cl_command_queue command_queue) { - int err = CL_SUCCESS; - if (m_externalHandleType == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD) - { - cl_int err = 0; - cl_device_id devList[] = { m_device, NULL }; - std::vector sema_props{ - (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, - (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, - }; - fd = (int)m_deviceSemaphore.getHandle(m_externalHandleType); - - err = check_external_semaphore_handle_type( - devList[0], CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); - if (CL_SUCCESS != err) - { - log_error("CL_SEMAPHORE_HANDLE_SYNC_FD_KHR not supported\n"); - return err; - } - - sema_props.push_back( - (cl_semaphore_properties_khr)CL_SEMAPHORE_HANDLE_SYNC_FD_KHR); - sema_props.push_back((cl_semaphore_properties_khr)fd); - - sema_props.push_back(0); - - if (m_externalSemaphore) - { - err = clReleaseSemaphoreKHRptr(m_externalSemaphore); - if (err != CL_SUCCESS) - { - log_error("Failed to release CL external semaphore\n"); - return err; - } - m_externalSemaphore = nullptr; - } - - m_externalSemaphore = clCreateSemaphoreWithPropertiesKHRptr( - m_context, sema_props.data(), &err); - if (CL_SUCCESS != err) - { - log_error("clCreateSemaphoreWithPropertiesKHRptr failed with %d\n", - err); - return err; - } - } - - err = clEnqueueWaitSemaphoresKHRptr(cmd_queue, 1, &m_externalSemaphore, - NULL, 0, NULL, NULL); - return err; + return clEnqueueWaitSemaphoresKHRptr(command_queue, 1, &m_externalSemaphore, + NULL, 0, NULL, nullptr); } -cl_semaphore_khr &clExternalSemaphore::getCLSemaphore() +cl_semaphore_khr &clExternalExportableSemaphore::getCLSemaphore() { return m_externalSemaphore; } @@ -1006,4 +1052,4 @@ VulkanImageTiling vkClExternalMemoryHandleTilingAssumption( } return mode; -} +} \ No newline at end of file diff --git a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.hpp b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.hpp index 12d467d8..16389c44 100644 --- a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.hpp +++ b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.hpp @@ -54,6 +54,9 @@ typedef cl_int (*pfnclGetSemaphoreHandleForTypeKHR)( cl_semaphore_khr sema_object, cl_device_id device, cl_external_semaphore_handle_type_khr handleType, size_t handle_size, void *handle, size_t *handleSize); +typedef cl_int (*pfnclReImportSemaphoreSyncFdKHR)( + cl_semaphore_khr sema_object, + cl_semaphore_reimport_properties_khr *reimport_props, int fd); extern pfnclCreateSemaphoreWithPropertiesKHR clCreateSemaphoreWithPropertiesKHRptr; @@ -64,6 +67,7 @@ extern pfnclEnqueueAcquireExternalMemObjectsKHR extern pfnclEnqueueReleaseExternalMemObjectsKHR clEnqueueReleaseExternalMemObjectsKHRptr; extern pfnclReleaseSemaphoreKHR clReleaseSemaphoreKHRptr; +extern pfnclReImportSemaphoreSyncFdKHR pfnclReImportSemaphoreSyncFdKHRptr; cl_int getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *, size_t, cl_image_format *, cl_image_desc *); @@ -97,7 +101,6 @@ protected: cl_mem m_externalMemory; int fd; void *handle; - cl_command_queue cmd_queue; clExternalMemoryImage(); public: @@ -112,6 +115,15 @@ public: }; class clExternalSemaphore { +public: + virtual int signal(cl_command_queue command_queue) = 0; + virtual int wait(cl_command_queue command_queue) = 0; + virtual cl_semaphore_khr &getCLSemaphore() = 0; + virtual ~clExternalSemaphore() = 0; +}; + + +class clExternalImportableSemaphore : public virtual clExternalSemaphore { protected: cl_semaphore_khr m_externalSemaphore; VulkanExternalSemaphoreHandleType m_externalHandleType; @@ -122,21 +134,42 @@ protected: void *handle; public: - clExternalSemaphore( + clExternalImportableSemaphore( const VulkanSemaphore &deviceSemaphore, cl_context context, VulkanExternalSemaphoreHandleType externalSemaphoreHandleType, cl_device_id deviceId); - virtual ~clExternalSemaphore() noexcept(false); - int signal(cl_command_queue command_queue); - int wait(cl_command_queue command_queue); - cl_semaphore_khr &getCLSemaphore(); - // operator openclExternalSemaphore_t() const; + ~clExternalImportableSemaphore() override; + int wait(cl_command_queue command_queue) override; + int signal(cl_command_queue command_queue) override; + cl_semaphore_khr &getCLSemaphore() override; }; -extern void init_cl_vk_ext(cl_platform_id); +class clExternalExportableSemaphore : public virtual clExternalSemaphore { +protected: + cl_semaphore_khr m_externalSemaphore; + VulkanExternalSemaphoreHandleType m_externalHandleType; + cl_device_id m_device; + cl_context m_context; + const VulkanSemaphore &m_deviceSemaphore; + int fd; + void *handle; + +public: + clExternalExportableSemaphore( + const VulkanSemaphore &deviceSemaphore, cl_context context, + VulkanExternalSemaphoreHandleType externalSemaphoreHandleType, + cl_device_id deviceId); + ~clExternalExportableSemaphore() override; + int signal(cl_command_queue command_queue) override; + int wait(cl_command_queue command_queue) override; + cl_semaphore_khr &getCLSemaphore() override; +}; + +extern void init_cl_vk_ext(cl_platform_id, cl_uint num_devices, + cl_device_id *deviceIds); VulkanImageTiling vkClExternalMemoryHandleTilingAssumption( cl_device_id deviceId, VulkanExternalMemoryHandleType vkExternalMemoryHandleType, int *error_ret); -#endif // _opencl_vulkan_wrapper_hpp_ +#endif // _opencl_vulkan_wrapper_hpp_ \ No newline at end of file diff --git a/test_conformance/compiler/test_feature_macro.cpp b/test_conformance/compiler/test_feature_macro.cpp index ef3c0028..7858c3c2 100644 --- a/test_conformance/compiler/test_feature_macro.cpp +++ b/test_conformance/compiler/test_feature_macro.cpp @@ -171,8 +171,8 @@ cl_int check_compiler_feature_info(cl_device_id deviceID, cl_context context, } else { - log_error("Error: The macro feature is defined and undefined " - "in the same time\n"); + log_error("Error: The feature macro is defined and undefined " + "at the same time\n"); error = OutputBuildLogs(program_supported, 1, &deviceID); test_error(error, "OutputBuildLogs failed.\n"); error = OutputBuildLogs(program_not_supported, 1, &deviceID); diff --git a/test_conformance/conversions/CMakeLists.txt b/test_conformance/conversions/CMakeLists.txt index 8ed3ba18..11106439 100644 --- a/test_conformance/conversions/CMakeLists.txt +++ b/test_conformance/conversions/CMakeLists.txt @@ -16,6 +16,6 @@ set_source_files_properties( COMPILE_FLAGS -march=i686) endif(NOT CMAKE_CL_64 AND NOT MSVC AND NOT ANDROID) -set_gnulike_module_compile_flags("-Wno-unused-but-set-variable -Wno-sign-compare") +set_gnulike_module_compile_flags("-Wno-sign-compare") include(../CMakeCommon.txt) diff --git a/test_conformance/conversions/conversions_data_info.h b/test_conformance/conversions/conversions_data_info.h index 043c509d..bf887ede 100644 --- a/test_conformance/conversions/conversions_data_info.h +++ b/test_conformance/conversions/conversions_data_info.h @@ -467,11 +467,11 @@ void DataInfoSpec::conv(OutType *out, InType *in) if (std::is_same::value) { #if defined(_MSC_VER) - cl_ulong l = ((cl_ulong *)in)[0]; double result; if (std::is_same::value) { + cl_ulong l = ((cl_ulong *)in)[0]; cl_long sl = ((cl_long)l < 0) ? (cl_long)((l >> 1) | (l & 1)) : (cl_long)l; #if defined(_M_X64) @@ -484,6 +484,7 @@ void DataInfoSpec::conv(OutType *out, InType *in) } else { + cl_long l = ((cl_long *)in)[0]; #if defined(_M_X64) _mm_store_sd(&result, _mm_cvtsi64_sd(_mm_setzero_pd(), l)); #else @@ -504,10 +505,10 @@ void DataInfoSpec::conv(OutType *out, InType *in) cl_float outVal = 0.f; #if defined(_MSC_VER) && defined(_M_X64) - cl_ulong l = ((cl_ulong *)in)[0]; float result; if (std::is_same::value) { + cl_ulong l = ((cl_ulong *)in)[0]; cl_long sl = ((cl_long)l < 0) ? (cl_long)((l >> 1) | (l & 1)) : (cl_long)l; _mm_store_ss(&result, _mm_cvtsi64_ss(_mm_setzero_ps(), sl)); @@ -516,6 +517,7 @@ void DataInfoSpec::conv(OutType *out, InType *in) } else { + cl_long l = ((cl_long *)in)[0]; _mm_store_ss(&result, _mm_cvtsi64_ss(_mm_setzero_ps(), l)); outVal = (l == 0 ? 0.0f : result); // Per IEEE-754-2008 5.4.1, // 0's always convert to +0.0 diff --git a/test_conformance/conversions/fplib.cpp b/test_conformance/conversions/fplib.cpp index 3b19b56d..8e6caba7 100644 --- a/test_conformance/conversions/fplib.cpp +++ b/test_conformance/conversions/fplib.cpp @@ -198,7 +198,6 @@ float qcom_u64_2_f32(uint64_t data, bool sat, roundingMode rnd) return as_float(result); } case qcomRTN: { - int inExact = 0; if (!data) return 0.0f; uint32_t exponent = (127 + 64 - clz(data) - 1) << (FLT_MANT_DIG - 1); //add 1 for the implied 1.0 in normalized fp32 numbers @@ -206,8 +205,6 @@ float qcom_u64_2_f32(uint64_t data, bool sat, roundingMode rnd) uint32_t mantissa; if (mantShift >= 0){ uint64_t temp = (uint64_t)data >> mantShift; - if (temp << mantShift != data) - inExact = 1; mantissa = (uint32_t)temp; } else diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_arguments.cpp b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_arguments.cpp index 5c8291f0..55c27ccf 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_arguments.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_arguments.cpp @@ -664,8 +664,8 @@ struct MutableDispatchSVMArguments : public BasicMutableCommandBufferTest // Allocate and initialize SVM for modified execution - cl_int *newWrapper = - (cl_int *)clSVMAlloc(context, CL_MEM_READ_WRITE, sizeof(cl_int), 0); + cl_int *newWrapper = (cl_int *)clSVMAlloc(context, CL_MEM_READ_WRITE, + sizeof(cl_int *), 0); cl_int *newBuffer = (cl_int *)clSVMAlloc( context, CL_MEM_READ_WRITE, num_elements * sizeof(cl_int), 0); test_assert_error(newWrapper != nullptr && newBuffer != nullptr, diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_image_arguments.cpp b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_image_arguments.cpp index b1ce25ec..d8036e17 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_image_arguments.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_image_arguments.cpp @@ -92,6 +92,7 @@ struct MutableDispatchImage1DArguments : public BasicMutableCommandBufferTest imageInfo.type = CL_MEM_OBJECT_IMAGE1D; imageInfo.format = &formats; imageInfo.width = 4; + imageInfo.rowPitch = imageInfo.width * get_pixel_size(imageInfo.format); BufferOwningPtr imageValues_input, imageValues_output, outputData; MTdataHolder d(gRandomSeed); @@ -285,6 +286,7 @@ struct MutableDispatchImage2DArguments : public BasicMutableCommandBufferTest imageInfo.width = 4; imageInfo.height = 4; imageInfo.format = &formats; + imageInfo.rowPitch = imageInfo.width * get_pixel_size(imageInfo.format); BufferOwningPtr imageValues_input, imageValues_output; 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 61600dc9..71b9017e 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 @@ -207,7 +207,7 @@ struct Dimensions : public InfoMutableCommandBufferTest { cl_int error = clCommandNDRangeKernelKHR( command_buffer, nullptr, nullptr, kernel, dimensions, nullptr, - &global_work_size, nullptr, 0, nullptr, nullptr, &command); + global_work_size_3d, nullptr, 0, nullptr, nullptr, &command); test_error(error, "clCommandNDRangeKernelKHR failed"); cl_uint test_dimensions = 0; @@ -231,6 +231,7 @@ struct Dimensions : public InfoMutableCommandBufferTest cl_mutable_command_khr command = nullptr; const size_t dimensions = 3; + const size_t global_work_size_3d[3] = { 64, 1, 1 }; }; struct InfoType : public InfoMutableCommandBufferTest 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 8c0c64f4..8b282cbc 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 @@ -64,7 +64,7 @@ static void log_info_semaphore_type( log_info("%s", semaphore_type_description.str().c_str()); } -static int init_vuikan_device() +static int init_vuikan_device(cl_uint num_devices, cl_device_id* deviceIds) { cl_platform_id platform = nullptr; @@ -77,7 +77,7 @@ static int init_vuikan_device() return err; } - init_cl_vk_ext(platform); + init_cl_vk_ext(platform, num_devices, deviceIds); return CL_SUCCESS; } @@ -101,7 +101,7 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -130,8 +130,8 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalImportableSemaphore sema_ext( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); // Needed by the macro cl_semaphore_khr sema = sema_ext.getCLSemaphore(); @@ -181,7 +181,7 @@ int test_external_semaphores_multi_context(cl_device_id deviceID, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -219,10 +219,11 @@ int test_external_semaphores_multi_context(cl_device_id deviceID, return TEST_FAIL; } - clExternalSemaphore sema_ext_1(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); - clExternalSemaphore sema_ext_2(vkVk2CLSemaphore, context2, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext_1( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore, context2, + vkExternalSemaphoreHandleType, + deviceID); clCommandQueueWrapper queue1 = clCreateCommandQueue(context, deviceID, 0, &err); @@ -288,7 +289,7 @@ static int semaphore_external_cross_queue_helper(cl_device_id deviceID, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -313,8 +314,8 @@ static int semaphore_external_cross_queue_helper(cl_device_id deviceID, VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); // Obtain pointers to semaphore's API GET_PFN(deviceID, clEnqueueSignalSemaphoresKHR); @@ -362,7 +363,7 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -392,8 +393,8 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); cl_int err = CL_SUCCESS; @@ -439,7 +440,7 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -468,8 +469,8 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); cl_int err = CL_SUCCESS; @@ -545,7 +546,7 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -574,8 +575,8 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); cl_int err = CL_SUCCESS; @@ -668,7 +669,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -697,8 +698,8 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); cl_int err = CL_SUCCESS; @@ -785,7 +786,7 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -823,10 +824,11 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, VulkanSemaphore vkVk2CLSemaphore(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext_1(vkVk2CLSemaphore, context, - vkExternalSemaphoreHandleType, deviceID); - clExternalSemaphore sema_ext_2(vkVk2CLSemaphore, context2, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext_1( + vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore, context2, + vkExternalSemaphoreHandleType, + deviceID); clCommandQueueWrapper queue1 = clCreateCommandQueue(context, deviceID, 0, &err); @@ -891,7 +893,7 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -922,10 +924,12 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, VulkanSemaphore vkVk2CLSemaphore2(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext_1(vkVk2CLSemaphore1, context, - vkExternalSemaphoreHandleType, deviceID); - clExternalSemaphore sema_ext_2(vkVk2CLSemaphore2, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext_1(vkVk2CLSemaphore1, context, + vkExternalSemaphoreHandleType, + deviceID); + clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore2, context, + vkExternalSemaphoreHandleType, + deviceID); cl_int err = CL_SUCCESS; @@ -980,7 +984,7 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, return TEST_SKIPPED_ITSELF; } - if (init_vuikan_device()) + if (init_vuikan_device(1, &deviceID)) { log_info("Cannot initialise Vulkan. " "Skipping test.\n"); @@ -1011,10 +1015,12 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, VulkanSemaphore vkVk2CLSemaphore2(vkDevice, vkExternalSemaphoreHandleType); - clExternalSemaphore sema_ext_1(vkVk2CLSemaphore1, context, - vkExternalSemaphoreHandleType, deviceID); - clExternalSemaphore sema_ext_2(vkVk2CLSemaphore2, context, - vkExternalSemaphoreHandleType, deviceID); + clExternalExportableSemaphore sema_ext_1(vkVk2CLSemaphore1, context, + vkExternalSemaphoreHandleType, + deviceID); + clExternalExportableSemaphore sema_ext_2(vkVk2CLSemaphore2, context, + vkExternalSemaphoreHandleType, + deviceID); cl_int err = CL_SUCCESS; @@ -1056,4 +1062,4 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, } return TEST_PASS; -} +} \ No newline at end of file diff --git a/test_conformance/geometrics/CMakeLists.txt b/test_conformance/geometrics/CMakeLists.txt index 8a6f25c6..3fee05fb 100644 --- a/test_conformance/geometrics/CMakeLists.txt +++ b/test_conformance/geometrics/CMakeLists.txt @@ -6,7 +6,5 @@ set(${MODULE_NAME}_SOURCES test_geometrics.cpp ) -set_gnulike_module_compile_flags("-Wno-sign-compare") - include(../CMakeCommon.txt) diff --git a/test_conformance/geometrics/test_geometrics_double.cpp b/test_conformance/geometrics/test_geometrics_double.cpp index 222017e6..66a671fd 100644 --- a/test_conformance/geometrics/test_geometrics_double.cpp +++ b/test_conformance/geometrics/test_geometrics_double.cpp @@ -189,7 +189,7 @@ int test_geom_cross_double(cl_device_id deviceID, cl_context context, cl_command clKernelWrapper kernel; clMemWrapper streams[3]; cl_double testVector[4]; - int error, i; + int error; size_t threads[1], localThreads[1]; BufferOwningPtr A(malloc(bufSize)); BufferOwningPtr B(malloc(bufSize)); @@ -203,7 +203,7 @@ int test_geom_cross_double(cl_device_id deviceID, cl_context context, cl_command return -1; /* Generate some streams. Note: deliberately do some random data in w to verify that it gets ignored */ - for( i = 0; i < size * vecsize; i++ ) + for (unsigned int i = 0; i < size * vecsize; i++) { inDataA[ i ] = get_random_double( -512.f, 512.f, d ); inDataB[ i ] = get_random_double( -512.f, 512.f, d ); @@ -233,7 +233,7 @@ int test_geom_cross_double(cl_device_id deviceID, cl_context context, cl_command } /* Assign streams and execute */ - for( i = 0; i < 3; i++ ) + for (unsigned int i = 0; i < 3; i++) { error = clSetKernelArg(kernel, i, sizeof( streams[i] ), &streams[i]); test_error( error, "Unable to set indexed kernel arguments" ); @@ -253,7 +253,7 @@ int test_geom_cross_double(cl_device_id deviceID, cl_context context, cl_command test_error( error, "Unable to read output array!" ); /* And verify! */ - for( i = 0; i < size; i++ ) + for (unsigned int i = 0; i < size; i++) { double errorTolerances[ 4 ]; // On an embedded device w/ round-to-zero, 3 ulps is the worst-case tolerance for cross product @@ -265,9 +265,12 @@ int test_geom_cross_double(cl_device_id deviceID, cl_context context, cl_command if( errs[ 0 ] > errorTolerances[ 0 ] || errs[ 1 ] > errorTolerances[ 1 ] || errs[ 2 ] > errorTolerances[ 2 ] ) { - log_error( "ERROR: Data sample %d does not validate! Expected (%a,%a,%a,%a), got (%a,%a,%a,%a)\n", - i, testVector[0], testVector[1], testVector[2], testVector[3], - outData[i*vecsize], outData[i*vecsize+1], outData[i*vecsize+2], outData[i*vecsize+3] ); + log_error("ERROR: Data sample %u does not validate! Expected " + "(%a,%a,%a,%a), got (%a,%a,%a,%a)\n", + i, testVector[0], testVector[1], testVector[2], + testVector[3], outData[i * vecsize], + outData[i * vecsize + 1], outData[i * vecsize + 2], + outData[i * vecsize + 3]); log_error( " Input: (%a %a %a) and (%a %a %a)\n", inDataA[ i * vecsize + 0 ], inDataA[ i * vecsize + 1 ], inDataA[ i * vecsize + 2 ], inDataB[ i * vecsize + 0 ], inDataB[ i * vecsize + 1 ], inDataB[ i * vecsize + 2 ] ); diff --git a/test_conformance/images/common.cpp b/test_conformance/images/common.cpp index 7323f11c..0b2c956c 100644 --- a/test_conformance/images/common.cpp +++ b/test_conformance/images/common.cpp @@ -16,26 +16,12 @@ #include "common.h" cl_channel_type floatFormats[] = { - CL_UNORM_SHORT_565, - CL_UNORM_SHORT_555, - CL_UNORM_INT_101010, -#ifdef OBSOLETE_FORAMT - CL_UNORM_SHORT_565_REV, - CL_UNORM_SHORT_555_REV, - CL_UNORM_INT_8888, - CL_UNORM_INT_8888_REV, - CL_UNORM_INT_101010_REV, -#endif + CL_UNORM_SHORT_565, CL_UNORM_SHORT_555, CL_UNORM_INT_101010, #ifdef CL_SFIXED14_APPLE CL_SFIXED14_APPLE, #endif - CL_UNORM_INT8, - CL_SNORM_INT8, - CL_UNORM_INT16, - CL_SNORM_INT16, - CL_FLOAT, - CL_HALF_FLOAT, - (cl_channel_type)-1, + CL_UNORM_INT8, CL_SNORM_INT8, CL_UNORM_INT16, CL_SNORM_INT16, + CL_FLOAT, CL_HALF_FLOAT, (cl_channel_type)-1, }; cl_channel_type intFormats[] = { diff --git a/test_conformance/images/kernel_read_write/main.cpp b/test_conformance/images/kernel_read_write/main.cpp index 0a93a974..debbdf18 100644 --- a/test_conformance/images/kernel_read_write/main.cpp +++ b/test_conformance/images/kernel_read_write/main.cpp @@ -202,7 +202,7 @@ static int doTest( cl_device_id device, cl_context context, cl_command_queue que if ((testTypesToRun & kReadWriteTests) && checkForReadWriteImageSupport(device)) { - return TEST_SKIPPED_ITSELF; + return ret; } if( ( testTypesToRun & kReadWriteTests ) && !gTestMipmaps ) diff --git a/test_conformance/integer_ops/test_abs.cpp b/test_conformance/integer_ops/test_abs.cpp index 24d0555b..1e1bb305 100644 --- a/test_conformance/integer_ops/test_abs.cpp +++ b/test_conformance/integer_ops/test_abs.cpp @@ -15,6 +15,8 @@ // #include "harness/compat.h" +#include + #include #include #include @@ -35,7 +37,12 @@ static int verify_abs_char( const void *p, const void *q, size_t n, const char * if( inA[i] < 0 ) r = -inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (char%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (char%s) 0x%2.2x) = *0x%2.2x vs " + "0x%2.2x\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } @@ -52,7 +59,12 @@ static int verify_abs_short( const void *p, const void *q, size_t n, const char if( inA[i] < 0 ) r = -inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (short%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (short%s) 0x%4.4x) = *0x%4.4x vs " + "0x%4.4x\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } @@ -68,7 +80,12 @@ static int verify_abs_int( const void *p, const void *q, size_t n, const char *s if( inA[i] < 0 ) r = -inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (int%s) 0x%2.2x) = *0x%8.8x vs 0x%8.8x\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (int%s) 0x%2.2x) = *0x%8.8x vs " + "0x%8.8x\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } @@ -84,7 +101,12 @@ static int verify_abs_long( const void *p, const void *q, size_t n, const char * if( inA[i] < 0 ) r = -inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (long%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (long%s) 0x%16.16" PRIx64 + ") = *0x%16.16" PRIx64 " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } @@ -100,7 +122,12 @@ static int verify_abs_uchar( const void *p, const void *q, size_t n, const char { cl_uchar r = inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (uchar%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (uchar%s) 0x%2.2x) = *0x%2.2x vs " + "0x%2.2x\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } @@ -115,7 +142,12 @@ static int verify_abs_ushort( const void *p, const void *q, size_t n, const char { cl_ushort r = inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (short%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (short%s) 0x%4.4x) = *0x%4.4x vs " + "0x%4.4x\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } @@ -129,7 +161,12 @@ static int verify_abs_uint( const void *p, const void *q, size_t n, const char * { cl_uint r = inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (int%s) 0x%2.2x) = *0x%8.8x vs 0x%8.8x\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (int%s) 0x%2.2x) = *0x%8.8x vs " + "0x%8.8x\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } @@ -143,7 +180,12 @@ static int verify_abs_ulong( const void *p, const void *q, size_t n, const char { cl_ulong r = inA[i]; if( r != outptr[i] ) - { log_info( "%ld) Failure for abs( (long%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i],r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for abs( (long%s) 0x%16.16" PRIx64 + ") = *0x%16.16" PRIx64 " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], r, outptr[i]); + return -1; + } } return 0; } diff --git a/test_conformance/integer_ops/test_absdiff.cpp b/test_conformance/integer_ops/test_absdiff.cpp index 710b9c4e..0d672f2d 100644 --- a/test_conformance/integer_ops/test_absdiff.cpp +++ b/test_conformance/integer_ops/test_absdiff.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "procs.h" template @@ -43,7 +45,12 @@ static int verify_absdiff_char( const void *p, const void *q, const void *r, siz { cl_uchar r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) - { log_info( "%ld) Failure for absdiff( (char%s) 0x%2.2x, (char%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for absdiff( (char%s) 0x%2.2x, (char%s) " + "0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -58,7 +65,12 @@ static int verify_absdiff_uchar( const void *p, const void *q, const void *r, si { cl_uchar r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) - { log_info( "%ld) Failure for absdiff( (uchar%s) 0x%2.2x, (uchar%s) 0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for absdiff( (uchar%s) 0x%2.2x, (uchar%s) " + "0x%2.2x) = *0x%2.2x vs 0x%2.2x\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -73,7 +85,12 @@ static int verify_absdiff_short( const void *p, const void *q, const void *r, si { cl_ushort r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) - { log_info( "%ld) Failure for absdiff( (short%s) 0x%4.4x, (short%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for absdiff( (short%s) 0x%4.4x, (short%s) " + "0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -88,7 +105,12 @@ static int verify_absdiff_ushort( const void *p, const void *q, const void *r, s { cl_ushort r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) - { log_info( "%ld) Failure for absdiff( (ushort%s) 0x%4.4x, (ushort%s) 0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for absdiff( (ushort%s) 0x%4.4x, (ushort%s) " + "0x%4.4x) = *0x%4.4x vs 0x%4.4x\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -104,7 +126,9 @@ static int verify_absdiff_int( const void *p, const void *q, const void *r, size cl_uint r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) { - log_info( "%ld) Failure for absdiff( (int%s) 0x%8.8x, (int%s) 0x%8.8x) = *0x%8.8x vs 0x%8.8x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); + log_info("%zu) Failure for absdiff( (int%s) 0x%8.8x, (int%s) " + "0x%8.8x) = *0x%8.8x vs 0x%8.8x\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); return -1; } } @@ -121,7 +145,12 @@ static int verify_absdiff_uint( const void *p, const void *q, const void *r, siz { cl_uint r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) - { log_info( "%ld) Failure for absdiff( (uint%s) 0x%8.8x, (uint%s) 0x%8.8x) = *0x%8.8x vs 0x%8.8x\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for absdiff( (uint%s) 0x%8.8x, (uint%s) " + "0x%8.8x) = *0x%8.8x vs 0x%8.8x\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -136,7 +165,13 @@ static int verify_absdiff_long( const void *p, const void *q, const void *r, siz { cl_ulong r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) - { log_info( "%ld) Failure for absdiff( (long%s) 0x%16.16llx, (long%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for absdiff( (long%s) 0x%16.16" PRIx64 + ", (long%s) 0x%16.16" PRIx64 ") = *0x%16.16" PRIx64 + " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -151,7 +186,13 @@ static int verify_absdiff_ulong( const void *p, const void *q, const void *r, si { cl_ulong r = abs_diff(inA[i], inB[i]); if( r != outptr[i] ) - { log_info( "%ld) Failure for absdiff( (ulong%s) 0x%16.16llx, (ulong%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%zu) Failure for absdiff( (ulong%s) 0x%16.16" PRIx64 + ", (ulong%s) 0x%16.16" PRIx64 ") = *0x%16.16" PRIx64 + " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } diff --git a/test_conformance/integer_ops/test_add_sat.cpp b/test_conformance/integer_ops/test_add_sat.cpp index e33f5c67..a62b979c 100644 --- a/test_conformance/integer_ops/test_add_sat.cpp +++ b/test_conformance/integer_ops/test_add_sat.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "procs.h" @@ -140,7 +141,13 @@ static int verify_addsat_long( const cl_long *inA, const cl_long *inB, const cl_ r = CL_LONG_MIN; } if( r != outptr[i] ) - { log_info( "%d) Failure for add_sat( (long%s) 0x%16.16llx, (long%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%d) Failure for add_sat( (long%s) 0x%16.16" PRIx64 + ", (long%s) 0x%16.16" PRIx64 ") = *0x%16.16" PRIx64 + " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -154,7 +161,13 @@ static int verify_addsat_ulong( const cl_ulong *inA, const cl_ulong *inB, const if( r < inA[i] ) r = CL_ULONG_MAX; if( r != outptr[i] ) - { log_info( "%d) Failure for add_sat( (ulong%s) 0x%16.16llx, (ulong%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%d) Failure for add_sat( (ulong%s) 0x%16.16" PRIx64 + ", (ulong%s) 0x%16.16" PRIx64 ") = *0x%16.16" PRIx64 + " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } diff --git a/test_conformance/integer_ops/test_integers.cpp b/test_conformance/integer_ops/test_integers.cpp index 6fa18e1e..20f19a29 100644 --- a/test_conformance/integer_ops/test_integers.cpp +++ b/test_conformance/integer_ops/test_integers.cpp @@ -17,6 +17,7 @@ #include "harness/conversions.h" #include +#include #define TEST_SIZE 512 @@ -198,13 +199,23 @@ int test_single_param_integer_kernel(cl_command_queue queue, cl_context context, case 8: if( useOpKernel ) - log_error( "ERROR: Data sample %d:%d does not validate! Expected (0x%16.16llx), got (0x%16.16llx), sources (0x%16.16llx, 0x%16.16llx)\n", - (int)i, (int)j, ((cl_ulong*)&expected)[0], *( (cl_ulong *)p ), - *( (cl_ulong *)in ), *( (cl_ulong *)in2 ) ); + log_error("ERROR: Data sample %d:%d does not " + "validate! Expected (0x%16.16" PRIx64 + "), got (0x%16.16" PRIx64 + "), sources (0x%16.16" PRIx64 + ", 0x%16.16" PRIx64 ")\n", + (int)i, (int)j, + ((cl_ulong *)&expected)[0], + *((cl_ulong *)p), *((cl_ulong *)in), + *((cl_ulong *)in2)); else - log_error( "ERROR: Data sample %d:%d does not validate! Expected (0x%16.16llx), got (0x%16.16llx), sources (0x%16.16llx)\n", - (int)i, (int)j, ((cl_ulong*)&expected)[0], *( (cl_ulong *)p ), - *( (cl_ulong *)in ) ); + log_error("ERROR: Data sample %d:%d does not " + "validate! Expected (0x%16.16" PRIx64 + "), got (0x%16.16" PRIx64 + "), sources (0x%16.16" PRIx64 ")\n", + (int)i, (int)j, + ((cl_ulong *)&expected)[0], + *((cl_ulong *)p), *((cl_ulong *)in)); break; } return -1; @@ -750,10 +761,14 @@ int test_two_param_integer_kernel(cl_command_queue queue, cl_context context, co break; case 8: - log_error( "ERROR: Data sample %d:%d does not validate! Expected (0x%16.16llx), got (0x%16.16llx), sources (0x%16.16llx, 0x%16.16llx)\n", - (int)i, (int)j, ((cl_ulong*)&expected)[ 0 ], *( (cl_ulong *)out ), - *( (cl_ulong *)inA ), - *( (cl_ulong *)inB ) ); + log_error("ERROR: Data sample %d:%d does not validate! " + "Expected (0x%16.16" PRIx64 + "), got (0x%16.16" PRIx64 + "), sources (0x%16.16" PRIx64 + ", 0x%16.16" PRIx64 ")\n", + (int)i, (int)j, ((cl_ulong *)&expected)[0], + *((cl_ulong *)out), *((cl_ulong *)inA), + *((cl_ulong *)inB)); break; } return -1; @@ -1417,11 +1432,14 @@ int test_three_param_integer_kernel(cl_command_queue queue, cl_context context, break; case 8: - log_error( "ERROR: Data sample %d:%d does not validate! Expected (0x%16.16llx), got (0x%16.16llx), sources (0x%16.16llx, 0x%16.16llx, 0x%16.16llx)\n", - (int)i, (int)j, ((cl_ulong*)&expected)[ 0 ], *( (cl_ulong *)out ), - *( (cl_ulong *)inA ), - *( (cl_ulong *)inB ), - *( (cl_ulong *)inC ) ); + log_error("ERROR: Data sample %d:%d does not validate! " + "Expected (0x%16.16" PRIx64 + "), got (0x%16.16" PRIx64 + "), sources (0x%16.16" PRIx64 + ", 0x%16.16" PRIx64 ", 0x%16.16" PRIx64 ")\n", + (int)i, (int)j, ((cl_ulong *)&expected)[0], + *((cl_ulong *)out), *((cl_ulong *)inA), + *((cl_ulong *)inB), *((cl_ulong *)inC)); break; } return -1; diff --git a/test_conformance/integer_ops/test_intmad24.cpp b/test_conformance/integer_ops/test_intmad24.cpp index 1b1d549c..d0fb3af9 100644 --- a/test_conformance/integer_ops/test_intmad24.cpp +++ b/test_conformance/integer_ops/test_intmad24.cpp @@ -139,8 +139,10 @@ verify_int_mad24(int *inptrA, int *inptrB, int *inptrC, int *outptr, size_t n, s r = a * b + inptrC[i]; if (r != outptr[i]) { - log_error( "Failed at %ld) 0x%8.8x * 0x%8.8x + 0x%8.8x = *0x%8.8x vs 0x%8.8x\n", i, a, b, inptrC[i], r, outptr[i] ); - return -1; + log_error("Failed at %zu) 0x%8.8x * 0x%8.8x + 0x%8.8x = *0x%8.8x " + "vs 0x%8.8x\n", + i, a, b, inptrC[i], r, outptr[i]); + return -1; } } @@ -160,8 +162,10 @@ verify_uint_mad24(cl_uint *inptrA, cl_uint *inptrB, cl_uint *inptrC, cl_uint *ou r = a * b + inptrC[i]; if (r != outptr[i]) { - log_error( "Failed at %ld) 0x%8.8x * 0x%8.8x + 0x%8.8x = *0x%8.8x vs 0x%8.8x\n", i, a, b, inptrC[i], r, outptr[i] ); - return -1; + log_error("Failed at %zu) 0x%8.8x * 0x%8.8x + 0x%8.8x = *0x%8.8x " + "vs 0x%8.8x\n", + i, a, b, inptrC[i], r, outptr[i]); + return -1; } } diff --git a/test_conformance/integer_ops/test_intmul24.cpp b/test_conformance/integer_ops/test_intmul24.cpp index 0985a6ae..5ba683ee 100644 --- a/test_conformance/integer_ops/test_intmul24.cpp +++ b/test_conformance/integer_ops/test_intmul24.cpp @@ -153,8 +153,10 @@ verify_uint_mul24(cl_uint *inptrA, cl_uint *inptrB, cl_uint *outptr, size_t n, s r = (inptrA[i] & 0xffffffU) * (inptrB[i] & 0xffffffU); if (r != outptr[i]) { - log_error( "failed at %ld: 0x%8.8x * 0x%8.8x = *0x%8.8x vs 0x%8.8x\n", i, inptrA[i], inptrB[i], r, outptr[i] ); - return -1; + log_error( + "failed at %zu: 0x%8.8x * 0x%8.8x = *0x%8.8x vs 0x%8.8x\n", i, + inptrA[i], inptrB[i], r, outptr[i]); + return -1; } } diff --git a/test_conformance/integer_ops/test_popcount.cpp b/test_conformance/integer_ops/test_popcount.cpp index 31e40615..04f30c9c 100644 --- a/test_conformance/integer_ops/test_popcount.cpp +++ b/test_conformance/integer_ops/test_popcount.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "procs.h" #define str(s) #s @@ -36,26 +38,29 @@ } \ } -#define __verify_popcount_func(__T) \ - static int verify_popcount_##__T( const void *p, const void *r, size_t n, const char *sizeName, size_t vecSize ) \ - { \ - const __T *inA = (const __T *) p; \ - const __T *outptr = (const __T *) r; \ - size_t i; \ - int _n = sizeof(__T)*8; \ - __T ref; \ - for(i = 0; i < n; i++) \ - { \ - __T x = inA[i]; \ - __T res = outptr[i]; \ - __popcnt(x, __T, _n, ref); \ - if(res != ref) \ - { \ - log_info( "%ld) Failure for popcount( (%s%s) 0x%x ) = *%d vs %d\n", i, str(__T), sizeName, x, (int)ref, (int)res ); \ - return -1; \ - }\ - } \ - return 0; \ +#define __verify_popcount_func(__T) \ + static int verify_popcount_##__T(const void *p, const void *r, size_t n, \ + const char *sizeName, size_t vecSize) \ + { \ + const __T *inA = (const __T *)p; \ + const __T *outptr = (const __T *)r; \ + size_t i; \ + int _n = sizeof(__T) * 8; \ + __T ref; \ + for (i = 0; i < n; i++) \ + { \ + __T x = inA[i]; \ + __T res = outptr[i]; \ + __popcnt(x, __T, _n, ref); \ + if (res != ref) \ + { \ + log_info( \ + "%zu) Failure for popcount( (%s%s) 0x%x ) = *%d vs %d\n", \ + i, str(__T), sizeName, (int)x, (int)ref, (int)res); \ + return -1; \ + } \ + } \ + return 0; \ } __verify_popcount_func(cl_char); diff --git a/test_conformance/integer_ops/test_sub_sat.cpp b/test_conformance/integer_ops/test_sub_sat.cpp index 2a88ee0d..d5348728 100644 --- a/test_conformance/integer_ops/test_sub_sat.cpp +++ b/test_conformance/integer_ops/test_sub_sat.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "procs.h" @@ -140,7 +141,13 @@ static int verify_subsat_long( const cl_long *inA, const cl_long *inB, const cl_ r = CL_LONG_MIN; } if( r != outptr[i] ) - { log_info( "%d) Failure for sub_sat( (long%s) 0x%16.16llx, (long%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%d) Failure for sub_sat( (long%s) 0x%16.16" PRIx64 + ", (long%s) 0x%16.16" PRIx64 ") = *0x%16.16" PRIx64 + " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } @@ -154,7 +161,13 @@ static int verify_subsat_ulong( const cl_ulong *inA, const cl_ulong *inB, const if( inA[i] < inB[i] ) r = 0; if( r != outptr[i] ) - { log_info( "%d) Failure for sub_sat( (ulong%s) 0x%16.16llx, (ulong%s) 0x%16.16llx) = *0x%16.16llx vs 0x%16.16llx\n", i, sizeName, inA[i], sizeName, inB[i], r, outptr[i] ); return -1; } + { + log_info("%d) Failure for sub_sat( (ulong%s) 0x%16.16" PRIx64 + ", (ulong%s) 0x%16.16" PRIx64 ") = *0x%16.16" PRIx64 + " vs 0x%16.16" PRIx64 "\n", + i, sizeName, inA[i], sizeName, inB[i], r, outptr[i]); + return -1; + } } return 0; } diff --git a/test_conformance/integer_ops/test_unary_ops.cpp b/test_conformance/integer_ops/test_unary_ops.cpp index c91c85ae..da3de6d1 100644 --- a/test_conformance/integer_ops/test_unary_ops.cpp +++ b/test_conformance/integer_ops/test_unary_ops.cpp @@ -16,6 +16,8 @@ #include "testBase.h" #include "harness/conversions.h" +#include + #define TEST_SIZE 512 enum OpKonstants @@ -71,8 +73,8 @@ int test_unary_op( cl_command_queue queue, cl_context context, OpKonstants which } else { - sprintf( loadLine, "vload%ld( tid, inOut )", vecSize ); - sprintf( storeLine, "vstore%ld( inOutVal, tid, inOut )", vecSize ); + sprintf(loadLine, "vload%zu( tid, inOut )", vecSize); + sprintf(storeLine, "vstore%zu( inOutVal, tid, inOut )", vecSize); } char sizeNames[][4] = { "", "", "2", "3", "4", "", "", "", "8", "", "", "", "", "", "", "", "16" }; @@ -159,8 +161,9 @@ template int VerifyFn( void * actualPtr, void * inputPtr, size_t vec if( actualData[ index ] != nextVal ) { - log_error( "ERROR: Validation failed on vector %ld:%ld (expected %lld, got %lld)", i, j, - (cl_long)nextVal, (cl_long)actualData[ index ] ); + log_error("ERROR: Validation failed on vector %zu:%zu " + "(expected %" PRId64 ", got %" PRId64 ")", + i, j, (cl_long)nextVal, (cl_long)actualData[index]); return -1; } } diff --git a/test_conformance/integer_ops/test_upsample.cpp b/test_conformance/integer_ops/test_upsample.cpp index 9ae3f0c3..33ecb586 100644 --- a/test_conformance/integer_ops/test_upsample.cpp +++ b/test_conformance/integer_ops/test_upsample.cpp @@ -213,7 +213,7 @@ void * create_upsample_data( ExplicitType type, void *sourceA, void *sourceB, si } break; default: - log_error( "ERROR: unknown type size: %ld\n", tSize ); + log_error("ERROR: unknown type size: %zu\n", tSize); return NULL; } diff --git a/test_conformance/integer_ops/verification_and_generation_functions.cpp b/test_conformance/integer_ops/verification_and_generation_functions.cpp index 25fbe717..1b745999 100644 --- a/test_conformance/integer_ops/verification_and_generation_functions.cpp +++ b/test_conformance/integer_ops/verification_and_generation_functions.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "procs.h" #include "harness/conversions.h" @@ -227,20 +229,50 @@ verify_long(int test, size_t vector_size, cl_long *inptrA, cl_long *inptrB, cl_l if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_long Verification failed at element %ld of %ld : 0x%llx %s 0x%llx = 0x%llx, got 0x%llx\n", i, n, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Vector shift failure at element %ld: original is 0x%llx %s %d (0x%llx)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); - log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %lld (0x%llx).\n", (int)log2(sizeof(cl_long)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); + log_error("cl_long Verification failed at element %zu of " + "%zu : 0x%" PRIx64 " %s 0x%" PRIx64 + " = 0x%" PRIx64 ", got 0x%" PRIx64 "\n", + i, n, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error( + "\t1) Vector shift failure at element %zu: original is " + "0x%" PRIx64 " %s %d (0x%" PRIx64 ")\n", + i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); + log_error("\t2) Take the %d LSBs of the shift to get the " + "final shift amount %" PRId64 " (0x%" PRIx64 + ").\n", + (int)log2(sizeof(cl_long) * 8), + inptrB[i] & shift_mask, inptrB[i] & shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_long Verification failed at element %ld of %ld (%ld): 0x%llx %s 0x%llx = 0x%llx, got 0x%llx\n", i, n, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%llx %s %d (0x%llx)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); - log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %lld (0x%llx).\n", (int)log2(sizeof(cl_long)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); + log_error("cl_long Verification failed at element %zu of " + "%zu (%zu): 0x%" PRIx64 " %s 0x%" PRIx64 + " = 0x%" PRIx64 ", got 0x%" PRIx64 "\n", + i, n, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error( + "\t1) Scalar shift failure at element %zu: original is " + "0x%" PRIx64 " %s %d (0x%" PRIx64 ")\n", + i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("\t2) Take the %d LSBs of the shift to get the " + "final shift amount %" PRId64 " (0x%" PRIx64 + ").\n", + (int)log2(sizeof(cl_long) * 8), + inptrB[j] & shift_mask, inptrB[j] & shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld (%ld): (0x%llx < 0x%llx) ? 0x%llx : 0x%llx = 0x%llx, got 0x%llx\n", i, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error("cl_int Verification failed at element %zu " + "(%zu): (0x%" PRIx64 " < 0x%" PRIx64 + ") ? 0x%" PRIx64 " : 0x%" PRIx64 " = 0x%" PRIx64 + ", got 0x%" PRIx64 "\n", + i, j, inptrA[j], inptrB[j], inptrA[i], inptrB[i], + r, outptr[i]); } else { - log_error("cl_long Verification failed at element %ld of %ld: 0x%llx %s 0x%llx = 0x%llx, got 0x%llx\n", i, n, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_long Verification failed at element %zu of " + "%zu: 0x%" PRIx64 " %s 0x%" PRIx64 " = 0x%" PRIx64 + ", got 0x%" PRIx64 "\n", + i, n, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { @@ -423,19 +455,49 @@ verify_ulong(int test, size_t vector_size, cl_ulong *inptrA, cl_ulong *inptrB, c if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_ulong Verification failed at element %ld of %ld: 0x%llx %s 0x%llx = 0x%llx, got 0x%llx\n", i, n, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Shift failure at element %ld: original is 0x%llx %s %d (0x%llx)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); - log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %llu (0x%llx).\n", (int)log2(sizeof(cl_ulong)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); + log_error("cl_ulong Verification failed at element %zu of " + "%zu: 0x%" PRIx64 " %s 0x%" PRIx64 " = 0x%" PRIx64 + ", got 0x%" PRIx64 "\n", + i, n, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error("\t1) Shift failure at element %zu: original is " + "0x%" PRIx64 " %s %d (0x%" PRIx64 ")\n", + i, inptrA[i], tests[test], (int)inptrB[i], + inptrB[i]); + log_error("\t2) Take the %d LSBs of the shift to get the " + "final shift amount %" PRIu64 " (0x%" PRIx64 + ").\n", + (int)log2(sizeof(cl_ulong) * 8), + inptrB[i] & shift_mask, inptrB[i] & shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_ulong Verification failed at element %ld of %ld (%ld): 0x%llx %s 0x%llx = 0x%llx, got 0x%llx\n", i, n, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%llx %s %d (0x%llx)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); - log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %lld (0x%llx).\n", (int)log2(sizeof(cl_long)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); + log_error("cl_ulong Verification failed at element %zu of " + "%zu (%zu): 0x%" PRIx64 " %s 0x%" PRIx64 + " = 0x%" PRIx64 ", got 0x%" PRIx64 "\n", + i, n, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error( + "\t1) Scalar shift failure at element %zu: original is " + "0x%" PRIx64 " %s %d (0x%" PRIx64 ")\n", + i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("\t2) Take the %d LSBs of the shift to get the " + "final shift amount %" PRId64 " (0x%" PRIx64 + ").\n", + (int)log2(sizeof(cl_long) * 8), + inptrB[j] & shift_mask, inptrB[j] & shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld of %ld (%ld): (0x%llx < 0x%llx) ? 0x%llx : 0x%llx = 0x%llx, got 0x%llx\n", i, n, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error("cl_int Verification failed at element %zu of " + "%zu (%zu): (0x%" PRIx64 " < 0x%" PRIx64 + ") ? 0x%" PRIx64 " : 0x%" PRIx64 " = 0x%" PRIx64 + ", got 0x%" PRIx64 "\n", + i, n, j, inptrA[j], inptrB[j], inptrA[i], + inptrB[i], r, outptr[i]); } else { - log_error("cl_ulong Verification failed at element %ld of %ld: 0x%llx %s 0x%llx = 0x%llx, got 0x%llx\n", i, n, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_ulong Verification failed at element %zu of " + "%zu: 0x%" PRIx64 " %s 0x%" PRIx64 " = 0x%" PRIx64 + ", got 0x%" PRIx64 "\n", + i, n, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { @@ -624,19 +686,37 @@ verify_int(int test, size_t vector_size, cl_int *inptrA, cl_int *inptrB, cl_int if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_int Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); + log_error("cl_int Verification failed at element %zu: 0x%x " + "%s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error("\t1) Shift failure at element %zu: original is " + "0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[i], + inptrB[i]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_int)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_int Verification failed at element %ld (%ld): 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("cl_int Verification failed at element %zu " + "(%zu): 0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error("\t1) Scalar shift failure at element %zu: " + "original is 0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[j], + inptrB[j]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_int)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld (%ld): (0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error( + "cl_int Verification failed at element %zu (%zu): " + "(0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[j], inptrB[j], inptrA[i], inptrB[i], r, + outptr[i]); } else { - log_error("cl_int Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_int Verification failed at element %zu: 0x%x " + "%s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { @@ -819,19 +899,37 @@ verify_uint(int test, size_t vector_size, cl_uint *inptrA, cl_uint *inptrB, cl_u if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_uint Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); + log_error("cl_uint Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error("\t1) Shift failure at element %zu: original is " + "0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[i], + inptrB[i]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_uint)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_uint Verification failed at element %ld (%ld): 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("cl_uint Verification failed at element %zu " + "(%zu): 0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error("\t1) Scalar shift failure at element %zu: " + "original is 0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[j], + inptrB[j]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_uint)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld (%ld): (0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error( + "cl_int Verification failed at element %zu (%zu): " + "(0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[j], inptrB[j], inptrA[i], inptrB[i], r, + outptr[i]); } else { - log_error("cl_uint Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_uint Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { @@ -1015,19 +1113,37 @@ verify_short(int test, size_t vector_size, cl_short *inptrA, cl_short *inptrB, c if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_short Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); + log_error("cl_short Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error("\t1) Shift failure at element %zu: original is " + "0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[i], + inptrB[i]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_short)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_short Verification failed at element %ld (%ld): 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("cl_short Verification failed at element %zu " + "(%zu): 0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error("\t1) Scalar shift failure at element %zu: " + "original is 0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[j], + inptrB[j]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_short)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld (%ld): (0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error( + "cl_int Verification failed at element %zu (%zu): " + "(0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[j], inptrB[j], inptrA[i], inptrB[i], r, + outptr[i]); } else { - log_error("cl_short Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_short Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { @@ -1213,19 +1329,37 @@ verify_ushort(int test, size_t vector_size, cl_ushort *inptrA, cl_ushort *inptrB if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_ushort Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); + log_error("cl_ushort Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error("\t1) Shift failure at element %zu: original is " + "0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[i], + inptrB[i]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_ushort)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_ushort Verification failed at element %ld (%ld): 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("cl_ushort Verification failed at element %zu " + "(%zu): 0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error("\t1) Scalar shift failure at element %zu: " + "original is 0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[j], + inptrB[j]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_ushort)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld (%ld): (0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error( + "cl_int Verification failed at element %zu (%zu): " + "(0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[j], inptrB[j], inptrA[i], inptrB[i], r, + outptr[i]); } else { - log_error("cl_ushort Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_ushort Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { @@ -1413,19 +1547,37 @@ verify_char(int test, size_t vector_size, cl_char *inptrA, cl_char *inptrB, cl_c if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_char Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); + log_error("cl_char Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error("\t1) Shift failure at element %zu: original is " + "0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[i], + inptrB[i]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_char)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_char Verification failed at element %ld (%ld): 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("cl_char Verification failed at element %zu " + "(%zu): 0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error("\t1) Scalar shift failure at element %zu: " + "original is 0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[j], + inptrB[j]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_long)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld (%ld): (0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error( + "cl_int Verification failed at element %zu (%zu): " + "(0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[j], inptrB[j], inptrA[i], inptrB[i], r, + outptr[i]); } else { - log_error("cl_char Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_char Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { @@ -1619,19 +1771,37 @@ verify_uchar(int test, size_t vector_size, cl_uchar *inptrA, cl_uchar *inptrB, c if (r != outptr[i]) { // Shift is tricky if (test == 8 || test == 9) { - log_error("cl_uchar Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); - log_error("\t1) Shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[i], inptrB[i]); + log_error("cl_uchar Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); + log_error("\t1) Shift failure at element %zu: original is " + "0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[i], + inptrB[i]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_uchar)*8), inptrB[i]&shift_mask, inptrB[i]&shift_mask); } else if (test == 10 || test == 11) { - log_error("cl_uchar Verification failed at element %ld (%ld): 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[i], tests[test], inptrB[j], r, outptr[i]); - log_error("\t1) Scalar shift failure at element %ld: original is 0x%x %s %d (0x%x)\n", i, inptrA[i], tests[test], (int)inptrB[j], inptrB[j]); + log_error("cl_uchar Verification failed at element %zu " + "(%zu): 0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[i], tests[test], inptrB[j], r, + outptr[i]); + log_error("\t1) Scalar shift failure at element %zu: " + "original is 0x%x %s %d (0x%x)\n", + i, inptrA[i], tests[test], (int)inptrB[j], + inptrB[j]); log_error("\t2) Take the %d LSBs of the shift to get the final shift amount %d (0x%x).\n", (int)log2(sizeof(cl_uchar)*8), inptrB[j]&shift_mask, inptrB[j]&shift_mask); } else if (test == 13) { - log_error("cl_int Verification failed at element %ld (%ld): (0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", i, j, inptrA[j], inptrB[j], - inptrA[i], inptrB[i], r, outptr[i]); + log_error( + "cl_int Verification failed at element %zu (%zu): " + "(0x%x < 0x%x) ? 0x%x : 0x%x = 0x%x, got 0x%x\n", + i, j, inptrA[j], inptrB[j], inptrA[i], inptrB[i], r, + outptr[i]); } else { - log_error("cl_uchar Verification failed at element %ld: 0x%x %s 0x%x = 0x%x, got 0x%x\n", i, inptrA[i], tests[test], inptrB[i], r, outptr[i]); + log_error("cl_uchar Verification failed at element %zu: " + "0x%x %s 0x%x = 0x%x, got 0x%x\n", + i, inptrA[i], tests[test], inptrB[i], r, + outptr[i]); } count++; if (count >= MAX_ERRORS_TO_PRINT) { diff --git a/test_conformance/math_brute_force/main.cpp b/test_conformance/math_brute_force/main.cpp index 8d8acb1b..b09a224d 100644 --- a/test_conformance/math_brute_force/main.cpp +++ b/test_conformance/math_brute_force/main.cpp @@ -843,10 +843,11 @@ test_status InitCL(cl_device_id device) IsTininessDetectedBeforeRounding(); cl_platform_id platform; - int err = clGetPlatformIDs(1, &platform, NULL); + int err = clGetDeviceInfo(gDevice, CL_DEVICE_PLATFORM, sizeof(platform), + &platform, NULL); if (err) { - print_error(err, "clGetPlatformIDs failed"); + print_error(err, "clGetDeviceInfo for CL_DEVICE_PLATFORM failed"); return TEST_FAIL; } diff --git a/test_conformance/math_brute_force/unary_float.cpp b/test_conformance/math_brute_force/unary_float.cpp index 0c497bc4..9666d5ea 100644 --- a/test_conformance/math_brute_force/unary_float.cpp +++ b/test_conformance/math_brute_force/unary_float.cpp @@ -303,15 +303,14 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) if (strcmp(fname, "exp") == 0 || strcmp(fname, "exp2") == 0) { - float exp_error = ulps; - + // For full profile, ULP depends on input value. + // For embedded profile, ULP comes from functionList. if (!gIsEmbedded) { - exp_error += floor(fabs(2 * s[j])); + ulps = 3.0f + floor(fabs(2 * s[j])); } - fail = !(fabsf(err) <= exp_error); - ulps = exp_error; + fail = !(fabsf(err) <= ulps); } if (strcmp(fname, "tan") == 0) { diff --git a/test_conformance/spir/CMakeLists.txt b/test_conformance/spir/CMakeLists.txt index f65c0313..1ac49ac3 100644 --- a/test_conformance/spir/CMakeLists.txt +++ b/test_conformance/spir/CMakeLists.txt @@ -1,6 +1,3 @@ -# Import function list from math_brute_force -add_definitions(-DFUNCTION_LIST_ULPS_ONLY) - set(SPIR_OUT ${CONFORMANCE_PREFIX}spir${CONFORMANCE_SUFFIX}) set (SPIR_SOURCES @@ -9,25 +6,18 @@ set (SPIR_SOURCES run_build_test.cpp run_services.cpp kernelargs.cpp - ../math_brute_force/function_list.cpp ) add_executable(${SPIR_OUT} ${SPIR_SOURCES}) if(UNIX) - set_target_properties(${SPIR_OUT} PROPERTIES - COMPILE_FLAGS "-fexceptions -frtti") + target_compile_options(${SPIR_OUT} PRIVATE -fexceptions -frtti) elseif(MSVC) - set_target_properties(${SPIR_OUT} PROPERTIES - COMPILE_FLAGS "/GR /EHs /EHc") + target_compile_options(${SPIR_OUT} PRIVATE /GR /EHs /EHc) endif() -TARGET_LINK_LIBRARIES(${SPIR_OUT} harness - ${CLConform_LIBRARIES}) - - -set_source_files_properties(${SPIR_SOURCES} PROPERTIES LANGUAGE CXX) +target_link_libraries(${SPIR_OUT} harness ${CLConform_LIBRARIES}) # Need to copy the spir zips to sit beside the executable diff --git a/test_conformance/spir/main.cpp b/test_conformance/spir/main.cpp index b02da734..ca02e5c2 100644 --- a/test_conformance/spir/main.cpp +++ b/test_conformance/spir/main.cpp @@ -13,6 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. // + +// Import function list from math_brute_force +#define FUNCTION_LIST_ULPS_ONLY +#include "../math_brute_force/function_list.cpp" + #include "harness/compat.h" #include diff --git a/test_conformance/spirv_new/CMakeLists.txt b/test_conformance/spirv_new/CMakeLists.txt index 68720975..89f43f26 100644 --- a/test_conformance/spirv_new/CMakeLists.txt +++ b/test_conformance/spirv_new/CMakeLists.txt @@ -1,16 +1,3 @@ -###################################################################################################### -#Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. -# -#This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -#This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -#third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -#broadcast or otherwise exploited in any manner without the express prior written permission -#of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -#disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -#in whole or in part other than under the terms of the Khronos Adopters Agreement -#or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -###################################################################################################### - set(MODULE_NAME SPIRV_NEW) file(GLOB SPIRV_NEW_SOURCES "*.cpp") diff --git a/test_conformance/spirv_new/assemble_spirv.py b/test_conformance/spirv_new/assemble_spirv.py index 99b16adf..d02e5421 100755 --- a/test_conformance/spirv_new/assemble_spirv.py +++ b/test_conformance/spirv_new/assemble_spirv.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ##################################################################### -# Copyright (c) 2020 The Khronos Group Inc. All Rights Reserved. +# Copyright (c) 2020-2023 The Khronos Group Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,6 +30,16 @@ import subprocess import sys from textwrap import wrap +# sub-directories for specific SPIR-V environments +spirv_envs = [ + '', # all files in the root directory are considered SPIR-V 1.0 + 'spv1.1', + 'spv1.2', + 'spv1.3', + 'spv1.4', + 'spv1.5', + 'spv1.6', +] def fatal(message): """Print an error message and exit with a non-zero status, to @@ -39,7 +49,7 @@ def fatal(message): sys.exit(1) -def assemble_spirv(asm_dir, bin_dir, spirv_as, verbose): +def assemble_spirv(asm_dir, bin_dir, spirv_as, spirv_env, verbose): """Assemble SPIR-V source into binaries.""" if not os.path.exists(bin_dir): @@ -57,8 +67,8 @@ def assemble_spirv(asm_dir, bin_dir, spirv_as, verbose): bin_file = asm_file_root + asm_file_ext.replace('asm', '') bin_file_path = os.path.join(bin_dir, bin_file) - command = '"{}" --target-env spv1.0 "{}" -o "{}"'.format( - spirv_as, asm_file_path, bin_file_path) + command = '"{}" --target-env "{}" "{}" -o "{}"'.format( + spirv_as, spirv_env, asm_file_path, bin_file_path) if subprocess.call(command, shell=True) != 0: assembly_failures = True print('ERROR: Failure assembling {}: ' @@ -72,7 +82,7 @@ def assemble_spirv(asm_dir, bin_dir, spirv_as, verbose): 'messages from the assembler, if any.'))) -def validate_spirv(bin_dir, spirv_val, verbose): +def validate_spirv(bin_dir, spirv_val, spirv_env, verbose): """Validates SPIR-V binaries. Ignores known failures.""" validation_failures = False @@ -83,8 +93,8 @@ def validate_spirv(bin_dir, spirv_val, verbose): if verbose: print(' Validating {}'.format(bin_file)) - command = '"{}" "{}"'.format( - spirv_val, bin_file_path) + command = '"{}" --target-env "{}" "{}"'.format( + spirv_val, spirv_env, bin_file_path) if subprocess.call(command, shell=True) != 0: print('ERROR: Failure validating {}: ' 'see above output.'.format( @@ -95,8 +105,6 @@ def validate_spirv(bin_dir, spirv_val, verbose): if validation_failures: fatal('ERROR: Validation failure(s) found. ' 'See above for validation output.') - else: - print('All SPIR-V binaries validated successfully.') def parse_args(): @@ -144,18 +152,26 @@ def main(): args = parse_args() - print('Assembling SPIR-V source into binaries...') - assemble_spirv(args.source_dir, args.output_dir, args.assembler, - args.verbose) - print('Finished assembling SPIR-V binaries.') - print() + for subdir in spirv_envs: + src_dir = os.path.join(args.source_dir, subdir) + out_dir = os.path.join(args.output_dir, subdir) + spirv_env = 'spv1.0' if subdir == '' else subdir + print('Assembling SPIR-V source into binaries for target {}...'. + format(spirv_env)) + assemble_spirv(src_dir, out_dir, args.assembler, + spirv_env, args.verbose) + print('Finished assembling SPIR-V binaries.') + print() - if args.skip_validation: - print('Skipping validation of SPIR-V binaries as requested.') - else: - print('Validating SPIR-V binaries...') - validate_spirv(args.output_dir, args.validator, args.verbose) - print() + if args.skip_validation: + print('Skipping validation of SPIR-V binaries as requested.') + else: + print('Validating SPIR-V binaries for target {}...'. + format(spirv_env)) + validate_spirv(out_dir, args.validator, + spirv_env, args.verbose) + print('All SPIR-V binaries validated successfully.') + print() print('Done.') diff --git a/test_conformance/spirv_new/main.cpp b/test_conformance/spirv_new/main.cpp index 41566837..fc3c0bec 100644 --- a/test_conformance/spirv_new/main.cpp +++ b/test_conformance/spirv_new/main.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 @@ -30,9 +33,12 @@ const std::string slash = "/"; #endif const std::string spvExt = ".spv"; +bool gVersionSkip = false; std::string gAddrWidth = ""; std::string spvBinariesPath = "spirv_bin"; -std::string spvBinariesPathArg = "--spirv-binaries-path"; + +const std::string spvBinariesPathArg = "--spirv-binaries-path"; +const std::string spvVersionSkipArg = "--skip-spirv-version-check"; std::vector readBinary(const char *file_name) { @@ -224,7 +230,10 @@ test_status InitCL(cl_device_id id) void printUsage() { log_info("Reading SPIR-V files from default '%s' path.\n", spvBinariesPath.c_str()); - log_info("In case you want to set other directory use '%s' argument.\n", spvBinariesPathArg.c_str()); + log_info("In case you want to set other directory use '%s' argument.\n", + spvBinariesPathArg.c_str()); + log_info("To skip the SPIR-V version check use the '%s' argument.\n", + spvVersionSkipArg.c_str()); } int main(int argc, const char *argv[]) @@ -243,6 +252,11 @@ int main(int argc, const char *argv[]) modifiedSpvBinariesPath = true; } } + if (argv[i] == spvVersionSkipArg) + { + gVersionSkip = true; + argsRemoveNum++; + } if (argsRemoveNum > 0) { for (int j = i; j < (argc - argsRemoveNum); ++j) diff --git a/test_conformance/spirv_new/procs.h b/test_conformance/spirv_new/procs.h index b293a520..a80d4edc 100644 --- a/test_conformance/spirv_new/procs.h +++ b/test_conformance/spirv_new/procs.h @@ -1,17 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to -the Khronos Group, Inc. This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not -be disclosed in whole or in part to third parties, and may not be reproduced, -republished, distributed, transmitted, displayed, broadcast or otherwise -exploited in any manner without the express prior written permission of Khronos -Group. The receipt or possession of this code does not convey any rights to -reproduce, disclose, or distribute its contents, or to manufacture, use, or sell -anything that it may describe, in whole or in part other than under the terms of -the Khronos Adopters Agreement or Khronos Conformance Test Source License -Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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. +// #pragma once diff --git a/test_conformance/spirv_new/spirv_asm/basic.spvasm32 b/test_conformance/spirv_new/spirv_asm/basic.spvasm32 new file mode 100644 index 00000000..a640c8c9 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/basic.spvasm32 @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 18 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %9 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %8 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %9 = OpFunction %void None %8 + %10 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpLabel + %13 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 16 + %14 = OpCompositeExtract %uint %13 0 + %15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %14 + %16 = OpLoad %uint %15 Aligned 4 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %10 %14 + OpStore %17 %16 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/basic.spvasm64 b/test_conformance/spirv_new/spirv_asm/basic.spvasm64 new file mode 100644 index 00000000..662bffbf --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/basic.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %10 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %10 = OpFunction %void None %9 + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %14 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 32 + %15 = OpCompositeExtract %ulong %14 0 + %16 = OpUConvert %uint %15 + %17 = OpSConvert %ulong %16 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %12 %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpSConvert %ulong %16 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %20 + OpStore %21 %19 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rte_half_short.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rte_half_short.spvasm32 new file mode 100644 index 00000000..1e693709 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rte_half_short.spvasm32 @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 20 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Float16 + OpCapability Int16 + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rte_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTE + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %1 = OpFunction %void None %14 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %15 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0 + %16 = OpCompositeExtract %uint %15 0 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %16 + %18 = OpLoad %half %17 Aligned 2 + %6 = OpConvertFToS %ushort %18 + %19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %16 + OpStore %19 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rte_half_short.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rte_half_short.spvasm64 new file mode 100644 index 00000000..db50de90 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rte_half_short.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability Int16 + OpCapability Float16 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rte_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTE + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half + %ulong_32 = OpConstant %ulong 32 +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %1 = OpFunction %void None %14 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0 + %17 = OpCompositeExtract %ulong %16 0 + %18 = OpShiftLeftLogical %ulong %17 %ulong_32 + %19 = OpShiftRightArithmetic %ulong %18 %ulong_32 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19 + %21 = OpLoad %half %20 Aligned 2 + %6 = OpConvertFToS %ushort %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19 + OpStore %22 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtn_half_short.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtn_half_short.spvasm32 new file mode 100644 index 00000000..c7c496c4 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtn_half_short.spvasm32 @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Float16 + OpCapability Int16 + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rtn_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTN + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %1 = OpFunction %void None %15 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %16 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0 + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %17 + %19 = OpLoad %half %18 Aligned 2 + %6 = OpConvertFToS %ushort %19 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %17 + OpStore %20 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtn_half_short.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtn_half_short.spvasm64 new file mode 100644 index 00000000..a30f6450 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtn_half_short.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability Float16 + OpCapability Int16 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rtn_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTN + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half + %ulong_32 = OpConstant %ulong 32 +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %1 = OpFunction %void None %14 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0 + %17 = OpCompositeExtract %ulong %16 0 + %18 = OpShiftLeftLogical %ulong %17 %ulong_32 + %19 = OpShiftRightArithmetic %ulong %18 %ulong_32 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19 + %21 = OpLoad %half %20 Aligned 2 + %6 = OpConvertFToS %ushort %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19 + OpStore %22 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtp_half_short.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtp_half_short.spvasm32 new file mode 100644 index 00000000..43c7fa24 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtp_half_short.spvasm32 @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Float16 + OpCapability Int16 + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rtp_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTP + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %1 = OpFunction %void None %15 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %16 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0 + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %17 + %19 = OpLoad %half %18 Aligned 2 + %6 = OpConvertFToS %ushort %19 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %17 + OpStore %20 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtp_half_short.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtp_half_short.spvasm64 new file mode 100644 index 00000000..e3a6b405 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtp_half_short.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability Float16 + OpCapability Int16 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rtp_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTP + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half + %ulong_32 = OpConstant %ulong 32 +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %1 = OpFunction %void None %14 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0 + %17 = OpCompositeExtract %ulong %16 0 + %18 = OpShiftLeftLogical %ulong %17 %ulong_32 + %19 = OpShiftRightArithmetic %ulong %18 %ulong_32 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19 + %21 = OpLoad %half %20 Aligned 2 + %6 = OpConvertFToS %ushort %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19 + OpStore %22 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtz_half_short.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtz_half_short.spvasm32 new file mode 100644 index 00000000..2d931cbd --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtz_half_short.spvasm32 @@ -0,0 +1,42 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 21 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Float16 + OpCapability Int16 + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rtz_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTZ + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %1 = OpFunction %void None %15 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %16 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0 + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %17 + %19 = OpLoad %half %18 Aligned 2 + %6 = OpConvertFToS %ushort %19 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %17 + OpStore %20 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtz_half_short.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtz_half_short.spvasm64 new file mode 100644 index 00000000..e237448f --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_rounding_rtz_half_short.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability Float16 + OpCapability Int16 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %1 "decorate_rounding_rtz_half_short" %gl_GlobalInvocationID + OpName %res "res" + OpName %in "in" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %6 FPRoundingMode RTZ + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid + %ushort = OpTypeInt 16 0 +%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half + %ulong_32 = OpConstant %ulong 32 +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %1 = OpFunction %void None %14 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort + %in = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0 + %17 = OpCompositeExtract %ulong %16 0 + %18 = OpShiftLeftLogical %ulong %17 %ulong_32 + %19 = OpShiftRightArithmetic %ulong %18 %ulong_32 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19 + %21 = OpLoad %half %20 Aligned 2 + %6 = OpConvertFToS %ushort %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19 + OpStore %22 %6 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_int.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_int.spvasm32 similarity index 97% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_int.spvasm32 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_int.spvasm32 index 3fa47c97..1b811208 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_int.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_int.spvasm32 @@ -8,7 +8,7 @@ OpCapability Kernel OpCapability Float64 OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_int" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_int" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uint.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_int.spvasm64 similarity index 98% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uint.spvasm64 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_int.spvasm64 index 7d9efb08..5bec065f 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uint.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_int.spvasm64 @@ -9,7 +9,7 @@ OpCapability Int64 OpCapability Float64 OpMemoryModel Physical64 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_uint" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_int" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uint.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_uint.spvasm32 similarity index 97% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uint.spvasm32 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_uint.spvasm32 index 06724891..c48185d3 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uint.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_uint.spvasm32 @@ -8,7 +8,7 @@ OpCapability Kernel OpCapability Float64 OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_uint" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_uint" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_int.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_uint.spvasm64 similarity index 98% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_int.spvasm64 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_uint.spvasm64 index 8609e208..49d19b8a 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_int.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_double_to_uint.spvasm64 @@ -9,7 +9,7 @@ OpCapability Int64 OpCapability Float64 OpMemoryModel Physical64 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_int" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_uint" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_char.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_char.spvasm32 similarity index 98% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_char.spvasm32 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_char.spvasm32 index 5437067f..5e1a9c26 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_char.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_char.spvasm32 @@ -8,7 +8,7 @@ OpCapability Kernel OpCapability Int8 OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_char" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_char" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_char.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_char.spvasm64 similarity index 98% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_char.spvasm64 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_char.spvasm64 index ba4d6492..af740589 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_char.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_char.spvasm64 @@ -9,7 +9,7 @@ OpCapability Int64 OpCapability Int8 OpMemoryModel Physical64 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_char" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_char" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_short.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_short.spvasm32 similarity index 97% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_short.spvasm32 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_short.spvasm32 index dbb3b44d..d2565830 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_short.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_short.spvasm32 @@ -8,7 +8,7 @@ OpCapability Kernel OpCapability Int16 OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_short" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_short" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_short.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_short.spvasm64 similarity index 98% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_short.spvasm64 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_short.spvasm64 index 2915c12c..7b9cfa80 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_short.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_short.spvasm64 @@ -9,7 +9,7 @@ OpCapability Int64 OpCapability Int16 OpMemoryModel Physical64 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_short" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_short" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uchar.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_uchar.spvasm32 similarity index 97% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uchar.spvasm32 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_uchar.spvasm32 index 9bffb686..150a3402 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uchar.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_uchar.spvasm32 @@ -8,7 +8,7 @@ OpCapability Kernel OpCapability Int8 OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_uchar" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_uchar" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uchar.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_uchar.spvasm64 similarity index 98% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uchar.spvasm64 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_uchar.spvasm64 index 354639fe..3152a026 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_uchar.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_uchar.spvasm64 @@ -9,7 +9,7 @@ OpCapability Int64 OpCapability Int8 OpMemoryModel Physical64 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_uchar" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_uchar" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_ushort.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_ushort.spvasm32 similarity index 97% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_ushort.spvasm32 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_ushort.spvasm32 index ffbb4177..26dc05f5 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_ushort.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_ushort.spvasm32 @@ -8,7 +8,7 @@ OpCapability Kernel OpCapability Int16 OpMemoryModel Physical32 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_ushort" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_ushort" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_ushort.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_ushort.spvasm64 similarity index 98% rename from test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_ushort.spvasm64 rename to test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_ushort.spvasm64 index 317f9929..a89239bf 100644 --- a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_ushort.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_float_to_ushort.spvasm64 @@ -9,7 +9,7 @@ OpCapability Int64 OpCapability Int16 OpMemoryModel Physical64 OpenCL - OpEntryPoint Kernel %1 "decorate_saturated_conversion_ushort" %gl_GlobalInvocationID + OpEntryPoint Kernel %1 "decorate_saturated_conversion_float_to_ushort" %gl_GlobalInvocationID OpName %res "res" OpName %lhs "lhs" OpName %rhs "rhs" diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_char.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_char.spvasm32 new file mode 100644 index 00000000..713d37cd --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_char.spvasm32 @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 25 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int8 + OpCapability Float16 + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %1 "decorate_saturated_conversion_half_to_char" %gl_GlobalInvocationID + OpName %res "res" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %7 SaturatedConversion + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %uchar = OpTypeInt 8 0 +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_half %_ptr_CrossWorkgroup_half +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %1 = OpFunction %void None %16 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %17 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0 + %18 = OpCompositeExtract %uint %17 0 + %19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %lhs %18 + %20 = OpLoad %half %19 Aligned 2 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %rhs %18 + %22 = OpLoad %half %21 Aligned 2 + %23 = OpFMul %half %20 %22 + %7 = OpConvertFToS %uchar %23 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %res %18 + OpStore %24 %7 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_char.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_char.spvasm64 new file mode 100644 index 00000000..10d8caa5 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_char.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability Int8 + OpCapability Float16 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %1 "decorate_saturated_conversion_half_to_char" %gl_GlobalInvocationID + OpName %res "res" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %7 SaturatedConversion + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid + %uchar = OpTypeInt 8 0 +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_half %_ptr_CrossWorkgroup_half + %ulong_32 = OpConstant %ulong 32 +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %1 = OpFunction %void None %16 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %18 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0 + %19 = OpCompositeExtract %ulong %18 0 + %20 = OpShiftLeftLogical %ulong %19 %ulong_32 + %21 = OpShiftRightArithmetic %ulong %20 %ulong_32 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %lhs %21 + %23 = OpLoad %half %22 Aligned 2 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %rhs %21 + %25 = OpLoad %half %24 Aligned 2 + %26 = OpFMul %half %23 %25 + %7 = OpConvertFToS %uchar %26 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %res %21 + OpStore %27 %7 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_uchar.spvasm32 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_uchar.spvasm32 new file mode 100644 index 00000000..41b68302 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_uchar.spvasm32 @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 25 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int8 + OpCapability Float16 + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %1 "decorate_saturated_conversion_half_to_uchar" %gl_GlobalInvocationID + OpName %res "res" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %7 SaturatedConversion + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid + %uchar = OpTypeInt 8 0 +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_half %_ptr_CrossWorkgroup_half +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %1 = OpFunction %void None %16 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %17 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0 + %18 = OpCompositeExtract %uint %17 0 + %19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %lhs %18 + %20 = OpLoad %half %19 Aligned 2 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %rhs %18 + %22 = OpLoad %half %21 Aligned 2 + %23 = OpFMul %half %20 %22 + %7 = OpConvertFToU %uchar %23 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %res %18 + OpStore %24 %7 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_uchar.spvasm64 b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_uchar.spvasm64 new file mode 100644 index 00000000..066b9d36 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/decorate_saturated_conversion_half_to_uchar.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability Int8 + OpCapability Float16 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %1 "decorate_saturated_conversion_half_to_uchar" %gl_GlobalInvocationID + OpName %res "res" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpName %entry "entry" + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import + OpDecorate %7 SaturatedConversion + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid + %uchar = OpTypeInt 8 0 +%_ptr_CrossWorkgroup_uchar = OpTypePointer CrossWorkgroup %uchar + %half = OpTypeFloat 16 +%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uchar %_ptr_CrossWorkgroup_half %_ptr_CrossWorkgroup_half + %ulong_32 = OpConstant %ulong 32 +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %1 = OpFunction %void None %16 + %res = OpFunctionParameter %_ptr_CrossWorkgroup_uchar + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_half + %entry = OpLabel + %18 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0 + %19 = OpCompositeExtract %ulong %18 0 + %20 = OpShiftLeftLogical %ulong %19 %ulong_32 + %21 = OpShiftRightArithmetic %ulong %20 %ulong_32 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %lhs %21 + %23 = OpLoad %half %22 Aligned 2 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %rhs %21 + %25 = OpLoad %half %24 Aligned 2 + %26 = OpFMul %half %23 %25 + %7 = OpConvertFToU %uchar %26 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uchar %res %21 + OpStore %27 %7 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_main.spvasm32 b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_main.spvasm32 new file mode 100644 index 00000000..dbdbe32e --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_main.spvasm32 @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 27 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpExtension "SPV_KHR_linkonce_odr" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %17 "test_linkonce_odr" %__spirv_BuiltInGlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %18 FuncParamAttr NoCapture + OpDecorate %a LinkageAttributes "a" LinkOnceODR + OpDecorate %b LinkageAttributes "b" Import + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %uint_5 = OpConstant %uint 5 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %6 = OpTypeFunction %uint %uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %b = OpFunction %uint None %6 + %8 = OpFunctionParameter %uint + OpFunctionEnd + %a = OpFunction %uint Pure %6 + %10 = OpFunctionParameter %uint + %11 = OpLabel + %13 = OpIAdd %uint %10 %uint_5 + OpReturnValue %13 + OpFunctionEnd + %17 = OpFunction %void None %16 + %18 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %19 = OpLabel + %20 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId Aligned 16 + %21 = OpCompositeExtract %uint %20 0 + %22 = OpFunctionCall %uint %a %21 + %23 = OpFunctionCall %uint %b %21 + %24 = OpIAdd %uint %22 %23 + %25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %18 %21 + OpStore %25 %24 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_main.spvasm64 b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_main.spvasm64 new file mode 100644 index 00000000..243ab6b7 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_main.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 30 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpExtension "SPV_KHR_linkonce_odr" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %18 "test_linkonce_odr" %__spirv_BuiltInGlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %19 FuncParamAttr NoCapture + OpDecorate %a LinkageAttributes "a" LinkOnceODR + OpDecorate %b LinkageAttributes "b" Import + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %uint_5 = OpConstant %uint 5 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %7 = OpTypeFunction %uint %uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %17 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %b = OpFunction %uint None %7 + %9 = OpFunctionParameter %uint + OpFunctionEnd + %a = OpFunction %uint Pure %7 + %11 = OpFunctionParameter %uint + %12 = OpLabel + %14 = OpIAdd %uint %11 %uint_5 + OpReturnValue %14 + OpFunctionEnd + %18 = OpFunction %void None %17 + %19 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %20 = OpLabel + %21 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId Aligned 32 + %22 = OpCompositeExtract %ulong %21 0 + %23 = OpUConvert %uint %22 + %24 = OpFunctionCall %uint %a %23 + %25 = OpFunctionCall %uint %b %23 + %26 = OpIAdd %uint %24 %25 + %27 = OpSConvert %ulong %23 + %28 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %19 %27 + OpStore %28 %26 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_noa_main.spvasm32 b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_noa_main.spvasm32 new file mode 100644 index 00000000..e0b01b66 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_noa_main.spvasm32 @@ -0,0 +1,44 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 27 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpExtension "SPV_KHR_linkonce_odr" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %17 "test_linkonce_odr" %__spirv_BuiltInGlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %18 FuncParamAttr NoCapture + OpDecorate %a LinkageAttributes "a" Import + OpDecorate %b LinkageAttributes "b" Import + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %uint_5 = OpConstant %uint 5 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %6 = OpTypeFunction %uint %uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %b = OpFunction %uint None %6 + %8 = OpFunctionParameter %uint + OpFunctionEnd + %a = OpFunction %uint None %6 + %10 = OpFunctionParameter %uint + OpFunctionEnd + %17 = OpFunction %void None %16 + %18 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %19 = OpLabel + %20 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId Aligned 16 + %21 = OpCompositeExtract %uint %20 0 + %22 = OpFunctionCall %uint %a %21 + %23 = OpFunctionCall %uint %b %21 + %24 = OpIAdd %uint %22 %23 + %25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %18 %21 + OpStore %25 %24 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_noa_main.spvasm64 b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_noa_main.spvasm64 new file mode 100644 index 00000000..bb022027 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_noa_main.spvasm64 @@ -0,0 +1,48 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 30 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpExtension "SPV_KHR_linkonce_odr" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %18 "test_linkonce_odr" %__spirv_BuiltInGlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %19 FuncParamAttr NoCapture + OpDecorate %a LinkageAttributes "a" Import + OpDecorate %b LinkageAttributes "b" Import + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %uint_5 = OpConstant %uint 5 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %7 = OpTypeFunction %uint %uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %17 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %b = OpFunction %uint None %7 + %9 = OpFunctionParameter %uint + OpFunctionEnd + %a = OpFunction %uint None %7 + %11 = OpFunctionParameter %uint + OpFunctionEnd + %18 = OpFunction %void None %17 + %19 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %20 = OpLabel + %21 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId Aligned 32 + %22 = OpCompositeExtract %ulong %21 0 + %23 = OpUConvert %uint %22 + %24 = OpFunctionCall %uint %a %23 + %25 = OpFunctionCall %uint %b %23 + %26 = OpIAdd %uint %24 %25 + %27 = OpSConvert %ulong %23 + %28 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %19 %27 + OpStore %28 %26 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_obj.spvasm32 b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_obj.spvasm32 new file mode 100644 index 00000000..59c3f9d9 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_obj.spvasm32 @@ -0,0 +1,28 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 14 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpExtension "SPV_KHR_linkonce_odr" + OpMemoryModel Physical32 OpenCL + OpDecorate %a LinkageAttributes "a" LinkOnceODR + OpDecorate %b LinkageAttributes "b" Export + %uint = OpTypeInt 32 0 + %uint_5 = OpConstant %uint 5 + %uint_0 = OpConstant %uint 0 + %3 = OpTypeFunction %uint %uint + %a = OpFunction %uint Pure %3 + %5 = OpFunctionParameter %uint + %6 = OpLabel + %8 = OpIAdd %uint %5 %uint_5 + OpReturnValue %8 + OpFunctionEnd + %b = OpFunction %uint Pure %3 + %10 = OpFunctionParameter %uint + %11 = OpLabel + %13 = OpISub %uint %uint_0 %10 + OpReturnValue %13 + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_obj.spvasm64 b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_obj.spvasm64 new file mode 100644 index 00000000..5df6fdfe --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/linkage_linkonce_odr_obj.spvasm64 @@ -0,0 +1,28 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 14 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpExtension "SPV_KHR_linkonce_odr" + OpMemoryModel Physical64 OpenCL + OpDecorate %a LinkageAttributes "a" LinkOnceODR + OpDecorate %b LinkageAttributes "b" Export + %uint = OpTypeInt 32 0 + %uint_5 = OpConstant %uint 5 + %uint_0 = OpConstant %uint 0 + %3 = OpTypeFunction %uint %uint + %a = OpFunction %uint Pure %3 + %5 = OpFunctionParameter %uint + %6 = OpLabel + %8 = OpIAdd %uint %5 %uint_5 + OpReturnValue %8 + OpFunctionEnd + %b = OpFunction %uint Pure %3 + %10 = OpFunctionParameter %uint + %11 = OpLabel + %13 = OpISub %uint %uint_0 %10 + OpReturnValue %13 + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.1/basic.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.1/basic.spvasm32 new file mode 100644 index 00000000..2388c840 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.1/basic.spvasm32 @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.1 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 18 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %9 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %8 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %9 = OpFunction %void None %8 + %10 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpLabel + %13 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 16 + %14 = OpCompositeExtract %uint %13 0 + %15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %14 + %16 = OpLoad %uint %15 Aligned 4 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %10 %14 + OpStore %17 %16 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.1/basic.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.1/basic.spvasm64 new file mode 100644 index 00000000..80bc770a --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.1/basic.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.1 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %10 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %10 = OpFunction %void None %9 + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %14 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 32 + %15 = OpCompositeExtract %ulong %14 0 + %16 = OpUConvert %uint %15 + %17 = OpSConvert %ulong %16 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %12 %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpSConvert %ulong %16 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %20 + OpStore %21 %19 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.2/basic.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.2/basic.spvasm32 new file mode 100644 index 00000000..f3233224 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.2/basic.spvasm32 @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.2 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 18 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %9 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %8 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %9 = OpFunction %void None %8 + %10 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpLabel + %13 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 16 + %14 = OpCompositeExtract %uint %13 0 + %15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %14 + %16 = OpLoad %uint %15 Aligned 4 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %10 %14 + OpStore %17 %16 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.2/basic.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.2/basic.spvasm64 new file mode 100644 index 00000000..fcf8b44e --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.2/basic.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.2 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %10 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %10 = OpFunction %void None %9 + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %14 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 32 + %15 = OpCompositeExtract %ulong %14 0 + %16 = OpUConvert %uint %15 + %17 = OpSConvert %ulong %16 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %12 %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpSConvert %ulong %16 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %20 + OpStore %21 %19 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.3/basic.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.3/basic.spvasm32 new file mode 100644 index 00000000..b47fbbf5 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.3/basic.spvasm32 @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.3 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 18 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %9 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %8 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %9 = OpFunction %void None %8 + %10 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpLabel + %13 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 16 + %14 = OpCompositeExtract %uint %13 0 + %15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %14 + %16 = OpLoad %uint %15 Aligned 4 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %10 %14 + OpStore %17 %16 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.3/basic.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.3/basic.spvasm64 new file mode 100644 index 00000000..ba5d232c --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.3/basic.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.3 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %10 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %10 = OpFunction %void None %9 + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %14 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 32 + %15 = OpCompositeExtract %ulong %14 0 + %16 = OpUConvert %uint %15 + %17 = OpSConvert %ulong %16 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %12 %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpSConvert %ulong %16 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %20 + OpStore %21 %19 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/basic.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/basic.spvasm32 new file mode 100644 index 00000000..407ef51d --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/basic.spvasm32 @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 18 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %9 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %8 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %9 = OpFunction %void None %8 + %10 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpLabel + %13 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 16 + %14 = OpCompositeExtract %uint %13 0 + %15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %14 + %16 = OpLoad %uint %15 Aligned 4 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %10 %14 + OpStore %17 %16 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/basic.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/basic.spvasm64 new file mode 100644 index 00000000..c2debf9c --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/basic.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %10 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %10 = OpFunction %void None %9 + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %14 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 32 + %15 = OpCompositeExtract %ulong %14 0 + %16 = OpUConvert %uint %15 + %17 = OpSConvert %ulong %16 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %12 %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpSConvert %ulong %16 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %20 + OpStore %21 %19 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.5/basic.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.5/basic.spvasm32 new file mode 100644 index 00000000..6b51ad5f --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.5/basic.spvasm32 @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 18 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %9 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %8 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %9 = OpFunction %void None %8 + %10 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpLabel + %13 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 16 + %14 = OpCompositeExtract %uint %13 0 + %15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %14 + %16 = OpLoad %uint %15 Aligned 4 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %10 %14 + OpStore %17 %16 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.5/basic.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.5/basic.spvasm64 new file mode 100644 index 00000000..fefc130c --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.5/basic.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.5 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %10 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %10 = OpFunction %void None %9 + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %14 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 32 + %15 = OpCompositeExtract %ulong %14 0 + %16 = OpUConvert %uint %15 + %17 = OpSConvert %ulong %16 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %12 %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpSConvert %ulong %16 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %20 + OpStore %21 %19 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/basic.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.6/basic.spvasm32 new file mode 100644 index 00000000..ff5745ae --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/basic.spvasm32 @@ -0,0 +1,33 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 18 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %9 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %8 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input + %9 = OpFunction %void None %8 + %10 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpLabel + %13 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 16 + %14 = OpCompositeExtract %uint %13 0 + %15 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %14 + %16 = OpLoad %uint %15 Aligned 4 + %17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %10 %14 + OpStore %17 %16 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.6/basic.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.6/basic.spvasm64 new file mode 100644 index 00000000..bed9d3aa --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.6/basic.spvasm64 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.6 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %10 "test_basic" %gl_GlobalInvocationID + OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId + OpDecorate %gl_GlobalInvocationID Constant + OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input + %10 = OpFunction %void None %9 + %11 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %12 = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %13 = OpLabel + %14 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 32 + %15 = OpCompositeExtract %ulong %14 0 + %16 = OpUConvert %uint %15 + %17 = OpSConvert %ulong %16 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %12 %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpSConvert %ulong %16 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %11 %20 + OpStore %21 %19 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/testBase.h b/test_conformance/spirv_new/testBase.h index 1bcd6df5..54fe15bd 100644 --- a/test_conformance/spirv_new/testBase.h +++ b/test_conformance/spirv_new/testBase.h @@ -1,15 +1,19 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. +// +// Copyright (c) 2016-2023 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. +// -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ #pragma once #ifndef _testBase_h diff --git a/test_conformance/spirv_new/test_basic_versions.cpp b/test_conformance/spirv_new/test_basic_versions.cpp new file mode 100644 index 00000000..afe17390 --- /dev/null +++ b/test_conformance/spirv_new/test_basic_versions.cpp @@ -0,0 +1,123 @@ +// +// Copyright (c) 2023 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 "types.hpp" + +#include +#include +#include + +extern bool gVersionSkip; + +TEST_SPIRV_FUNC(basic_versions) +{ + cl_int error = CL_SUCCESS; + + MTdataHolder d(gRandomSeed); + + std::vector h_src(num_elements); + generate_random_data(kInt, h_src.size(), d, h_src.data()); + + clMemWrapper src = + clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, + h_src.size() * sizeof(cl_int), h_src.data(), &error); + test_error(error, "Unable to create source buffer"); + + clMemWrapper dst = + clCreateBuffer(context, 0, h_src.size() * sizeof(cl_int), NULL, &error); + test_error(error, "Unable to create destination buffer"); + + std::map mapILtoSubdir({ + { "SPIR-V_1.0", "" }, // SPIR-V 1.0 files are in the base directory + { "SPIR-V_1.1", "spv1.1" }, + { "SPIR-V_1.2", "spv1.2" }, + { "SPIR-V_1.3", "spv1.3" }, + { "SPIR-V_1.4", "spv1.4" }, + { "SPIR-V_1.5", "spv1.5" }, + { "SPIR-V_1.6", "spv1.6" }, + }); + + size_t sz = 0; + error = clGetDeviceInfo(deviceID, 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); + test_error(error, "Unable to query device IL versions string"); + + for (auto& testCase : mapILtoSubdir) + { + if (gVersionSkip) + { + log_info(" Skipping version check for %s.\n", + testCase.first.c_str()); + } + else if (ilVersions.find(testCase.first) == std::string::npos) + { + log_info(" Version %s is not supported; skipping test.\n", + testCase.first.c_str()); + continue; + } + else + { + log_info(" testing %s...\n", testCase.first.c_str()); + } + + const cl_int zero = 0; + error = + clEnqueueFillBuffer(queue, dst, &zero, sizeof(zero), 0, + h_src.size() * sizeof(cl_int), 0, NULL, NULL); + test_error(error, "Unable to initialize destination buffer"); + + std::string filename = testCase.second + "/basic"; + + clProgramWrapper prog; + error = get_program_with_il(prog, deviceID, context, filename.c_str()); + test_error(error, "Unable to build SPIR-V program"); + + clKernelWrapper kernel = clCreateKernel(prog, "test_basic", &error); + test_error(error, "Unable to create SPIR-V kernel"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + error |= clSetKernelArg(kernel, 1, sizeof(src), &src); + test_error(error, "Unable to set kernel arguments"); + + size_t global = num_elements; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + test_error(error, "Unable to enqueue kernel"); + + std::vector h_dst(num_elements); + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, + h_dst.size() * sizeof(cl_int), h_dst.data(), + 0, NULL, NULL); + test_error(error, "Unable to read destination buffer"); + + for (int i = 0; i < num_elements; i++) + { + if (h_dst[i] != h_src[i]) + { + log_error("Values do not match at location %d\n", i); + return TEST_FAIL; + } + } + } + + return TEST_PASS; +} diff --git a/test_conformance/spirv_new/test_cl_khr_spirv_no_integer_wrap_decoration.cpp b/test_conformance/spirv_new/test_cl_khr_spirv_no_integer_wrap_decoration.cpp index 0728ea03..95227b28 100644 --- a/test_conformance/spirv_new/test_cl_khr_spirv_no_integer_wrap_decoration.cpp +++ b/test_conformance/spirv_new/test_cl_khr_spirv_no_integer_wrap_decoration.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2018 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2018-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_decorate.cpp b/test_conformance/spirv_new/test_decorate.cpp index ccd74315..db58e6b7 100644 --- a/test_conformance/spirv_new/test_decorate.cpp +++ b/test_conformance/spirv_new/test_decorate.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed h_in whole or h_in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited h_in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -h_in whole or h_in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" @@ -19,10 +22,7 @@ or Khronos Conformance Test Source License Agreement as executed between Khronos #include #include -#ifndef isnan -// Ensure isnan is always present as a macro -#define isnan std::isnan -#endif +#include long double reference_remainderl(long double x, long double y); int gIsInRTZMode = 0; @@ -30,7 +30,6 @@ int gDeviceILogb0 = 1; int gDeviceILogbNaN = 1; int gCheckTininessBeforeRounding = 1; - static int verify_results(cl_device_id deviceID, cl_context context, cl_command_queue queue, @@ -44,7 +43,8 @@ static int verify_results(cl_device_id deviceID, cl_int err = 0; RandomSeed seed(gRandomSeed); - for (int i = 0; i < num; i++) { + for (int i = 0; i < num; i++) + { h_lhs[i] = genrand(seed); h_rhs[i] = genrand(seed); } @@ -86,8 +86,10 @@ static int verify_results(cl_device_id deviceID, err = clEnqueueReadBuffer(queue, res, CL_TRUE, 0, bytes, &h_res[0], 0, NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to read to output"); - for (int i = 0; i < num; i++) { - if (h_res[i] != (h_lhs[i] + h_rhs[i])) { + for (int i = 0; i < num; i++) + { + if (h_res[i] != (h_lhs[i] + h_rhs[i])) + { log_error("Values do not match at location %d\n", i); return -1; } @@ -132,12 +134,10 @@ TEST_SPIRV_FUNC(decorate_constant) TEST_SPIRV_FUNC(decorate_cpacked) { - PACKED( - struct packed_struct_t { - cl_int ival; - cl_char cval; - } - ); + PACKED(struct packed_struct_t { + cl_int ival; + cl_char cval; + }); typedef struct packed_struct_t packed_t; @@ -166,9 +166,10 @@ TEST_SPIRV_FUNC(decorate_cpacked) err = clEnqueueReadBuffer(queue, res, CL_TRUE, 0, bytes, &h_res[0], 0, NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to read to output"); - for (int i = 0; i < num; i++) { - if (h_res[i].ival != 2100483600 || - h_res[i].cval != 127) { + for (int i = 0; i < num; i++) + { + if (h_res[i].ival != 2100483600 || h_res[i].cval != 127) + { log_error("Values do not match at location %d\n", i); return -1; } @@ -177,20 +178,79 @@ TEST_SPIRV_FUNC(decorate_cpacked) return 0; } -template -int verify_saturated_results(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - const char *kname, - const clProgramWrapper &prog) +template +static inline Ti generate_saturated_lhs_input(RandomSeed &seed) { - if(std::string(kname).find("double") != std::string::npos) { - if(!is_extension_available(deviceID, "cl_khr_fp64")) { - log_info("Extension cl_khr_fp64 not supported; skipping double tests.\n"); - return 0; - } + constexpr auto loVal = std::numeric_limits::min(); + constexpr auto hiVal = std::numeric_limits::max(); + constexpr Tl range = (Tl)(hiVal) - (Tl)(loVal); + + if (std::is_same::value) + { + return cl_half_from_float(genrand(seed) * range, CL_HALF_RTE); } + return genrand(seed) * range; +} + +template +static inline Ti generate_saturated_rhs_input(RandomSeed &seed) +{ + constexpr auto hiVal = std::numeric_limits::max(); + + Tl val = genrand(seed) % hiVal; + if (std::is_same::value) + { + if (val > 0 && val * 20 < hiVal) + { + return cl_half_from_float(NAN, CL_HALF_RTE); + } + return cl_half_from_float(val, CL_HALF_RTE); + } + + if (val > 0 && val * 20 < hiVal) + { + return (Ti)NAN; + } + return val; +} + +template +static inline To compute_saturated_output(Ti lhs, Ti rhs) +{ + constexpr auto loVal = std::numeric_limits::min(); + constexpr auto hiVal = std::numeric_limits::max(); + + if (std::is_same::value) + { + cl_float f = cl_half_to_float(lhs) * cl_half_to_float(rhs); + + // Quantize to fp16: + f = cl_half_to_float(cl_half_from_float(f, CL_HALF_RTE)); + + To val = (To)std::min(std::max(f, loVal), hiVal); + if (isnan(cl_half_from_float(rhs, CL_HALF_RTE))) + { + val = 0; + } + return val; + } + + Tl ival = (Tl)(lhs * rhs); + To val = (To)std::min(std::max(ival, loVal), hiVal); + + if (isnan(rhs)) + { + val = 0; + } + return val; +} + +template +int verify_saturated_results(cl_device_id deviceID, cl_context context, + cl_command_queue queue, const char *kname, + const clProgramWrapper &prog) +{ cl_int err = 0; const int num = 1 << 20; @@ -204,21 +264,11 @@ int verify_saturated_results(cl_device_id deviceID, std::vector h_lhs(num); std::vector h_rhs(num); - To loVal = std::numeric_limits::min(); - To hiVal = std::numeric_limits::max(); - - Tl range = (Tl)(hiVal) - (Tl)(loVal); - RandomSeed seed(gRandomSeed); - for (int i = 0; i < num; i++) { - h_lhs[i] = genrand(seed) * range; - Tl val = (genrand(seed) % hiVal); - // randomly set some values on rhs to NaN - if (val * 20 < hiVal) { - h_rhs[i] = NAN; - } else { - h_rhs[i] = (Ti)(val); - } + for (int i = 0; i < num; i++) + { + h_lhs[i] = generate_saturated_lhs_input(seed); + h_rhs[i] = generate_saturated_rhs_input(seed); } clMemWrapper lhs = clCreateBuffer(context, CL_MEM_READ_ONLY, in_bytes, NULL, &err); @@ -253,16 +303,13 @@ int verify_saturated_results(cl_device_id deviceID, err = clEnqueueReadBuffer(queue, res, CL_TRUE, 0, out_bytes, &h_res[0], 0, NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to read to output"); - for (int i = 0; i < num; i++) { - Tl ival = (Tl)(h_lhs[i] * h_rhs[i]); - To val = (To)std::min(std::max(ival, loVal), hiVal); + for (int i = 0; i < num; i++) + { + To val = compute_saturated_output(h_lhs[i], h_rhs[i]); - if (isnan(h_rhs[i])) { - val = 0; - } - - if (val != h_res[i]) { - log_error("Value error at %d\n", i); + if (val != h_res[i]) + { + log_error("Value error at %d: got %d, want %d\n", i, val, h_res[i]); return -1; } } @@ -278,31 +325,47 @@ int test_saturate_full(cl_device_id deviceID, const char *name, const char *types) { - if(std::string(types).find("double") != std::string::npos) { - if(!is_extension_available(deviceID, "cl_khr_fp64")) { - log_info("Extension cl_khr_fp64 not supported; skipping double tests.\n"); + if (std::string(types).find("double") != std::string::npos) + { + if (!is_extension_available(deviceID, "cl_khr_fp64")) + { + log_info("Extension cl_khr_fp64 not supported; skipping double " + "tests.\n"); return 0; } } + + if (std::string(types).find("half") != std::string::npos) + { + if (!is_extension_available(deviceID, "cl_khr_fp16")) + { + log_info( + "Extension cl_khr_fp16 not supported; skipping half tests.\n"); + return 0; + } + } + clProgramWrapper prog; cl_int err = 0; err = get_program_with_il(prog, deviceID, context, name); SPIRV_CHECK_ERROR(err, "Failed to build program"); - return verify_saturated_results(deviceID, context, queue, name, prog); + return verify_saturated_results(deviceID, context, queue, name, + prog); } -#define TEST_SATURATED_CONVERSION(Ti, Tl, To) \ - TEST_SPIRV_FUNC(decorate_saturated_conversion_##To) \ - { \ - typedef cl_##Ti cl_Ti; \ - typedef cl_##Tl cl_Tl; \ - typedef cl_##To cl_To; \ - return test_saturate_full \ - (deviceID, context, queue, \ - "decorate_saturated_conversion_" #To, \ - #Ti #Tl #To); \ - } \ +#define TEST_SATURATED_CONVERSION(Ti, Tl, To) \ + TEST_SPIRV_FUNC(decorate_saturated_conversion_##Ti##_to_##To) \ + { \ + typedef cl_##Ti cl_Ti; \ + 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); \ + } +TEST_SATURATED_CONVERSION(half, short, char) +TEST_SATURATED_CONVERSION(half, ushort, uchar) TEST_SATURATED_CONVERSION(float, int, char) TEST_SATURATED_CONVERSION(float, uint, uchar) TEST_SATURATED_CONVERSION(float, int, short) @@ -318,13 +381,26 @@ int test_fp_rounding(cl_device_id deviceID, std::vector &h_in, std::vector &h_out) { - if(std::string(name).find("double") != std::string::npos) { - if(!is_extension_available(deviceID, "cl_khr_fp64")) { - log_info("Extension cl_khr_fp64 not supported; skipping double tests.\n"); + if (std::string(name).find("double") != std::string::npos) + { + if (!is_extension_available(deviceID, "cl_khr_fp64")) + { + log_info("Extension cl_khr_fp64 not supported; skipping double " + "tests.\n"); return 0; } } - + + if (std::string(name).find("half") != std::string::npos) + { + if (!is_extension_available(deviceID, "cl_khr_fp16")) + { + log_info( + "Extension cl_khr_fp16 not supported; skipping half tests.\n"); + return 0; + } + } + const int num = h_in.size(); const size_t in_bytes = num * sizeof(Ti); const size_t out_bytes = num * sizeof(To); @@ -359,9 +435,12 @@ int test_fp_rounding(cl_device_id deviceID, err = clEnqueueReadBuffer(queue, out, CL_TRUE, 0, out_bytes, &h_res[0], 0, NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to read from output"); - for (int i = 0; i < num; i++) { - if (h_res[i] != h_out[i]) { - log_error("Values do not match at location %d. Original :%lf, Expected: %ld, Found %ld\n", + for (int i = 0; i < num; i++) + { + if (h_res[i] != h_out[i]) + { + log_error("Values do not match at location %d. Original :%lf, " + "Expected: %ld, Found %ld\n", i, h_in[i], h_out[i], h_res[i]); return -1; } @@ -370,60 +449,80 @@ int test_fp_rounding(cl_device_id deviceID, return 0; } -template -inline To round_to_zero(Ti in) +template static inline double to_double(T in) { return in; } + +template <> inline double to_double(cl_half in) { return cl_half_to_float(in); } + +template static inline To round_to_zero(Ti in) { - To out = (To)(in); - return out; + return (To)to_double(in); } -template -int sign(T val) +template static inline int sign(T val) { if (val < 0) return -1; if (val > 0) return 1; return 0; } -template -inline To round_to_even(Ti in) +template static inline To round_to_even(Ti in) { - // https://en.wikipedia.org/wiki/Rounding#Round_half_to_even - return std::floor(in + 0.5) - 1 + std::abs(sign(reference_remainderl((long double)in, 2) - 0.5)); + double din = to_double(in); + return std::floor(din + 0.5) - 1 + + std::abs(sign(reference_remainderl((long double)din, 2) - 0.5)); } -template -inline To round_to_posinf(Ti in) +template static inline To round_to_posinf(Ti in) { - To out = std::ceil(in); - return out; + return std::ceil(to_double(in)); } -template -inline To round_to_neginf(Ti in) +template static inline To round_to_neginf(Ti in) { - To out = std::floor(in); - return out; + return std::floor(to_double(in)); } -#define TEST_SPIRV_FP_ROUNDING_DECORATE(name, func, Ti, To) \ - TEST_SPIRV_FUNC(decorate_fp_rounding_mode_##name##_##Ti##_##To) \ - { \ - typedef cl_##Ti clTi; \ - typedef cl_##To clTo; \ - const int num = 1 << 16; \ - std::vector in(num); \ - std::vector out(num); \ - RandomSeed seed(gRandomSeed); \ - \ - for (int i = 0; i < num; i++) { \ - in[i] = num * genrand(seed) - num/2; \ - out[i] = func(in[i]); \ - } \ - const char *name = "decorate_rounding_" #name "_" #Ti "_" #To; \ - return test_fp_rounding(deviceID, context, queue, \ - name, in, out); \ - } \ +template +static inline Ti generate_fprounding_input(RandomSeed &seed) +{ + if (std::is_same::value) + { + constexpr auto minVal = + static_cast(std::numeric_limits::min() / 2); + constexpr auto maxVal = + static_cast(std::numeric_limits::max() / 2); + cl_float f = genrandReal_range(minVal, maxVal, seed); + return cl_half_from_float(f, CL_HALF_RTE); + } + + constexpr auto minVal = static_cast(std::numeric_limits::min() / 2); + constexpr auto maxVal = static_cast(std::numeric_limits::max() / 2); + return genrandReal_range(minVal, maxVal, seed); +} + +#define TEST_SPIRV_FP_ROUNDING_DECORATE(name, func, Ti, To) \ + TEST_SPIRV_FUNC(decorate_fp_rounding_mode_##name##_##Ti##_##To) \ + { \ + typedef cl_##Ti clTi; \ + typedef cl_##To clTo; \ + const int num = 1 << 16; \ + std::vector in(num); \ + std::vector out(num); \ + RandomSeed seed(gRandomSeed); \ + \ + for (int i = 0; i < num; i++) \ + { \ + in[i] = generate_fprounding_input(seed); \ + out[i] = func(in[i]); \ + } \ + const char *name = "decorate_rounding_" #name "_" #Ti "_" #To; \ + return test_fp_rounding(deviceID, context, queue, name, in, out); \ + } + +TEST_SPIRV_FP_ROUNDING_DECORATE(rte, round_to_even, half, short); +TEST_SPIRV_FP_ROUNDING_DECORATE(rtz, round_to_zero, half, short); +TEST_SPIRV_FP_ROUNDING_DECORATE(rtp, round_to_posinf, half, short); +TEST_SPIRV_FP_ROUNDING_DECORATE(rtn, round_to_neginf, half, short); TEST_SPIRV_FP_ROUNDING_DECORATE(rte, round_to_even, float, int); TEST_SPIRV_FP_ROUNDING_DECORATE(rtz, round_to_zero, float, int); diff --git a/test_conformance/spirv_new/test_get_program_il.cpp b/test_conformance/spirv_new/test_get_program_il.cpp index c535eb53..e84f2242 100644 --- a/test_conformance/spirv_new/test_get_program_il.cpp +++ b/test_conformance/spirv_new/test_get_program_il.cpp @@ -1,17 +1,18 @@ -/****************************************************************** -Copyright (c) 2020 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to -the Khronos Group, Inc. This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not -be disclosed in whole or in part to third parties, and may not be reproduced, -republished, distributed, transmitted, displayed, broadcast or otherwise -exploited in any manner without the express prior written permission of Khronos -Group. The receipt or possession of this code does not convey any rights to -reproduce, disclose, or distribute its contents, or to manufacture, use, or sell -anything that it may describe, in whole or in part other than under the terms of -the Khronos Adopters Agreement or Khronos Conformance Test Source License -Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2020-2023 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" diff --git a/test_conformance/spirv_new/test_linkage.cpp b/test_conformance/spirv_new/test_linkage.cpp index cf518c3e..ea17040a 100644 --- a/test_conformance/spirv_new/test_linkage.cpp +++ b/test_conformance/spirv_new/test_linkage.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed h_in whole or h_in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited h_in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -h_in whole or h_in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" @@ -141,3 +144,96 @@ TEST_SPIRV_FUNC(linkage_import_function_link) return 0; } + +static int test_linkonce_odr_helper(cl_device_id deviceID, cl_context context, + cl_command_queue queue, + const char *main_module_filename) +{ + cl_int err = 0; + + clProgramWrapper prog_obj; + err = test_linkage_compile(deviceID, context, queue, + "linkage_linkonce_odr_obj", prog_obj); + SPIRV_CHECK_ERROR(err, "Failed to compile export program"); + + clProgramWrapper prog_main; + err = test_linkage_compile(deviceID, context, queue, main_module_filename, + prog_main); + SPIRV_CHECK_ERROR(err, "Failed to compile import program"); + + cl_program progs[] = { prog_obj, prog_main }; + + clProgramWrapper prog = + clLinkProgram(context, 1, &deviceID, NULL, 2, progs, NULL, NULL, &err); + SPIRV_CHECK_ERROR(err, "Failed to link programs"); + + clKernelWrapper kernel = clCreateKernel(prog, "test_linkonce_odr", &err); + SPIRV_CHECK_ERROR(err, "Failed to create spv kernel"); + + const int num = 256; + std::vector h_in(num); + RandomSeed seed(gRandomSeed); + for (int i = 0; i < num; i++) + { + h_in[i] = genrand(seed) % 2048; + } + + size_t bytes = sizeof(cl_int) * num; + clMemWrapper in = + clCreateBuffer(context, CL_MEM_READ_WRITE, bytes, NULL, &err); + SPIRV_CHECK_ERROR(err, "Failed to create in buffer"); + + err = clEnqueueWriteBuffer(queue, in, CL_TRUE, 0, bytes, &h_in[0], 0, NULL, + NULL); + SPIRV_CHECK_ERROR(err, "Failed to copy to in buffer"); + + err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &in); + SPIRV_CHECK_ERROR(err, "Failed to set arg 1"); + + size_t global = num; + err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, NULL, + NULL); + SPIRV_CHECK_ERROR(err, "Failed to enqueue cl kernel"); + + std::vector h_out(num); + err = clEnqueueReadBuffer(queue, in, CL_TRUE, 0, bytes, &h_out[0], 0, NULL, + NULL); + SPIRV_CHECK_ERROR(err, "Failed to read to output"); + + for (int i = 0; i < num; i++) + { + if (h_out[i] != 5) + { + log_error("Incorrect values at location %d\n", i); + return TEST_FAIL; + } + } + + return TEST_PASS; +} + +TEST_SPIRV_FUNC(linkage_linkonce_odr) +{ + if (!is_extension_available(deviceID, "cl_khr_spirv_linkonce_odr")) + { + log_info("Extension cl_khr_spirv_linkonce_odr not supported; skipping " + "tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + int result = TEST_PASS; + + // 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, + "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, + "linkage_linkonce_odr_noa_main"); + + return result; +} diff --git a/test_conformance/spirv_new/test_op_atomic.cpp b/test_conformance/spirv_new/test_op_atomic.cpp index e4b6feb1..0ee2cfb0 100644 --- a/test_conformance/spirv_new/test_op_atomic.cpp +++ b/test_conformance/spirv_new/test_op_atomic.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_branch.cpp b/test_conformance/spirv_new/test_op_branch.cpp index ec61afd9..f87de6c6 100644 --- a/test_conformance/spirv_new/test_op_branch.cpp +++ b/test_conformance/spirv_new/test_op_branch.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_branch_conditional.cpp b/test_conformance/spirv_new/test_op_branch_conditional.cpp index ad94b824..8f628798 100644 --- a/test_conformance/spirv_new/test_op_branch_conditional.cpp +++ b/test_conformance/spirv_new/test_op_branch_conditional.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_composite_construct.cpp b/test_conformance/spirv_new/test_op_composite_construct.cpp index e009eadf..7ca87626 100644 --- a/test_conformance/spirv_new/test_op_composite_construct.cpp +++ b/test_conformance/spirv_new/test_op_composite_construct.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_constant.cpp b/test_conformance/spirv_new/test_op_constant.cpp index 7c3c146c..c026fd42 100644 --- a/test_conformance/spirv_new/test_op_constant.cpp +++ b/test_conformance/spirv_new/test_op_constant.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_copy_object.cpp b/test_conformance/spirv_new/test_op_copy_object.cpp index 868300d3..b012960e 100644 --- a/test_conformance/spirv_new/test_op_copy_object.cpp +++ b/test_conformance/spirv_new/test_op_copy_object.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_fmath.cpp b/test_conformance/spirv_new/test_op_fmath.cpp index 3cf01837..de887bfe 100644 --- a/test_conformance/spirv_new/test_op_fmath.cpp +++ b/test_conformance/spirv_new/test_op_fmath.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_function.cpp b/test_conformance/spirv_new/test_op_function.cpp index 16183e80..4a0f4d26 100644 --- a/test_conformance/spirv_new/test_op_function.cpp +++ b/test_conformance/spirv_new/test_op_function.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_lifetime.cpp b/test_conformance/spirv_new/test_op_lifetime.cpp index b60e14d6..86e7ce06 100644 --- a/test_conformance/spirv_new/test_op_lifetime.cpp +++ b/test_conformance/spirv_new/test_op_lifetime.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_loop_merge.cpp b/test_conformance/spirv_new/test_op_loop_merge.cpp index 23d257d9..3cac3284 100644 --- a/test_conformance/spirv_new/test_op_loop_merge.cpp +++ b/test_conformance/spirv_new/test_op_loop_merge.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_negate.cpp b/test_conformance/spirv_new/test_op_negate.cpp index 5009be93..281b1f8c 100644 --- a/test_conformance/spirv_new/test_op_negate.cpp +++ b/test_conformance/spirv_new/test_op_negate.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_opaque.cpp b/test_conformance/spirv_new/test_op_opaque.cpp index e6216061..52b54a25 100644 --- a/test_conformance/spirv_new/test_op_opaque.cpp +++ b/test_conformance/spirv_new/test_op_opaque.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_phi.cpp b/test_conformance/spirv_new/test_op_phi.cpp index f9c69d79..77c1a572 100644 --- a/test_conformance/spirv_new/test_op_phi.cpp +++ b/test_conformance/spirv_new/test_op_phi.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_selection_merge.cpp b/test_conformance/spirv_new/test_op_selection_merge.cpp index 6ea47f35..2b06ce85 100644 --- a/test_conformance/spirv_new/test_op_selection_merge.cpp +++ b/test_conformance/spirv_new/test_op_selection_merge.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_spec_constant.cpp b/test_conformance/spirv_new/test_op_spec_constant.cpp index a280a4f7..67ca7b5f 100644 --- a/test_conformance/spirv_new/test_op_spec_constant.cpp +++ b/test_conformance/spirv_new/test_op_spec_constant.cpp @@ -1,17 +1,18 @@ -/****************************************************************** -Copyright (c) 2020 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to -the Khronos Group, Inc. This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not -be disclosed in whole or in part to third parties, and may not be reproduced, -republished, distributed, transmitted, displayed, broadcast or otherwise -exploited in any manner without the express prior written permission of Khronos -Group. The receipt or possession of this code does not convey any rights to -reproduce, disclose, or distribute its contents, or to manufacture, use, or sell -anything that it may describe, in whole or in part other than under the terms of -the Khronos Adopters Agreement or Khronos Conformance Test Source License -Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2020-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_undef.cpp b/test_conformance/spirv_new/test_op_undef.cpp index 659ab1a9..43610f82 100644 --- a/test_conformance/spirv_new/test_op_undef.cpp +++ b/test_conformance/spirv_new/test_op_undef.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_vector_extract.cpp b/test_conformance/spirv_new/test_op_vector_extract.cpp index f77aa7a2..62a155b4 100644 --- a/test_conformance/spirv_new/test_op_vector_extract.cpp +++ b/test_conformance/spirv_new/test_op_vector_extract.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/test_op_vector_insert.cpp b/test_conformance/spirv_new/test_op_vector_insert.cpp index 62fc78cb..ed472385 100644 --- a/test_conformance/spirv_new/test_op_vector_insert.cpp +++ b/test_conformance/spirv_new/test_op_vector_insert.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" 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 0be4e8b7..da79d3be 100644 --- a/test_conformance/spirv_new/test_op_vector_times_scalar.cpp +++ b/test_conformance/spirv_new/test_op_vector_times_scalar.cpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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 "types.hpp" diff --git a/test_conformance/spirv_new/types.hpp b/test_conformance/spirv_new/types.hpp index 728b2445..e40197af 100644 --- a/test_conformance/spirv_new/types.hpp +++ b/test_conformance/spirv_new/types.hpp @@ -1,15 +1,18 @@ -/****************************************************************** -Copyright (c) 2016 The Khronos Group Inc. All Rights Reserved. - -This code is protected by copyright laws and contains material proprietary to the Khronos Group, Inc. -This is UNPUBLISHED PROPRIETARY SOURCE CODE that may not be disclosed in whole or in part to -third parties, and may not be reproduced, republished, distributed, transmitted, displayed, -broadcast or otherwise exploited in any manner without the express prior written permission -of Khronos Group. The receipt or possession of this code does not convey any rights to reproduce, -disclose, or distribute its contents, or to manufacture, use, or sell anything that it may describe, -in whole or in part other than under the terms of the Khronos Adopters Agreement -or Khronos Conformance Test Source License Agreement as executed between Khronos and the recipient. -******************************************************************/ +// +// Copyright (c) 2016-2023 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. +// #pragma once #include @@ -91,6 +94,13 @@ T genrandReal(RandomSeed &seed) return genrand_real1(seed); } +// Longer-term this could be refactored out and replace random_float(): +template T genrandReal_range(T low, T high, RandomSeed &seed) +{ + T t = genrand_real1(seed); + return (1.0 - t) * low + t * high; +} + template T genrandRealVec(RandomSeed &seed) { diff --git a/test_conformance/subgroups/procs.h b/test_conformance/subgroups/procs.h index af6444c0..ba40a9f9 100644 --- a/test_conformance/subgroups/procs.h +++ b/test_conformance/subgroups/procs.h @@ -21,67 +21,51 @@ #include "harness/errorHelpers.h" #include "harness/conversions.h" #include "harness/typeWrappers.h" -#include "harness/mt19937.h" -extern MTdata gMTdata; - -extern int test_sub_group_info_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_sub_group_info_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_work_item_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_work_item_functions_core(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_barrier_functions_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_barrier_functions_core(cl_device_id device, cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_pipe_functions(cl_device_id device, cl_context context, +int test_sub_group_info_ext(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_sub_group_info_core(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_work_item_functions_ext(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_work_item_functions_core(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_subgroup_functions_ext(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_subgroup_functions_core(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_barrier_functions_ext(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_ifp_ext(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_ifp_core(cl_device_id device, cl_context context, - cl_command_queue queue, int num_elements); -extern int test_subgroup_functions_extended_types(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_non_uniform_vote(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_non_uniform_arithmetic( - cl_device_id device, cl_context context, cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_ballot(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_clustered_reduce(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_shuffle(cl_device_id device, +int test_barrier_functions_core(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_ifp_ext(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_ifp_core(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_subgroup_functions_extended_types(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); -extern int test_subgroup_functions_shuffle_relative(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_subgroup_functions_rotate(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements); +int test_subgroup_functions_non_uniform_vote(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements); +int test_subgroup_functions_non_uniform_arithmetic(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements); +int test_subgroup_functions_ballot(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_subgroup_functions_clustered_reduce(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements); +int test_subgroup_functions_shuffle(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); +int test_subgroup_functions_shuffle_relative(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements); +int test_subgroup_functions_rotate(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); #endif /*_procs_h*/ diff --git a/test_conformance/thread_dimensions/main.cpp b/test_conformance/thread_dimensions/main.cpp index 9a1ce609..236d7731 100644 --- a/test_conformance/thread_dimensions/main.cpp +++ b/test_conformance/thread_dimensions/main.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 The Khronos Group Inc. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -19,25 +19,74 @@ #include #include "procs.h" +// Additional parameters to limit test scope (-n,-b,-x) +cl_uint maxThreadDimension = 0; +cl_uint bufferSize = 0; +cl_uint bufferStep = 0; + test_definition test_list[] = { - ADD_TEST( quick_1d_explicit_local ), - ADD_TEST( quick_2d_explicit_local ), - ADD_TEST( quick_3d_explicit_local ), - ADD_TEST( quick_1d_implicit_local ), - ADD_TEST( quick_2d_implicit_local ), - ADD_TEST( quick_3d_implicit_local ), - ADD_TEST( full_1d_explicit_local ), - ADD_TEST( full_2d_explicit_local ), - ADD_TEST( full_3d_explicit_local ), - ADD_TEST( full_1d_implicit_local ), - ADD_TEST( full_2d_implicit_local ), - ADD_TEST( full_3d_implicit_local ), + ADD_TEST(quick_1d_explicit_local), ADD_TEST(quick_2d_explicit_local), + ADD_TEST(quick_3d_explicit_local), ADD_TEST(quick_1d_implicit_local), + ADD_TEST(quick_2d_implicit_local), ADD_TEST(quick_3d_implicit_local), + ADD_TEST(full_1d_explicit_local), ADD_TEST(full_2d_explicit_local), + ADD_TEST(full_3d_explicit_local), ADD_TEST(full_1d_implicit_local), + ADD_TEST(full_2d_implicit_local), ADD_TEST(full_3d_implicit_local), }; -const int test_num = ARRAY_SIZE( test_list ); +const int test_num = ARRAY_SIZE(test_list); int main(int argc, const char *argv[]) { + int delArg = 0; + for (auto i = 0; i < argc; i++) + { + delArg = 0; + + if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) + { + log_info("Thread dimensions options:\n"); + log_info("\t-n\tMaximum thread dimension value\n"); + log_info("\t-b\tSpecifies a buffer size for calculations\n"); + log_info("\t-x\tSpecifies a step for calculations\n"); + } + if (strcmp(argv[i], "-n") == 0) + { + delArg++; + if (atoi(argv[i + 1]) < 1) + { + log_info("ERROR: -n Maximum thread dimension value must be " + "greater than 0"); + return TEST_FAIL; + } + maxThreadDimension = atoi(argv[i + 1]); + delArg++; + } + if (strcmp(argv[i], "-b") == 0) + { + delArg++; + if (atoi(argv[i + 1]) < 1) + { + log_info("ERROR: -b Buffer size must be greater than 0"); + return TEST_FAIL; + } + bufferSize = atoi(argv[i + 1]); + delArg++; + } + if (strcmp(argv[i], "-x") == 0) + { + delArg++; + if (atoi(argv[i + 1]) < 1) + { + log_info("ERROR: -x Buffer step must be greater than 0"); + return TEST_FAIL; + } + bufferStep = atoi(argv[i + 1]); + delArg++; + } + for (int j = i; j < argc - delArg; j++) argv[j] = argv[j + delArg]; + argc -= delArg; + i -= delArg; + } + return runTestHarness(argc, argv, test_num, test_list, false, 0); } - diff --git a/test_conformance/thread_dimensions/procs.h b/test_conformance/thread_dimensions/procs.h index d01d3c50..261d8bf2 100644 --- a/test_conformance/thread_dimensions/procs.h +++ b/test_conformance/thread_dimensions/procs.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 @@ -21,17 +21,52 @@ extern const int kVectorSizeCount; -extern int test_quick_1d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_quick_2d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_quick_3d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_quick_1d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_quick_2d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_quick_3d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); - -extern int test_full_1d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_full_2d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_full_3d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_full_1d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_full_2d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_full_3d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_quick_1d_explicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_quick_2d_explicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_quick_3d_explicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_quick_1d_implicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_quick_2d_implicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_quick_3d_implicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_full_1d_explicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_full_2d_explicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_full_3d_explicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_full_1d_implicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_full_2d_implicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_full_3d_implicit_local(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); diff --git a/test_conformance/thread_dimensions/test_thread_dimensions.cpp b/test_conformance/thread_dimensions/test_thread_dimensions.cpp index c8d22c66..8eec15c1 100644 --- a/test_conformance/thread_dimensions/test_thread_dimensions.cpp +++ b/test_conformance/thread_dimensions/test_thread_dimensions.cpp @@ -1,6 +1,6 @@ // // Copyright (c) 2017 The Khronos Group Inc. -// +// // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -25,38 +25,46 @@ #define ITERATIONS 4 #define DEBUG 0 -// If the environment variable DO_NOT_LIMIT_THREAD_SIZE is not set, the test will limit the maximum total -// global dimensions tested to this value. -#define MAX_TOTAL_GLOBAL_THREADS_FOR_TEST (1<<24) +// If the environment variable DO_NOT_LIMIT_THREAD_SIZE is not set, the test +// will limit the maximum total global dimensions tested to this value. +#define MAX_TOTAL_GLOBAL_THREADS_FOR_TEST (1 << 24) int limit_size = 0; -static int -get_maximums(cl_kernel kernel, cl_context context, - size_t *max_workgroup_size_result, - cl_ulong *max_allcoation_result, - cl_ulong *max_physical_result) { +extern cl_uint maxThreadDimension; +extern cl_uint bufferSize; +extern cl_uint bufferStep; + +static int get_maximums(cl_kernel kernel, cl_context context, + size_t *max_workgroup_size_result, + cl_ulong *max_allcoation_result, + cl_ulong *max_physical_result) +{ int err = 0; cl_uint i; cl_device_id *devices; // Get all the devices in the device group size_t num_devices_returned; - err = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &num_devices_returned); - if(err != CL_SUCCESS) + err = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, + &num_devices_returned); + if (err != CL_SUCCESS) { log_error("clGetContextInfo() failed (%d).\n", err); return -10; } devices = (cl_device_id *)malloc(num_devices_returned); - err = clGetContextInfo(context, CL_CONTEXT_DEVICES, num_devices_returned, devices, NULL); - if(err != CL_SUCCESS) + err = clGetContextInfo(context, CL_CONTEXT_DEVICES, num_devices_returned, + devices, NULL); + if (err != CL_SUCCESS) { log_error("clGetContextInfo() failed (%d).\n", err); return -10; } num_devices_returned /= sizeof(cl_device_id); - if (num_devices_returned > 1) log_info("%d devices in device group.\n", (int)num_devices_returned); - if (num_devices_returned < 1) { + if (num_devices_returned > 1) + log_info("%d devices in device group.\n", (int)num_devices_returned); + if (num_devices_returned < 1) + { log_error("0 devices found for this kernel.\n"); return -1; } @@ -69,12 +77,16 @@ get_maximums(cl_kernel kernel, cl_context context, cl_ulong max_physical = 0; cl_ulong current_physical = 0; - for (i=0; i= final_x_size)\n" -" error = 64;\n" -" if (get_global_id(1) >= final_y_size)\n" -" error = 128;\n" -" if (get_global_id(2) >= final_z_size)\n" -" error = 256;\n" -"\n" -" unsigned long t_address = (unsigned long)get_global_id(2)*(unsigned long)final_y_size*(unsigned long)final_x_size + \n" -" (unsigned long)get_global_id(1)*(unsigned long)final_x_size + (unsigned long)get_global_id(0);\n" -" if ((t_address >= start_address) && (t_address < end_address))\n" -" atom_add(&dst[t_address-start_address], 1u);\n" -" if (error)\n" -" atom_or(&dst[t_address-start_address], error);\n" -"\n" -"}\n"; + "\n" + "#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable\n" + "#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable\n" + "__kernel void test_thread_dimension_atomic(__global uint *dst, \n" + " uint final_x_size, uint final_y_size, uint final_z_size,\n" + " ulong start_address, ulong end_address)\n" + "{\n" + " uint error = 0;\n" + " if (get_global_id(0) >= final_x_size)\n" + " error = 64;\n" + " if (get_global_id(1) >= final_y_size)\n" + " error = 128;\n" + " if (get_global_id(2) >= final_z_size)\n" + " error = 256;\n" + "\n" + " unsigned long t_address = (unsigned " + "long)get_global_id(2)*(unsigned long)final_y_size*(unsigned " + "long)final_x_size + \n" + " (unsigned long)get_global_id(1)*(unsigned " + "long)final_x_size + (unsigned long)get_global_id(0);\n" + " if ((t_address >= start_address) && (t_address < end_address))\n" + " atom_add(&dst[t_address-start_address], 1u);\n" + " if (error)\n" + " atom_or(&dst[t_address-start_address], error);\n" + "\n" + "}\n"; static const char *thread_dimension_kernel_code_not_atomic_long = -"\n" -"__kernel void test_thread_dimension_not_atomic(__global uint *dst, \n" -" uint final_x_size, uint final_y_size, uint final_z_size,\n" -" ulong start_address, ulong end_address)\n" -"{\n" -" uint error = 0;\n" -" if (get_global_id(0) >= final_x_size)\n" -" error = 64;\n" -" if (get_global_id(1) >= final_y_size)\n" -" error = 128;\n" -" if (get_global_id(2) >= final_z_size)\n" -" error = 256;\n" -"\n" -" unsigned long t_address = (unsigned long)get_global_id(2)*(unsigned long)final_y_size*(unsigned long)final_x_size + \n" -" (unsigned long)get_global_id(1)*(unsigned long)final_x_size + (unsigned long)get_global_id(0);\n" -" if ((t_address >= start_address) && (t_address < end_address))\n" -" dst[t_address-start_address]++;\n" -" if (error)\n" -" dst[t_address-start_address]|=error;\n" -"\n" -"}\n"; + "\n" + "__kernel void test_thread_dimension_not_atomic(__global uint *dst, \n" + " uint final_x_size, uint final_y_size, uint final_z_size,\n" + " ulong start_address, ulong end_address)\n" + "{\n" + " uint error = 0;\n" + " if (get_global_id(0) >= final_x_size)\n" + " error = 64;\n" + " if (get_global_id(1) >= final_y_size)\n" + " error = 128;\n" + " if (get_global_id(2) >= final_z_size)\n" + " error = 256;\n" + "\n" + " unsigned long t_address = (unsigned " + "long)get_global_id(2)*(unsigned long)final_y_size*(unsigned " + "long)final_x_size + \n" + " (unsigned long)get_global_id(1)*(unsigned " + "long)final_x_size + (unsigned long)get_global_id(0);\n" + " if ((t_address >= start_address) && (t_address < end_address))\n" + " dst[t_address-start_address]++;\n" + " if (error)\n" + " dst[t_address-start_address]|=error;\n" + "\n" + "}\n"; static const char *thread_dimension_kernel_code_atomic_not_long = -"\n" -"#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable\n" -"#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable\n" -"__kernel void test_thread_dimension_atomic(__global uint *dst, \n" -" uint final_x_size, uint final_y_size, uint final_z_size,\n" -" uint start_address, uint end_address)\n" -"{\n" -" uint error = 0;\n" -" if (get_global_id(0) >= final_x_size)\n" -" error = 64;\n" -" if (get_global_id(1) >= final_y_size)\n" -" error = 128;\n" -" if (get_global_id(2) >= final_z_size)\n" -" error = 256;\n" -"\n" -" unsigned int t_address = (unsigned int)get_global_id(2)*(unsigned int)final_y_size*(unsigned int)final_x_size + \n" -" (unsigned int)get_global_id(1)*(unsigned int)final_x_size + (unsigned int)get_global_id(0);\n" -" if ((t_address >= start_address) && (t_address < end_address))\n" -" atom_add(&dst[t_address-start_address], 1u);\n" -" if (error)\n" -" atom_or(&dst[t_address-start_address], error);\n" -"\n" -"}\n"; + "\n" + "#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable\n" + "#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable\n" + "__kernel void test_thread_dimension_atomic(__global uint *dst, \n" + " uint final_x_size, uint final_y_size, uint final_z_size,\n" + " uint start_address, uint end_address)\n" + "{\n" + " uint error = 0;\n" + " if (get_global_id(0) >= final_x_size)\n" + " error = 64;\n" + " if (get_global_id(1) >= final_y_size)\n" + " error = 128;\n" + " if (get_global_id(2) >= final_z_size)\n" + " error = 256;\n" + "\n" + " unsigned int t_address = (unsigned int)get_global_id(2)*(unsigned " + "int)final_y_size*(unsigned int)final_x_size + \n" + " (unsigned int)get_global_id(1)*(unsigned int)final_x_size " + "+ (unsigned int)get_global_id(0);\n" + " if ((t_address >= start_address) && (t_address < end_address))\n" + " atom_add(&dst[t_address-start_address], 1u);\n" + " if (error)\n" + " atom_or(&dst[t_address-start_address], error);\n" + "\n" + "}\n"; static const char *thread_dimension_kernel_code_not_atomic_not_long = -"\n" -"__kernel void test_thread_dimension_not_atomic(__global uint *dst, \n" -" uint final_x_size, uint final_y_size, uint final_z_size,\n" -" uint start_address, uint end_address)\n" -"{\n" -" uint error = 0;\n" -" if (get_global_id(0) >= final_x_size)\n" -" error = 64;\n" -" if (get_global_id(1) >= final_y_size)\n" -" error = 128;\n" -" if (get_global_id(2) >= final_z_size)\n" -" error = 256;\n" -"\n" -" unsigned int t_address = (unsigned int)get_global_id(2)*(unsigned int)final_y_size*(unsigned int)final_x_size + \n" -" (unsigned int)get_global_id(1)*(unsigned int)final_x_size + (unsigned int)get_global_id(0);\n" -" if ((t_address >= start_address) && (t_address < end_address))\n" -" dst[t_address-start_address]++;\n" -" if (error)\n" -" dst[t_address-start_address]|=error;\n" -"\n" -"}\n"; + "\n" + "__kernel void test_thread_dimension_not_atomic(__global uint *dst, \n" + " uint final_x_size, uint final_y_size, uint final_z_size,\n" + " uint start_address, uint end_address)\n" + "{\n" + " uint error = 0;\n" + " if (get_global_id(0) >= final_x_size)\n" + " error = 64;\n" + " if (get_global_id(1) >= final_y_size)\n" + " error = 128;\n" + " if (get_global_id(2) >= final_z_size)\n" + " error = 256;\n" + "\n" + " unsigned int t_address = (unsigned int)get_global_id(2)*(unsigned " + "int)final_y_size*(unsigned int)final_x_size + \n" + " (unsigned int)get_global_id(1)*(unsigned int)final_x_size " + "+ (unsigned int)get_global_id(0);\n" + " if ((t_address >= start_address) && (t_address < end_address))\n" + " dst[t_address-start_address]++;\n" + " if (error)\n" + " dst[t_address-start_address]|=error;\n" + "\n" + "}\n"; char dim_str[128]; -char * -print_dimensions(size_t x, size_t y, size_t z, cl_uint dim) { +char *print_dimensions(size_t x, size_t y, size_t z, cl_uint dim) +{ // Not thread safe... - if (dim == 1) { + if (dim == 1) + { snprintf(dim_str, 128, "[%d]", (int)x); - } else if (dim == 2) { + } + else if (dim == 2) + { snprintf(dim_str, 128, "[%d x %d]", (int)x, (int)y); - } else if (dim == 3) { + } + else if (dim == 3) + { snprintf(dim_str, 128, "[%d x %d x %d]", (int)x, (int)y, (int)z); - } else { + } + else + { snprintf(dim_str, 128, "INVALID DIM: %d", dim); } return dim_str; } char dim_str2[128]; -char * -print_dimensions2(size_t x, size_t y, size_t z, cl_uint dim) { +char *print_dimensions2(size_t x, size_t y, size_t z, cl_uint dim) +{ // Not thread safe... - if (dim == 1) { + if (dim == 1) + { snprintf(dim_str2, 128, "[%d]", (int)x); - } else if (dim == 2) { + } + else if (dim == 2) + { snprintf(dim_str2, 128, "[%d x %d]", (int)x, (int)y); - } else if (dim == 3) { + } + else if (dim == 3) + { snprintf(dim_str2, 128, "[%d x %d x %d]", (int)x, (int)y, (int)z); - } else { + } + else + { snprintf(dim_str2, 128, "INVALID DIM: %d", dim); } return dim_str2; @@ -246,57 +293,64 @@ print_dimensions2(size_t x, size_t y, size_t z, cl_uint dim) { /* - This tests thread dimensions by executing a kernel across a range of dimensions. - Each kernel instance does an atomic write into a specific location in a buffer to - ensure that the correct dimensions are run. To handle large dimensions, the kernel - masks its execution region internally. This allows a small (128MB) buffer to be used - for very large executions by running the kernel multiple times. + This tests thread dimensions by executing a kernel across a range of + dimensions. Each kernel instance does an atomic write into a specific location + in a buffer to ensure that the correct dimensions are run. To handle large + dimensions, the kernel masks its execution region internally. This allows a + small (128MB) buffer to be used for very large executions by running the kernel + multiple times. */ -int run_test(cl_context context, cl_command_queue queue, cl_kernel kernel, cl_mem array, cl_uint memory_size, cl_uint dimensions, +int run_test(cl_context context, cl_command_queue queue, cl_kernel kernel, + cl_mem array, cl_uint memory_size, cl_uint dimensions, cl_uint final_x_size, cl_uint final_y_size, cl_uint final_z_size, cl_uint local_x_size, cl_uint local_y_size, cl_uint local_z_size, int explict_local) { cl_uint errors = 0; size_t global_size[3], local_size[3]; - global_size[0] = final_x_size; local_size[0] = local_x_size; - global_size[1] = final_y_size; local_size[1] = local_y_size; - global_size[2] = final_z_size; local_size[2] = local_z_size; + global_size[0] = final_x_size; + local_size[0] = local_x_size; + global_size[1] = final_y_size; + local_size[1] = local_y_size; + global_size[2] = final_z_size; + local_size[2] = local_z_size; cl_ulong start_valid_memory_address = 0; cl_ulong end_valid_memory_address = memory_size; - cl_ulong last_memory_address = (cl_ulong)final_x_size*(cl_ulong)final_y_size*(cl_ulong)final_z_size*sizeof(cl_uint); + cl_ulong last_memory_address = (cl_ulong)final_x_size + * (cl_ulong)final_y_size * (cl_ulong)final_z_size * sizeof(cl_uint); if (end_valid_memory_address > last_memory_address) end_valid_memory_address = last_memory_address; - int number_of_iterations_required = (int)ceil((double)last_memory_address/(double)memory_size); - log_info("\t\tTest requires %gMB (%d test iterations using an allocation of %gMB).\n", - (double)last_memory_address/(1024.0*1024.0), number_of_iterations_required, (double)memory_size/(1024.0*1024.0)); - //log_info("Last memory address: %llu, memory_size: %llu\n", last_memory_address, memory_size); + int number_of_iterations_required = + (int)ceil((double)last_memory_address / (double)memory_size); + log_info("\t\tTest requires %gMB (%d test iterations using an allocation " + "of %gMB).\n", + (double)last_memory_address / (1024.0 * 1024.0), + number_of_iterations_required, + (double)memory_size / (1024.0 * 1024.0)); + // log_info("Last memory address: %llu, memory_size: %llu\n", + // last_memory_address, memory_size); while (end_valid_memory_address <= last_memory_address) { int err; const int fill_pattern = 0x0; - err = clEnqueueFillBuffer(queue, - array, - (void*)&fill_pattern, - sizeof(fill_pattern), - 0, - memory_size, - 0, - NULL, + err = clEnqueueFillBuffer(queue, array, (void *)&fill_pattern, + sizeof(fill_pattern), 0, memory_size, 0, NULL, NULL); - if (err != CL_SUCCESS) { - print_error( err, "Failed to set fill buffer."); + if (err != CL_SUCCESS) + { + print_error(err, "Failed to set fill buffer."); return -3; } - cl_ulong start_valid_index = start_valid_memory_address/sizeof(cl_uint); - cl_ulong end_valid_index = end_valid_memory_address/sizeof(cl_uint); + cl_ulong start_valid_index = + start_valid_memory_address / sizeof(cl_uint); + cl_ulong end_valid_index = end_valid_memory_address / sizeof(cl_uint); - cl_uint start_valid_index_int = (cl_uint) start_valid_index; - cl_uint end_valid_index_int = (cl_uint) end_valid_index; + cl_uint start_valid_index_int = (cl_uint)start_valid_index; + cl_uint end_valid_index_int = (cl_uint)end_valid_index; // Set the arguments err = clSetKernelArg(kernel, 0, sizeof(array), &array); @@ -305,115 +359,149 @@ int run_test(cl_context context, cl_command_queue queue, cl_kernel kernel, cl_me err |= clSetKernelArg(kernel, 3, sizeof(final_z_size), &final_z_size); if (gHasLong) { - err |= clSetKernelArg(kernel, 4, sizeof(start_valid_index), &start_valid_index); - err |= clSetKernelArg(kernel, 5, sizeof(end_valid_index), &end_valid_index); + err |= clSetKernelArg(kernel, 4, sizeof(start_valid_index), + &start_valid_index); + err |= clSetKernelArg(kernel, 5, sizeof(end_valid_index), + &end_valid_index); } else { - err |= clSetKernelArg(kernel, 4, sizeof(start_valid_index_int), &start_valid_index_int); - err |= clSetKernelArg(kernel, 5, sizeof(end_valid_index_int), &end_valid_index_int); + err |= clSetKernelArg(kernel, 4, sizeof(start_valid_index_int), + &start_valid_index_int); + err |= clSetKernelArg(kernel, 5, sizeof(end_valid_index_int), + &end_valid_index_int); } - if (err != CL_SUCCESS) { - print_error( err, "Failed to set arguments."); + if (err != CL_SUCCESS) + { + print_error(err, "Failed to set arguments."); return -3; } // Execute the kernel - if (explict_local == 0) { - err = clEnqueueNDRangeKernel(queue, kernel, dimensions, NULL, global_size, NULL, 0, NULL, NULL); - if (DEBUG) log_info("\t\t\tExecuting kernel with global %s, NULL local, %d dim, start address %llu, end address %llu.\n", - print_dimensions(global_size[0], global_size[1], global_size[2], dimensions), - dimensions, start_valid_memory_address, end_valid_memory_address); - } else { - err = clEnqueueNDRangeKernel(queue, kernel, dimensions, NULL, global_size, local_size, 0, NULL, NULL); - if (DEBUG) log_info("\t\t\tExecuting kernel with global %s, local %s, %d dim, start address %llu, end address %llu.\n", - print_dimensions(global_size[0], global_size[1], global_size[2], dimensions), print_dimensions2(local_size[0], local_size[1], local_size[2], dimensions), - dimensions, start_valid_memory_address, end_valid_memory_address); + if (explict_local == 0) + { + err = clEnqueueNDRangeKernel(queue, kernel, dimensions, NULL, + global_size, NULL, 0, NULL, NULL); + if (DEBUG) + log_info("\t\t\tExecuting kernel with global %s, NULL local, " + "%d dim, start address %llu, end address %llu.\n", + print_dimensions(global_size[0], global_size[1], + global_size[2], dimensions), + dimensions, start_valid_memory_address, + end_valid_memory_address); } - if (err == CL_OUT_OF_RESOURCES) { - log_info("WARNING: kernel reported CL_OUT_OF_RESOURCES, indicating the global dimensions are too large. Skipping this size.\n"); + else + { + err = + clEnqueueNDRangeKernel(queue, kernel, dimensions, NULL, + global_size, local_size, 0, NULL, NULL); + if (DEBUG) + log_info("\t\t\tExecuting kernel with global %s, local %s, %d " + "dim, start address %llu, end address %llu.\n", + print_dimensions(global_size[0], global_size[1], + global_size[2], dimensions), + print_dimensions2(local_size[0], local_size[1], + local_size[2], dimensions), + dimensions, start_valid_memory_address, + end_valid_memory_address); + } + if (err == CL_OUT_OF_RESOURCES) + { + log_info( + "WARNING: kernel reported CL_OUT_OF_RESOURCES, indicating the " + "global dimensions are too large. Skipping this size.\n"); return 0; } - if (err != CL_SUCCESS) { - print_error( err, "Failed to execute kernel\n"); + if (err != CL_SUCCESS) + { + print_error(err, "Failed to execute kernel\n"); return -3; } - void* mapped = clEnqueueMapBuffer(queue, array, CL_TRUE, CL_MAP_READ, 0, memory_size, 0, NULL, NULL, &err ); - if (err != CL_SUCCESS) { - print_error( err, "Failed to map results\n"); + void *mapped = clEnqueueMapBuffer(queue, array, CL_TRUE, CL_MAP_READ, 0, + memory_size, 0, NULL, NULL, &err); + if (err != CL_SUCCESS) + { + print_error(err, "Failed to map results\n"); return -4; } - cl_uint* data = (cl_uint*)mapped; + cl_uint *data = (cl_uint *)mapped; // Verify the data cl_uint i; - cl_uint last_address = (cl_uint)(end_valid_memory_address - start_valid_memory_address)/(cl_uint)sizeof(cl_uint); - for (i=0; i last_memory_address) end_valid_memory_address = last_memory_address; } - if (errors) - log_error("%d errors.\n", errors); + if (errors) log_error("%d errors.\n", errors); return errors; } +static cl_uint max_x_size = 1, min_x_size = 1, max_y_size = 1, min_y_size = 1, + max_z_size = 1, min_z_size = 1; - -static cl_uint max_x_size=1, min_x_size=1, max_y_size=1, min_y_size=1, max_z_size=1, min_z_size=1; - -static void set_min(cl_uint *x, cl_uint *y, cl_uint *z) { - if (*x < min_x_size) - *x = min_x_size; - if (*y < min_y_size) - *y = min_y_size; - if (*z < min_z_size) - *z = min_z_size; - if (*x > max_x_size) - *x = max_x_size; - if (*y > max_y_size) - *y = max_y_size; - if (*z > max_z_size) - *z = max_z_size; +static void set_min(cl_uint *x, cl_uint *y, cl_uint *z) +{ + if (*x < min_x_size) *x = min_x_size; + if (*y < min_y_size) *y = min_y_size; + if (*z < min_z_size) *z = min_z_size; + if (*x > max_x_size) *x = max_x_size; + if (*y > max_y_size) *y = max_y_size; + if (*z > max_z_size) *z = max_z_size; } -int -test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue queue, cl_uint dimensions, cl_uint min_dim, cl_uint max_dim, cl_uint quick_test, cl_uint size_increase_per_iteration, int explicit_local) { +int test_thread_dimensions(cl_device_id device, cl_context context, + cl_command_queue queue, cl_uint dimensions, + cl_uint min_dim, cl_uint max_dim, cl_uint quick_test, + cl_uint size_increase_per_iteration, + int explicit_local) +{ cl_mem array; cl_program program; cl_kernel kernel; @@ -424,9 +512,10 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue int use_atomics = 1; MTdata d; - if (getenv("CL_WIMPY_MODE") && !quick_test) { - log_info("CL_WIMPY_MODE enabled, skipping test\n"); - return 0; + if (getenv("CL_WIMPY_MODE") && !quick_test) + { + log_info("CL_WIMPY_MODE enabled, skipping test\n"); + return 0; } // Unconditionally test larger sizes for CL 1.1 @@ -434,41 +523,74 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue limit_size = 0; /* Check if atomics are supported. */ - if (!is_extension_available(device, "cl_khr_global_int32_base_atomics")) { - log_info("WARNING: Base atomics not supported (cl_khr_global_int32_base_atomics). Test will not be guaranteed to catch overlaping thread dimensions.\n"); + if (!is_extension_available(device, "cl_khr_global_int32_base_atomics")) + { + log_info("WARNING: Base atomics not supported " + "(cl_khr_global_int32_base_atomics). Test will not be " + "guaranteed to catch overlaping thread dimensions.\n"); use_atomics = 0; } if (quick_test) - log_info("WARNING: Running quick test. This will only test the base dimensions (power of two) and base-1 with all local threads fixed in one dim.\n"); + log_info("WARNING: Running quick test. This will only test the base " + "dimensions (power of two) and base-1 with all local threads " + "fixed in one dim.\n"); // Verify that we can test this many dimensions - err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(device_max_dimensions), &device_max_dimensions, NULL); - test_error(err, "clGetDeviceInfo for CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS failed"); + err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, + sizeof(device_max_dimensions), &device_max_dimensions, + NULL); + test_error(err, + "clGetDeviceInfo for CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS failed"); - if (dimensions > device_max_dimensions) { - log_info("Can not test %d dimensions when device only supports %d.\n", dimensions, device_max_dimensions); + if (dimensions > device_max_dimensions) + { + log_info("Can not test %d dimensions when device only supports %d.\n", + dimensions, device_max_dimensions); return 0; } log_info("Setting random seed to 0.\n"); - if (gHasLong) { - if (use_atomics) { - err = create_single_kernel_helper( context, &program, &kernel, 1, &thread_dimension_kernel_code_atomic_long, "test_thread_dimension_atomic" ); - } else { - err = create_single_kernel_helper( context, &program, &kernel, 1, &thread_dimension_kernel_code_not_atomic_long, "test_thread_dimension_not_atomic" ); + if (gHasLong) + { + if (use_atomics) + { + err = create_single_kernel_helper( + context, &program, &kernel, 1, + &thread_dimension_kernel_code_atomic_long, + "test_thread_dimension_atomic"); } - } else { - if (use_atomics) { - err = create_single_kernel_helper( context, &program, &kernel, 1, &thread_dimension_kernel_code_atomic_not_long, "test_thread_dimension_atomic" ); - } else { - err = create_single_kernel_helper( context, &program, &kernel, 1, &thread_dimension_kernel_code_not_atomic_not_long, "test_thread_dimension_not_atomic" ); + else + { + err = create_single_kernel_helper( + context, &program, &kernel, 1, + &thread_dimension_kernel_code_not_atomic_long, + "test_thread_dimension_not_atomic"); } } - test_error( err, "Unable to create testing kernel" ); + else + { + if (use_atomics) + { + err = create_single_kernel_helper( + context, &program, &kernel, 1, + &thread_dimension_kernel_code_atomic_not_long, + "test_thread_dimension_atomic"); + } + else + { + err = create_single_kernel_helper( + context, &program, &kernel, 1, + &thread_dimension_kernel_code_not_atomic_not_long, + "test_thread_dimension_not_atomic"); + } + } + test_error(err, "Unable to create testing kernel"); - err = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(max_local_workgroup_size), max_local_workgroup_size, NULL); + 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"); // Get the maximum sizes supported by this device @@ -477,50 +599,68 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue cl_ulong max_physical = 0; int found_size = 0; - err = get_maximums(kernel, context, - &max_workgroup_size, &max_allocation, &max_physical); + err = get_maximums(kernel, context, &max_workgroup_size, &max_allocation, + &max_physical); - // Make sure we don't try to allocate more than half the physical memory present. - if (max_allocation > (max_physical/2)) { - log_info("Limiting max allocation to half of the maximum physical memory (%gMB of %gMB physical).\n", - (max_physical/2/(1024.0*1024.0)), (max_physical/(1024.0*1024.0))); - max_allocation = max_physical/2; + // Make sure we don't try to allocate more than half the physical memory + // present. + if (max_allocation > (max_physical / 2)) + { + log_info("Limiting max allocation to half of the maximum physical " + "memory (%gMB of %gMB physical).\n", + (max_physical / 2 / (1024.0 * 1024.0)), + (max_physical / (1024.0 * 1024.0))); + max_allocation = max_physical / 2; } // Limit the maximum we'll allocate for this test to 512 to be reasonable. - if (max_allocation > 1024*1024*512) { - log_info("Limiting max allocation to 512MB from device maximum allocation of %gMB.\n", (max_allocation/1024.0/1024.0)); - max_allocation = 1024*1024*512; + if (max_allocation > 1024 * 1024 * 512) + { + log_info("Limiting max allocation to 512MB from device maximum " + "allocation of %gMB.\n", + (max_allocation / 1024.0 / 1024.0)); + max_allocation = 1024 * 1024 * 512; } - max_memory_size = (cl_uint)(max_allocation); - if (max_memory_size > 512*1024*1024) - max_memory_size = 512*1024*1024; + max_memory_size = bufferSize ? bufferSize : (cl_uint)(max_allocation); + if (max_memory_size > 512 * 1024 * 1024) + max_memory_size = 512 * 1024 * 1024; memory_size = max_memory_size; - log_info("Memory allocation size to use is %gMB, max workgroup size is %d.\n", max_memory_size/(1024.0*1024.0), (int)max_workgroup_size); + log_info( + "Memory allocation size to use is %gMB, max workgroup size is %d.\n", + max_memory_size / (1024.0 * 1024.0), (int)max_workgroup_size); - while (!found_size && memory_size >= max_memory_size/8) { + while (!found_size && memory_size >= max_memory_size / 8) + { array = clCreateBuffer(context, CL_MEM_READ_WRITE, memory_size, NULL, &err); - if (err == CL_MEM_OBJECT_ALLOCATION_FAILURE || err == CL_OUT_OF_HOST_MEMORY) { - memory_size -= max_memory_size/16; + if (err == CL_MEM_OBJECT_ALLOCATION_FAILURE + || err == CL_OUT_OF_HOST_MEMORY) + { + memory_size -= max_memory_size / 16; continue; } - if (err) { - print_error( err, "clCreateBuffer failed"); + if (err) + { + print_error(err, "clCreateBuffer failed"); return -1; } found_size = 1; } - if (!found_size) { - log_error("Failed to find a working size greater than 1/8th of the reported allocation size.\n"); + if (!found_size) + { + log_error("Failed to find a working size greater than 1/8th of the " + "reported allocation size.\n"); return -1; } - if (memory_size < max_memory_size) { - log_info("Note: failed to allocate %gMB, using %gMB instead.\n", max_memory_size/(1024.0*1024.0), memory_size/(1024.0*1024.0)); + if (memory_size < max_memory_size) + { + log_info("Note: failed to allocate %gMB, using %gMB instead.\n", + max_memory_size / (1024.0 * 1024.0), + memory_size / (1024.0 * 1024.0)); } int errors = 0; @@ -530,171 +670,290 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue // 2 tests with each dimensions +/- 1 // 2 tests with all dimensions +/- 1 // 2 random tests - cl_uint tests_per_size = 1 + 2*dimensions + 2 + 2; + cl_uint tests_per_size = 1 + 2 * dimensions + 2 + 2; // 1 test with 1 as the local threads in each dimensions // 1 test with all the local threads in each dimension // 2 random tests cl_uint local_tests_per_size = 1 + dimensions + 2; - if (explicit_local == 0) - local_tests_per_size = 1; + if (explicit_local == 0) local_tests_per_size = 1; - max_x_size=1, min_x_size=1, max_y_size=1, min_y_size=1, max_z_size=1, min_z_size=1; + max_x_size = 1, min_x_size = 1, max_y_size = 1, min_y_size = 1, + max_z_size = 1, min_z_size = 1; - if (dimensions > 3) { + if (dimensions > 3) + { log_error("Invalid dimensions: %d\n", dimensions); return -1; } max_x_size = max_dim; min_x_size = min_dim; - if (dimensions > 1) { + if (dimensions > 1) + { max_y_size = max_dim; min_y_size = min_dim; } - if (dimensions > 2) { + if (dimensions > 2) + { max_z_size = max_dim; min_z_size = min_dim; } - log_info("Testing with dimensions up to %s.\n", print_dimensions(max_x_size, max_y_size, max_z_size, dimensions)); + log_info("Testing with dimensions up to %s.\n", + print_dimensions(max_x_size, max_y_size, max_z_size, dimensions)); + if (bufferSize) + { + log_info("Testing with buffer size %d.\n", bufferSize); + } + if (bufferStep) + { + log_info("Testing with buffer step %d.\n", bufferStep); + } cl_uint x_size, y_size, z_size; - d = init_genrand( gRandomSeed ); + d = init_genrand(gRandomSeed); z_size = min_z_size; - while (z_size <= max_z_size) { + while (z_size <= max_z_size) + { y_size = min_y_size; - while (y_size <= max_y_size) { + while (y_size <= max_y_size) + { x_size = min_x_size; - while (x_size <= max_x_size) { + while (x_size <= max_x_size) + { - log_info("Base test size %s:\n", print_dimensions(x_size, y_size, z_size, dimensions)); + log_info("Base test size %s:\n", + print_dimensions(x_size, y_size, z_size, dimensions)); cl_uint sub_test; cl_uint final_x_size, final_y_size, final_z_size; - for (sub_test = 0; sub_test < tests_per_size; sub_test++) { + for (sub_test = 0; sub_test < tests_per_size; sub_test++) + { final_x_size = x_size; final_y_size = y_size; final_z_size = z_size; - if (sub_test == 0) { - if (DEBUG) log_info("\tTesting with base dimensions %s.\n", print_dimensions(final_x_size, final_y_size, final_z_size, dimensions)); - } else if (quick_test) { - // If we are in quick mode just do 1 run with x-1, y-1, and z-1. - if (sub_test > 1) - break; + if (sub_test == 0) + { + if (DEBUG) + log_info( + "\tTesting with base dimensions %s.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions)); + } + else if (quick_test) + { + // If we are in quick mode just do 1 run with x-1, y-1, + // and z-1. + if (sub_test > 1) break; final_x_size--; final_y_size--; final_z_size--; set_min(&final_x_size, &final_y_size, &final_z_size); - if (DEBUG) log_info("\tTesting with all base dimensions - 1 %s.\n", print_dimensions(final_x_size, final_y_size, final_z_size, dimensions)); - } else if (sub_test <= dimensions*2) { - int dim_to_change = (sub_test-1)%dimensions; - //log_info ("dim_to_change: %d (sub_test:%d) dimensions %d\n", dim_to_change,sub_test, dimensions); + if (DEBUG) + log_info( + "\tTesting with all base dimensions - 1 %s.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions)); + } + else if (sub_test <= dimensions * 2) + { + int dim_to_change = (sub_test - 1) % dimensions; + // log_info ("dim_to_change: %d (sub_test:%d) dimensions + // %d\n", dim_to_change,sub_test, dimensions); int up_down = (sub_test > dimensions) ? 0 : 1; - if (dim_to_change == 0) { + if (dim_to_change == 0) + { final_x_size += (up_down) ? -1 : +1; - } else if (dim_to_change == 1) { + } + else if (dim_to_change == 1) + { final_y_size += (up_down) ? -1 : +1; - } else if (dim_to_change == 2) { + } + else if (dim_to_change == 2) + { final_z_size += (up_down) ? -1 : +1; - } else { - log_error("Invalid dim_to_change: %d\n", dim_to_change); + } + else + { + log_error("Invalid dim_to_change: %d\n", + dim_to_change); return -1; } set_min(&final_x_size, &final_y_size, &final_z_size); - if (DEBUG) log_info("\tTesting with one base dimension +/- 1 %s.\n", print_dimensions(final_x_size, final_y_size, final_z_size, dimensions)); - } else if (sub_test == (dimensions*2+1)) { - if (dimensions == 1) - continue; + if (DEBUG) + log_info( + "\tTesting with one base dimension +/- 1 %s.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions)); + } + else if (sub_test == (dimensions * 2 + 1)) + { + if (dimensions == 1) continue; final_x_size--; final_y_size--; final_z_size--; set_min(&final_x_size, &final_y_size, &final_z_size); - if (DEBUG) log_info("\tTesting with all base dimensions - 1 %s.\n", print_dimensions(final_x_size, final_y_size, final_z_size, dimensions)); - } else if (sub_test == (dimensions*2+2)) { - if (dimensions == 1) - continue; + if (DEBUG) + log_info( + "\tTesting with all base dimensions - 1 %s.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions)); + } + else if (sub_test == (dimensions * 2 + 2)) + { + if (dimensions == 1) continue; final_x_size++; final_y_size++; final_z_size++; set_min(&final_x_size, &final_y_size, &final_z_size); - if (DEBUG) log_info("\tTesting with all base dimensions + 1 %s.\n", print_dimensions(final_x_size, final_y_size, final_z_size, dimensions)); - } else { - final_x_size = (int)get_random_float(0, (x_size/size_increase_per_iteration), d)+x_size/size_increase_per_iteration; - final_y_size = (int)get_random_float(0, (y_size/size_increase_per_iteration), d)+y_size/size_increase_per_iteration; - final_z_size = (int)get_random_float(0, (z_size/size_increase_per_iteration), d)+z_size/size_increase_per_iteration; + if (DEBUG) + log_info( + "\tTesting with all base dimensions + 1 %s.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions)); + } + else + { + final_x_size = + (int)get_random_float( + 0, (x_size / size_increase_per_iteration), d) + + x_size / size_increase_per_iteration; + final_y_size = + (int)get_random_float( + 0, (y_size / size_increase_per_iteration), d) + + y_size / size_increase_per_iteration; + final_z_size = + (int)get_random_float( + 0, (z_size / size_increase_per_iteration), d) + + z_size / size_increase_per_iteration; set_min(&final_x_size, &final_y_size, &final_z_size); - if (DEBUG) log_info("\tTesting with random dimensions %s.\n", print_dimensions(final_x_size, final_y_size, final_z_size, dimensions)); + if (DEBUG) + log_info( + "\tTesting with random dimensions %s.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions)); } - if (limit_size && final_x_size*final_y_size*final_z_size >= MAX_TOTAL_GLOBAL_THREADS_FOR_TEST) { - log_info("Skipping size %s as it exceeds max test threads of %d.\n", print_dimensions(final_x_size, final_y_size, final_z_size, dimensions), MAX_TOTAL_GLOBAL_THREADS_FOR_TEST); + if (limit_size + && final_x_size * final_y_size * final_z_size + >= MAX_TOTAL_GLOBAL_THREADS_FOR_TEST) + { + log_info("Skipping size %s as it exceeds max test " + "threads of %d.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions), + MAX_TOTAL_GLOBAL_THREADS_FOR_TEST); continue; } cl_uint local_test; cl_uint local_x_size, local_y_size, local_z_size; - cl_uint previous_local_x_size=0, previous_local_y_size=0, previous_local_z_size=0; - for (local_test = 0; local_test < local_tests_per_size; local_test++) { + cl_uint previous_local_x_size = 0, + previous_local_y_size = 0, + previous_local_z_size = 0; + for (local_test = 0; local_test < local_tests_per_size; + local_test++) + { local_x_size = 1; local_y_size = 1; local_z_size = 1; - if (local_test == 0) { - } else if (local_test <= dimensions) { - int dim_to_change = (local_test-1)%dimensions; - if (dim_to_change == 0) { + if (local_test == 0) + { + } + else if (local_test <= dimensions) + { + int dim_to_change = (local_test - 1) % dimensions; + if (dim_to_change == 0) + { local_x_size = (cl_uint)max_workgroup_size; - } else if (dim_to_change == 1) { + } + else if (dim_to_change == 1) + { local_y_size = (cl_uint)max_workgroup_size; - } else if (dim_to_change == 2) { + } + else if (dim_to_change == 2) + { local_z_size = (cl_uint)max_workgroup_size; - } else { - log_error("Invalid dim_to_change: %d\n", dim_to_change); + } + else + { + log_error("Invalid dim_to_change: %d\n", + dim_to_change); free_mtdata(d); return -1; } - } else { - local_x_size = (int)get_random_float(1, (int)max_workgroup_size, d); - while ((local_x_size > 1) && (final_x_size%local_x_size != 0)) + } + else + { + local_x_size = (int)get_random_float( + 1, (int)max_workgroup_size, d); + while ((local_x_size > 1) + && (final_x_size % local_x_size != 0)) local_x_size--; - int remainder = (int)floor((double)max_workgroup_size/local_x_size); + int remainder = (int)floor( + (double)max_workgroup_size / local_x_size); // Evenly prefer dimensions 2 and 1 first - if (local_test % 2) { - if (dimensions > 1) { - local_y_size = (int)get_random_float(1, (int)remainder, d); - while ((local_y_size > 1) && (final_y_size%local_y_size != 0)) + if (local_test % 2) + { + if (dimensions > 1) + { + local_y_size = (int)get_random_float( + 1, (int)remainder, d); + while ( + (local_y_size > 1) + && (final_y_size % local_y_size != 0)) local_y_size--; - remainder = (int)floor((double)remainder/local_y_size); + remainder = (int)floor((double)remainder + / local_y_size); } - if (dimensions > 2) { - local_z_size = (int)get_random_float(1, (int)remainder, d); - while ((local_z_size > 1) && (final_z_size%local_z_size != 0)) + if (dimensions > 2) + { + local_z_size = (int)get_random_float( + 1, (int)remainder, d); + while ( + (local_z_size > 1) + && (final_z_size % local_z_size != 0)) local_z_size--; } - } else { - if (dimensions > 2) { - local_z_size = (int)get_random_float(1, (int)remainder, d); - while ((local_z_size > 1) && (final_z_size%local_z_size != 0)) + } + else + { + if (dimensions > 2) + { + local_z_size = (int)get_random_float( + 1, (int)remainder, d); + while ( + (local_z_size > 1) + && (final_z_size % local_z_size != 0)) local_z_size--; - remainder = (int)floor((double)remainder/local_z_size); + remainder = (int)floor((double)remainder + / local_z_size); } - if (dimensions > 1) { - local_y_size = (int)get_random_float(1, (int)remainder, d); - while ((local_y_size > 1) && (final_y_size%local_y_size != 0)) + if (dimensions > 1) + { + local_y_size = (int)get_random_float( + 1, (int)remainder, d); + while ( + (local_y_size > 1) + && (final_y_size % local_y_size != 0)) local_y_size--; } } } - // Put all the threads in one dimension to speed up the test in quick mode. - if (quick_test) { + // Put all the threads in one dimension to speed up the + // test in quick mode. + if (quick_test) + { local_y_size = 1; local_z_size = 1; local_x_size = 1; - if (final_z_size > final_y_size && final_z_size > final_x_size) + if (final_z_size > final_y_size + && final_z_size > final_x_size) local_z_size = (cl_uint)max_workgroup_size; else if (final_y_size > final_x_size) local_y_size = (cl_uint)max_workgroup_size; @@ -704,56 +963,85 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue if (local_x_size > max_local_workgroup_size[0]) local_x_size = (int)max_local_workgroup_size[0]; - if (dimensions > 1 && local_y_size > max_local_workgroup_size[1]) + if (dimensions > 1 + && local_y_size > max_local_workgroup_size[1]) local_y_size = (int)max_local_workgroup_size[1]; - if (dimensions > 2 && local_z_size > max_local_workgroup_size[2]) + if (dimensions > 2 + && local_z_size > max_local_workgroup_size[2]) local_z_size = (int)max_local_workgroup_size[2]; // Cleanup the local dimensions - while ((local_x_size > 1) && (final_x_size%local_x_size != 0)) + while ((local_x_size > 1) + && (final_x_size % local_x_size != 0)) local_x_size--; - while ((local_y_size > 1) && (final_y_size%local_y_size != 0)) + while ((local_y_size > 1) + && (final_y_size % local_y_size != 0)) local_y_size--; - while ((local_z_size > 1) && (final_z_size%local_z_size != 0)) + while ((local_z_size > 1) + && (final_z_size % local_z_size != 0)) local_z_size--; - if ((previous_local_x_size == local_x_size) && (previous_local_y_size == local_y_size) && (previous_local_z_size == local_z_size)) + if ((previous_local_x_size == local_x_size) + && (previous_local_y_size == local_y_size) + && (previous_local_z_size == local_z_size)) continue; - if (explicit_local == 0) { + if (explicit_local == 0) + { local_x_size = 0; local_y_size = 0; local_z_size = 0; } - if (DEBUG) log_info("\t\tTesting local size %s.\n", print_dimensions(local_x_size, local_y_size, local_z_size, dimensions)); + if (DEBUG) + log_info( + "\t\tTesting local size %s.\n", + print_dimensions(local_x_size, local_y_size, + local_z_size, dimensions)); - if (explicit_local == 0) { - log_info("\tTesting global %s local [NULL]...\n", - print_dimensions(final_x_size, final_y_size, final_z_size, dimensions)); - } else { - log_info("\tTesting global %s local %s...\n", - print_dimensions(final_x_size, final_y_size, final_z_size, dimensions), - print_dimensions2(local_x_size, local_y_size, local_z_size, dimensions)); + if (explicit_local == 0) + { + log_info( + "\tTesting global %s local [NULL]...\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions)); + } + else + { + log_info( + "\tTesting global %s local %s...\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions), + print_dimensions2(local_x_size, local_y_size, + local_z_size, dimensions)); } - // Avoid running with very small local sizes on very large global sizes - cl_uint total_local_size = local_x_size * local_y_size * local_z_size; + // Avoid running with very small local sizes on very + // large global sizes + cl_uint total_local_size = + local_x_size * local_y_size * local_z_size; long total_global_size = final_x_size * final_y_size * final_z_size; if (total_local_size < max_workgroup_size) { - if (total_global_size > 16384*16384) { - if (total_local_size < 64) { - log_info("Skipping test as local_size is small and it will take a long time.\n"); - continue; - } + if (((total_global_size > 16384 * 16384) + && (total_local_size < 64)) + || ((total_global_size > 8192 * 8192) + && (total_local_size < 16))) + { + log_info("Skipping test as local_size is small " + "and it will take a long time.\n"); + continue; } } - err = run_test(context, queue, kernel, array, memory_size, dimensions, - final_x_size, final_y_size, final_z_size, - local_x_size, local_y_size, local_z_size, explicit_local); + err = + run_test(context, queue, kernel, array, memory_size, + dimensions, final_x_size, final_y_size, + final_z_size, local_x_size, local_y_size, + local_z_size, explicit_local); - // If we failed to execute, then return so we don't crash. - if (err < 0) { + // If we failed to execute, then return so we don't + // crash. + if (err < 0) + { clReleaseMemObject(array); clReleaseKernel(kernel); clReleaseProgram(program); @@ -762,10 +1050,14 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue } // Otherwise, if we had errors add them up. - if (err) { - log_error("Test global %s local %s failed.\n", - print_dimensions(final_x_size, final_y_size, final_z_size, dimensions), - print_dimensions2(local_x_size, local_y_size, local_z_size, dimensions)); + if (err) + { + log_error( + "Test global %s local %s failed.\n", + print_dimensions(final_x_size, final_y_size, + final_z_size, dimensions), + print_dimensions2(local_x_size, local_y_size, + local_z_size, dimensions)); errors++; clReleaseMemObject(array); clReleaseKernel(kernel); @@ -780,30 +1072,23 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue previous_local_z_size = local_z_size; // Only test one config in quick mode. - if (quick_test) - break; + if (quick_test) break; } // local_test size } // sub_test // Increment the x_size - if (x_size == max_x_size) - break; + if (x_size == max_x_size) break; x_size *= size_increase_per_iteration; - if (x_size > max_x_size) - x_size = max_x_size; + if (x_size > max_x_size) x_size = max_x_size; } // x_size // Increment the y_size - if (y_size == max_y_size) - break; + if (y_size == max_y_size) break; y_size *= size_increase_per_iteration; - if (y_size > max_y_size) - y_size = max_y_size; + if (y_size > max_y_size) y_size = max_y_size; } // y_size // Increment the z_size - if (z_size == max_z_size) - break; + if (z_size == max_z_size) break; z_size *= size_increase_per_iteration; - if (z_size > max_z_size) - z_size = max_z_size; + if (z_size > max_z_size) z_size = max_z_size; } // z_size @@ -811,75 +1096,108 @@ test_thread_dimensions(cl_device_id device, cl_context context, cl_command_queue clReleaseMemObject(array); clReleaseKernel(kernel); clReleaseProgram(program); - if (errors) - log_error("%d total errors.\n", errors); + if (errors) log_error("%d total errors.\n", errors); return errors; - } #define QUICK 1 #define FULL 0 -int test_quick_1d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_quick_1d_explicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 1, 1, 65536*512, QUICK, 4, 1); + return test_thread_dimensions( + deviceID, context, queue, 1, 1, + maxThreadDimension ? maxThreadDimension : 65536 * 512, QUICK, 4, 1); } -int test_quick_2d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_quick_2d_explicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 2, 1, 65536/4, QUICK, 16, 1); + return test_thread_dimensions( + deviceID, context, queue, 2, 1, + maxThreadDimension ? maxThreadDimension : 65536 / 4, QUICK, 16, 1); } -int test_quick_3d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_quick_3d_explicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 3, 1, 1024, QUICK, 32, 1); + return test_thread_dimensions( + deviceID, context, queue, 3, 1, + maxThreadDimension ? maxThreadDimension : 1024, QUICK, 32, 1); } -int test_quick_1d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_quick_1d_implicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 1, 1, 65536*256, QUICK, 4, 0); + return test_thread_dimensions( + deviceID, context, queue, 1, 1, + maxThreadDimension ? maxThreadDimension : 65536 * 256, QUICK, 4, 0); } -int test_quick_2d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_quick_2d_implicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 2, 1, 65536/4, QUICK, 16, 0); + return test_thread_dimensions( + deviceID, context, queue, 2, 1, + maxThreadDimension ? maxThreadDimension : 65536 / 4, QUICK, 16, 0); } -int test_quick_3d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_quick_3d_implicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 3, 1, 1024, QUICK, 32, 0); + return test_thread_dimensions( + deviceID, context, queue, 3, 1, + maxThreadDimension ? maxThreadDimension : 1024, QUICK, 32, 0); } -int test_full_1d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_full_1d_explicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 1, 1, 65536*512, FULL, 4, 1); + return test_thread_dimensions( + deviceID, context, queue, 1, 1, + maxThreadDimension ? maxThreadDimension : 65536 * 512, FULL, 4, 1); } -int test_full_2d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_full_2d_explicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 2, 1, 65536/4, FULL, 16, 1); + return test_thread_dimensions( + deviceID, context, queue, 2, 1, + maxThreadDimension ? maxThreadDimension : 65536 / 4, FULL, 16, 1); } -int test_full_3d_explicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_full_3d_explicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 3, 1, 1024, FULL, 32, 1); + return test_thread_dimensions( + deviceID, context, queue, 3, 1, + maxThreadDimension ? maxThreadDimension : 1024, FULL, 32, 1); } -int test_full_1d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_full_1d_implicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 1, 1, 65536*256, FULL, 4, 0); + return test_thread_dimensions( + deviceID, context, queue, 1, 1, + maxThreadDimension ? maxThreadDimension : 65536 * 256, FULL, 4, 0); } -int test_full_2d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_full_2d_implicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 2, 1, 65536/4, FULL, 16, 0); + return test_thread_dimensions( + deviceID, context, queue, 2, 1, + maxThreadDimension ? maxThreadDimension : 65536 / 4, FULL, 16, 0); } -int test_full_3d_implicit_local(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +int test_full_3d_implicit_local(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) { - return test_thread_dimensions(deviceID, context, queue, 3, 1, 1024, FULL, 32, 0); + return test_thread_dimensions( + deviceID, context, queue, 3, 1, + maxThreadDimension ? maxThreadDimension : 1024, FULL, 32, 0); } - diff --git a/test_conformance/vulkan/main.cpp b/test_conformance/vulkan/main.cpp index 5c699b63..aec3f7c5 100644 --- a/test_conformance/vulkan/main.cpp +++ b/test_conformance/vulkan/main.cpp @@ -369,7 +369,7 @@ int main(int argc, const char *argv[]) log_info(" TEST SKIPPED\n"); return CL_SUCCESS; } - init_cl_vk_ext(platform); + init_cl_vk_ext(platform, num_devices, devices); // Execute tests. // Note: don't use the entire harness, because we have a different way of @@ -381,4 +381,4 @@ int main(int argc, const char *argv[]) errNum = parseAndCallCommandLineTests(argCount, argList, devices[device_no], test_num, test_list, config); return errNum; -} +} \ No newline at end of file diff --git a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp index 196a8f33..2787c171 100644 --- a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp @@ -89,10 +89,10 @@ int run_test_with_two_queue( { int err = CL_SUCCESS; size_t global_work_size[1]; - uint8_t *error_2; - cl_mem error_1; - cl_kernel update_buffer_kernel; - cl_kernel kernel_cq; + uint8_t *error_2 = nullptr; + cl_mem error_1 = nullptr; + cl_kernel update_buffer_kernel = nullptr; + cl_kernel kernel_cq = nullptr; clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL; const char *program_source_const = kernel_text_numbuffer_2; @@ -140,9 +140,9 @@ int run_test_with_two_queue( } else { - clVk2CLExternalSemaphore = new clExternalSemaphore( + clVk2CLExternalSemaphore = new clExternalImportableSemaphore( vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); - clCl2VkExternalSemaphore = new clExternalSemaphore( + clCl2VkExternalSemaphore = new clExternalExportableSemaphore( vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); } @@ -413,8 +413,8 @@ int run_test_with_one_queue( { log_info("RUNNING TEST WITH ONE QUEUE...... \n\n"); size_t global_work_size[1]; - uint8_t *error_2; - cl_mem error_1; + uint8_t *error_2 = nullptr; + cl_mem error_1 = nullptr; cl_kernel update_buffer_kernel; clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL; @@ -453,9 +453,9 @@ int run_test_with_one_queue( } else { - clVk2CLExternalSemaphore = new clExternalSemaphore( + clVk2CLExternalSemaphore = new clExternalImportableSemaphore( vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); - clCl2VkExternalSemaphore = new clExternalSemaphore( + clCl2VkExternalSemaphore = new clExternalExportableSemaphore( vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); } @@ -699,8 +699,8 @@ int run_test_with_multi_import_same_ctx( VulkanExternalSemaphoreHandleType vkExternalSemaphoreHandleType) { size_t global_work_size[1]; - uint8_t *error_2; - cl_mem error_1; + uint8_t *error_2 = nullptr; + cl_mem error_1 = nullptr; int numImports = numBuffers; cl_kernel update_buffer_kernel; clExternalSemaphore *clVk2CLExternalSemaphore = NULL; @@ -742,9 +742,9 @@ int run_test_with_multi_import_same_ctx( } else { - clVk2CLExternalSemaphore = new clExternalSemaphore( + clVk2CLExternalSemaphore = new clExternalImportableSemaphore( vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); - clCl2VkExternalSemaphore = new clExternalSemaphore( + clCl2VkExternalSemaphore = new clExternalExportableSemaphore( vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); } @@ -1025,9 +1025,9 @@ int run_test_with_multi_import_diff_ctx( VulkanExternalSemaphoreHandleType vkExternalSemaphoreHandleType) { size_t global_work_size[1]; - uint8_t *error_3; - cl_mem error_1; - cl_mem error_2; + uint8_t *error_3 = nullptr; + cl_mem error_1 = nullptr; + cl_mem error_2 = nullptr; int numImports = numBuffers; cl_kernel update_buffer_kernel1[MAX_IMPORTS]; cl_kernel update_buffer_kernel2[MAX_IMPORTS]; @@ -1071,17 +1071,17 @@ int run_test_with_multi_import_diff_ctx( } else { - clVk2CLExternalSemaphore = new clExternalSemaphore( + clVk2CLExternalSemaphore = new clExternalImportableSemaphore( vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); - clCl2VkExternalSemaphore = new clExternalSemaphore( + clCl2VkExternalSemaphore = new clExternalExportableSemaphore( vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); - clVk2CLExternalSemaphore2 = - new clExternalSemaphore(vkVk2CLSemaphore, context2, - vkExternalSemaphoreHandleType, deviceId); - clCl2VkExternalSemaphore2 = - new clExternalSemaphore(vkCl2VkSemaphore, context2, - vkExternalSemaphoreHandleType, deviceId); + clVk2CLExternalSemaphore2 = new clExternalImportableSemaphore( + vkVk2CLSemaphore, context2, vkExternalSemaphoreHandleType, + deviceId); + clCl2VkExternalSemaphore2 = new clExternalExportableSemaphore( + vkCl2VkSemaphore, context2, vkExternalSemaphoreHandleType, + deviceId); } const uint32_t maxIter = innerIterations; diff --git a/test_conformance/vulkan/test_vulkan_interop_image.cpp b/test_conformance/vulkan/test_vulkan_interop_image.cpp index 872044df..7ca7b7f3 100644 --- a/test_conformance/vulkan/test_vulkan_interop_image.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_image.cpp @@ -251,9 +251,9 @@ int run_test_with_two_queue( clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL; - clVk2CLExternalSemaphore = new clExternalSemaphore( + clVk2CLExternalSemaphore = new clExternalImportableSemaphore( vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); - clCl2VkExternalSemaphore = new clExternalSemaphore( + clCl2VkExternalSemaphore = new clExternalExportableSemaphore( vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); std::vector vkImage2DListDeviceMemory1; @@ -816,9 +816,9 @@ int run_test_with_one_queue( clExternalSemaphore *clVk2CLExternalSemaphore = NULL; clExternalSemaphore *clCl2VkExternalSemaphore = NULL; - clVk2CLExternalSemaphore = new clExternalSemaphore( + clVk2CLExternalSemaphore = new clExternalImportableSemaphore( vkVk2CLSemaphore, context, vkExternalSemaphoreHandleType, deviceId); - clCl2VkExternalSemaphore = new clExternalSemaphore( + clCl2VkExternalSemaphore = new clExternalExportableSemaphore( vkCl2VkSemaphore, context, vkExternalSemaphoreHandleType, deviceId); std::vector vkImage2DListDeviceMemory1;