diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 26c4af9984..bba469b763 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -31,6 +31,17 @@ jobs: - uses: actions/checkout@v4 - name: Setup Ninja uses: seanmiddleditch/gha-setup-ninja@master + - name: Install Arm and AArch64 compilers + if: ${{ matrix.arch == 'arm' || matrix.arch == 'aarch64' }} + run: | + sudo apt-get update + sudo apt-get install -y \ + gcc-12-arm-linux-gnueabihf g++-12-arm-linux-gnueabihf \ + gcc-12-aarch64-linux-gnu g++-12-aarch64-linux-gnu + sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-12 12 + sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-12 12 + sudo update-alternatives --install /usr/bin/aarch64-linux-gnu-gcc aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc-12 12 + sudo update-alternatives --install /usr/bin/aarch64-linux-gnu-g++ aarch64-linux-gnu-g++ /usr/bin/aarch64-linux-gnu-g++-12 12 - name: Setup OpenGL build dependencies if: ${{ matrix.gl }} run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cfef6b332..e4c3181848 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,6 @@ if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang" # Enable more warnings if not doing a release build. add_cxx_flag_if_supported(-Wall) endif() - add_cxx_flag_if_supported(-Wno-narrowing) add_cxx_flag_if_supported(-Wno-format) add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive add_cxx_flag_if_supported(-Wno-unknown-pragmas) # Issue #785 @@ -153,8 +152,14 @@ if(MSVC) endif() if( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_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") - 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") + set(Shared_Flags_Intel "-Qlong-double -Qpc80 /DWIN32 /D_WINDOWS /W3 /GR /EHsc -nologo -Od -D_CRT_NONSTDC_NO_WARNINGS -EHsc -Wall -fp:strict") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Shared_Flags_Intel}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${Shared_Flags_Intel}") + if (NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "IntelLLVM")) + set(ICC_Extra_Flags "-Qdiag-disable:68,111,177,186,161,869,1028,2259,2553,181,239,265,1188 -fp:source") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ICC_Extra_Flags}") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ICC_Extra_Flags}") + endif() endif() # To handle addresses larger than 2 gigabytes for 32bit targets diff --git a/README.md b/README.md index 34322f48cc..6d46ce992f 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ require compilation, these are: The Khronos [Conformance Process Document](https://members.khronos.org/document/dl/911) details the steps required for a conformance submission. -In this repository [opencl_conformance_tests_full.csv](test_conformance/submission_details_template.txt) +In this repository [opencl_conformance_tests_full.csv](test_conformance/opencl_conformance_tests_full.csv) defines the full list of tests which must be run for conformance. The output log of which must be included alongside a filled in [submission details template](test_conformance/submission_details_template.txt). diff --git a/presubmit.sh b/presubmit.sh index b519d68388..a248a15ca3 100755 --- a/presubmit.sh +++ b/presubmit.sh @@ -4,9 +4,6 @@ set -e export TOP=$(pwd) -TOOLCHAIN_URL_arm="https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz" -TOOLCHAIN_URL_aarch64="https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz" - TOOLCHAIN_PREFIX_arm=arm-linux-gnueabihf TOOLCHAIN_PREFIX_aarch64=aarch64-linux-gnu @@ -20,14 +17,6 @@ echo # Prepare toolchain if needed if [[ ${JOB_ARCHITECTURE} != "" && ${RUNNER_OS} != "Windows" ]]; then - TOOLCHAIN_URL_VAR=TOOLCHAIN_URL_${JOB_ARCHITECTURE} - TOOLCHAIN_URL=${!TOOLCHAIN_URL_VAR} - wget ${TOOLCHAIN_URL} - TOOLCHAIN_ARCHIVE=${TOOLCHAIN_URL##*/} - tar xf ${TOOLCHAIN_ARCHIVE} - TOOLCHAIN_DIR=${TOP}/${TOOLCHAIN_ARCHIVE%.tar.xz} - export PATH=${TOOLCHAIN_DIR}/bin:${PATH} - TOOLCHAIN_PREFIX_VAR=TOOLCHAIN_PREFIX_${JOB_ARCHITECTURE} TOOLCHAIN_PREFIX=${!TOOLCHAIN_PREFIX_VAR} diff --git a/test_common/gl/setup_osx.cpp b/test_common/gl/setup_osx.cpp index 084703a7c7..298f1a92a3 100644 --- a/test_common/gl/setup_osx.cpp +++ b/test_common/gl/setup_osx.cpp @@ -19,21 +19,28 @@ class OSXGLEnvironment : public GLEnvironment { - public: - OSXGLEnvironment() - { - mCGLContext = NULL; - } +private: + bool mIsGlutInit; + +public: + OSXGLEnvironment() + { + mCGLContext = NULL; + mIsGlutInit = false; + } virtual int Init( int *argc, char **argv, int use_opengl_32 ) { if (!use_opengl_32) { - - // Create a GLUT window to render into - glutInit( argc, argv ); - glutInitWindowSize( 512, 512 ); - glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); - glutCreateWindow( "OpenCL <-> OpenGL Test" ); + if (!mIsGlutInit) + { + // Create a GLUT window to render into + glutInit(argc, argv); + glutInitWindowSize(512, 512); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + glutCreateWindow("OpenCL <-> OpenGL Test"); + mIsGlutInit = true; + } } else { diff --git a/test_common/harness/compat.h b/test_common/harness/compat.h index e8a3047e94..150c4364c8 100644 --- a/test_common/harness/compat.h +++ b/test_common/harness/compat.h @@ -112,12 +112,19 @@ int feclearexcept(int excepts); #if defined(__INTEL_COMPILER) #include -#elif __cplusplus && defined(_MSC_VER) -#include #else #include #endif +#ifdef __cplusplus +#include +extern "C" { +using std::isfinite; +using std::isinf; +using std::isnan; +} +#endif + #ifndef M_PI #define M_PI 3.14159265358979323846264338327950288 #endif @@ -140,18 +147,6 @@ extern "C" { #define INFINITY (FLT_MAX + FLT_MAX) #endif -#ifndef isfinite -#define isfinite(x) _finite(x) -#endif - -#ifndef isnan -#define isnan(x) ((x) != (x)) -#endif - -#ifndef isinf -#define isinf(_x) ((_x) == INFINITY || (_x) == -INFINITY) -#endif - #if _MSC_VER < 1900 && !defined(__INTEL_COMPILER) double rint(double x); diff --git a/test_common/harness/errorHelpers.cpp b/test_common/harness/errorHelpers.cpp index c2e1e5256b..64c730b32d 100644 --- a/test_common/harness/errorHelpers.cpp +++ b/test_common/harness/errorHelpers.cpp @@ -105,6 +105,12 @@ const char *IGetErrorString(int clErrorCode) case CL_INVALID_SPEC_ID: return "CL_INVALID_SPEC_ID"; case CL_MAX_SIZE_RESTRICTION_EXCEEDED: return "CL_MAX_SIZE_RESTRICTION_EXCEEDED"; + case CL_INCOMPATIBLE_COMMAND_QUEUE_KHR: + return "CL_INCOMPATIBLE_COMMAND_QUEUE_KHR"; + case CL_INVALID_SYNC_POINT_WAIT_LIST_KHR: + return "CL_INVALID_SYNC_POINT_WAIT_LIST_KHR"; + case CL_INVALID_COMMAND_BUFFER_KHR: + return "CL_INVALID_COMMAND_BUFFER_KHR"; default: return "(unknown)"; } } @@ -190,6 +196,8 @@ const char *GetChannelTypeName(cl_channel_type type) case CL_UNORM_SHORT_565: return "CL_UNORM_SHORT_565"; case CL_UNORM_SHORT_555: return "CL_UNORM_SHORT_555"; case CL_UNORM_INT_101010: return "CL_UNORM_INT_101010"; + case CL_UNORM_INT_101010_2: return "CL_UNORM_INT_101010_2"; + case CL_UNORM_INT_2_101010_EXT: return "CL_UNORM_INT_2_101010_EXT"; case CL_SIGNED_INT8: return "CL_SIGNED_INT8"; case CL_SIGNED_INT16: return "CL_SIGNED_INT16"; case CL_SIGNED_INT32: return "CL_SIGNED_INT32"; @@ -220,6 +228,8 @@ int IsChannelTypeSupported(cl_channel_type type) case CL_UNORM_SHORT_565: case CL_UNORM_SHORT_555: case CL_UNORM_INT_101010: + case CL_UNORM_INT_101010_2: + case CL_UNORM_INT_2_101010_EXT: case CL_SIGNED_INT8: case CL_SIGNED_INT16: case CL_SIGNED_INT32: diff --git a/test_common/harness/imageHelpers.cpp b/test_common/harness/imageHelpers.cpp index e13404b9a5..b354baebe3 100644 --- a/test_common/harness/imageHelpers.cpp +++ b/test_common/harness/imageHelpers.cpp @@ -99,7 +99,9 @@ uint32_t get_channel_data_type_size(cl_channel_type channelType) case CL_UNORM_SHORT_565: case CL_UNORM_SHORT_555: return 2; - case CL_UNORM_INT_101010: return 4; + case CL_UNORM_INT_101010: + case CL_UNORM_INT_101010_2: + case CL_UNORM_INT_2_101010_EXT: return 4; case CL_FLOAT: return sizeof(cl_float); @@ -162,24 +164,27 @@ cl_channel_type get_channel_type_from_name(const char *name) { cl_channel_type type; const char *name; - } typeNames[] = { { CL_SNORM_INT8, "CL_SNORM_INT8" }, - { CL_SNORM_INT16, "CL_SNORM_INT16" }, - { CL_UNORM_INT8, "CL_UNORM_INT8" }, - { CL_UNORM_INT16, "CL_UNORM_INT16" }, - { CL_UNORM_INT24, "CL_UNORM_INT24" }, - { CL_UNORM_SHORT_565, "CL_UNORM_SHORT_565" }, - { CL_UNORM_SHORT_555, "CL_UNORM_SHORT_555" }, - { CL_UNORM_INT_101010, "CL_UNORM_INT_101010" }, - { CL_SIGNED_INT8, "CL_SIGNED_INT8" }, - { CL_SIGNED_INT16, "CL_SIGNED_INT16" }, - { CL_SIGNED_INT32, "CL_SIGNED_INT32" }, - { CL_UNSIGNED_INT8, "CL_UNSIGNED_INT8" }, - { CL_UNSIGNED_INT16, "CL_UNSIGNED_INT16" }, - { CL_UNSIGNED_INT32, "CL_UNSIGNED_INT32" }, - { CL_HALF_FLOAT, "CL_HALF_FLOAT" }, - { CL_FLOAT, "CL_FLOAT" }, + } typeNames[] = { + { CL_SNORM_INT8, "CL_SNORM_INT8" }, + { CL_SNORM_INT16, "CL_SNORM_INT16" }, + { CL_UNORM_INT8, "CL_UNORM_INT8" }, + { CL_UNORM_INT16, "CL_UNORM_INT16" }, + { CL_UNORM_INT24, "CL_UNORM_INT24" }, + { CL_UNORM_SHORT_565, "CL_UNORM_SHORT_565" }, + { CL_UNORM_SHORT_555, "CL_UNORM_SHORT_555" }, + { CL_UNORM_INT_101010, "CL_UNORM_INT_101010" }, + { CL_UNORM_INT_101010_2, "CL_UNORM_INT_101010_2" }, + { CL_UNORM_INT_2_101010_EXT, "CL_UNORM_INT_2_101010_EXT" }, + { CL_SIGNED_INT8, "CL_SIGNED_INT8" }, + { CL_SIGNED_INT16, "CL_SIGNED_INT16" }, + { CL_SIGNED_INT32, "CL_SIGNED_INT32" }, + { CL_UNSIGNED_INT8, "CL_UNSIGNED_INT8" }, + { CL_UNSIGNED_INT16, "CL_UNSIGNED_INT16" }, + { CL_UNSIGNED_INT32, "CL_UNSIGNED_INT32" }, + { CL_HALF_FLOAT, "CL_HALF_FLOAT" }, + { CL_FLOAT, "CL_FLOAT" }, #ifdef CL_SFIXED14_APPLE - { CL_SFIXED14_APPLE, "CL_SFIXED14_APPLE" } + { CL_SFIXED14_APPLE, "CL_SFIXED14_APPLE" } #endif }; for (size_t i = 0; i < sizeof(typeNames) / sizeof(typeNames[0]); i++) @@ -286,7 +291,8 @@ uint32_t get_pixel_size(const cl_image_format *format) case CL_FLOAT: return get_format_channel_count(format) * sizeof(cl_float); - case CL_UNORM_INT_101010_2: return 4; + case CL_UNORM_INT_101010_2: + case CL_UNORM_INT_2_101010_EXT: return 4; case CL_UNSIGNED_INT_RAW10_EXT: case CL_UNSIGNED_INT_RAW12_EXT: return 2; @@ -484,6 +490,32 @@ size_t compare_scanlines(const image_descriptor *imageInfo, const char *aPtr, } break; + case CL_SNORM_INT8: { + cl_uchar aPixel = *(cl_uchar *)aPtr; + cl_uchar bPixel = *(cl_uchar *)bPtr; + // -1.0 is defined as 0x80 and 0x81 + aPixel = (aPixel == 0x80) ? 0x81 : aPixel; + bPixel = (bPixel == 0x80) ? 0x81 : bPixel; + if (aPixel != bPixel) + { + return column; + } + } + break; + + case CL_SNORM_INT16: { + cl_ushort aPixel = *(cl_ushort *)aPtr; + cl_ushort bPixel = *(cl_ushort *)bPtr; + // -1.0 is defined as 0x8000 and 0x8001 + aPixel = (aPixel == 0x8000) ? 0x8001 : aPixel; + bPixel = (bPixel == 0x8000) ? 0x8001 : bPixel; + if (aPixel != bPixel) + { + return column; + } + } + break; + default: if (memcmp(aPtr, bPtr, pixel_size) != 0) return column; break; @@ -934,6 +966,8 @@ float get_max_relative_error(const cl_image_format *format, case CL_UNORM_SHORT_565: case CL_UNORM_SHORT_555: case CL_UNORM_INT_101010: + case CL_UNORM_INT_101010_2: + case CL_UNORM_INT_2_101010_EXT: // Maximum sampling error for round to zero normalization based on // multiplication by reciprocal (using reciprocal generated in // round to +inf mode, so that 1.0 matches spec) @@ -1017,7 +1051,9 @@ size_t get_format_max_int(const cl_image_format *format) case CL_UNORM_SHORT_565: case CL_UNORM_SHORT_555: return 31; - case CL_UNORM_INT_101010: return 1023; + case CL_UNORM_INT_101010: + case CL_UNORM_INT_101010_2: + case CL_UNORM_INT_2_101010_EXT: return 1023; case CL_HALF_FLOAT: return 1 << 10; @@ -1049,7 +1085,9 @@ int get_format_min_int(const cl_image_format *format) case CL_UNORM_SHORT_565: case CL_UNORM_SHORT_555: - case CL_UNORM_INT_101010: return 0; + case CL_UNORM_INT_101010: + case CL_UNORM_INT_101010_2: + case CL_UNORM_INT_2_101010_EXT: return 0; case CL_HALF_FLOAT: return -(1 << 10); @@ -1465,6 +1503,24 @@ void read_image_pixel_float(void *imageData, image_descriptor *imageInfo, int x, break; } + case CL_UNORM_INT_101010_2: { + cl_uint *dPtr = (cl_uint *)ptr; + tempData[0] = (float)((dPtr[0] >> 22) & 0x3ff) / (float)1023; + tempData[1] = (float)((dPtr[0] >> 12) & 0x3ff) / (float)1023; + tempData[2] = (float)(dPtr[0] >> 2 & 0x3ff) / (float)1023; + tempData[3] = (float)(dPtr[0] >> 0 & 3) / (float)3; + break; + } + + case CL_UNORM_INT_2_101010_EXT: { + cl_uint *dPtr = (cl_uint *)ptr; + tempData[0] = (float)((dPtr[0] >> 30) & 0x3) / (float)3; + tempData[1] = (float)((dPtr[0] >> 20) & 0x3ff) / (float)1023; + tempData[2] = (float)(dPtr[0] >> 10 & 0x3ff) / (float)1023; + tempData[3] = (float)(dPtr[0] >> 0 & 0x3ff) / (float)1023; + break; + } + case CL_FLOAT: { float *dPtr = (float *)ptr; for (i = 0; i < channelCount; i++) tempData[i] = (float)dPtr[i]; @@ -2730,6 +2786,23 @@ void pack_image_pixel(float *srcVector, const cl_image_format *imageFormat, | (((unsigned int)NORMALIZE(srcVector[2], 1023.f) & 1023) << 0); break; } + case CL_UNORM_INT_101010_2: { + cl_uint *ptr = (cl_uint *)outData; + ptr[0] = + (((unsigned int)NORMALIZE(srcVector[0], 1023.f) & 1023) << 22) + | (((unsigned int)NORMALIZE(srcVector[1], 1023.f) & 1023) << 12) + | (((unsigned int)NORMALIZE(srcVector[2], 1023.f) & 1023) << 2) + | (((unsigned int)NORMALIZE(srcVector[3], 3.f) & 3) << 0); + break; + } + case CL_UNORM_INT_2_101010_EXT: { + cl_uint *ptr = (cl_uint *)outData; + ptr[0] = (((unsigned int)NORMALIZE(srcVector[0], 3.f) & 3) << 30) + | (((unsigned int)NORMALIZE(srcVector[1], 1023.f) & 1023) << 20) + | (((unsigned int)NORMALIZE(srcVector[2], 1023.f) & 1023) << 10) + | (((unsigned int)NORMALIZE(srcVector[3], 1023.f) & 1023) << 0); + break; + } case CL_SIGNED_INT8: { cl_char *ptr = (cl_char *)outData; for (unsigned int i = 0; i < channelCount; i++) @@ -2892,6 +2965,34 @@ void pack_image_pixel_error(const float *srcVector, break; } + case CL_UNORM_INT_101010_2: { + const cl_uint *ptr = (const cl_uint *)results; + + errors[0] = ((ptr[0] >> 22) & 1023) + - NORMALIZE_UNROUNDED(srcVector[0], 1023.f); + errors[1] = ((ptr[0] >> 12) & 1023) + - NORMALIZE_UNROUNDED(srcVector[1], 1023.f); + errors[2] = ((ptr[0] >> 2) & 1023) + - NORMALIZE_UNROUNDED(srcVector[2], 1023.f); + errors[3] = + ((ptr[0] >> 0) & 3) - NORMALIZE_UNROUNDED(srcVector[3], 3.f); + + break; + } + case CL_UNORM_INT_2_101010_EXT: { + const cl_uint *ptr = (const cl_uint *)results; + + errors[0] = + ((ptr[0] >> 30) & 3) - NORMALIZE_UNROUNDED(srcVector[0], 3.f); + errors[1] = ((ptr[0] >> 20) & 1023) + - NORMALIZE_UNROUNDED(srcVector[1], 1023.f); + errors[2] = ((ptr[0] >> 10) & 1023) + - NORMALIZE_UNROUNDED(srcVector[2], 1023.f); + errors[3] = ((ptr[0] >> 0) & 1023) + - NORMALIZE_UNROUNDED(srcVector[3], 1023.f); + + break; + } case CL_SIGNED_INT8: { const cl_char *ptr = (const cl_char *)results; diff --git a/test_common/harness/kernelHelpers.cpp b/test_common/harness/kernelHelpers.cpp index c307fca559..8e41fbdd33 100644 --- a/test_common/harness/kernelHelpers.cpp +++ b/test_common/harness/kernelHelpers.cpp @@ -1319,7 +1319,9 @@ size_t get_pixel_bytes(const cl_image_format *fmt) case CL_UNORM_SHORT_565: case CL_UNORM_SHORT_555: return 2; - case CL_UNORM_INT_101010: return 4; + case CL_UNORM_INT_101010: + case CL_UNORM_INT_101010_2: + case CL_UNORM_INT_2_101010_EXT: return 4; case CL_SNORM_INT8: case CL_UNORM_INT8: @@ -1623,7 +1625,7 @@ Version get_device_cl_c_version(cl_device_id device) &opencl_c_version_size_in_bytes); test_error_ret(error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_VERSION\n", - (Version{ -1, 0 })); + (Version{ 0, 0 })); std::string opencl_c_version(opencl_c_version_size_in_bytes, '\0'); error = @@ -1632,13 +1634,13 @@ Version get_device_cl_c_version(cl_device_id device) test_error_ret(error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_VERSION\n", - (Version{ -1, 0 })); + (Version{ 0, 0 })); // Scrape out the major, minor pair from the string. auto major = opencl_c_version[opencl_c_version.find('.') - 1]; auto minor = opencl_c_version[opencl_c_version.find('.') + 1]; - return Version{ major - '0', minor - '0' }; + return Version{ (cl_uint)(major - '0'), (cl_uint)(minor - '0') }; } Version get_device_latest_cl_c_version(cl_device_id device) @@ -1656,7 +1658,7 @@ Version get_device_latest_cl_c_version(cl_device_id device) &opencl_c_all_versions_size_in_bytes); test_error_ret( error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_ALL_VERSIONS", - (Version{ -1, 0 })); + (Version{ 0, 0 })); std::vector name_versions( opencl_c_all_versions_size_in_bytes / sizeof(cl_name_version)); error = clGetDeviceInfo(device, CL_DEVICE_OPENCL_C_ALL_VERSIONS, @@ -1664,14 +1666,14 @@ Version get_device_latest_cl_c_version(cl_device_id device) name_versions.data(), nullptr); test_error_ret( error, "clGetDeviceInfo failed for CL_DEVICE_OPENCL_C_ALL_VERSIONS", - (Version{ -1, 0 })); + (Version{ 0, 0 })); Version max_supported_cl_c_version{}; for (const auto &name_version : name_versions) { Version current_version{ - static_cast(CL_VERSION_MAJOR(name_version.version)), - static_cast(CL_VERSION_MINOR(name_version.version)) + static_cast(CL_VERSION_MAJOR(name_version.version)), + static_cast(CL_VERSION_MINOR(name_version.version)) }; max_supported_cl_c_version = (current_version > max_supported_cl_c_version) @@ -1692,7 +1694,7 @@ Version get_max_OpenCL_C_for_context(cl_context context) auto error = clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, nullptr, &devices_size_in_bytes); test_error_ret(error, "clGetDeviceInfo failed for CL_CONTEXT_DEVICES", - (Version{ -1, 0 })); + (Version{ 0, 0 })); std::vector devices(devices_size_in_bytes / sizeof(cl_device_id)); error = clGetContextInfo(context, CL_CONTEXT_DEVICES, devices_size_in_bytes, @@ -1756,8 +1758,8 @@ bool device_supports_cl_c_version(cl_device_id device, Version version) for (const auto &name_version : name_versions) { Version current_version{ - static_cast(CL_VERSION_MAJOR(name_version.version)), - static_cast(CL_VERSION_MINOR(name_version.version)) + static_cast(CL_VERSION_MAJOR(name_version.version)), + static_cast(CL_VERSION_MINOR(name_version.version)) }; if (current_version == version) { diff --git a/test_common/harness/kernelHelpers.h b/test_common/harness/kernelHelpers.h index 518b27499a..29160dc466 100644 --- a/test_common/harness/kernelHelpers.h +++ b/test_common/harness/kernelHelpers.h @@ -39,21 +39,6 @@ #include -/* - * The below code is intended to be used at the top of kernels that appear - * inline in files to set line and file info for the kernel: - * - * const char *source = { - * INIT_OPENCL_DEBUG_INFO - * "__kernel void foo( int x )\n" - * "{\n" - * " ...\n" - * "}\n" - * }; - */ -#define INIT_OPENCL_DEBUG_INFO SET_OPENCL_LINE_INFO(__LINE__, __FILE__) -#define SET_OPENCL_LINE_INFO(_line, _file) \ - "#line " STRINGIFY(_line) " " STRINGIFY(_file) "\n" #ifndef STRINGIFY_VALUE #define STRINGIFY_VALUE(_x) STRINGIFY(_x) #endif @@ -85,13 +70,6 @@ extern int create_single_kernel_helper_create_program_for_device( unsigned int numKernelLines, const char **kernelProgram, const char *buildOptions = NULL); -/* Creates OpenCL C++ program. This one must be used for creating OpenCL C++ - * program. */ -extern int create_openclcpp_program(cl_context context, cl_program *outProgram, - unsigned int numKernelLines, - const char **kernelProgram, - const char *buildOptions = NULL); - /* Builds program (outProgram) and creates one kernel */ int build_program_create_kernel_helper( cl_context context, cl_program *outProgram, cl_kernel *outKernel, diff --git a/test_common/harness/msvc9.c b/test_common/harness/msvc9.c index 29b45d656d..ef70035fb1 100644 --- a/test_common/harness/msvc9.c +++ b/test_common/harness/msvc9.c @@ -714,6 +714,11 @@ int32_t float2int(float fx) return u.i; } +#ifndef __has_builtin +#define __has_builtin(x) 0 +#endif + +#if !__has_builtin(__builtin_clz) #if !defined(_WIN64) /** Returns the number of leading 0-bits in x, starting at the most significant bit position. @@ -778,6 +783,7 @@ int __builtin_clz(unsigned int pattern) } #endif // !defined(_WIN64) +#endif // !__has_builtin(__builtin_clz) #include #include diff --git a/test_common/harness/parseParameters.cpp b/test_common/harness/parseParameters.cpp index 2fc31d26ea..2949938114 100644 --- a/test_common/harness/parseParameters.cpp +++ b/test_common/harness/parseParameters.cpp @@ -25,8 +25,6 @@ #include #include -using namespace std; - #define DEFAULT_COMPILATION_PROGRAM "cl_offline_compiler" #define DEFAULT_SPIRV_VALIDATOR "spirv-val" diff --git a/test_common/harness/rounding_mode.cpp b/test_common/harness/rounding_mode.cpp index 191c04d929..b2e443b783 100644 --- a/test_common/harness/rounding_mode.cpp +++ b/test_common/harness/rounding_mode.cpp @@ -240,7 +240,7 @@ void UnFlushToZero(void *p) #if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) union { void *p; - int i; + unsigned int i; } u = { p }; _mm_setcsr(u.i); #elif defined(__arm__) || defined(__aarch64__) diff --git a/test_common/harness/testHarness.cpp b/test_common/harness/testHarness.cpp index 0e3c49e9a3..df54a35d71 100644 --- a/test_common/harness/testHarness.cpp +++ b/test_common/harness/testHarness.cpp @@ -62,6 +62,27 @@ bool gCoreILProgram = true; #define DEFAULT_NUM_ELEMENTS 0x4000 +test_definition *test_registry::definitions() { return &m_definitions[0]; } + +size_t test_registry::num_tests() { return m_definitions.size(); } + +void test_registry::add_test(test *t, const char *name, Version version) +{ + + m_tests.push_back(t); + test_definition testDef; + testDef.func = t->getFunction(); + testDef.name = name; + testDef.min_version = version; + m_definitions.push_back(testDef); +} + +test_registry &test_registry::getInstance() +{ + static test_registry instance; + return instance; +} + static int saveResultsToJson(const char *suiteName, test_definition testList[], unsigned char selectedTestList[], test_status resultTestList[], int testNum) @@ -689,6 +710,7 @@ static void print_results(int failed, int count, const char *name) log_error("FAILED %s.\n", name); } } + fflush(stdout); } int parseAndCallCommandLineTests(int argc, const char *argv[], @@ -1294,6 +1316,43 @@ cl_platform_id getPlatformFromDevice(cl_device_id deviceID) return platform; } +/** + * Helper to return a string containing platform information + * for the specified platform info parameter. + */ +std::string get_platform_info_string(cl_platform_id platform, + cl_platform_info param_name) +{ + size_t size = 0; + int err; + + if ((err = clGetPlatformInfo(platform, param_name, 0, NULL, &size)) + != CL_SUCCESS + || size == 0) + { + throw std::runtime_error("clGetPlatformInfo failed\n"); + } + + std::vector info(size); + + if ((err = clGetPlatformInfo(platform, param_name, size, info.data(), NULL)) + != CL_SUCCESS) + { + throw std::runtime_error("clGetPlatformInfo failed\n"); + } + + /* The returned string does not include the null terminator. */ + return std::string(info.data(), size - 1); +} + +bool is_platform_extension_available(cl_platform_id platform, + const char *extensionName) +{ + std::string extString = + get_platform_info_string(platform, CL_PLATFORM_EXTENSIONS); + return extString.find(extensionName) != std::string::npos; +} + void PrintArch(void) { vlog("sizeof( void*) = %zu\n", sizeof(void *)); diff --git a/test_common/harness/testHarness.h b/test_common/harness/testHarness.h index 9e3800f669..45f4ce7995 100644 --- a/test_common/harness/testHarness.h +++ b/test_common/harness/testHarness.h @@ -21,28 +21,36 @@ #include #include +#include class Version { public: Version(): m_major(0), m_minor(0) {} - Version(int major, int minor): m_major(major), m_minor(minor) {} + + Version(cl_uint major, cl_uint minor): m_major(major), m_minor(minor) {} int major() const { return m_major; } int minor() const { return m_minor; } - bool operator>(const Version &rhs) const { return to_int() > rhs.to_int(); } - bool operator<(const Version &rhs) const { return to_int() < rhs.to_int(); } + bool operator>(const Version &rhs) const + { + return to_uint() > rhs.to_uint(); + } + bool operator<(const Version &rhs) const + { + return to_uint() < rhs.to_uint(); + } bool operator<=(const Version &rhs) const { - return to_int() <= rhs.to_int(); + return to_uint() <= rhs.to_uint(); } bool operator>=(const Version &rhs) const { - return to_int() >= rhs.to_int(); + return to_uint() >= rhs.to_uint(); } bool operator==(const Version &rhs) const { - return to_int() == rhs.to_int(); + return to_uint() == rhs.to_uint(); } - int to_int() const { return m_major * 10 + m_minor; } + cl_uint to_uint() const { return m_major * 10 + m_minor; } std::string to_string() const { std::stringstream ss; @@ -51,8 +59,8 @@ class Version { } private: - int m_major; - int m_minor; + cl_uint m_major; + cl_uint m_minor; }; Version get_device_cl_version(cl_device_id device); @@ -95,6 +103,53 @@ struct test_harness_config unsigned numWorkerThreads; }; + +struct test +{ + virtual test_function_pointer getFunction() = 0; +}; + +class test_registry { +private: + std::vector m_tests; + std::vector m_definitions; + +public: + static test_registry &getInstance(); + + test_definition *definitions(); + + size_t num_tests(); + + void add_test(test *t, const char *name, Version version); + test_registry() {} +}; + +template T *register_test(const char *name, Version version) +{ + T *t = new T(); + test_registry::getInstance().add_test((test *)t, name, version); + return t; +} + +#define REGISTER_TEST_VERSION(name, version) \ + extern int test_##name(cl_device_id deviceID, cl_context context, \ + cl_command_queue queue, int num_elements); \ + class test_##name##_class : public test { \ + private: \ + test_function_pointer fn; \ + \ + public: \ + test_##name##_class(): fn(test_##name) {} \ + test_function_pointer getFunction() { return fn; } \ + }; \ + test_##name##_class *var_##name = \ + register_test(#name, version); \ + int test_##name(cl_device_id deviceID, cl_context context, \ + cl_command_queue queue, int num_elements) + +#define REGISTER_TEST(name) REGISTER_TEST_VERSION(name, Version(1, 2)) + extern int gFailCount; extern int gTestCount; extern cl_uint gReSeed; @@ -187,6 +242,10 @@ extern int gHasLong; // This is set to 1 if the device suppots long and ulong extern bool gCoreILProgram; extern cl_platform_id getPlatformFromDevice(cl_device_id deviceID); +extern std::string get_platform_info_string(cl_platform_id platform, + cl_platform_info param_name); +extern bool is_platform_extension_available(cl_platform_id platform, + const char *extensionName); #if !defined(__APPLE__) void memset_pattern4(void *, const void *, size_t); diff --git a/test_conformance/SVM/test_enqueue_api.cpp b/test_conformance/SVM/test_enqueue_api.cpp index 2b39f9e8d8..256df43fe3 100644 --- a/test_conformance/SVM/test_enqueue_api.cpp +++ b/test_conformance/SVM/test_enqueue_api.cpp @@ -193,7 +193,8 @@ int test_svm_enqueue_api(cl_device_id deviceID, cl_context c, cl_command_queue q for (size_t j = 0; j < data_size; ++j) { if (dst_ptr[j] != src_ptr[j]) { - log_error("Invalid data at index %ld, dst_ptr %d, src_ptr %d\n", j, dst_ptr[j], src_ptr[j]); + log_error("Invalid data at index %zu, dst_ptr %d, src_ptr %d\n", j, + dst_ptr[j], src_ptr[j]); return TEST_FAIL; } } @@ -291,8 +292,10 @@ int test_svm_enqueue_api(cl_device_id deviceID, cl_context c, cl_command_queue q //check if number of SVM pointers returned in the callback matches with expected if (data.num_svm_pointers != buffers.size()) { - log_error("Invalid number of SVM pointers returned in the callback, expected: %ld, got: %d\n", buffers.size(), data.num_svm_pointers); - return TEST_FAIL; + log_error("Invalid number of SVM pointers returned in the callback, " + "expected: %zu, got: %d\n", + buffers.size(), data.num_svm_pointers); + return TEST_FAIL; } //check if pointers returned in callback are correct @@ -300,8 +303,9 @@ int test_svm_enqueue_api(cl_device_id deviceID, cl_context c, cl_command_queue q { if (data.svm_pointers[i] != buffers[i]) { - log_error("Invalid SVM pointer returned in the callback, idx: %ld\n", i); - return TEST_FAIL; + log_error("Invalid SVM pointer returned in the callback, idx: %zu\n", + i); + return TEST_FAIL; } } diff --git a/test_conformance/allocations/allocation_execute.cpp b/test_conformance/allocations/allocation_execute.cpp index 692424ceb1..f01dfd8fbc 100644 --- a/test_conformance/allocations/allocation_execute.cpp +++ b/test_conformance/allocations/allocation_execute.cpp @@ -373,8 +373,8 @@ int execute_kernel(cl_context context, cl_command_queue *queue, if (result != SUCCEEDED) { if (result == FAILED_TOO_BIG) - log_info("\t\tExecute kernel failed: %s (global dim: %ld, local " - "dim: %ld)\n", + log_info("\t\tExecute kernel failed: %s (global dim: %zu, local " + "dim: %zu)\n", IGetErrorString(error), global_dims[0], local_dims[0]); else print_error(error, "clEnqueueNDRangeKernel failed"); diff --git a/test_conformance/api/CMakeLists.txt b/test_conformance/api/CMakeLists.txt index 96d12f435d..b32fe92a5d 100644 --- a/test_conformance/api/CMakeLists.txt +++ b/test_conformance/api/CMakeLists.txt @@ -11,6 +11,7 @@ set(${MODULE_NAME}_SOURCES test_queries.cpp test_create_kernels.cpp test_kernels.cpp + test_kernel_local_memory_size.cpp test_kernel_private_memory_size.cpp test_api_min_max.cpp test_kernel_arg_changes.cpp diff --git a/test_conformance/api/main.cpp b/test_conformance/api/main.cpp index 97dcc84df7..abdd026e46 100644 --- a/test_conformance/api/main.cpp +++ b/test_conformance/api/main.cpp @@ -146,6 +146,8 @@ test_definition test_list[] = { ADD_TEST_VERSION(consistency_subgroups, Version(3, 0)), ADD_TEST_VERSION(consistency_prog_ctor_dtor, Version(3, 0)), ADD_TEST_VERSION(consistency_3d_image_writes, Version(3, 0)), + ADD_TEST(consistency_requirements_fp64), + ADD_TEST(consistency_requirements_fp16), ADD_TEST(min_image_formats), ADD_TEST(set_command_queue_property), @@ -161,6 +163,7 @@ test_definition test_list[] = { ADD_TEST_VERSION(negative_create_command_queue_with_properties, Version(2, 0)), ADD_TEST(negative_create_command_queue_with_properties_khr), + ADD_TEST(kernel_local_memory_size), }; const int test_num = ARRAY_SIZE(test_list); diff --git a/test_conformance/api/procs.h b/test_conformance/api/procs.h index ee39c9823c..780b39de8b 100644 --- a/test_conformance/api/procs.h +++ b/test_conformance/api/procs.h @@ -203,9 +203,21 @@ extern int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_consistency_requirements_fp64(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_consistency_requirements_fp16(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); extern int test_min_image_formats(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_kernel_local_memory_size(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); extern int test_negative_get_platform_info(cl_device_id deviceID, cl_context context, cl_command_queue queue, diff --git a/test_conformance/api/test_api_consistency.cpp b/test_conformance/api/test_api_consistency.cpp index 56c831815e..974d552d0f 100644 --- a/test_conformance/api/test_api_consistency.cpp +++ b/test_conformance/api/test_api_consistency.cpp @@ -1151,3 +1151,150 @@ int test_consistency_3d_image_writes(cl_device_id deviceID, cl_context context, return TEST_PASS; } + +int test_consistency_requirements_fp64(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, int num_elements) +{ + cl_int error = CL_SUCCESS; + cl_device_fp_config value = 0; + + if (is_extension_available(deviceID, "cl_khr_fp64")) + { + const Version version = get_device_cl_version(deviceID); + + error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG, + sizeof(value), &value, nullptr); + test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG"); + test_assert_error( + value > 0, "CL_DEVICE_DOUBLE_FP_CONFIG must return nonzero value"); + if (version < Version(2, 0)) + { + test_assert_error( + value + & (CL_FP_FMA | CL_FP_ROUND_TO_NEAREST | CL_FP_ROUND_TO_ZERO + | CL_FP_ROUND_TO_INF | CL_FP_INF_NAN | CL_FP_DENORM), + "Reported double fp config doesn't meet minimum set " + "for OpenCL 1.0, OpenCL 1.1, OpenCL 1.2 devices"); + } + else + { + test_assert_error( + value + & (CL_FP_FMA | CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN + | CL_FP_DENORM), + "Reported double fp config doesn't meet minimum set " + "for OpenCL 2.0 or newer devices"); + } + + error = + clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, + sizeof(value), &value, nullptr); + test_error( + error, + "Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE"); + test_assert_error(value > 0, + "CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return " + "nonzero value"); + + error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, + sizeof(value), &value, nullptr); + test_error(error, + "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE"); + test_assert_error( + value > 0, + "CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE must return nonzero value"); + } + else + { + error = clGetDeviceInfo(deviceID, CL_DEVICE_DOUBLE_FP_CONFIG, + sizeof(value), &value, nullptr); + test_error(error, "Unable to get device CL_DEVICE_DOUBLE_FP_CONFIG"); + test_assert_error(value == 0, + "CL_DEVICE_DOUBLE_FP_CONFIG must return 0"); + + error = + clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, + sizeof(value), &value, nullptr); + test_error( + error, + "Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE"); + test_assert_error( + value == 0, + "CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE must return 0"); + + error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, + sizeof(value), &value, nullptr); + test_error(error, + "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE"); + test_assert_error(value == 0, + "CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE must return 0"); + } + + return TEST_PASS; +} + +int test_consistency_requirements_fp16(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, int num_elements) +{ + cl_int error = CL_SUCCESS; + cl_device_fp_config value = 0; + + if (is_extension_available(deviceID, "cl_khr_fp16")) + { + error = clGetDeviceInfo(deviceID, CL_DEVICE_HALF_FP_CONFIG, + sizeof(value), &value, nullptr); + test_error(error, "Unable to get device CL_DEVICE_HALF_FP_CONFIG"); + test_assert_error(value > 0, + "CL_DEVICE_HALF_FP_CONFIG must return nonzero value"); + + test_assert_error((value & (CL_FP_ROUND_TO_NEAREST | CL_FP_INF_NAN)) + || (value & CL_FP_ROUND_TO_ZERO), + "Reported half fp config doesn't meet minimum set"); + + error = clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, + sizeof(value), &value, nullptr); + test_error( + error, + "Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF"); + test_assert_error(value > 0, + "CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return " + "nonzero value"); + + error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, + sizeof(value), &value, nullptr); + test_error(error, + "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF"); + test_assert_error( + value > 0, + "CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF must return nonzero value"); + } + else + { + error = clGetDeviceInfo(deviceID, CL_DEVICE_HALF_FP_CONFIG, + sizeof(value), &value, nullptr); + test_failure_error( + error, CL_INVALID_VALUE, + "cl_khr_fp16 is not available; CL_DEVICE_HALF_FP_CONFIG must fail " + "with CL_INVALID_VALUE"); + + error = clGetDeviceInfo(deviceID, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, + sizeof(value), &value, nullptr); + test_error( + error, + "Unable to get device CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF"); + test_assert_error(value == 0, + "CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF must return " + "0"); + + error = clGetDeviceInfo(deviceID, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, + sizeof(value), &value, nullptr); + test_error(error, + "Unable to get device CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF"); + test_assert_error(value == 0, + "CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF must return 0"); + } + + return TEST_PASS; +} diff --git a/test_conformance/api/test_api_min_max.cpp b/test_conformance/api/test_api_min_max.cpp index f92f224ffc..eb119006a4 100644 --- a/test_conformance/api/test_api_min_max.cpp +++ b/test_conformance/api/test_api_min_max.cpp @@ -1626,8 +1626,8 @@ int test_min_max_constant_buffer_size(cl_device_id deviceID, cl_context context, /* Test running the kernel and verifying it */ threads[0] = numberOfInts; localThreads[0] = 1; - log_info("Filling constant buffer with %d cl_ints (%d bytes).\n", - (int)threads[0], (int)(threads[0] * sizeof(cl_int))); + log_info("Filling constant buffer with %zu cl_ints (%zu bytes).\n", + threads[0], threads[0] * sizeof(cl_int)); error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, localThreads, 0, NULL, &event); diff --git a/test_conformance/api/test_clone_kernel.cpp b/test_conformance/api/test_clone_kernel.cpp index cc95c9b055..8cf88b3fc4 100644 --- a/test_conformance/api/test_clone_kernel.cpp +++ b/test_conformance/api/test_clone_kernel.cpp @@ -20,8 +20,6 @@ #include #include -using namespace std; - const char *clone_kernel_test_img[] = { "__kernel void img_read_kernel(read_only image2d_t img, sampler_t sampler, __global int* outbuf)\n" diff --git a/test_conformance/api/test_kernel_local_memory_size.cpp b/test_conformance/api/test_kernel_local_memory_size.cpp new file mode 100644 index 0000000000..5cd613f83f --- /dev/null +++ b/test_conformance/api/test_kernel_local_memory_size.cpp @@ -0,0 +1,312 @@ +// +// Copyright (c) 2020 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 "testBase.h" +#include "harness/testHarness.h" +#include + +static const char* local_memory_kernel = R"CLC( +__kernel void local_memory_kernel(global int* data) { + __local int array[10]; + + size_t id = get_global_id(0); + array[id] = 2 * id; + data[id] = array[id]; + + barrier(CLK_LOCAL_MEM_FENCE); + if(id == 0) + { + for(size_t i = 0; i < 10; i++) + data[id] += array[i]; + } +} +)CLC"; + +static const char* local_param_kernel = R"CLC( +__kernel void local_param_kernel(__local int* local_ptr, __global int* src, + __global int* dst) { + + size_t id = get_global_id(0); + + local_ptr[id] = src[id]; + barrier(CLK_GLOBAL_MEM_FENCE); + dst[id] = local_ptr[id]; + barrier(CLK_LOCAL_MEM_FENCE); + if(id == 9) + { + for(size_t i = 0; i < 10; i++) + dst[id] += local_ptr[i]; + } +} +)CLC"; + +static const char* local_param_local_memory_kernel = R"CLC( +__kernel void local_param_local_memory_kernel(__local int* local_ptr, + __global int* src, __global int* dst) { + + size_t id = get_global_id(0); + + __local int local_data[10]; + local_ptr[id] = src[id]; + barrier(CLK_LOCAL_MEM_FENCE); + + local_data[id] = local_ptr[id] * 2; + barrier(CLK_LOCAL_MEM_FENCE); + + dst[id] = local_data[id]; + barrier(CLK_LOCAL_MEM_FENCE); + if(id == 9) + { + for(size_t i = 0; i < 10; i++) + dst[id] += local_data[i]; + dst[id] += 666; + } +} +)CLC"; + +int test_kernel_local_memory_size(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) +{ + int error; + clProgramWrapper program; + clKernelWrapper kernel; + + cl_ulong kernel_local_usage = 0; + size_t param_value_size_ret = 0; + + // Check memory needed to execute empty kernel with __local variable + if (create_single_kernel_helper(context, &program, &kernel, 1, + &local_memory_kernel, "local_memory_kernel") + != 0) + { + return TEST_FAIL; + } + + error = clGetKernelWorkGroupInfo( + kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), + &kernel_local_usage, ¶m_value_size_ret); + test_error(error, + "clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed"); + + test_assert_error(param_value_size_ret == sizeof(cl_ulong), + "param_value_size_ret failed"); + + constexpr size_t size = 10; + constexpr size_t memory = size * sizeof(cl_int); + + const size_t global_work_size[] = { size }; + const size_t local_work_size[] = { size }; + + int data[size]; + for (size_t i = 0; i < size; i++) + { + data[i] = 0; + } + clMemWrapper streams[2]; + + streams[0] = + clCreateBuffer(context, CL_MEM_READ_WRITE, memory, NULL, &error); + test_error(error, "Creating test array failed"); + + error = clSetKernelArg(kernel, 0, sizeof(streams[0]), &streams[0]); + test_error(error, "Unable to set indexed kernel arguments"); + + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, global_work_size, + local_work_size, 0, NULL, nullptr); + test_error(error, "clEnqueueNDRangeKernel failed."); + + error = clEnqueueReadBuffer(queue, streams[0], CL_TRUE, 0, memory, data, 0, + NULL, NULL); + test_error(error, "clEnqueueReadBuffer failed"); + + auto local_memory_kernel_verify = [&]() { + constexpr size_t size = 10; + int testData[size]; + for (size_t i = 0; i < size; i++) + { + testData[i] = i * 2; + testData[0] += testData[i]; + } + for (size_t i = 0; i < size; i++) + { + if (data[i] != testData[i]) return false; + } + return true; + }; + test_assert_error(local_memory_kernel_verify(), + "local_memory_kernel data verification failed"); + + test_assert_error(kernel_local_usage >= memory, + "kernel local mem size failed"); + + + // Check memory needed to execute empty kernel with __local parameter with + // setKernelArg + if (create_single_kernel_helper(context, &program, &kernel, 1, + &local_param_kernel, "local_param_kernel") + != 0) + { + return TEST_FAIL; + } + + kernel_local_usage = 0; + param_value_size_ret = 0; + + for (size_t i = 0; i < size; i++) + { + data[i] = i; + } + + streams[0] = + clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, memory, data, &error); + test_error(error, "Creating test array failed"); + streams[1] = + clCreateBuffer(context, CL_MEM_READ_WRITE, memory, nullptr, &error); + test_error(error, "Creating test array failed"); + + error = clSetKernelArg(kernel, 0, memory, NULL); + test_error(error, "Unable to set indexed kernel arguments"); + error = clSetKernelArg(kernel, 1, sizeof(streams[0]), &streams[0]); + test_error(error, "Unable to set indexed kernel arguments"); + error = clSetKernelArg(kernel, 2, sizeof(streams[1]), &streams[1]); + test_error(error, "Unable to set indexed kernel arguments"); + + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, global_work_size, + local_work_size, 0, NULL, nullptr); + test_error(error, "clEnqueueNDRangeKernel failed."); + + error = clEnqueueReadBuffer(queue, streams[1], CL_TRUE, 0, memory, data, 0, + NULL, NULL); + test_error(error, "clEnqueueReadBuffer failed"); + + error = clGetKernelWorkGroupInfo( + kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), + &kernel_local_usage, ¶m_value_size_ret); + test_error(error, + "clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed"); + + test_assert_error(param_value_size_ret == sizeof(cl_ulong), + "param_value_size_ret failed"); + + auto local_param_kernel_verify = [&]() { + constexpr size_t size = 10; + int testData[size]; + int sum = 0; + for (size_t i = 0; i < size; i++) + { + testData[i] = i; + sum += testData[i]; + } + testData[9] += sum; + for (size_t i = 0; i < size; i++) + { + if (data[i] != testData[i]) return false; + } + + return true; + }; + test_assert_error(local_param_kernel_verify(), + "local_param_kernel data verificaion failed"); + + test_assert_error(kernel_local_usage >= memory, + "kernel local mem size failed"); + + + // Check memory needed to execute kernel with __local variable and __local + // parameter with setKernelArg + if (create_single_kernel_helper(context, &program, &kernel, 1, + &local_param_local_memory_kernel, + "local_param_local_memory_kernel") + != 0) + { + return TEST_FAIL; + } + + kernel_local_usage = 0; + param_value_size_ret = 0; + + for (size_t i = 0; i < size; i++) + { + data[i] = i; + } + + streams[0] = + clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, memory, data, &error); + test_error(error, "Creating test array failed"); + streams[1] = + clCreateBuffer(context, CL_MEM_READ_WRITE, memory, nullptr, &error); + test_error(error, "Creating test array failed"); + + error = clSetKernelArg(kernel, 0, memory, NULL); + test_error(error, "Unable to set indexed kernel arguments"); + error = clSetKernelArg(kernel, 1, sizeof(streams[0]), &streams[0]); + test_error(error, "Unable to set indexed kernel arguments"); + error = clSetKernelArg(kernel, 2, sizeof(streams[1]), &streams[1]); + test_error(error, "Unable to set indexed kernel arguments"); + + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, global_work_size, + local_work_size, 0, NULL, nullptr); + test_error(error, "clEnqueueNDRangeKernel failed."); + + error = clEnqueueReadBuffer(queue, streams[1], CL_TRUE, 0, memory, data, 0, + NULL, NULL); + test_error(error, "clEnqueueReadBuffer failed"); + + + error = clGetKernelWorkGroupInfo( + kernel, deviceID, CL_KERNEL_LOCAL_MEM_SIZE, sizeof(kernel_local_usage), + &kernel_local_usage, ¶m_value_size_ret); + test_error(error, + "clGetKernelWorkGroupInfo for CL_KERNEL_LOCAL_MEM_SIZE failed"); + + test_assert_error(param_value_size_ret == sizeof(cl_ulong), + "param_value_size_ret failed"); + + auto local_param_local_memory_kernel_verify = [&]() { + constexpr size_t size = 10; + int testData[size]; + for (size_t i = 0; i < size; i++) + { + testData[i] = i * 2; + } + + int temp = testData[9]; + for (size_t i = 0; i < size; i++) + { + if (i == 9) + testData[9] += temp; + else + testData[9] += testData[i]; + } + testData[9] += 666; + + for (size_t i = 0; i < size; i++) + { + if (data[i] != testData[i]) return false; + } + + return true; + }; + test_assert_error( + local_param_local_memory_kernel_verify(), + "local_param_local_memory_kernel data verificaion failed"); + + test_assert_error(kernel_local_usage >= 2 * memory, + "kernel local mem size failed"); + + return CL_SUCCESS; +} diff --git a/test_conformance/api/test_queries.cpp b/test_conformance/api/test_queries.cpp index c82017ba60..2c4bdb1072 100644 --- a/test_conformance/api/test_queries.cpp +++ b/test_conformance/api/test_queries.cpp @@ -154,7 +154,7 @@ int sampler_param_test(cl_sampler sampler, cl_sampler_info param_name, return 0; } -static cl_int normalized_coord_values[] = { CL_TRUE, CL_FALSE }; +static cl_bool normalized_coord_values[] = { CL_TRUE, CL_FALSE }; static cl_addressing_mode addressing_mode_values[] = { CL_ADDRESS_NONE, CL_ADDRESS_CLAMP_TO_EDGE, CL_ADDRESS_CLAMP, CL_ADDRESS_REPEAT, CL_ADDRESS_MIRRORED_REPEAT diff --git a/test_conformance/api/test_queue_hint.cpp b/test_conformance/api/test_queue_hint.cpp index 558ca1aa3f..8e9b686980 100644 --- a/test_conformance/api/test_queue_hint.cpp +++ b/test_conformance/api/test_queue_hint.cpp @@ -19,11 +19,6 @@ #include #include -using namespace std; -/* - -*/ - const char *queue_hint_test_kernel[] = { "__kernel void vec_cpy(__global int *src, __global int *dst)\n" "{\n" diff --git a/test_conformance/api/test_queue_properties.cpp b/test_conformance/api/test_queue_properties.cpp index 768bd5deab..a60211a2ec 100644 --- a/test_conformance/api/test_queue_properties.cpp +++ b/test_conformance/api/test_queue_properties.cpp @@ -22,7 +22,6 @@ #include #include -using namespace std; /* The test against cl_khr_create_command_queue extension. It validates if devices with Opencl 1.X can use clCreateCommandQueueWithPropertiesKHR function. Based on device capabilities test will create queue with NULL properties, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE property and diff --git a/test_conformance/atomics/test_atomics.cpp b/test_conformance/atomics/test_atomics.cpp index caa4b78f6e..db0d000a7b 100644 --- a/test_conformance/atomics/test_atomics.cpp +++ b/test_conformance/atomics/test_atomics.cpp @@ -1292,8 +1292,8 @@ cl_long test_atomic_and_result_long(size_t size, cl_long *startRefValues, int test_atomic_and(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { - TestFns set = { 0xffffffff, - 0xffffffffffffffffLL, + TestFns set = { (cl_int)0xffffffff, + (cl_long)0xffffffffffffffffLL, test_bitwise_num_results, test_atomic_and_result_int, NULL, diff --git a/test_conformance/basic/CMakeLists.txt b/test_conformance/basic/CMakeLists.txt index bf1f3bd63a..7292bc9d37 100644 --- a/test_conformance/basic/CMakeLists.txt +++ b/test_conformance/basic/CMakeLists.txt @@ -1,5 +1,9 @@ set(MODULE_NAME BASIC) +if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") + add_cxx_flag_if_supported(-Wno-narrowing) +endif() + set(${MODULE_NAME}_SOURCES main.cpp test_fpmath.cpp diff --git a/test_conformance/basic/test_arrayimagecopy.cpp b/test_conformance/basic/test_arrayimagecopy.cpp index 906070d020..b0322ed540 100644 --- a/test_conformance/basic/test_arrayimagecopy.cpp +++ b/test_conformance/basic/test_arrayimagecopy.cpp @@ -22,16 +22,22 @@ #include #include #include +#include #include "procs.h" +using test_function_t = int (*)(cl_device_id, cl_context, cl_command_queue, + cl_mem_flags, cl_mem_flags, cl_mem_object_type, + const cl_image_format *); + int test_arrayimagecopy_single_format(cl_device_id device, cl_context context, cl_command_queue queue, - cl_mem_flags flags, + cl_mem_flags buffer_flags, + cl_mem_flags image_flags, cl_mem_object_type image_type, const cl_image_format *format) { - cl_uchar *bufptr, *imgptr; + std::unique_ptr bufptr, imgptr; clMemWrapper buffer, image; int img_width = 512; int img_height = 512; @@ -40,62 +46,78 @@ int test_arrayimagecopy_single_format(cl_device_id device, cl_context context, size_t buffer_size; cl_int err; cl_event copyevent; + RandomSeed seed(gRandomSeed); log_info("Testing %s %s\n", GetChannelOrderName(format->image_channel_order), GetChannelTypeName(format->image_channel_data_type)); + elem_size = get_pixel_size(format); + + buffer_size = + sizeof(cl_uchar) * elem_size * img_width * img_height * img_depth; + + if (image_flags & CL_MEM_USE_HOST_PTR || image_flags & CL_MEM_COPY_HOST_PTR) + { + imgptr.reset(static_cast( + create_random_data(kUChar, seed, buffer_size))); + } + + bufptr.reset( + static_cast(create_random_data(kUChar, seed, buffer_size))); + if (CL_MEM_OBJECT_IMAGE2D == image_type) { - image = create_image_2d(context, flags, format, img_width, img_height, - 0, nullptr, &err); + image = create_image_2d(context, image_flags, format, img_width, + img_height, 0, imgptr.get(), &err); } else { - image = create_image_3d(context, flags, format, img_width, img_height, - img_depth, 0, 0, nullptr, &err); + image = + create_image_3d(context, image_flags, format, img_width, img_height, + img_depth, 0, 0, imgptr.get(), &err); } test_error(err, "create_image_xd failed"); - err = clGetImageInfo(image, CL_IMAGE_ELEMENT_SIZE, sizeof(size_t), - &elem_size, NULL); - test_error(err, "clGetImageInfo failed"); - - buffer_size = - sizeof(cl_uchar) * elem_size * img_width * img_height * img_depth; - - buffer = - clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size, NULL, &err); - test_error(err, "clCreateBuffer failed"); + if (buffer_flags & CL_MEM_USE_HOST_PTR + || buffer_flags & CL_MEM_COPY_HOST_PTR) + { + buffer = clCreateBuffer(context, buffer_flags, buffer_size, + bufptr.get(), &err); + test_error(err, "clCreateBuffer failed"); + } + else + { + buffer = + clCreateBuffer(context, buffer_flags, buffer_size, nullptr, &err); + test_error(err, "clCreateBuffer failed"); - RandomSeed seed(gRandomSeed); - bufptr = - static_cast(create_random_data(kUChar, seed, buffer_size)); + err = clEnqueueWriteBuffer(queue, buffer, CL_TRUE, 0, buffer_size, + bufptr.get(), 0, nullptr, nullptr); + test_error(err, "clEnqueueWriteBuffer failed"); + } size_t origin[3] = { 0, 0, 0 }, region[3] = { img_width, img_height, img_depth }; - err = clEnqueueWriteBuffer(queue, buffer, CL_TRUE, 0, buffer_size, bufptr, - 0, NULL, NULL); - test_error(err, "clEnqueueWriteBuffer failed"); err = clEnqueueCopyBufferToImage(queue, buffer, image, 0, origin, region, 0, - NULL, ©event); + nullptr, ©event); test_error(err, "clEnqueueCopyImageToBuffer failed"); - imgptr = static_cast(malloc(buffer_size)); + imgptr.reset(static_cast(malloc(buffer_size))); err = clEnqueueReadImage(queue, image, CL_TRUE, origin, region, 0, 0, - imgptr, 1, ©event, NULL); + imgptr.get(), 1, ©event, nullptr); test_error(err, "clEnqueueReadImage failed"); err = clReleaseEvent(copyevent); test_error(err, "clReleaseEvent failed"); - if (memcmp(bufptr, imgptr, buffer_size) != 0) + if (memcmp(bufptr.get(), imgptr.get(), buffer_size) != 0) { log_error("ERROR: Results did not validate!\n"); - auto inchar = static_cast(bufptr); - auto outchar = static_cast(imgptr); + auto inchar = static_cast(bufptr.get()); + auto outchar = static_cast(imgptr.get()); int failuresPrinted = 0; for (int i = 0; i < (int)buffer_size; i += (int)elem_size) { @@ -119,9 +141,6 @@ int test_arrayimagecopy_single_format(cl_device_id device, cl_context context, err = -1; } - free(bufptr); - free(imgptr); - if (err) log_error( "ARRAY to IMAGE copy test failed for image_channel_order=0x%lx and " @@ -134,26 +153,28 @@ int test_arrayimagecopy_single_format(cl_device_id device, cl_context context, int test_arrayimagecommon(cl_device_id device, cl_context context, - cl_command_queue queue, cl_mem_flags flags, - cl_mem_object_type image_type) + cl_command_queue queue, cl_mem_flags buffer_flags, + cl_mem_flags image_flags, + cl_mem_object_type image_type, + test_function_t test_function) { cl_int err; cl_uint num_formats; - err = clGetSupportedImageFormats(context, flags, image_type, 0, NULL, - &num_formats); + err = clGetSupportedImageFormats(context, image_flags, image_type, 0, + nullptr, &num_formats); test_error(err, "clGetSupportedImageFormats failed"); std::vector formats(num_formats); - err = clGetSupportedImageFormats(context, flags, image_type, num_formats, - formats.data(), NULL); + err = clGetSupportedImageFormats(context, image_flags, image_type, + num_formats, formats.data(), nullptr); test_error(err, "clGetSupportedImageFormats failed"); for (const auto &format : formats) { - err |= test_arrayimagecopy_single_format(device, context, queue, flags, - image_type, &format); + err |= test_function(device, context, queue, buffer_flags, image_flags, + image_type, &format); } if (err) @@ -172,7 +193,8 @@ int test_arrayimagecopy(cl_device_id device, cl_context context, PASSIVE_REQUIRE_IMAGE_SUPPORT(device) return test_arrayimagecommon(device, context, queue, CL_MEM_READ_WRITE, - CL_MEM_OBJECT_IMAGE2D); + CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, + test_arrayimagecopy_single_format); } @@ -181,6 +203,7 @@ int test_arrayimagecopy3d(cl_device_id device, cl_context context, { PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device) - return test_arrayimagecommon(device, context, queue, CL_MEM_READ_ONLY, - CL_MEM_OBJECT_IMAGE3D); + return test_arrayimagecommon(device, context, queue, CL_MEM_READ_WRITE, + CL_MEM_READ_ONLY, CL_MEM_OBJECT_IMAGE3D, + test_arrayimagecopy_single_format); } diff --git a/test_conformance/basic/test_global_linear_id.cpp b/test_conformance/basic/test_global_linear_id.cpp index 046d12a1bf..ccd8ce27c8 100644 --- a/test_conformance/basic/test_global_linear_id.cpp +++ b/test_conformance/basic/test_global_linear_id.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 @@ -22,105 +22,93 @@ #include #include "harness/rounding_mode.h" +#include +#include + #include "procs.h" -static const char *global_linear_id_2d_code = -"__kernel void test_global_linear_id_2d(global int *dst)\n" -"{\n" -" int tid_x = get_global_id(0);\n" -" int tid_y = get_global_id(1);\n" -"\n" -" int linear_id = tid_y * get_global_size(0) + tid_x;\n" -" int result = (linear_id == (int)get_global_linear_id()) ? 0x1 : 0x0;\n" -" dst[linear_id] = result;\n" -"}\n"; - -static const char *global_linear_id_1d_code = -"__kernel void test_global_linear_id_1d(global int *dst)\n" -"{\n" -" int tid_x = get_global_id(0);\n" -"\n" -" int result = (tid_x == (int)get_global_linear_id()) ? 0x1 : 0x0;\n" -" dst[tid_x] = result;\n" -"}\n"; - - -static int -verify_global_linear_id(int *result, int n) +namespace { +const char *global_linear_id_2d_code = R"( +__kernel void test_global_linear_id_2d(global int *dst) { - int i; - for (i=0; i &result, int n) +{ + if (std::any_of(result.begin(), result.begin() + n, + [](cl_int value) { return 0 == value; })) { - if (result[i] == 0) - { - log_error("get_global_linear_id failed\n"); - return -1; - } + log_error("get_global_linear_id failed\n"); + return TEST_FAIL; } log_info("get_global_linear_id passed\n"); - return 0; + return TEST_PASS; +} } - -int -test_global_linear_id(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) +int test_global_linear_id(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) { - cl_mem streams; - cl_program program[2]; - cl_kernel kernel[2]; - - int *output_ptr; - size_t threads[2]; - int err; - num_elements = (int)sqrt((float)num_elements); - int length = num_elements * num_elements; - - output_ptr = (int *)malloc(sizeof(int) * length); - - streams = clCreateBuffer(context, CL_MEM_READ_WRITE, length * sizeof(int), - NULL, &err); - test_error( err, "clCreateBuffer failed."); - - err = create_single_kernel_helper(context, &program[0], &kernel[0], 1, - &global_linear_id_1d_code, - "test_global_linear_id_1d"); - test_error( err, "create_single_kernel_helper failed"); - err = create_single_kernel_helper(context, &program[1], &kernel[1], 1, - &global_linear_id_2d_code, - "test_global_linear_id_2d"); - test_error( err, "create_single_kernel_helper failed"); - - err = clSetKernelArg(kernel[0], 0, sizeof streams, &streams); - test_error( err, "clSetKernelArgs failed."); - err = clSetKernelArg(kernel[1], 0, sizeof streams, &streams); - test_error( err, "clSetKernelArgs failed."); - - threads[0] = (size_t)num_elements; - threads[1] = (size_t)num_elements; - err = clEnqueueNDRangeKernel(queue, kernel[1], 2, NULL, threads, NULL, 0, NULL, NULL); - test_error( err, "clEnqueueNDRangeKernel failed."); - - err = clEnqueueReadBuffer(queue, streams, CL_TRUE, 0, length*sizeof(int), output_ptr, 0, NULL, NULL); - test_error( err, "clEnqueueReadBuffer failed."); - - err = verify_global_linear_id(output_ptr, length); - - threads[0] = (size_t)num_elements; - err = clEnqueueNDRangeKernel(queue, kernel[1], 1, NULL, threads, NULL, 0, NULL, NULL); - test_error( err, "clEnqueueNDRangeKernel failed."); - - err = clEnqueueReadBuffer(queue, streams, CL_TRUE, 0, num_elements*sizeof(int), output_ptr, 0, NULL, NULL); - test_error( err, "clEnqueueReadBuffer failed."); - - err = verify_global_linear_id(output_ptr, num_elements); - - // cleanup - clReleaseMemObject(streams); - clReleaseKernel(kernel[0]); - clReleaseKernel(kernel[1]); - clReleaseProgram(program[0]); - clReleaseProgram(program[1]); - free(output_ptr); + clProgramWrapper program[2]; + clKernelWrapper kernel[2]; + + const char *kernel_names[] = { "test_global_linear_id_1d", + "test_global_linear_id_2d" }; + const char *kernel_code[] = { global_linear_id_1d_code, + global_linear_id_2d_code }; + int err = CL_SUCCESS; + + num_elements = static_cast(sqrt(static_cast(num_elements))); + int length = 1; + size_t threads[] = { static_cast(num_elements), + static_cast(num_elements) }; + + for (int i = 0; i < ARRAY_SIZE(program) && !err; i++) + { + length *= num_elements; + + std::vector output(length); + + clMemWrapper streams = clCreateBuffer( + context, CL_MEM_READ_WRITE, length * sizeof(cl_int), nullptr, &err); + test_error(err, "clCreateBuffer failed."); + + err = create_single_kernel_helper(context, &program[i], &kernel[i], 1, + &kernel_code[i], kernel_names[i]); + test_error(err, "create_single_kernel_helper failed"); + + err = clSetKernelArg(kernel[i], 0, sizeof streams, &streams); + test_error(err, "clSetKernelArgs failed."); + + err = clEnqueueNDRangeKernel(queue, kernel[i], i + 1, nullptr, threads, + nullptr, 0, nullptr, nullptr); + test_error(err, "clEnqueueNDRangeKernel failed."); + + err = clEnqueueReadBuffer(queue, streams, CL_TRUE, 0, + length * sizeof(cl_int), output.data(), 0, + nullptr, nullptr); + test_error(err, "clEnqueueReadBuffer failed."); + + err = verify_global_linear_id(output, length); + } return err; } diff --git a/test_conformance/basic/test_imagearraycopy.cpp b/test_conformance/basic/test_imagearraycopy.cpp index 0ba2ea5234..abd3323614 100644 --- a/test_conformance/basic/test_imagearraycopy.cpp +++ b/test_conformance/basic/test_imagearraycopy.cpp @@ -22,15 +22,22 @@ #include #include #include +#include #include "procs.h" +using test_function_t = int (*)(cl_device_id, cl_context, cl_command_queue, + cl_mem_flags, cl_mem_flags, cl_mem_object_type, + const cl_image_format *); + int test_imagearraycopy_single_format(cl_device_id device, cl_context context, cl_command_queue queue, - cl_mem_flags flags, + cl_mem_flags image_flags, + cl_mem_flags buffer_flags, cl_mem_object_type image_type, const cl_image_format *format) { + std::unique_ptr bufptr, imgptr; clMemWrapper buffer, image; const int img_width = 512; const int img_height = 512; @@ -39,53 +46,63 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context, size_t buffer_size; cl_int err; cl_event copyevent; + RandomSeed seed(gRandomSeed); + + const size_t origin[3] = { 0, 0, 0 }, + region[3] = { img_width, img_height, img_depth }; log_info("Testing %s %s\n", GetChannelOrderName(format->image_channel_order), GetChannelTypeName(format->image_channel_data_type)); + elem_size = get_pixel_size(format); + buffer_size = + sizeof(cl_uchar) * elem_size * img_width * img_height * img_depth; + + if (image_flags & CL_MEM_USE_HOST_PTR || image_flags & CL_MEM_COPY_HOST_PTR) + { + imgptr.reset(static_cast( + create_random_data(kUChar, seed, buffer_size))); + } + + bufptr.reset( + static_cast(create_random_data(kUChar, seed, buffer_size))); + if (CL_MEM_OBJECT_IMAGE2D == image_type) { - image = create_image_2d(context, flags, format, img_width, img_height, - 0, nullptr, &err); + image = create_image_2d(context, image_flags, format, img_width, + img_height, 0, imgptr.get(), &err); } else { - image = create_image_3d(context, flags, format, img_width, img_height, - img_depth, 0, 0, nullptr, &err); + image = + create_image_3d(context, image_flags, format, img_width, img_height, + img_depth, 0, 0, imgptr.get(), &err); } test_error(err, "create_image_xd failed"); - err = clGetImageInfo(image, CL_IMAGE_ELEMENT_SIZE, sizeof(size_t), - &elem_size, nullptr); - test_error(err, "clGetImageInfo failed"); + if (!(image_flags & CL_MEM_USE_HOST_PTR + || image_flags & CL_MEM_COPY_HOST_PTR)) + { + imgptr.reset(static_cast( + create_random_data(kUChar, seed, buffer_size))); - buffer_size = - sizeof(cl_uchar) * elem_size * img_width * img_height * img_depth; + err = clEnqueueWriteImage(queue, image, CL_TRUE, origin, region, 0, 0, + imgptr.get(), 0, nullptr, nullptr); + test_error(err, "clEnqueueWriteImage failed"); + } - buffer = - clCreateBuffer(context, CL_MEM_READ_WRITE, buffer_size, nullptr, &err); + buffer = clCreateBuffer(context, buffer_flags, buffer_size, nullptr, &err); test_error(err, "clCreateBuffer failed"); - - RandomSeed seed(gRandomSeed); - cl_uchar *imgptr = - static_cast(create_random_data(kUChar, seed, buffer_size)); - - const size_t origin[3] = { 0, 0, 0 }, - region[3] = { img_width, img_height, img_depth }; - err = clEnqueueWriteImage(queue, image, CL_TRUE, origin, region, 0, 0, - imgptr, 0, nullptr, nullptr); - test_error(err, "clEnqueueWriteImage failed"); - err = clEnqueueCopyImageToBuffer(queue, image, buffer, origin, region, 0, 0, nullptr, ©event); test_error(err, "clEnqueueCopyImageToBuffer failed"); - cl_uchar *bufptr = static_cast(malloc(buffer_size)); + bufptr.reset(static_cast(malloc(buffer_size))); - err = clEnqueueReadBuffer(queue, buffer, CL_TRUE, 0, buffer_size, bufptr, 1, - ©event, nullptr); + err = clEnqueueReadBuffer(queue, buffer, CL_TRUE, 0, buffer_size, + bufptr.get(), 1, ©event, nullptr); test_error(err, "clEnqueueReadBuffer failed"); err = clReleaseEvent(copyevent); @@ -94,14 +111,14 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context, image_descriptor compareImageInfo = { 0 }; compareImageInfo.format = format; compareImageInfo.width = buffer_size / get_pixel_size(format); - size_t where = compare_scanlines(&compareImageInfo, - reinterpret_cast(imgptr), - reinterpret_cast(bufptr)); + size_t where = compare_scanlines( + &compareImageInfo, reinterpret_cast(imgptr.get()), + reinterpret_cast(bufptr.get())); if (where < compareImageInfo.width) { log_error("ERROR: Results did not validate!\n"); - auto inchar = static_cast(imgptr); - auto outchar = static_cast(bufptr); + auto inchar = static_cast(imgptr.get()); + auto outchar = static_cast(bufptr.get()); int failuresPrinted = 0; for (size_t i = 0; i < buffer_size; i += elem_size) { @@ -125,9 +142,6 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context, err = -1; } - free(imgptr); - free(bufptr); - if (err) log_error( "IMAGE to ARRAY copy test failed for image_channel_order=0x%lx and " @@ -139,33 +153,35 @@ int test_imagearraycopy_single_format(cl_device_id device, cl_context context, } int test_imagearraycommon(cl_device_id device, cl_context context, - cl_command_queue queue, cl_mem_flags flags, - cl_mem_object_type image_type) + cl_command_queue queue, cl_mem_flags image_flags, + cl_mem_flags buffer_flags, + cl_mem_object_type image_type, + test_function_t test_function) { cl_int err; cl_uint num_formats; - err = clGetSupportedImageFormats(context, flags, image_type, 0, nullptr, - &num_formats); + err = clGetSupportedImageFormats(context, image_flags, image_type, 0, + nullptr, &num_formats); test_error(err, "clGetSupportedImageFormats failed"); std::vector formats(num_formats); - err = clGetSupportedImageFormats(context, flags, image_type, num_formats, - formats.data(), nullptr); + err = clGetSupportedImageFormats(context, image_flags, image_type, + num_formats, formats.data(), nullptr); test_error(err, "clGetSupportedImageFormats failed"); for (const auto &format : formats) { - err |= test_imagearraycopy_single_format(device, context, queue, flags, - image_type, &format); + err |= test_function(device, context, queue, image_flags, buffer_flags, + image_type, &format); } if (err) - log_error("ARRAY to IMAGE%s copy test failed\n", + log_error("IMAGE%s to ARRAY copy test failed\n", convert_image_type_to_string(image_type)); else - log_info("ARRAY to IMAGE%s copy test passed\n", + log_info("IMAGE%s to ARRAY copy test passed\n", convert_image_type_to_string(image_type)); return err; @@ -177,7 +193,8 @@ int test_imagearraycopy(cl_device_id device, cl_context context, PASSIVE_REQUIRE_IMAGE_SUPPORT(device) return test_imagearraycommon(device, context, queue, CL_MEM_READ_WRITE, - CL_MEM_OBJECT_IMAGE2D); + CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE2D, + test_imagearraycopy_single_format); } @@ -187,5 +204,6 @@ int test_imagearraycopy3d(cl_device_id device, cl_context context, PASSIVE_REQUIRE_3D_IMAGE_SUPPORT(device) return test_imagearraycommon(device, context, queue, CL_MEM_READ_ONLY, - CL_MEM_OBJECT_IMAGE3D); -} \ No newline at end of file + CL_MEM_READ_WRITE, CL_MEM_OBJECT_IMAGE3D, + test_imagearraycopy_single_format); +} diff --git a/test_conformance/basic/test_preprocessors.cpp b/test_conformance/basic/test_preprocessors.cpp index e67487eb2c..994b62f254 100644 --- a/test_conformance/basic/test_preprocessors.cpp +++ b/test_conformance/basic/test_preprocessors.cpp @@ -217,7 +217,7 @@ int test_kernel_preprocessor_macros(cl_device_id deviceID, cl_context context, c // The OpenCL version reported by the macro reports the feature level supported by the compiler. Since // this doesn't directly match any property we can query, we just check to see if it's a sane value auto device_cl_version = get_device_cl_version(deviceID); - int device_cl_version_int = device_cl_version.to_int() * 10; + int device_cl_version_int = device_cl_version.to_uint() * 10; if ((results[2] < 100) || (results[2] > device_cl_version_int)) { log_error("ERROR: Kernel preprocessor __OPENCL_VERSION__ does not make " @@ -241,14 +241,16 @@ int test_kernel_preprocessor_macros(cl_device_id deviceID, cl_context context, c int cl_c_minor_version = (results[3] / 10) % 10; if ((results[3] < 100) || (!device_supports_cl_c_version( - deviceID, Version{ cl_c_major_version, cl_c_minor_version }))) + deviceID, + Version{ (cl_uint)cl_c_major_version, + (cl_uint)cl_c_minor_version }))) { auto device_version = get_device_cl_c_version(deviceID); log_error( "ERROR: Kernel preprocessor __OPENCL_C_VERSION__ does not make " "sense w.r.t. device's version string! " "(preprocessor states %d, CL_DEVICE_OPENCL_C_VERSION is %d (%s))\n", - results[3], device_version.to_int() * 10, + results[3], device_version.to_uint() * 10, device_version.to_string().c_str()); log_error("This means that CL_DEVICE_OPENCL_C_VERSION < " "__OPENCL_C_VERSION__"); diff --git a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp index 21db20dd8f..b4330e9235 100644 --- a/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/opencl_vulkan_wrapper.cpp @@ -477,12 +477,13 @@ getCLImageInfoFromVkImageInfo(const VkImageCreateInfo *VulkanImageCreateInfo, throw std::runtime_error("get2DImageDimensions failed!!!"); } - img_desc->image_depth = 0; // VulkanImageCreateInfo->extent.depth; + img_desc->image_depth = + static_cast(VulkanImageCreateInfo->extent.depth); img_desc->image_array_size = 0; img_desc->image_row_pitch = 0; // Row pitch set to zero as host_ptr is NULL img_desc->image_slice_pitch = img_desc->image_row_pitch * img_desc->image_height; - img_desc->num_mip_levels = 1; + img_desc->num_mip_levels = 0; img_desc->num_samples = 0; img_desc->buffer = NULL; @@ -606,19 +607,20 @@ clExternalMemory::clExternalMemory( #ifdef _WIN32 log_info("Opaque file descriptors are not supported on Windows\n"); ASSERT(0); -#endif +#else fd = (int)deviceMemory->getHandle(externalMemoryHandleType); err = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); extMemProperties.push_back( (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_FD_KHR); extMemProperties.push_back((cl_mem_properties)fd); +#endif break; case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: #ifndef _WIN32 + log_info("Opaque NT handles are only supported on Windows\n"); ASSERT(0); #else - log_info(" Opaque NT handles are only supported on Windows\n"); handle = deviceMemory->getHandle(externalMemoryHandleType); err = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); @@ -627,11 +629,35 @@ clExternalMemory::clExternalMemory( extMemProperties.push_back((cl_mem_properties)handle); #endif break; - case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME: { #ifndef _WIN32 + log_info("Opaque NT handles are only supported on Windows\n"); ASSERT(0); #else + const std::wstring &name = deviceMemory->getName(); + if (name.size()) + { + err = check_external_memory_handle_type( + devList[0], + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties.push_back((cl_mem_properties)name.c_str()); + } + else + { + throw std::runtime_error("Unsupported operation: import via " + "name but no name provided\n"); + } +#endif + } + break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: +#ifndef _WIN32 log_info("Opaque D3DKMT handles are only supported on Windows\n"); + ASSERT(0); +#else handle = deviceMemory->getHandle(externalMemoryHandleType); err = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); @@ -642,13 +668,13 @@ clExternalMemory::clExternalMemory( #endif break; default: - ASSERT(0); log_error("Unsupported external memory handle type\n"); + ASSERT(0); break; } if (CL_SUCCESS != err) { - throw std::runtime_error("Unsupported external memory type\n "); + throw std::runtime_error("Unsupported external memory type\n"); } extMemProperties.push_back( @@ -663,7 +689,7 @@ clExternalMemory::clExternalMemory( if (CL_SUCCESS != err) { log_error("clCreateBufferWithProperties failed with %d\n", err); - throw std::runtime_error("clCreateBufferWithProperties failed "); + throw std::runtime_error("clCreateBufferWithProperties failed\n"); } } clExternalMemoryImage::clExternalMemoryImage( @@ -676,6 +702,14 @@ clExternalMemoryImage::clExternalMemoryImage( std::vector extMemProperties1; cl_device_id devList[] = { deviceId, NULL }; + VulkanImageTiling vulkanImageTiling = + vkClExternalMemoryHandleTilingAssumption( + deviceId, externalMemoryHandleType, &errcode_ret); + if (CL_SUCCESS != errcode_ret) + { + throw std::runtime_error("Failed to query OpenCL tiling mode"); + } + #ifdef _WIN32 if (!is_extension_available(devList[0], "cl_khr_external_memory_win32")) { @@ -695,7 +729,6 @@ clExternalMemoryImage::clExternalMemoryImage( { #ifdef _WIN32 case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT: - log_info("Opaque NT handles are only supported on Windows\n"); handle = deviceMemory.getHandle(externalMemoryHandleType); errcode_ret = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); @@ -703,8 +736,26 @@ clExternalMemoryImage::clExternalMemoryImage( (cl_mem_properties)CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KHR); extMemProperties1.push_back((cl_mem_properties)handle); break; + case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME: { + const std::wstring &name = deviceMemory.getName(); + if (name.size()) + { + errcode_ret = check_external_memory_handle_type( + devList[0], + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties1.push_back( + (cl_mem_properties) + CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_NAME_KHR); + extMemProperties1.push_back((cl_mem_properties)name.c_str()); + } + else + { + throw std::runtime_error("Unsupported operation: import via " + "name but no name provided\n"); + } + } + break; case VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT: - log_info("Opaque D3DKMT handles are only supported on Windows\n"); handle = deviceMemory.getHandle(externalMemoryHandleType); errcode_ret = check_external_memory_handle_type( devList[0], CL_EXTERNAL_MEMORY_HANDLE_OPAQUE_WIN32_KMT_KHR); @@ -724,14 +775,15 @@ clExternalMemoryImage::clExternalMemoryImage( break; #endif default: - ASSERT(0); log_error("Unsupported external memory handle type\n"); + ASSERT(0); break; } if (CL_SUCCESS != errcode_ret) { - throw std::runtime_error("Unsupported external memory type\n "); + throw std::runtime_error("Unsupported external memory type\n"); } + // Set cl_image_desc size_t clImageFormatSize; cl_image_desc image_desc; @@ -744,7 +796,16 @@ clExternalMemoryImage::clExternalMemoryImage( &VulkanImageCreateInfo, image2D.getSize(), &img_format, &image_desc); if (CL_SUCCESS != errcode_ret) { - throw std::runtime_error("getCLImageInfoFromVkImageInfo failed!!!"); + throw std::runtime_error("getCLImageInfoFromVkImageInfo failed\n"); + } + + // If OpenCL will assume linear, query the Vulkan image's row pitch, + // otherwise it may not match OpenCL's assumption of the row pitch. + if (vulkanImageTiling == VULKAN_IMAGE_TILING_LINEAR) + { + VkSubresourceLayout subresourceLayout = image2D.getSubresourceLayout(); + image_desc.image_row_pitch = subresourceLayout.rowPitch; + image_desc.image_slice_pitch = subresourceLayout.depthPitch; } extMemProperties1.push_back( @@ -758,7 +819,7 @@ clExternalMemoryImage::clExternalMemoryImage( &image_desc, NULL, &errcode_ret); if (CL_SUCCESS != errcode_ret) { - throw std::runtime_error("clCreateImageWithProperties failed!!!"); + throw std::runtime_error("clCreateImageWithProperties failed\n"); } } @@ -806,21 +867,24 @@ clExternalImportableSemaphore::clExternalImportableSemaphore( switch (externalSemaphoreHandleType) { case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD: +#ifdef _WIN32 + log_info("Opaque file descriptors are not supported on Windows\n"); + ASSERT(0); +#else 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 + log_info("Opaque NT handles are only supported on Windows\n"); ASSERT(0); #else - log_info(" Opaque NT handles are only supported on Windows\n"); - handle = semaphore.getName().size() - ? NULL - : semaphore.getHandle(externalSemaphoreHandleType); + handle = semaphore.getHandle(externalSemaphoreHandleType); err = check_external_semaphore_handle_type( devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KHR); sema_props.push_back((cl_semaphore_properties_khr) @@ -828,11 +892,34 @@ clExternalImportableSemaphore::clExternalImportableSemaphore( sema_props.push_back((cl_semaphore_properties_khr)handle); #endif break; + case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME: { +#ifndef _WIN32 + log_info("Opaque NT handles are only supported on Windows\n"); + ASSERT(0); +#else + const std::wstring &name = semaphore.getName(); + if (name.size()) + { + err = check_external_semaphore_handle_type( + devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR); + sema_props.push_back( + (cl_semaphore_properties_khr) + CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_NAME_KHR); + sema_props.push_back((cl_semaphore_properties_khr)name.c_str()); + } + else + { + throw std::runtime_error("Unsupported operation: import via " + "name but no name provided\n"); + } +#endif + } + break; case VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT: #ifndef _WIN32 + log_info("Opaque D3DKMT handles are only supported on Windows\n"); ASSERT(0); #else - log_info(" Opaque D3DKMT handles are only supported on Windows\n"); handle = semaphore.getHandle(externalSemaphoreHandleType); err = check_external_semaphore_handle_type( devList[0], CL_SEMAPHORE_HANDLE_OPAQUE_WIN32_KMT_KHR); @@ -850,8 +937,8 @@ clExternalImportableSemaphore::clExternalImportableSemaphore( sema_props.push_back(static_cast(-1)); break; default: - ASSERT(0); log_error("Unsupported external memory handle type\n"); + ASSERT(0); break; } if (CL_SUCCESS != err) diff --git a/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp b/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp index 412aa0a92d..ab4acb431a 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_api_list.hpp @@ -100,7 +100,8 @@ VK_FUNC_DECL(vkEnumerateDeviceExtensionProperties) \ VK_FUNC_DECL(vkGetPhysicalDeviceSurfaceSupportKHR) \ VK_FUNC_DECL(vkImportSemaphoreFdKHR) \ - VK_FUNC_DECL(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) + VK_FUNC_DECL(vkGetPhysicalDeviceExternalSemaphorePropertiesKHR) \ + VK_FUNC_DECL(vkGetImageSubresourceLayout) #define VK_WINDOWS_FUNC_LIST \ VK_FUNC_DECL(vkGetMemoryWin32HandleKHR) \ VK_FUNC_DECL(vkGetSemaphoreWin32HandleKHR) \ @@ -200,5 +201,6 @@ #define vkGetMemoryWin32HandleKHR _vkGetMemoryWin32HandleKHR #define vkGetSemaphoreWin32HandleKHR _vkGetSemaphoreWin32HandleKHR #define vkImportSemaphoreWin32HandleKHR _vkImportSemaphoreWin32HandleKHR +#define vkGetImageSubresourceLayout _vkGetImageSubresourceLayout #endif //_vulkan_api_list_hpp_ diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp index f694954ef9..1c433a7176 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.cpp @@ -50,7 +50,6 @@ const VulkanPhysicalDevice &getVulkanPhysicalDevice() cl_uint num_devices = 0; cl_uint device_no = 0; const size_t bufsize = BUFFERSIZE; - char buf[BUFFERSIZE]; const VulkanInstance &instance = getVulkanInstance(); const VulkanPhysicalDeviceList &physicalDeviceList = instance.getPhysicalDeviceList(); @@ -753,43 +752,37 @@ std::ostream &operator<<(std::ostream &os, VulkanFormat format) return os; } -static char *findFilePath(const std::string filename) +static std::string findFilePath(const std::string &filename, + const std::string &startdir) { const char *searchPath[] = { - "./", // Same dir - "./shaders/", // In shaders folder in same dir - "../test_conformance/vulkan/shaders/" // In src folder + "/shaders/", // shaders directory, for most builds + "/../shaders/", // one directory up, for multi-config builds }; for (unsigned int i = 0; i < sizeof(searchPath) / sizeof(char *); ++i) { - std::string path(searchPath[i]); + std::string path(startdir); + path += searchPath[i]; + path += filename; - path.append(filename); FILE *fp; fp = fopen(path.c_str(), "rb"); if (fp != NULL) { fclose(fp); - // File found - char *file_path = (char *)(malloc(path.length() + 1)); - strncpy(file_path, path.c_str(), path.length() + 1); - return file_path; - } - if (fp) - { - fclose(fp); + return path; } } // File not found - return 0; + return ""; } -std::vector readFile(const std::string &filename) +std::vector readFile(const std::string &filename, + const std::string &startdir = "") { - char *file_path = findFilePath(filename); - - std::ifstream file(file_path, std::ios::ate | std::ios::binary); + std::string filepath = findFilePath(filename, startdir); + std::ifstream file(filepath, std::ios::ate | std::ios::binary); if (!file.is_open()) { @@ -800,6 +793,6 @@ std::vector readFile(const std::string &filename) file.seekg(0); file.read(buffer.data(), fileSize); file.close(); - printf("filesize is %d", fileSize); + printf("filesize is %zu\n", fileSize); return buffer; } diff --git a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp index b3cc7e44cc..d2f4b7bf91 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_utility.hpp @@ -72,5 +72,6 @@ operator<<(std::ostream& os, VulkanExternalSemaphoreHandleType externalSemaphoreHandleType); std::ostream& operator<<(std::ostream& os, VulkanFormat format); -std::vector readFile(const std::string& filename); +std::vector readFile(const std::string& filename, + const std::string& startdir); #endif // _vulkan_utility_hpp_ diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp index d175ba6fb4..6c31a35d48 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.cpp @@ -137,7 +137,7 @@ VulkanInstance::VulkanInstance(): m_vkInstance(VK_NULL_HANDLE) vkApplicationInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); vkApplicationInfo.pEngineName = "No engine"; vkApplicationInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); - vkApplicationInfo.apiVersion = VK_API_VERSION_1_0; + vkApplicationInfo.apiVersion = VK_API_VERSION_1_1; std::vector enabledExtensionNameList; enabledExtensionNameList.push_back( @@ -1870,6 +1870,16 @@ VulkanExtent3D VulkanImage2D::getExtent3D(uint32_t mipLevel) const return VulkanExtent3D(width, height, depth); } +VkSubresourceLayout VulkanImage2D::getSubresourceLayout() const +{ + VkImageSubresource subresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0 }; + + VkSubresourceLayout subresourceLayout = { 0 }; + vkGetImageSubresourceLayout(m_device, m_vkImage, &subresource, + &subresourceLayout); + return subresourceLayout; +} + ////////////////////////////////// // VulkanImage3D implementation // ////////////////////////////////// @@ -1966,35 +1976,51 @@ class WindowsSecurityAttributes { ~WindowsSecurityAttributes(); }; - WindowsSecurityAttributes::WindowsSecurityAttributes() { +#define CHECK(ok, msg) \ + if (!ok) \ + { \ + throw std::runtime_error(msg); \ + } + + BOOL ok; + HANDLE tokenHandle; + + ok = OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &tokenHandle); + CHECK(ok, "Failed to open process access token"); + + DWORD tokenInformationLength = 0; + GetTokenInformation(tokenHandle, TokenDefaultDacl, NULL, 0, + &tokenInformationLength); + CHECK(tokenInformationLength, + "Failed to retrieve TokenDefaultDacl info buffer length"); + m_winPSecurityDescriptor = (PSECURITY_DESCRIPTOR)calloc( - 1, SECURITY_DESCRIPTOR_MIN_LENGTH + 2 * sizeof(void **)); - // CHECK_NEQ(m_winPSecurityDescriptor, (PSECURITY_DESCRIPTOR)NULL); - PSID *ppSID = (PSID *)((PBYTE)m_winPSecurityDescriptor - + SECURITY_DESCRIPTOR_MIN_LENGTH); - PACL *ppACL = (PACL *)((PBYTE)ppSID + sizeof(PSID *)); - InitializeSecurityDescriptor(m_winPSecurityDescriptor, - SECURITY_DESCRIPTOR_REVISION); - SID_IDENTIFIER_AUTHORITY sidIdentifierAuthority = - SECURITY_WORLD_SID_AUTHORITY; - AllocateAndInitializeSid(&sidIdentifierAuthority, 1, SECURITY_WORLD_RID, 0, - 0, 0, 0, 0, 0, 0, ppSID); - EXPLICIT_ACCESS explicitAccess; - ZeroMemory(&explicitAccess, sizeof(EXPLICIT_ACCESS)); - explicitAccess.grfAccessPermissions = - STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL; - explicitAccess.grfAccessMode = SET_ACCESS; - explicitAccess.grfInheritance = INHERIT_ONLY; - explicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID; - explicitAccess.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; - explicitAccess.Trustee.ptstrName = (LPTSTR)*ppSID; - SetEntriesInAcl(1, &explicitAccess, NULL, ppACL); - SetSecurityDescriptorDacl(m_winPSecurityDescriptor, TRUE, *ppACL, FALSE); + 1, SECURITY_DESCRIPTOR_MIN_LENGTH + tokenInformationLength); + assert(m_winPSecurityDescriptor != (PSECURITY_DESCRIPTOR)NULL); + + TOKEN_DEFAULT_DACL *pTokenDefaultDacl = + reinterpret_cast( + (PBYTE)m_winPSecurityDescriptor + SECURITY_DESCRIPTOR_MIN_LENGTH); + ok = GetTokenInformation(tokenHandle, TokenDefaultDacl, pTokenDefaultDacl, + tokenInformationLength, &tokenInformationLength); + CHECK(ok, "Failed to retrieve TokenDefaultDacl info of access token"); + + ok = InitializeSecurityDescriptor(m_winPSecurityDescriptor, + SECURITY_DESCRIPTOR_REVISION); + CHECK(ok, "Failed to init security descriptor"); + + ok = SetSecurityDescriptorDacl(m_winPSecurityDescriptor, TRUE, + pTokenDefaultDacl->DefaultDacl, FALSE); + CHECK(ok, "Failed to set DACL info for given security descriptor"); + m_winSecurityAttributes.nLength = sizeof(m_winSecurityAttributes); m_winSecurityAttributes.lpSecurityDescriptor = m_winPSecurityDescriptor; m_winSecurityAttributes.bInheritHandle = TRUE; + + CloseHandle(tokenHandle); +#undef CHECK_WIN } SECURITY_ATTRIBUTES *WindowsSecurityAttributes::operator&() @@ -2004,17 +2030,6 @@ SECURITY_ATTRIBUTES *WindowsSecurityAttributes::operator&() WindowsSecurityAttributes::~WindowsSecurityAttributes() { - PSID *ppSID = (PSID *)((PBYTE)m_winPSecurityDescriptor - + SECURITY_DESCRIPTOR_MIN_LENGTH); - PACL *ppACL = (PACL *)((PBYTE)ppSID + sizeof(PSID *)); - if (*ppSID) - { - FreeSid(*ppSID); - } - if (*ppACL) - { - LocalFree(*ppACL); - } free(m_winPSecurityDescriptor); } @@ -2029,8 +2044,9 @@ VulkanDeviceMemory::VulkanDeviceMemory(const VulkanDeviceMemory &deviceMemory) VulkanDeviceMemory::VulkanDeviceMemory( const VulkanDevice &device, uint64_t size, const VulkanMemoryType &memoryType, - VulkanExternalMemoryHandleType externalMemoryHandleType, const void *name) - : m_device(device), m_size(size), m_isDedicated(false) + VulkanExternalMemoryHandleType externalMemoryHandleType, + const std::wstring name) + : m_device(device), m_size(size), m_isDedicated(false), m_name(name) { #if defined(_WIN32) || defined(_WIN64) WindowsSecurityAttributes winSecurityAttributes; @@ -2042,8 +2058,15 @@ VulkanDeviceMemory::VulkanDeviceMemory( vkExportMemoryWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportMemoryWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)name; + vkExportMemoryWin32HandleInfoKHR.name = NULL; + if (externalMemoryHandleType + == VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalMemoryHandleType = + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportMemoryAllocateInfoKHR vkExportMemoryAllocateInfoKHR = {}; @@ -2073,9 +2096,10 @@ VulkanDeviceMemory::VulkanDeviceMemory( VulkanDeviceMemory::VulkanDeviceMemory( const VulkanDevice &device, const VulkanImage &image, const VulkanMemoryType &memoryType, - VulkanExternalMemoryHandleType externalMemoryHandleType, const void *name) + VulkanExternalMemoryHandleType externalMemoryHandleType, + const std::wstring name) : m_device(device), m_size(image.getSize()), - m_isDedicated(image.isDedicated()) + m_isDedicated(image.isDedicated()), m_name(name) { #if defined(_WIN32) || defined(_WIN64) WindowsSecurityAttributes winSecurityAttributes; @@ -2087,8 +2111,15 @@ VulkanDeviceMemory::VulkanDeviceMemory( vkExportMemoryWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportMemoryWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)name; + vkExportMemoryWin32HandleInfoKHR.name = NULL; + if (externalMemoryHandleType + == VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalMemoryHandleType = + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportMemoryAllocateInfoKHR vkExportMemoryAllocateInfoKHR = {}; @@ -2135,9 +2166,10 @@ VulkanDeviceMemory::VulkanDeviceMemory( VulkanDeviceMemory::VulkanDeviceMemory( const VulkanDevice &device, const VulkanBuffer &buffer, const VulkanMemoryType &memoryType, - VulkanExternalMemoryHandleType externalMemoryHandleType, const void *name) + VulkanExternalMemoryHandleType externalMemoryHandleType, + const std::wstring name) : m_device(device), m_size(buffer.getSize()), - m_isDedicated(buffer.isDedicated()) + m_isDedicated(buffer.isDedicated()), m_name(name) { #if defined(_WIN32) || defined(_WIN64) WindowsSecurityAttributes winSecurityAttributes; @@ -2149,8 +2181,15 @@ VulkanDeviceMemory::VulkanDeviceMemory( vkExportMemoryWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportMemoryWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)name; + vkExportMemoryWin32HandleInfoKHR.name = NULL; + if (externalMemoryHandleType + == VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportMemoryWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalMemoryHandleType = + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportMemoryAllocateInfoKHR vkExportMemoryAllocateInfoKHR = {}; @@ -2281,6 +2320,8 @@ void VulkanDeviceMemory::bindImage(const VulkanImage &image, uint64_t offset) vkBindImageMemory(m_device, image, m_vkDeviceMemory, offset); } +const std::wstring &VulkanDeviceMemory::getName() const { return m_name; } + VulkanDeviceMemory::operator VkDeviceMemory() const { return m_vkDeviceMemory; } //////////////////////////////////// @@ -2308,8 +2349,15 @@ VulkanSemaphore::VulkanSemaphore( vkExportSemaphoreWin32HandleInfoKHR.pAttributes = &winSecurityAttributes; vkExportSemaphoreWin32HandleInfoKHR.dwAccess = DXGI_SHARED_RESOURCE_READ | DXGI_SHARED_RESOURCE_WRITE; - vkExportSemaphoreWin32HandleInfoKHR.name = - m_name.size() ? (LPCWSTR)m_name.c_str() : NULL; + vkExportSemaphoreWin32HandleInfoKHR.name = NULL; + + if (externalSemaphoreHandleType + == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME) + { + vkExportSemaphoreWin32HandleInfoKHR.name = (LPCWSTR)m_name.c_str(); + externalSemaphoreHandleType = + VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT; + } #endif VkExportSemaphoreCreateInfoKHR vkExportSemaphoreCreateInfoKHR = {}; diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp index f9f547b829..b528f4aade 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper.hpp @@ -22,6 +22,7 @@ #include "vulkan_list_map.hpp" #include "vulkan_api_list.hpp" #include +#include class VulkanInstance { friend const VulkanInstance &getVulkanInstance(); @@ -552,6 +553,7 @@ class VulkanImage2D : public VulkanImage { VulkanSharingMode sharingMode = VULKAN_SHARING_MODE_EXCLUSIVE); virtual ~VulkanImage2D(); virtual VulkanExtent3D getExtent3D(uint32_t mipLevel = 0) const; + virtual VkSubresourceLayout getSubresourceLayout() const; VulkanImage2D(const VulkanImage2D &image2D); }; @@ -580,7 +582,7 @@ class VulkanDeviceMemory { VkDeviceMemory m_vkDeviceMemory; uint64_t m_size; bool m_isDedicated; - + const std::wstring m_name; VulkanDeviceMemory(const VulkanDeviceMemory &deviceMemory); @@ -589,17 +591,17 @@ class VulkanDeviceMemory { const VulkanMemoryType &memoryType, VulkanExternalMemoryHandleType externalMemoryHandleType = VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE, - const void *name = NULL); + const std::wstring name = L""); VulkanDeviceMemory(const VulkanDevice &device, const VulkanImage &image, const VulkanMemoryType &memoryType, VulkanExternalMemoryHandleType externalMemoryHandleType = VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE, - const void *name = NULL); + const std::wstring name = L""); VulkanDeviceMemory(const VulkanDevice &device, const VulkanBuffer &buffer, const VulkanMemoryType &memoryType, VulkanExternalMemoryHandleType externalMemoryHandleType = VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_NONE, - const void *name = NULL); + const std::wstring name = L""); virtual ~VulkanDeviceMemory(); uint64_t getSize() const; #ifdef _WIN32 @@ -614,6 +616,7 @@ class VulkanDeviceMemory { void unmap(); void bindBuffer(const VulkanBuffer &buffer, uint64_t offset = 0); void bindImage(const VulkanImage &image, uint64_t offset = 0); + const std::wstring &getName() const; operator VkDeviceMemory() const; }; diff --git a/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp b/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp index 5164ade5cc..4180e12b60 100644 --- a/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp +++ b/test_conformance/common/vulkan_wrapper/vulkan_wrapper_types.hpp @@ -22,6 +22,7 @@ #define VULKAN_MIN_BUFFER_OFFSET_COPY_ALIGNMENT 4 #define VULKAN_REMAINING_MIP_LEVELS VK_REMAINING_MIP_LEVELS #define VULKAN_REMAINING_ARRAY_LAYERS VK_REMAINING_ARRAY_LAYERS +#define VULKAN_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME_BIT 0x10000000 class VulkanInstance; class VulkanPhysicalDevice; @@ -159,7 +160,9 @@ enum VulkanExternalMemoryHandleType VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR, VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_KMT = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR - | VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR + | VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR, + VULKAN_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME = + VULKAN_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME_BIT }; enum VulkanExternalSemaphoreHandleType @@ -172,7 +175,9 @@ enum VulkanExternalSemaphoreHandleType VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR, VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD = - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR, + VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME = + VULKAN_HANDLE_TYPE_OPAQUE_WIN32_NT_NAME_BIT }; enum VulkanBufferUsage diff --git a/test_conformance/compiler/main.cpp b/test_conformance/compiler/main.cpp index f0a9ef3a13..e31300c83b 100644 --- a/test_conformance/compiler/main.cpp +++ b/test_conformance/compiler/main.cpp @@ -91,6 +91,8 @@ test_definition test_list[] = { ADD_TEST_VERSION(pragma_unroll, Version(2, 0)), ADD_TEST_VERSION(features_macro, Version(3, 0)), + ADD_TEST(features_macro_coupling), + ADD_TEST(unload_valid), // ADD_TEST(unload_invalid), // disabling temporarily, see GitHub #977 ADD_TEST(unload_repeated), diff --git a/test_conformance/compiler/procs.h b/test_conformance/compiler/procs.h index 10ae142b88..4a425ffe79 100644 --- a/test_conformance/compiler/procs.h +++ b/test_conformance/compiler/procs.h @@ -235,6 +235,10 @@ extern int test_pragma_unroll(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); extern int test_features_macro(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); +extern int test_features_macro_coupling(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); extern int test_unload_valid(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); extern int test_unload_invalid(cl_device_id deviceID, cl_context context, diff --git a/test_conformance/compiler/test_compiler_defines_for_extensions.cpp b/test_conformance/compiler/test_compiler_defines_for_extensions.cpp index ffd0d6a099..4a6545b6c2 100644 --- a/test_conformance/compiler/test_compiler_defines_for_extensions.cpp +++ b/test_conformance/compiler/test_compiler_defines_for_extensions.cpp @@ -20,6 +20,7 @@ #include #endif +// clang-format off // List should follow order in the extension spec const char *known_extensions[] = { "cl_khr_byte_addressable_store", @@ -92,7 +93,9 @@ const char *known_extensions[] = { "cl_khr_external_memory_dma_buf", "cl_khr_command_buffer", "cl_khr_command_buffer_mutable_dispatch", + "cl_khr_command_buffer_multi_device" }; +// clang-format on size_t num_known_extensions = ARRAY_SIZE(known_extensions); size_t first_API_extension = 32; diff --git a/test_conformance/compiler/test_feature_macro.cpp b/test_conformance/compiler/test_feature_macro.cpp index 7858c3c25f..2f973eec2c 100644 --- a/test_conformance/compiler/test_feature_macro.cpp +++ b/test_conformance/compiler/test_feature_macro.cpp @@ -17,6 +17,7 @@ #include #include #include "errorHelpers.h" +#include "harness/featureHelpers.h" const char* macro_supported_source = R"(kernel void enabled(global int * buf) { int n = get_global_id(0); @@ -833,3 +834,56 @@ int test_features_macro(cl_device_id deviceID, cl_context context, return error; } + +// This test checks that a supported feature comes with other required features +int test_features_macro_coupling(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) +{ + OpenCLCFeatures features; + int error = get_device_cl_c_features(deviceID, features); + if (error) + { + log_error("Couldn't query OpenCL C features for the device!\n"); + return TEST_FAIL; + } + + if (features.supports__opencl_c_3d_image_writes + && !features.supports__opencl_c_images) + { + log_error("OpenCL C compilers that define the feature macro " + "__opencl_c_3d_image_writes must also define the feature " + "macro __opencl_c_images!\n"); + return TEST_FAIL; + } + + if (features.supports__opencl_c_device_enqueue + && !(features.supports__opencl_c_program_scope_global_variables + && features.supports__opencl_c_generic_address_space)) + { + log_error("OpenCL C compilers that define the feature macro " + "__opencl_c_device_enqueue must also define " + "__opencl_c_generic_address_space and " + "__opencl_c_program_scope_global_variables!\n"); + return TEST_FAIL; + } + + if (features.supports__opencl_c_pipes + && !features.supports__opencl_c_generic_address_space) + { + log_error("OpenCL C compilers that define the feature macro " + "__opencl_c_pipes must also define the feature macro " + "__opencl_c_generic_address_space!\n"); + return TEST_FAIL; + } + + if (features.supports__opencl_c_read_write_images + && !features.supports__opencl_c_images) + { + log_error("OpenCL C compilers that define the feature macro " + "__opencl_c_read_write_images must also define the feature " + "macro __opencl_c_images!\n"); + return TEST_FAIL; + } + + return TEST_PASS; +} diff --git a/test_conformance/compiler/test_preprocessor.cpp b/test_conformance/compiler/test_preprocessor.cpp index 7308950aee..3c5c2045ea 100644 --- a/test_conformance/compiler/test_preprocessor.cpp +++ b/test_conformance/compiler/test_preprocessor.cpp @@ -89,7 +89,7 @@ int test_preprocessor_define_udef(cl_device_id deviceID, cl_context context, cl_ error = clEnqueueWriteBuffer(queue, buffer[0], CL_TRUE, 0, num_elements*sizeof(cl_int), srcData, 0, NULL, NULL); test_error(error, "clEnqueueWriteBuffer failed"); - size_t threads[3] = {num_elements, 0, 0}; + size_t threads[3] = { (size_t)num_elements, 0, 0 }; error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL); test_error(error, "clEnqueueNDRangeKernel failed"); @@ -175,7 +175,7 @@ int test_preprocessor_include(cl_device_id deviceID, cl_context context, cl_comm error = clSetKernelArg(kernel, 1, sizeof(buffer[1]), &buffer[1]); test_error(error, "clSetKernelArg failed"); - size_t threads[3] = {num_elements, 0, 0}; + size_t threads[3] = { (size_t)num_elements, 0, 0 }; error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL); test_error(error, "clEnqueueNDRangeKernel failed"); @@ -272,7 +272,7 @@ int test_preprocessor_line_error(cl_device_id deviceID, cl_context context, cl_c error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]); test_error(error, "clSetKernelArg failed"); - size_t threads[3] = {num_elements, 0, 0}; + size_t threads[3] = { (size_t)num_elements, 0, 0 }; error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL); test_error(error, "clEnqueueNDRangeKernel failed"); @@ -313,7 +313,7 @@ int test_preprocessor_pragma(cl_device_id deviceID, cl_context context, cl_comma error = clSetKernelArg(kernel, 0, sizeof(buffer[0]), &buffer[0]); test_error(error, "clSetKernelArg failed"); - size_t threads[3] = {num_elements, 0, 0}; + size_t threads[3] = { (size_t)num_elements, 0, 0 }; error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads, NULL, 0, NULL, NULL); test_error(error, "clEnqueueNDRangeKernel failed"); diff --git a/test_conformance/computeinfo/main.cpp b/test_conformance/computeinfo/main.cpp index 478f19f4b9..3f0551687e 100644 --- a/test_conformance/computeinfo/main.cpp +++ b/test_conformance/computeinfo/main.cpp @@ -35,11 +35,11 @@ typedef struct } device_info; device_info device_infos[] = { - { CL_DEVICE_TYPE_DEFAULT, "CL_DEVICE_TYPE_DEFAULT", -1, NULL }, - { CL_DEVICE_TYPE_CPU, "CL_DEVICE_TYPE_CPU", -1, NULL }, - { CL_DEVICE_TYPE_GPU, "CL_DEVICE_TYPE_GPU", -1, NULL }, - { CL_DEVICE_TYPE_ACCELERATOR, "CL_DEVICE_TYPE_ACCELERATOR", -1, NULL }, - { CL_DEVICE_TYPE_ALL, "CL_DEVICE_TYPE_ALL", -1, NULL }, + { CL_DEVICE_TYPE_DEFAULT, "CL_DEVICE_TYPE_DEFAULT", 0, NULL }, + { CL_DEVICE_TYPE_CPU, "CL_DEVICE_TYPE_CPU", 0, NULL }, + { CL_DEVICE_TYPE_GPU, "CL_DEVICE_TYPE_GPU", 0, NULL }, + { CL_DEVICE_TYPE_ACCELERATOR, "CL_DEVICE_TYPE_ACCELERATOR", 0, NULL }, + { CL_DEVICE_TYPE_ALL, "CL_DEVICE_TYPE_ALL", 0, NULL }, }; // config types diff --git a/test_conformance/conversions/CMakeLists.txt b/test_conformance/conversions/CMakeLists.txt index e2e9766725..32990ebae4 100644 --- a/test_conformance/conversions/CMakeLists.txt +++ b/test_conformance/conversions/CMakeLists.txt @@ -1,5 +1,9 @@ set(MODULE_NAME CONVERSIONS) +if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") + add_cxx_flag_if_supported(-Wno-narrowing) +endif() + set (${MODULE_NAME}_SOURCES Sleep.cpp test_conversions.cpp basic_test_conversions.cpp ) diff --git a/test_conformance/conversions/basic_test_conversions.cpp b/test_conformance/conversions/basic_test_conversions.cpp index dcfe513ed9..3880c820c4 100644 --- a/test_conformance/conversions/basic_test_conversions.cpp +++ b/test_conformance/conversions/basic_test_conversions.cpp @@ -1540,7 +1540,11 @@ cl_program MakeProgram(Type outType, Type inType, SaturationMode sat, *outKernel = NULL; const char *flags = NULL; - if (gForceFTZ || gForceHalfFTZ) flags = "-cl-denorms-are-zero"; + if ((gForceFTZ && (inType == kfloat || outType == kfloat)) + || (gForceHalfFTZ && (inType == khalf || outType == khalf))) + { + flags = "-cl-denorms-are-zero"; + } // build it std::string sourceString = source.str(); diff --git a/test_conformance/device_execution/execute_block.cpp b/test_conformance/device_execution/execute_block.cpp index 5b7ee2f1c4..bd876113eb 100644 --- a/test_conformance/device_execution/execute_block.cpp +++ b/test_conformance/device_execution/execute_block.cpp @@ -1016,7 +1016,7 @@ int test_execute_block(cl_device_id device, cl_context context, cl_command_queue size_t ret_len; cl_int n, err_ret, res = 0; clCommandQueueWrapper dev_queue; - cl_int kernel_results[MAX_GWS] = {0xDEADBEEF}; + cl_int kernel_results[MAX_GWS] = { (cl_int)0xDEADBEEF }; size_t max_local_size = 1; err_ret = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(max_local_size), &max_local_size, &ret_len); diff --git a/test_conformance/device_partition/test_device_partition.cpp b/test_conformance/device_partition/test_device_partition.cpp index cb53605ab1..e6db2e5afb 100644 --- a/test_conformance/device_partition/test_device_partition.cpp +++ b/test_conformance/device_partition/test_device_partition.cpp @@ -353,7 +353,8 @@ int test_device_set(size_t deviceCount, size_t queueCount, cl_device_id *devices } -int init_device_partition_test(cl_device_id parentDevice, cl_uint &maxComputeUnits, cl_uint &maxSubDevices) +int init_device_partition_test(cl_device_id parentDevice, + cl_uint &maxComputeUnits, cl_uint &maxSubDevices) { int err = clGetDeviceInfo(parentDevice, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(maxComputeUnits), &maxComputeUnits, NULL); test_error( err, "Unable to get maximal number of compute units" ); @@ -440,23 +441,33 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma properties_returned[1] == CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE || properties_returned[1] == CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE || properties_returned[1] == CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE))) { - log_error("properties_returned[%d] 0x%x != 0x%x partition_type[%d].", i, properties_returned[i], partition_type[i], i); - return -1; - } + log_error( + "properties_returned[%d] 0x%x != 0x%x partition_type[%d].", i, + static_cast(properties_returned[i]), + static_cast(partition_type[i]), i); + return -1; + } } } // for } #define PROPERTY_TYPES 8 cl_device_partition_property partitionProp[PROPERTY_TYPES][5] = { - { CL_DEVICE_PARTITION_EQUALLY, maxComputeUnits / 2, 0, 0, 0 } , - { CL_DEVICE_PARTITION_BY_COUNTS, 1, maxComputeUnits - 1, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 } , - { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_NUMA, 0, 0, 0 } , - { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE, 0, 0, 0 } , - { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE, 0, 0, 0 } , - { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE, 0, 0, 0 } , - { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE, 0, 0, 0 } , - { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 } + { CL_DEVICE_PARTITION_EQUALLY, (cl_int)maxComputeUnits / 2, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_COUNTS, 1, (cl_int)maxComputeUnits - 1, + CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_NUMA, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE, 0, 0, 0 }, + { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, + CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE, 0, 0, 0 } }; // loop thru each type, creating sub-devices for each type @@ -485,8 +496,10 @@ int test_partition_of_device(cl_device_id deviceID, cl_context context, cl_comma } else { - log_info("Testing on device %p partition type \"%s\" (%d,%d)\n", deviceID, printPartition(partitionProp[i][0]), - partitionProp[i][1], partitionProp[i][2]); + log_info("Testing on device %p partition type \"%s\" (%d,%d)\n", + deviceID, printPartition(partitionProp[i][0]), + static_cast(partitionProp[i][1]), + static_cast(partitionProp[i][2])); } cl_uint deviceCount; diff --git a/test_conformance/device_timer/main.cpp b/test_conformance/device_timer/main.cpp index 1c460af89f..adcb6ffc8e 100644 --- a/test_conformance/device_timer/main.cpp +++ b/test_conformance/device_timer/main.cpp @@ -23,13 +23,6 @@ #include #endif -#include "procs.h" - -test_definition test_list[] = { - ADD_TEST( timer_resolution_queries ), - ADD_TEST( device_and_host_timers ), -}; - test_status InitCL(cl_device_id device) { auto version = get_device_cl_version(device); @@ -70,11 +63,10 @@ test_status InitCL(cl_device_id device) return TEST_PASS; } - -const int test_num = ARRAY_SIZE( test_list ); - int main(int argc, const char *argv[]) { - return runTestHarnessWithCheck( argc, argv, test_num, test_list, false, 0, InitCL ); + return runTestHarnessWithCheck( + argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0, InitCL); } diff --git a/test_conformance/device_timer/procs.h b/test_conformance/device_timer/procs.h deleted file mode 100644 index 8157ec7f59..0000000000 --- a/test_conformance/device_timer/procs.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) 2017 The Khronos Group Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -#ifndef __PROCS_H__ -#define __PROCS_H__ - -extern int test_device_and_host_timers(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); - -extern int test_timer_resolution_queries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); -#endif // #ifndef __PROCS_H__ diff --git a/test_conformance/device_timer/test_device_timer.cpp b/test_conformance/device_timer/test_device_timer.cpp index c5943fadc6..88bd9a3caa 100644 --- a/test_conformance/device_timer/test_device_timer.cpp +++ b/test_conformance/device_timer/test_device_timer.cpp @@ -17,6 +17,7 @@ #include #include "harness/errorHelpers.h" #include "harness/compat.h" +#include "harness/testHarness.h" #if !defined(_WIN32) #include "unistd.h" // For "sleep" @@ -24,7 +25,7 @@ #define ALLOWED_ERROR 0.005f -int test_device_and_host_timers(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(device_and_host_timers) { int errors = 0; cl_int result = CL_SUCCESS; @@ -124,7 +125,7 @@ int test_device_and_host_timers(cl_device_id deviceID, cl_context context, cl_co return errors; } -int test_timer_resolution_queries(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) +REGISTER_TEST(timer_resolution_queries) { int errors = 0; cl_int result = CL_SUCCESS; diff --git a/test_conformance/events/test_event_dependencies.cpp b/test_conformance/events/test_event_dependencies.cpp index 3cc183bd82..b40a69dd81 100644 --- a/test_conformance/events/test_event_dependencies.cpp +++ b/test_conformance/events/test_event_dependencies.cpp @@ -32,7 +32,7 @@ const char *write_kernels[] = { }; #define TEST_SIZE 10000 -#define TEST_COUNT 100 +#define TEST_COUNT 10 #define RANDOMIZE 1 #define DEBUG_OUT 0 @@ -447,6 +447,14 @@ int test_event_enqueue_wait_for_events_run_test( test_error(error, "clEnqueueReadBuffer failed"); + error = clFinish(queues[0]); + test_error(error, "clFinish(queues[0]) failed"); + if (two_queues) + { + error = clFinish(queues[1]); + test_error(error, "clFinish(queues[1]) failed"); + } + failed = 0; for (i = 0; i < (int)TEST_SIZE; i++) if (values[i] != expected_value) diff --git a/test_conformance/events/test_userevents.cpp b/test_conformance/events/test_userevents.cpp index 1fdb4ea46f..b716b5c7b0 100644 --- a/test_conformance/events/test_userevents.cpp +++ b/test_conformance/events/test_userevents.cpp @@ -28,18 +28,6 @@ /////////////////////////////////////////////////////////////////////////////// // CL error checking. -#if defined(_MSC_VER) -#define CL_EXIT_ERROR(cmd, ...) \ - { \ - if ((cmd) != CL_SUCCESS) \ - { \ - log_error("CL ERROR: %s %u: ", __FILE__, __LINE__); \ - log_error(##__VA_ARGS__); \ - log_error("\n"); \ - return -1; \ - } \ - } -#else #define CL_EXIT_ERROR(cmd, format, ...) \ { \ if ((cmd) != CL_SUCCESS) \ @@ -50,7 +38,6 @@ return -1; \ } \ } -#endif #define CL_EXIT_BUILD_ERROR(cmd, program, format, ...) \ { \ diff --git a/test_conformance/extensions/CMakeLists.txt b/test_conformance/extensions/CMakeLists.txt index 77aa2f18eb..e0e790c235 100644 --- a/test_conformance/extensions/CMakeLists.txt +++ b/test_conformance/extensions/CMakeLists.txt @@ -1,3 +1,7 @@ +# Note: Each extension adds its own test executable to the build. When +# creating tests for a new extension ensure to update the +# `opencl_conformance_tests_*.csv` files with the path to the new binary so +# that the extension tests are included in conformance test runs. add_subdirectory( cl_ext_cxx_for_opencl ) add_subdirectory( cl_khr_command_buffer ) add_subdirectory( cl_khr_dx9_media_sharing ) diff --git a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp index b3e0a93e74..97dcb9da41 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.cpp @@ -70,6 +70,9 @@ bool BasicCommandBufferTest::Skip() != 0; out_of_order_support = capabilities & CL_COMMAND_BUFFER_CAPABILITY_OUT_OF_ORDER_KHR; + device_side_enqueue_support = + (capabilities & CL_COMMAND_BUFFER_CAPABILITY_DEVICE_SIDE_ENQUEUE_KHR) + != 0; // Skip if queue properties don't contain those required return required_properties != (required_properties & queue_properties); @@ -177,6 +180,71 @@ cl_int BasicCommandBufferTest::SetUp(int elements) namespace { +// Test that the CL_COMMAND_BUFFER_FLAGS_KHR bitfield is parsed correctly when +// multiple flags are set. +struct MultiFlagCreationTest : public BasicCommandBufferTest +{ + using BasicCommandBufferTest::BasicCommandBufferTest; + + cl_int Run() override + { + cl_command_buffer_properties_khr flags = 0; + size_t num_flags_set = 0; + bool multi_flags_supported = true; + cl_int error = CL_SUCCESS; + + // First try to find multiple flags that are supported by the driver and + // device. + if (simultaneous_use_support) + { + flags |= CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR; + num_flags_set++; + } + + if (device_side_enqueue_support) + { + flags |= CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR; + num_flags_set++; + } + + if (is_extension_available( + device, CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_NAME)) + { + flags |= CL_COMMAND_BUFFER_MUTABLE_KHR; + num_flags_set++; + } + + // If we can't find multiple supported flags, still set a bitfield but + // expect CL_INVALID_PROPERTY to be returned on creation. + if (num_flags_set < 2) + { + flags = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR + | CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR; + + multi_flags_supported = false; + } + + cl_command_buffer_properties_khr props[] = { + CL_COMMAND_BUFFER_FLAGS_KHR, flags, 0 + }; + + command_buffer = clCreateCommandBufferKHR(1, &queue, props, &error); + if (multi_flags_supported) + { + test_error(error, "clCreateCommandBufferKHR failed"); + } + else + { + test_failure_error_ret( + error, CL_INVALID_PROPERTY, + "clCreateCommandBufferKHR should return CL_INVALID_PROPERTY", + TEST_FAIL); + } + + return CL_SUCCESS; + } +}; + // Test enqueuing a command-buffer containing a single NDRange command once struct BasicEnqueueTest : public BasicCommandBufferTest { @@ -421,6 +489,13 @@ struct InterleavedEnqueueTest : public BasicCommandBufferTest } // anonymous namespace +int test_multi_flag_creation(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + return MakeAndRunTest(device, context, queue, + num_elements); +} + int test_single_ndrange(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { diff --git a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h index 3981427c0c..efe5bb14fd 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h +++ b/test_conformance/extensions/cl_khr_command_buffer/basic_command_buffer.h @@ -75,6 +75,7 @@ struct BasicCommandBufferTest : CommandBufferTestBase // Device support query results bool simultaneous_use_support; bool out_of_order_support; + bool device_side_enqueue_support; // user request for simultaneous use bool simultaneous_use_requested; 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 d614725786..e31205ee97 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 @@ -772,6 +772,7 @@ struct MutableDispatchSVMArguments : public MutableDispatchArgumentsTest exec_info.param_value = &new_buffer; cl_mutable_dispatch_config_khr dispatch_config{}; + dispatch_config.command = command; dispatch_config.num_svm_args = 1; dispatch_config.arg_svm_list = &arg_svm; dispatch_config.num_exec_infos = 1; diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp index 753cc3be06..ebf30a00fe 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_full_dispatch.cpp @@ -100,22 +100,18 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest if ((available_caps & CL_MUTABLE_DISPATCH_EXEC_INFO_KHR) == 0) { - error = create_single_kernel_helper_create_program( - context, &program, 1, &kernel_str_no_svm); + error = create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str_no_svm, + "full_dispatch"); } else { - error = create_single_kernel_helper_create_program( - context, &program, 1, &kernel_str_svm); + error = + create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str_svm, "full_dispatch"); } test_error(error, "Failed to create program with source"); - error = clBuildProgram(program, 1, &device, nullptr, nullptr, nullptr); - test_error(error, "Failed to build program"); - - kernel = clCreateKernel(program, "full_dispatch", &error); - test_error(error, "Failed to create copy kernel"); - return CL_SUCCESS; } @@ -241,6 +237,9 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest error = clEnqueueSVMUnmap(queue, buf, 0, nullptr, nullptr); test_error(error, "clEnqueueSVMUnmap failed for svm buffer"); + error = clFinish(queue); + test_error(error, "clFinish failed"); + return res; } @@ -300,6 +299,11 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest }; size_t work_offset = 0; + /* Round the global work size up to nearest multiple of the local work + * size to ensure work group uniformity. */ + num_elements = + ((num_elements + group_size - 1) / group_size) * group_size; + cl_int error = clCommandNDRangeKernelKHR( command_buffer, nullptr, props, kernel, 1, &work_offset, &num_elements, &group_size, 0, nullptr, nullptr, &command); @@ -381,18 +385,23 @@ struct MutableCommandFullDispatch : InfoMutableCommandBufferTest dispatch_config.global_work_offset = &work_offset; } - if ((available_caps & CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR) != 0) - { - num_elements /= 2; - dispatch_config.global_work_size = &num_elements; - } - if ((available_caps & CL_MUTABLE_DISPATCH_LOCAL_SIZE_KHR) != 0) { group_size /= 2; dispatch_config.local_work_size = &group_size; } + if ((available_caps & CL_MUTABLE_DISPATCH_GLOBAL_SIZE_KHR) != 0) + { + num_elements /= 2; + /* Round the global work size up to nearest multiple of the local + * work size to ensure work group uniformity. */ + num_elements = + ((num_elements + group_size - 1) / group_size) * group_size; + + dispatch_config.global_work_size = &num_elements; + } + cl_uint num_configs = 1; cl_command_buffer_update_type_khr config_types[1] = { CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_simultaneous.cpp b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_simultaneous.cpp index f6a407a522..9f0d806b9d 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_simultaneous.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_simultaneous.cpp @@ -243,7 +243,7 @@ struct SimultaneousMutableDispatchTest : public BasicMutableCommandBufferTest CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR }; const void* configs[1] = { &dispatch_config }; - error = clUpdateMutableCommandsKHR(command_buffer, num_configs, + error = clUpdateMutableCommandsKHR(work_command_buffer, num_configs, config_types, configs); test_error(error, "clUpdateMutableCommandsKHR failed"); @@ -361,7 +361,7 @@ struct SimultaneousMutableDispatchTest : public BasicMutableCommandBufferTest CL_STRUCTURE_TYPE_MUTABLE_DISPATCH_CONFIG_KHR }; const void* configs[1] = { &dispatch_config }; - error = clUpdateMutableCommandsKHR(command_buffer, num_configs, + error = clUpdateMutableCommandsKHR(work_command_buffer, num_configs, config_types, configs); test_error(error, "clUpdateMutableCommandsKHR failed"); diff --git a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_work_groups.cpp b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_work_groups.cpp index aaf0caa4a8..ad20fbe3b2 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_work_groups.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/mutable_command_work_groups.cpp @@ -82,14 +82,42 @@ struct MutableDispatchWorkGroups : public BasicMutableCommandBufferTest || BasicMutableCommandBufferTest::Skip(); } + cl_int SetUpKernel() override + { + // Create kernel + const char *num_groups_kernel = + R"( + __kernel void sample_test(__global int *dst) + { + size_t tid = get_global_id(0); + dst[tid] = get_num_groups(0); + })"; + + cl_int error = create_single_kernel_helper( + context, &program, &kernel, 1, &num_groups_kernel, "sample_test"); + test_error(error, "Creating kernel failed"); + + return CL_SUCCESS; + } + + cl_int SetUpKernelArgs() override + { + cl_int error = CL_SUCCESS; + stream = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeToAllocate, + nullptr, &error); + test_error(error, "Creating src buffer"); + + error = clSetKernelArg(kernel, 0, sizeof(cl_mem), &stream); + test_error(error, "Unable to set indexed kernel arguments"); + + return CL_SUCCESS; + } + cl_int SetUp(int elements) override { cl_int error = BasicMutableCommandBufferTest::SetUp(elements); test_error(error, "BasicMutableCommandBufferTest::SetUp failed"); - error = SetUpKernel(); - test_error(error, "SetUpKernel failed"); - cl_command_buffer_properties_khr properties[5]; int index = 0; properties[index++] = CL_COMMAND_BUFFER_FLAGS_KHR; @@ -110,23 +138,7 @@ struct MutableDispatchWorkGroups : public BasicMutableCommandBufferTest cl_int Run() override { - const char *num_groups_kernel = - R"( - __kernel void sample_test(__global int *dst) - { - size_t tid = get_global_id(0); - dst[tid] = get_num_groups(0); - })"; - cl_int error = create_single_kernel_helper( - context, &program, &kernel, 1, &num_groups_kernel, "sample_test"); - test_error(error, "Creating kernel failed"); - - clMemWrapper stream = clCreateBuffer(context, CL_MEM_READ_WRITE, - sizeToAllocate, nullptr, &error); - - error = clSetKernelArg(kernel, 0, sizeof(cl_mem), &stream); - test_error(error, "Unable to set indexed kernel arguments"); - + cl_int error = CL_SUCCESS; // Record an ND-range kernel of the kernel above in the command buffer // with a non-null local work size so that the resulting number of // workgroups will be greater than 1. @@ -262,6 +274,7 @@ struct MutableDispatchWorkGroups : public BasicMutableCommandBufferTest clCommandBufferWrapper single_command_buffer; cl_mutable_command_khr command = nullptr; + clMemWrapper stream; Configuration config; size_t info_global_size = 0; diff --git a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp index 6ef26bb9fa..81f68cd4be 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_event_sync.cpp @@ -18,6 +18,8 @@ #include "procs.h" #include +#include +#include //-------------------------------------------------------------------------- enum class EventMode @@ -416,6 +418,12 @@ struct CommandBufferEventSync : public BasicCommandBufferTest error = clFinish(queue); test_error(error, "clFinish failed"); + for (unsigned i = 0; i < 30; ++i) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + if (confirmation) break; + } + // verify the result if (!confirmation) { @@ -575,7 +583,7 @@ struct CommandBufferEventSync : public BasicCommandBufferTest // process secondary queue error = - clEnqueueFillBuffer(queue_sec, in_mem, &pattern_pri, sizeof(cl_int), + clEnqueueFillBuffer(queue_sec, in_mem, &pattern_sec, sizeof(cl_int), 0, data_size(), 0, nullptr, nullptr); test_error(error, "clEnqueueFillBuffer failed"); @@ -585,8 +593,9 @@ struct CommandBufferEventSync : public BasicCommandBufferTest "clEnqueueCommandBufferKHR in secondary queue failed"); // process primary queue - error = clEnqueueFillBuffer(queue, in_mem, &pattern_pri, sizeof(cl_int), - 0, data_size(), 0, nullptr, event_ptrs[0]); + error = + clEnqueueFillBuffer(queue, in_mem, &pattern_pri, sizeof(cl_int), 0, + data_size(), 1, &test_event, event_ptrs[0]); test_error(error, "clEnqueueFillBuffer failed"); cl_event wait_list[] = { test_event, @@ -763,6 +772,12 @@ struct CommandBufferEventSync : public BasicCommandBufferTest error = clFinish(queue); test_error(error, "clFinish failed"); + for (unsigned i = 0; i < 30; ++i) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + if (confirmation) break; + } + // verify the result if (!confirmation) { diff --git a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_printf.cpp b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_printf.cpp index 80fac2ada1..a20e8d3299 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_printf.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_printf.cpp @@ -175,7 +175,7 @@ struct CommandBufferPrintfTest : public BasicCommandBufferTest nullptr, &error); test_error(error, "clCreateBuffer failed"); - cl_int offset[] = { 0, max_pattern_length }; + cl_uint offset[] = { 0, max_pattern_length }; off_mem = clCreateBuffer(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(offset), offset, &error); @@ -274,7 +274,9 @@ struct CommandBufferPrintfTest : public BasicCommandBufferTest &pattern[0], 0, nullptr, nullptr); test_error(error, "clEnqueueWriteBuffer failed"); - cl_int offset[] = { 0, pattern.size() - 1 }; + test_assert_error(pattern.size() - 1 <= CL_UINT_MAX, + "pattern.size() - 1 does not fit in a cl_uint"); + cl_uint offset[] = { 0, static_cast(pattern.size() - 1) }; error = clEnqueueWriteBuffer(queue, off_mem, CL_TRUE, 0, sizeof(offset), offset, 0, nullptr, nullptr); test_error(error, "clEnqueueWriteBuffer failed"); diff --git a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_test_barrier.cpp b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_test_barrier.cpp index 72c5fcfb23..8c42033360 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/command_buffer_test_barrier.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/command_buffer_test_barrier.cpp @@ -93,6 +93,9 @@ struct BarrierWithWaitListKHR : public BasicCommandBufferTest 0, data_size(), 0, nullptr, nullptr); test_error(error, "clEnqueueFillBufferKHR failed"); + error = clFinish(queue); + test_error(error, "clFinish"); + error = clEnqueueCommandBufferKHR( 0, nullptr, out_of_order_command_buffer, 0, nullptr, &event); test_error(error, "clEnqueueCommandBufferKHR failed"); diff --git a/test_conformance/extensions/cl_khr_command_buffer/main.cpp b/test_conformance/extensions/cl_khr_command_buffer/main.cpp index ea8fddbe8b..93e1448ea5 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/main.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/main.cpp @@ -16,6 +16,7 @@ #include "harness/testHarness.h" test_definition test_list[] = { + ADD_TEST(multi_flag_creation), ADD_TEST(single_ndrange), ADD_TEST(interleaved_enqueue), ADD_TEST(mixed_commands), diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp index 20087b93b3..541ab51690 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy.cpp @@ -40,7 +40,7 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest if (check_image_support) { - image = create_image_2d(context, CL_MEM_READ_WRITE, &formats, + image = create_image_2d(context, CL_MEM_READ_WRITE, &format, img_width, img_height, 0, NULL, &error); test_error(error, "create_image_2d failed"); @@ -72,19 +72,31 @@ struct CommandBufferCopyBaseTest : BasicCommandBufferTest return BasicCommandBufferTest::Skip() || command_buffer_multi_device; } +private: + static constexpr size_t num_channels = 4; + protected: - const size_t img_width = 512; - const size_t img_height = 512; - const size_t origin[3] = { 0, 0, 0 }; - const size_t region[3] = { img_width, img_height, 1 }; - const cl_image_format formats = { CL_RGBA, CL_UNSIGNED_INT8 }; + static constexpr size_t img_width = 512; + static constexpr size_t img_height = 512; + static constexpr size_t origin[3] = { 0, 0, 0 }; + static constexpr size_t region[3] = { img_width, img_height, 1 }; + static constexpr cl_image_format format = { CL_RGBA, CL_UNSIGNED_INT8 }; + static constexpr size_t data_size = + img_width * img_height * num_channels * sizeof(uint8_t); clMemWrapper image; clMemWrapper buffer; - const size_t data_size = img_width * img_height * sizeof(cl_char); clMemWrapper in_mem; clMemWrapper out_mem; }; +template +constexpr size_t CommandBufferCopyBaseTest::origin[3]; +template +constexpr size_t CommandBufferCopyBaseTest::region[3]; +template +constexpr cl_image_format + CommandBufferCopyBaseTest::format; + namespace { // CL_INVALID_COMMAND_QUEUE if command_queue is not NULL. @@ -226,7 +238,7 @@ struct CommandBufferCopyImageDifferentContexts context1 = clCreateContext(0, 1, &device, nullptr, nullptr, &error); test_error(error, "Failed to create context"); - image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &formats, + image_ctx = create_image_2d(context1, CL_MEM_READ_WRITE, &format, img_width, img_height, 0, NULL, &error); test_error(error, "create_image_2d failed"); diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp index a6e5af2cdf..5103669ebf 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_copy_image.cpp @@ -143,7 +143,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest TEST_FAIL); error = clCommandCopyImageToBufferKHR( - command_buffer, nullptr, nullptr, src_image, dst_image_ctx, origin, + command_buffer, nullptr, nullptr, src_image, out_mem_ctx, origin, region, 0, 0, nullptr, nullptr, nullptr); test_failure_error_ret(error, CL_INVALID_CONTEXT, @@ -192,6 +192,12 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest elements / 64, 64, 0, NULL, &error); test_error(error, "create_image_2d failed"); + out_mem_ctx = clCreateBuffer(context1, CL_MEM_WRITE_ONLY, + sizeof(cl_int) * num_elements + * buffer_size_multiplier, + nullptr, &error); + test_error(error, "clCreateBuffer failed"); + queue1 = clCreateCommandQueue(context1, device, 0, &error); test_error(error, "clCreateCommandQueue failed"); @@ -202,6 +208,7 @@ struct CommandBufferCopyImageContextNotSame : public CommandCopyBaseTest clCommandQueueWrapper queue1; clMemWrapper src_image_ctx; clMemWrapper dst_image_ctx; + clMemWrapper out_mem_ctx; }; // CL_INVALID_SYNC_POINT_WAIT_LIST_KHR if sync_point_wait_list is NULL and diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp index 5cc287c0bb..f6401cead6 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_create.cpp @@ -102,9 +102,8 @@ struct CreateCommandBufferRepeatedProperties : public BasicCommandBufferTest cl_int error = CL_SUCCESS; cl_command_buffer_properties_khr repeated_properties[5] = { - CL_COMMAND_BUFFER_FLAGS_KHR, CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR, - CL_COMMAND_BUFFER_FLAGS_KHR, CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR, - 0 + CL_COMMAND_BUFFER_FLAGS_KHR, rep_prop, CL_COMMAND_BUFFER_FLAGS_KHR, + rep_prop, 0 }; command_buffer = @@ -115,7 +114,7 @@ struct CreateCommandBufferRepeatedProperties : public BasicCommandBufferTest TEST_FAIL); cl_command_buffer_properties_khr invalid_properties[3] = { - CL_COMMAND_BUFFER_FLAGS_KHR, CL_INVALID_PROPERTY, 0 + CL_COMMAND_BUFFER_FLAGS_KHR, (cl_command_buffer_properties_khr)-1, 0 }; command_buffer = @@ -127,6 +126,33 @@ struct CreateCommandBufferRepeatedProperties : public BasicCommandBufferTest return CL_SUCCESS; } + + bool Skip() override + { + bool skip = true; + + if (simultaneous_use_support) + { + rep_prop = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR; + skip = false; + } + else if (device_side_enqueue_support) + { + rep_prop = CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR; + skip = false; + } + else if (is_extension_available( + device, + CL_KHR_COMMAND_BUFFER_MUTABLE_DISPATCH_EXTENSION_NAME)) + { + rep_prop = CL_COMMAND_BUFFER_MUTABLE_KHR; + skip = false; + } + + return skip; + } + + cl_command_buffer_properties_khr rep_prop = 0; }; // CL_INVALID_PROPERTY if values specified in properties are valid but are not @@ -140,8 +166,7 @@ struct CreateCommandBufferNotSupportedProperties : public BasicCommandBufferTest cl_int error = CL_SUCCESS; cl_command_buffer_properties_khr properties[3] = { - CL_COMMAND_BUFFER_FLAGS_KHR, CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR, - 0 + CL_COMMAND_BUFFER_FLAGS_KHR, unsupported_prop, 0 }; command_buffer = @@ -156,21 +181,23 @@ struct CreateCommandBufferNotSupportedProperties : public BasicCommandBufferTest bool Skip() override { - cl_device_command_buffer_capabilities_khr capabilities; - cl_int error = - clGetDeviceInfo(device, CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR, - sizeof(capabilities), &capabilities, NULL); - test_error(error, - "Unable to query CL_DEVICE_COMMAND_BUFFER_CAPABILITIES_KHR"); - - bool device_supports_simultaneous_use = - (capabilities & CL_COMMAND_BUFFER_CAPABILITY_SIMULTANEOUS_USE_KHR) - != 0; - - // If device supports command queue property - // CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR test should be skipped - return device_supports_simultaneous_use; + bool skip = true; + + if (!simultaneous_use_support) + { + unsupported_prop = CL_COMMAND_BUFFER_SIMULTANEOUS_USE_KHR; + skip = false; + } + else if (!device_side_enqueue_support) + { + unsupported_prop = CL_COMMAND_BUFFER_DEVICE_SIDE_SYNC_KHR; + skip = false; + } + + return skip; } + + cl_command_buffer_properties_khr unsupported_prop = 0; }; // CL_INCOMPATIBLE_COMMAND_QUEUE_KHR if the properties of any command-queue in diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp index 1932ef5469..e00ca293d6 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_buffer_get_info.cpp @@ -218,18 +218,22 @@ struct GetCommandBufferInfo : public BasicCommandBufferTest cl_int RunPropArrayInfoTest() { - std::vector properties; - properties.resize(number_of_properties); - - cl_int error = clGetCommandBufferInfoKHR( - command_buffer, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, - number_of_properties * sizeof(cl_command_buffer_properties_khr) - 1, - properties.data(), nullptr); - - test_failure_error_ret(error, CL_INVALID_VALUE, - "clGetCommandBufferInfoKHR should return " - "CL_INVALID_VALUE", - TEST_FAIL); + if (0 != number_of_properties) + { + std::vector properties; + properties.resize(number_of_properties); + + cl_int error = clGetCommandBufferInfoKHR( + command_buffer, CL_COMMAND_BUFFER_PROPERTIES_ARRAY_KHR, + number_of_properties * sizeof(cl_command_buffer_properties_khr) + - 1, + properties.data(), nullptr); + + test_failure_error_ret(error, CL_INVALID_VALUE, + "clGetCommandBufferInfoKHR should return " + "CL_INVALID_VALUE", + TEST_FAIL); + } return TEST_PASS; } diff --git a/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp b/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp index 2d5327717c..05774bc00f 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp +++ b/test_conformance/extensions/cl_khr_command_buffer/negative_command_nd_range_kernel.cpp @@ -298,10 +298,10 @@ __kernel void printf_kernel() { } )"; - error = build_program_create_kernel_helper(context, &program, &kernel, - 1, &kernel_str, - "printf_kernel", nullptr); - test_error(error, "build_program_create_kernel_helper failed"); + error = + create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str, "printf_kernel", nullptr); + test_error(error, "create_single_kernel_helper failed"); return CL_SUCCESS; } @@ -407,10 +407,10 @@ enqueue_kernel(def_q, CLK_ENQUEUE_FLAGS_WAIT_KERNEL, ndrange, )"; std::string build_options = std::string(" ") + cl_std; - error = build_program_create_kernel_helper( - context, &program, &kernel, 1, &kernel_str, "enqueue_call_kernel", - build_options.c_str()); - test_error(error, "build_program_create_kernel_helper failed"); + error = create_single_kernel_helper(context, &program, &kernel, 1, + &kernel_str, "enqueue_call_kernel", + build_options.c_str()); + test_error(error, "create_single_kernel_helper failed"); return CL_SUCCESS; } diff --git a/test_conformance/extensions/cl_khr_command_buffer/procs.h b/test_conformance/extensions/cl_khr_command_buffer/procs.h index b2bd7c6c62..2a1e199b44 100644 --- a/test_conformance/extensions/cl_khr_command_buffer/procs.h +++ b/test_conformance/extensions/cl_khr_command_buffer/procs.h @@ -19,6 +19,8 @@ #include // Basic command-buffer tests +extern int test_multi_flag_creation(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); extern int test_single_ndrange(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); extern int test_interleaved_enqueue(cl_device_id device, cl_context context, diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_create_context.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_create_context.cpp index 6033ce9bdb..310c08703a 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_create_context.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_create_context.cpp @@ -24,7 +24,7 @@ int context_create(cl_device_id deviceID, cl_context context, CResult result; // create device - std::auto_ptr deviceWrapper; + std::unique_ptr deviceWrapper; if (!DeviceCreate(adapterType, deviceWrapper)) { result.ResultSub(CResult::TEST_ERROR); @@ -68,7 +68,7 @@ int context_create(cl_device_id deviceID, cl_context context, } void *objectSharedHandle = 0; - std::auto_ptr surface; + std::unique_ptr surface; if (!MediaSurfaceCreate( adapterType, width, height, surfaceFormat, *deviceWrapper, surface, (sharedHandle == SHARED_HANDLE_ENABLED) ? true : false, diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_api.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_api.cpp index 68db364c90..0f3fe4f630 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_api.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_api.cpp @@ -27,7 +27,7 @@ int api_functions(cl_device_id deviceID, cl_context context, CResult result; // create device - std::auto_ptr deviceWrapper; + std::unique_ptr deviceWrapper; if (!DeviceCreate(adapterType, deviceWrapper)) { result.ResultSub(CResult::TEST_ERROR); @@ -87,7 +87,7 @@ int api_functions(cl_device_id deviceID, cl_context context, } void *objectSharedHandle = 0; - std::auto_ptr surface; + std::unique_ptr surface; // create surface if (!MediaSurfaceCreate( diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_kernel.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_kernel.cpp index 8476122362..b8c97f801e 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_kernel.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_functions_kernel.cpp @@ -48,7 +48,7 @@ int kernel_functions(cl_device_id deviceID, cl_context context, CResult result; - std::auto_ptr deviceWrapper; + std::unique_ptr deviceWrapper; if (!DeviceCreate(adapterType, deviceWrapper)) { result.ResultSub(CResult::TEST_ERROR); @@ -102,7 +102,7 @@ int kernel_functions(cl_device_id deviceID, cl_context context, } void *objectSrcHandle = 0; - std::auto_ptr surfaceSrc; + std::unique_ptr surfaceSrc; if (!MediaSurfaceCreate(adapterType, width, height, surfaceFormat, *deviceWrapper, surfaceSrc, (sharedHandle == SHARED_HANDLE_ENABLED) ? true @@ -116,7 +116,7 @@ int kernel_functions(cl_device_id deviceID, cl_context context, } void *objectDstHandle = 0; - std::auto_ptr surfaceDst; + std::unique_ptr surfaceDst; if (!MediaSurfaceCreate(adapterType, width, height, surfaceFormat, *deviceWrapper, surfaceDst, (sharedHandle == SHARED_HANDLE_ENABLED) ? true diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_get_device_ids.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_get_device_ids.cpp index 613a602c69..e8f1193eb0 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_get_device_ids.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_get_device_ids.cpp @@ -21,7 +21,7 @@ int get_device_ids(cl_device_id deviceID, cl_context context, { CResult result; - std::auto_ptr deviceWrapper; + std::unique_ptr deviceWrapper; if (!DeviceCreate(adapterType, deviceWrapper)) { result.ResultSub(CResult::TEST_ERROR); diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_interop_sync.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_interop_sync.cpp index 280f47b5e1..1147cc4528 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_interop_sync.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_interop_sync.cpp @@ -26,7 +26,7 @@ int interop_user_sync(cl_device_id deviceID, cl_context context, CResult result; // create device - std::auto_ptr deviceWrapper; + std::unique_ptr deviceWrapper; if (!DeviceCreate(adapterType, deviceWrapper)) { result.ResultSub(CResult::TEST_ERROR); @@ -72,7 +72,7 @@ int interop_user_sync(cl_device_id deviceID, cl_context context, } void *objectSharedHandle = 0; - std::auto_ptr surface; + std::unique_ptr surface; if (!MediaSurfaceCreate( adapterType, width, height, surfaceFormat, *deviceWrapper, surface, (sharedHandle == SHARED_HANDLE_ENABLED) ? true : false, diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_memory_access.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_memory_access.cpp index c724242233..2833dcf151 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_memory_access.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_memory_access.cpp @@ -23,7 +23,7 @@ int memory_access(cl_device_id deviceID, cl_context context, { CResult result; - std::auto_ptr deviceWrapper; + std::unique_ptr deviceWrapper; // creates device if (!DeviceCreate(adapterType, deviceWrapper)) { @@ -74,7 +74,7 @@ int memory_access(cl_device_id deviceID, cl_context context, } void *objectSharedHandle = 0; - std::auto_ptr surface; + std::unique_ptr surface; // creates surface if (!MediaSurfaceCreate( diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_other_data_types.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_other_data_types.cpp index 8ff71279ec..81807bcdfb 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/test_other_data_types.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/test_other_data_types.cpp @@ -57,7 +57,7 @@ int other_data_types(cl_device_id deviceID, cl_context context, return result.Result(); } - std::auto_ptr deviceWrapper; + std::unique_ptr deviceWrapper; if (!DeviceCreate(adapterType, deviceWrapper)) { result.ResultSub(CResult::TEST_ERROR); @@ -158,7 +158,7 @@ int other_data_types(cl_device_id deviceID, cl_context context, } void *objectSrcHandle = 0; - std::auto_ptr surfaceSrc; + std::unique_ptr surfaceSrc; if (!MediaSurfaceCreate(adapterType, width, height, surfaceFormat, *deviceWrapper, surfaceSrc, (sharedHandle == SHARED_HANDLE_ENABLED) ? true @@ -172,7 +172,7 @@ int other_data_types(cl_device_id deviceID, cl_context context, } void *objectDstHandle = 0; - std::auto_ptr surfaceDst; + std::unique_ptr surfaceDst; if (!MediaSurfaceCreate(adapterType, width, height, surfaceFormat, *deviceWrapper, surfaceDst, (sharedHandle == SHARED_HANDLE_ENABLED) ? true diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.cpp b/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.cpp index 87eb13c3ca..3b0bf0adfe 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.cpp +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.cpp @@ -224,7 +224,7 @@ bool YUVGenerate(TSurfaceFormat surfaceFormat, std::vector &yuv, return true; } -bool YUVSurfaceSetNV12(std::auto_ptr &surface, +bool YUVSurfaceSetNV12(std::unique_ptr &surface, const std::vector &yuv, unsigned int width, unsigned int height) { @@ -257,7 +257,7 @@ bool YUVSurfaceSetNV12(std::auto_ptr &surface, #endif } -bool YUVSurfaceSetYV12(std::auto_ptr &surface, +bool YUVSurfaceSetYV12(std::unique_ptr &surface, const std::vector &yuv, unsigned int width, unsigned int height) { @@ -305,7 +305,7 @@ bool YUVSurfaceSetYV12(std::auto_ptr &surface, } bool YUVSurfaceSet(TSurfaceFormat surfaceFormat, - std::auto_ptr &surface, + std::unique_ptr &surface, const std::vector &yuv, unsigned int width, unsigned int height) { @@ -326,7 +326,7 @@ bool YUVSurfaceSet(TSurfaceFormat surfaceFormat, return true; } -bool YUVSurfaceGetNV12(std::auto_ptr &surface, +bool YUVSurfaceGetNV12(std::unique_ptr &surface, std::vector &yuv, unsigned int width, unsigned int height) { @@ -363,7 +363,7 @@ bool YUVSurfaceGetNV12(std::auto_ptr &surface, #endif } -bool YUVSurfaceGetYV12(std::auto_ptr &surface, +bool YUVSurfaceGetYV12(std::unique_ptr &surface, std::vector &yuv, unsigned int width, unsigned int height) { @@ -411,7 +411,7 @@ bool YUVSurfaceGetYV12(std::auto_ptr &surface, } bool YUVSurfaceGet(TSurfaceFormat surfaceFormat, - std::auto_ptr &surface, + std::unique_ptr &surface, std::vector &yuv, unsigned int width, unsigned int height) { @@ -1078,7 +1078,7 @@ bool GetImageInfo(cl_mem object, cl_image_format formatExp, } bool GetMemObjInfo(cl_mem object, cl_dx9_media_adapter_type_khr adapterType, - std::auto_ptr &surface, + std::unique_ptr &surface, void *shareHandleExp) { bool result = true; @@ -1172,7 +1172,7 @@ bool GetMemObjInfo(cl_mem object, cl_dx9_media_adapter_type_khr adapterType, bool ImageInfoVerify(cl_dx9_media_adapter_type_khr adapterType, const std::vector &memObjList, unsigned int width, unsigned int height, - std::auto_ptr &surface, + std::unique_ptr &surface, void *sharedHandle) { if (memObjList.size() != 2 && memObjList.size() != 3) @@ -1379,19 +1379,19 @@ D3DFORMAT SurfaceFormatToD3D(TSurfaceFormat surfaceFormat) #endif bool DeviceCreate(cl_dx9_media_adapter_type_khr adapterType, - std::auto_ptr &device) + std::unique_ptr &device) { switch (adapterType) { #if defined(_WIN32) case CL_ADAPTER_D3D9_KHR: - device = std::auto_ptr(new CD3D9Wrapper()); + device = std::unique_ptr(new CD3D9Wrapper()); break; case CL_ADAPTER_D3D9EX_KHR: - device = std::auto_ptr(new CD3D9ExWrapper()); + device = std::unique_ptr(new CD3D9ExWrapper()); break; case CL_ADAPTER_DXVA_KHR: - device = std::auto_ptr(new CDXVAWrapper()); + device = std::unique_ptr(new CDXVAWrapper()); break; #endif default: @@ -1551,7 +1551,7 @@ void SurfaceFormatToString(TSurfaceFormat surfaceFormat, std::string &str) bool MediaSurfaceCreate(cl_dx9_media_adapter_type_khr adapterType, unsigned int width, unsigned int height, TSurfaceFormat surfaceFormat, CDeviceWrapper &device, - std::auto_ptr &surface, + std::unique_ptr &surface, bool sharedHandle, void **objectSharedHandle) { switch (adapterType) @@ -1559,7 +1559,7 @@ bool MediaSurfaceCreate(cl_dx9_media_adapter_type_khr adapterType, #if defined(_WIN32) case CL_ADAPTER_D3D9_KHR: { surface = - std::auto_ptr(new CD3D9SurfaceWrapper); + std::unique_ptr(new CD3D9SurfaceWrapper); CD3D9SurfaceWrapper *d3dSurface = static_cast(surface.get()); HRESULT hr = 0; @@ -1578,7 +1578,7 @@ bool MediaSurfaceCreate(cl_dx9_media_adapter_type_khr adapterType, break; case CL_ADAPTER_D3D9EX_KHR: { surface = - std::auto_ptr(new CD3D9SurfaceWrapper); + std::unique_ptr(new CD3D9SurfaceWrapper); CD3D9SurfaceWrapper *d3dSurface = static_cast(surface.get()); HRESULT hr = 0; @@ -1598,7 +1598,7 @@ bool MediaSurfaceCreate(cl_dx9_media_adapter_type_khr adapterType, break; case CL_ADAPTER_DXVA_KHR: { surface = - std::auto_ptr(new CD3D9SurfaceWrapper); + std::unique_ptr(new CD3D9SurfaceWrapper); CD3D9SurfaceWrapper *d3dSurface = static_cast(surface.get()); HRESULT hr = 0; diff --git a/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.h b/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.h index 56c0fc2c4d..9c18eaff38 100644 --- a/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.h +++ b/test_conformance/extensions/cl_khr_dx9_media_sharing/utils.h @@ -116,24 +116,24 @@ void YUVGenerateYV12(std::vector &yuv, unsigned int width, bool YUVGenerate(TSurfaceFormat surfaceFormat, std::vector &yuv, unsigned int width, unsigned int height, cl_uchar valueMin, cl_uchar valueMax, double valueAdd = 0.0); -bool YUVSurfaceSetNV12(std::auto_ptr &surface, +bool YUVSurfaceSetNV12(std::unique_ptr &surface, const std::vector &yuv, unsigned int width, unsigned int height); -bool YUVSurfaceSetYV12(std::auto_ptr &surface, +bool YUVSurfaceSetYV12(std::unique_ptr &surface, const std::vector &yuv, unsigned int width, unsigned int height); bool YUVSurfaceSet(TSurfaceFormat surfaceFormat, - std::auto_ptr &surface, + std::unique_ptr &surface, const std::vector &yuv, unsigned int width, unsigned int height); -bool YUVSurfaceGetNV12(std::auto_ptr &surface, +bool YUVSurfaceGetNV12(std::unique_ptr &surface, std::vector &yuv, unsigned int width, unsigned int height); -bool YUVSurfaceGetYV12(std::auto_ptr &surface, +bool YUVSurfaceGetYV12(std::unique_ptr &surface, std::vector &yuv, unsigned int width, unsigned int height); bool YUVSurfaceGet(TSurfaceFormat surfaceFormat, - std::auto_ptr &surface, + std::unique_ptr &surface, std::vector &yuv, unsigned int width, unsigned int height); bool YUVCompareNV12(const std::vector &yuvTest, @@ -178,12 +178,12 @@ bool GetImageInfo(cl_mem object, cl_image_format formatExp, size_t slicePitchExp, size_t widthExp, size_t heightExp, size_t depthExp, unsigned int planeExp); bool GetMemObjInfo(cl_mem object, cl_dx9_media_adapter_type_khr adapterType, - std::auto_ptr &surface, + std::unique_ptr &surface, void *shareHandleExp); bool ImageInfoVerify(cl_dx9_media_adapter_type_khr adapterType, const std::vector &memObjList, unsigned int width, unsigned int height, - std::auto_ptr &surface, + std::unique_ptr &surface, void *sharedHandle); bool ImageFormatCheck(cl_context context, cl_mem_object_type imageType, const cl_image_format imageFormatCheck); @@ -195,7 +195,7 @@ D3DFORMAT SurfaceFormatToD3D(TSurfaceFormat surfaceFormat); #endif bool DeviceCreate(cl_dx9_media_adapter_type_khr adapterType, - std::auto_ptr &device); + std::unique_ptr &device); bool SurfaceFormatCheck(cl_dx9_media_adapter_type_khr adapterType, const CDeviceWrapper &device, TSurfaceFormat surfaceFormat); @@ -204,7 +204,7 @@ void SurfaceFormatToString(TSurfaceFormat surfaceFormat, std::string &str); bool MediaSurfaceCreate(cl_dx9_media_adapter_type_khr adapterType, unsigned int width, unsigned int height, TSurfaceFormat surfaceFormat, CDeviceWrapper &device, - std::auto_ptr &surface, + std::unique_ptr &surface, bool sharedHandle, void **objectSharedHandle); cl_int diff --git a/test_conformance/extensions/cl_khr_external_semaphore/main.cpp b/test_conformance/extensions/cl_khr_external_semaphore/main.cpp index 909a017293..f3ead65e92 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/main.cpp +++ b/test_conformance/extensions/cl_khr_external_semaphore/main.cpp @@ -19,17 +19,13 @@ test_definition test_list[] = { ADD_TEST(external_semaphores_queries), ADD_TEST(external_semaphores_cross_context), ADD_TEST(external_semaphores_simple_1), - // ADD_TEST(external_semaphores_simple_2), + ADD_TEST(external_semaphores_simple_2), ADD_TEST(external_semaphores_reuse), ADD_TEST(external_semaphores_cross_queues_ooo), ADD_TEST(external_semaphores_cross_queues_io), ADD_TEST(external_semaphores_cross_queues_io2), ADD_TEST(external_semaphores_multi_signal), ADD_TEST(external_semaphores_multi_wait), - // ADD_TEST(external_semaphores_order_1), - // ADD_TEST(external_semaphores_order_2), - // ADD_TEST(external_semaphores_order_3), - // ADD_TEST(external_semaphores_invalid_command) }; diff --git a/test_conformance/extensions/cl_khr_external_semaphore/procs.h b/test_conformance/extensions/cl_khr_external_semaphore/procs.h index 75d7f9d282..f9b7a4ce90 100644 --- a/test_conformance/extensions/cl_khr_external_semaphore/procs.h +++ b/test_conformance/extensions/cl_khr_external_semaphore/procs.h @@ -59,24 +59,8 @@ extern int test_external_semaphores_multi_wait(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_external_semaphores_order_1(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_external_semaphores_order_2(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); -extern int test_external_semaphores_order_3(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); extern int test_external_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_external_semaphores_invalid_command(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - int num_elements); #endif // CL_KHR_EXTERNAL_SEMAPHORE_PROCS_H \ No newline at end of file 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 7d21284973..78431c76e5 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 @@ -6,8 +6,6 @@ #include #include -#define FLUSH_DELAY_S 5 - #define SEMAPHORE_PARAM_TEST(param_name, param_type, expected) \ do \ { \ @@ -126,14 +124,14 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, { if (!is_extension_available(deviceID, "cl_khr_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -197,10 +195,15 @@ int test_external_semaphores_queries(cl_device_id deviceID, cl_context context, test_error(err, "Could not release semaphore"); SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 1); - // Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled + // Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the correct // state + cl_semaphore_payload_khr expected_payload_value = + (vkExternalSemaphoreHandleType + == VULKAN_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD) + ? 1 + : 0; SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr, - 0); + expected_payload_value); } return TEST_PASS; @@ -214,7 +217,7 @@ int test_external_semaphores_cross_context(cl_device_id deviceID, cl_int err = CL_SUCCESS; if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -344,7 +347,7 @@ int test_external_semaphores_simple_1(cl_device_id deviceID, cl_context context, { if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -424,7 +427,7 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, { if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -502,7 +505,10 @@ int test_external_semaphores_simple_2(cl_device_id deviceID, cl_context context, // Flush and delay err = clFlush(queue); test_error(err, "Could not flush queue"); - std::this_thread::sleep_for(std::chrono::seconds(FLUSH_DELAY_S)); + + cl_event event_list[] = { signal_event, wait_event }; + err = clWaitForEvents(2, event_list); + test_error(err, "Could not wait on events"); // Ensure all events are completed except for task_1 test_assert_event_inprogress(task_1_event); @@ -533,7 +539,7 @@ int test_external_semaphores_reuse(cl_device_id deviceID, cl_context context, { if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -658,7 +664,7 @@ static int external_semaphore_cross_queue_helper(cl_device_id deviceID, { if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -778,7 +784,7 @@ int test_external_semaphores_cross_queues_io2(cl_device_id deviceID, { if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -892,7 +898,7 @@ int test_external_semaphores_multi_signal(cl_device_id deviceID, { if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -988,7 +994,7 @@ int test_external_semaphores_multi_wait(cl_device_id deviceID, { if (!is_extension_available(deviceID, "cl_khr_external_semaphore")) { - log_info("cl_khr_semaphore is not supported on this platoform. " + log_info("cl_khr_semaphore is not supported on this platform. " "Skipping test.\n"); return TEST_SKIPPED_ITSELF; } diff --git a/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt b/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt index c1a95a9790..682ada5f95 100644 --- a/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt +++ b/test_conformance/extensions/cl_khr_semaphore/CMakeLists.txt @@ -3,10 +3,12 @@ set(MODULE_NAME CL_KHR_SEMAPHORE) set(${MODULE_NAME}_SOURCES main.cpp test_semaphores.cpp + test_semaphores_negative_wait_signal.cpp test_semaphores_negative_release_retain.cpp test_semaphores_negative_getinfo.cpp - test_semaphores_negative_wait.cpp test_semaphores_negative_create.cpp + test_semaphores_cross_queue.cpp + test_semaphores_queries.cpp semaphore_base.h ) diff --git a/test_conformance/extensions/cl_khr_semaphore/main.cpp b/test_conformance/extensions/cl_khr_semaphore/main.cpp index 2ad561ff8e..00732d547b 100644 --- a/test_conformance/extensions/cl_khr_semaphore/main.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/main.cpp @@ -33,8 +33,12 @@ test_definition test_list[] = { ADD_TEST_VERSION(semaphores_cross_queues_io, Version(1, 2)), ADD_TEST_VERSION(semaphores_multi_signal, Version(1, 2)), ADD_TEST_VERSION(semaphores_multi_wait, Version(1, 2)), - ADD_TEST_VERSION(semaphores_queries, Version(1, 2)), + ADD_TEST_VERSION(semaphores_device_list_queries, Version(1, 2)), + ADD_TEST_VERSION(semaphores_no_device_list_queries, Version(1, 2)), + ADD_TEST_VERSION(semaphores_multi_device_context_queries, Version(1, 2)), ADD_TEST_VERSION(semaphores_import_export_fd, Version(1, 2)), + ADD_TEST_VERSION(semaphores_ooo_ops_single_queue, Version(1, 2)), + ADD_TEST_VERSION(semaphores_ooo_ops_cross_queue, Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_create_invalid_context, Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_create_invalid_property, Version(1, 2)), @@ -58,6 +62,16 @@ test_definition test_list[] = { Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_wait_invalid_event_status, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_signal_invalid_command_queue, + Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_signal_invalid_value, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_signal_invalid_semaphore, + Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_signal_invalid_context, Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_signal_invalid_event_wait_list, + Version(1, 2)), + ADD_TEST_VERSION(semaphores_negative_signal_invalid_event_status, + Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_release, Version(1, 2)), ADD_TEST_VERSION(semaphores_negative_retain, Version(1, 2)), }; diff --git a/test_conformance/extensions/cl_khr_semaphore/procs.h b/test_conformance/extensions/cl_khr_semaphore/procs.h index ce392effc7..29047b95c7 100644 --- a/test_conformance/extensions/cl_khr_semaphore/procs.h +++ b/test_conformance/extensions/cl_khr_semaphore/procs.h @@ -39,8 +39,18 @@ extern int test_semaphores_multi_signal(cl_device_id deviceID, int num_elements); extern int test_semaphores_multi_wait(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements); -extern int test_semaphores_queries(cl_device_id deviceID, cl_context context, - cl_command_queue queue, int num_elements); +extern int test_semaphores_device_list_queries(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_semaphores_no_device_list_queries(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_semaphores_multi_device_context_queries(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + int num_elements); extern int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, cl_command_queue queue, @@ -93,6 +103,25 @@ extern int test_semaphores_negative_wait_invalid_event_wait_list( extern int test_semaphores_negative_wait_invalid_event_status( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); +extern int test_semaphores_negative_signal_invalid_command_queue( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_signal_invalid_value(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_signal_invalid_semaphore( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_signal_invalid_context( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_signal_invalid_event_wait_list( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); +extern int test_semaphores_negative_signal_invalid_event_status( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements); extern int test_semaphores_negative_release(cl_device_id device, cl_context context, cl_command_queue queue, @@ -101,3 +130,11 @@ extern int test_semaphores_negative_retain(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements); +extern int test_semaphores_ooo_ops_single_queue(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements); +extern int test_semaphores_ooo_ops_cross_queue(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements); diff --git a/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h index e50f33aedd..6e88b22cf4 100644 --- a/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h +++ b/test_conformance/extensions/cl_khr_semaphore/semaphore_base.h @@ -17,11 +17,33 @@ #define CL_KHR_SEMAPHORE_BASE_H #include + +#include + #include "harness/deviceInfo.h" #include "harness/testHarness.h" - #include "harness/typeWrappers.h" +// scope guard helper to ensure proper releasing of sub devices +struct SubDevicesScopeGuarded +{ + SubDevicesScopeGuarded(const cl_int dev_count) + { + sub_devices.resize(dev_count); + } + ~SubDevicesScopeGuarded() + { + for (auto &device : sub_devices) + { + cl_int err = clReleaseDevice(device); + if (err != CL_SUCCESS) + log_error("\n Releasing sub-device failed \n"); + } + } + + std::vector sub_devices; +}; + struct SemaphoreBase { SemaphoreBase(cl_device_id device): device(device) {} @@ -153,8 +175,9 @@ class clSemaphoreWrapper { struct SemaphoreTestBase : public SemaphoreBase { SemaphoreTestBase(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreBase(device), context(context), semaphore(this) + cl_command_queue queue, cl_int nelems) + : SemaphoreBase(device), context(context), semaphore(this), + num_elems(nelems) { cl_int error = init_extension_functions(); if (error != CL_SUCCESS) @@ -172,11 +195,12 @@ struct SemaphoreTestBase : public SemaphoreBase cl_context context = nullptr; clCommandQueueWrapper queue = nullptr; clSemaphoreWrapper semaphore = nullptr; + cl_int num_elems = 0; }; template int MakeAndRunTest(cl_device_id device, cl_context context, - cl_command_queue queue) + cl_command_queue queue, cl_int nelems) { if (!is_extension_available(device, "cl_khr_semaphore")) { @@ -188,7 +212,7 @@ int MakeAndRunTest(cl_device_id device, cl_context context, cl_int status = TEST_PASS; try { - auto test_fixture = T(device, context, queue); + auto test_fixture = T(device, context, queue, nelems); status = test_fixture.Run(); } catch (const std::runtime_error &e) { diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp index f4f2832414..dc896cbe58 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2023 The Khronos Group Inc. +// Copyright (c) 2024 The Khronos Group Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,62 +14,13 @@ // limitations under the License. // - -#include "harness/typeWrappers.h" -#include "harness/errorHelpers.h" -#include #include -#include -#include #include "semaphore_base.h" -#define FLUSH_DELAY_S 5 +#include "semaphore_base.h" -#define SEMAPHORE_PARAM_TEST(param_name, param_type, expected) \ - do \ - { \ - param_type value; \ - size_t size; \ - cl_int error = clGetSemaphoreInfoKHR(semaphore, param_name, \ - sizeof(value), &value, &size); \ - test_error(error, "Unable to get " #param_name " from semaphore"); \ - if (value != expected) \ - { \ - test_fail("ERROR: Parameter %s did not validate! (expected %d, " \ - "got %d)\n", \ - #param_name, expected, value); \ - } \ - if (size != sizeof(value)) \ - { \ - test_fail( \ - "ERROR: Returned size of parameter %s does not validate! " \ - "(expected %d, got %d)\n", \ - #param_name, (int)sizeof(value), (int)size); \ - } \ - } while (false) - -#define SEMAPHORE_PARAM_TEST_ARRAY(param_name, param_type, num_params, \ - expected) \ - do \ - { \ - param_type value[num_params]; \ - size_t size; \ - cl_int error = clGetSemaphoreInfoKHR(semaphore, param_name, \ - sizeof(value), &value, &size); \ - test_error(error, "Unable to get " #param_name " from semaphore"); \ - if (size != sizeof(value)) \ - { \ - test_fail( \ - "ERROR: Returned size of parameter %s does not validate! " \ - "(expected %d, got %d)\n", \ - #param_name, (int)sizeof(value), (int)size); \ - } \ - if (memcmp(value, expected, size) != 0) \ - { \ - test_fail("ERROR: Parameter %s did not validate!\n", #param_name); \ - } \ - } while (false) +#define FLUSH_DELAY_S 5 namespace { @@ -78,8 +29,8 @@ const char* source = "__kernel void empty() {}"; struct SimpleSemaphore1 : public SemaphoreTestBase { SimpleSemaphore1(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -128,8 +79,8 @@ struct SimpleSemaphore1 : public SemaphoreTestBase struct SimpleSemaphore2 : public SemaphoreTestBase { SimpleSemaphore2(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -209,8 +160,8 @@ struct SimpleSemaphore2 : public SemaphoreTestBase struct SemaphoreReuse : public SemaphoreTestBase { SemaphoreReuse(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -299,101 +250,12 @@ struct SemaphoreReuse : public SemaphoreTestBase } }; -template struct SemaphoreCrossQueue : public SemaphoreTestBase -{ - SemaphoreCrossQueue(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - // Helper function that signals and waits on semaphore across two different - // queues. - int semaphore_cross_queue_helper(cl_device_id deviceID, cl_context context, - cl_command_queue queue_1, - cl_command_queue queue_2) - { - cl_int err = CL_SUCCESS; - // Create semaphore - cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - 0 - }; - semaphore = - clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_error(err, "Could not create semaphore"); - - // Signal semaphore on queue_1 - clEventWrapper signal_event; - err = clEnqueueSignalSemaphoresKHR(queue_1, 1, semaphore, nullptr, 0, - nullptr, &signal_event); - test_error(err, "Could not signal semaphore"); - - // Wait semaphore on queue_2 - clEventWrapper wait_event; - err = clEnqueueWaitSemaphoresKHR(queue_2, 1, semaphore, nullptr, 0, - nullptr, &wait_event); - test_error(err, "Could not wait semaphore"); - - // Finish queue_1 and queue_2 - err = clFinish(queue_1); - test_error(err, "Could not finish queue"); - - err = clFinish(queue_2); - test_error(err, "Could not finish queue"); - - // Ensure all events are completed - test_assert_event_complete(signal_event); - test_assert_event_complete(wait_event); - - return TEST_PASS; - } - - cl_int run_in_order() - { - cl_int err = CL_SUCCESS; - // Create in-order queues - clCommandQueueWrapper queue_1 = - clCreateCommandQueue(context, device, 0, &err); - test_error(err, "Could not create command queue"); - - clCommandQueueWrapper queue_2 = - clCreateCommandQueue(context, device, 0, &err); - test_error(err, "Could not create command queue"); - - return semaphore_cross_queue_helper(device, context, queue_1, queue_2); - } - - cl_int run_out_of_order() - { - cl_int err = CL_SUCCESS; - // Create ooo queues - clCommandQueueWrapper queue_1 = clCreateCommandQueue( - context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); - test_error(err, "Could not create command queue"); - - clCommandQueueWrapper queue_2 = clCreateCommandQueue( - context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); - test_error(err, "Could not create command queue"); - - return semaphore_cross_queue_helper(device, context, queue_1, queue_2); - } - - cl_int Run() override - { - if (in_order) - return run_in_order(); - else - return run_out_of_order(); - } -}; - struct SemaphoreMultiSignal : public SemaphoreTestBase { SemaphoreMultiSignal(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue), semaphore_second(this) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems), + semaphore_second(this) {} cl_int Run() override @@ -455,8 +317,9 @@ struct SemaphoreMultiSignal : public SemaphoreTestBase struct SemaphoreMultiWait : public SemaphoreTestBase { SemaphoreMultiWait(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue), semaphore_second(this) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems), + semaphore_second(this) {} cl_int Run() override @@ -515,76 +378,12 @@ struct SemaphoreMultiWait : public SemaphoreTestBase clSemaphoreWrapper semaphore_second = nullptr; }; -struct SemaphoreQueries : public SemaphoreTestBase -{ - SemaphoreQueries(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - cl_int Run() override - { - cl_int err = CL_SUCCESS; - // Create binary semaphore - cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), - (cl_semaphore_properties_khr)device, - CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, - 0 - }; - semaphore = - clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_error(err, "Could not create semaphore"); - - // Confirm that querying CL_SEMAPHORE_TYPE_KHR returns - // CL_SEMAPHORE_TYPE_BINARY_KHR - SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr, - CL_SEMAPHORE_TYPE_BINARY_KHR); - - // Confirm that querying CL_SEMAPHORE_CONTEXT_KHR returns the right - // context - SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_CONTEXT_KHR, cl_context, context); - - // Confirm that querying CL_SEMAPHORE_REFERENCE_COUNT_KHR returns the - // right value - SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 1); - - err = clRetainSemaphoreKHR(semaphore); - test_error(err, "Could not retain semaphore"); - SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 2); - - err = clReleaseSemaphoreKHR(semaphore); - test_error(err, "Could not release semaphore"); - SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 1); - - // Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns the - // same device id the semaphore was created with - SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id, - device); - - // Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the same - // properties the semaphore was created with - SEMAPHORE_PARAM_TEST_ARRAY(CL_SEMAPHORE_PROPERTIES_KHR, - cl_semaphore_properties_khr, 6, sema_props); - - // Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled - // state - SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr, - 0); - - return CL_SUCCESS; - } -}; - struct SemaphoreImportExportFD : public SemaphoreTestBase { SemaphoreImportExportFD(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue), semaphore_second(this) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems), + semaphore_second(this) {} cl_int Run() override @@ -674,7 +473,8 @@ struct SemaphoreImportExportFD : public SemaphoreTestBase int test_semaphores_simple_1(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - return MakeAndRunTest(deviceID, context, defaultQueue); + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); } // Confirm that signal a semaphore with no event dependencies will not result @@ -682,32 +482,16 @@ int test_semaphores_simple_1(cl_device_id deviceID, cl_context context, int test_semaphores_simple_2(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - return MakeAndRunTest(deviceID, context, defaultQueue); + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); } // Confirm that a semaphore can be reused multiple times int test_semaphores_reuse(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - return MakeAndRunTest(deviceID, context, defaultQueue); -} - -// Confirm that a semaphore works across different ooo queues -int test_semaphores_cross_queues_ooo(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) -{ - return MakeAndRunTest>(deviceID, context, - defaultQueue); -} - -// Confirm that a semaphore works across different in-order queues -int test_semaphores_cross_queues_io(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, - int num_elements) -{ - return MakeAndRunTest>(deviceID, context, - defaultQueue); + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); } // Confirm that we can signal multiple semaphores with one command @@ -715,22 +499,16 @@ int test_semaphores_multi_signal(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - return MakeAndRunTest(deviceID, context, - defaultQueue); + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); } // Confirm that we can wait for multiple semaphores with one command int test_semaphores_multi_wait(cl_device_id deviceID, cl_context context, cl_command_queue defaultQueue, int num_elements) { - return MakeAndRunTest(deviceID, context, defaultQueue); -} - -// Confirm the semaphores can be successfully queried -int test_semaphores_queries(cl_device_id deviceID, cl_context context, - cl_command_queue defaultQueue, int num_elements) -{ - return MakeAndRunTest(deviceID, context, defaultQueue); + return MakeAndRunTest(deviceID, context, defaultQueue, + num_elements); } // Test it is possible to export a semaphore to a sync fd and import the same @@ -740,5 +518,5 @@ int test_semaphores_import_export_fd(cl_device_id deviceID, cl_context context, int num_elements) { return MakeAndRunTest(deviceID, context, - defaultQueue); + defaultQueue, num_elements); } diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp new file mode 100644 index 0000000000..0ee126f2d7 --- /dev/null +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_cross_queue.cpp @@ -0,0 +1,343 @@ +// +// Copyright (c) 2024 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include + +#include "semaphore_base.h" + +namespace { + +template struct SemaphoreCrossQueue : public SemaphoreTestBase +{ + SemaphoreCrossQueue(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + // Helper function that signals and waits on semaphore across two different + // queues. + int semaphore_cross_queue_helper(cl_device_id deviceID, cl_context context, + cl_command_queue queue_1, + cl_command_queue queue_2) + { + cl_int err = CL_SUCCESS; + // Create semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_error(err, "Could not create semaphore"); + + // Signal semaphore on queue_1 + clEventWrapper signal_event; + err = clEnqueueSignalSemaphoresKHR(queue_1, 1, semaphore, nullptr, 0, + nullptr, &signal_event); + test_error(err, "Could not signal semaphore"); + + // Wait semaphore on queue_2 + clEventWrapper wait_event; + err = clEnqueueWaitSemaphoresKHR(queue_2, 1, semaphore, nullptr, 0, + nullptr, &wait_event); + test_error(err, "Could not wait semaphore"); + + // Finish queue_1 and queue_2 + err = clFinish(queue_1); + test_error(err, "Could not finish queue"); + + err = clFinish(queue_2); + test_error(err, "Could not finish queue"); + + // Ensure all events are completed + test_assert_event_complete(signal_event); + test_assert_event_complete(wait_event); + + return TEST_PASS; + } + + cl_int run_in_order() + { + cl_int err = CL_SUCCESS; + // Create in-order queues + clCommandQueueWrapper queue_1 = + clCreateCommandQueue(context, device, 0, &err); + test_error(err, "Could not create command queue"); + + clCommandQueueWrapper queue_2 = + clCreateCommandQueue(context, device, 0, &err); + test_error(err, "Could not create command queue"); + + return semaphore_cross_queue_helper(device, context, queue_1, queue_2); + } + + cl_int run_out_of_order() + { + cl_int err = CL_SUCCESS; + // Create ooo queues + clCommandQueueWrapper queue_1 = clCreateCommandQueue( + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + test_error(err, "Could not create command queue"); + + clCommandQueueWrapper queue_2 = clCreateCommandQueue( + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err); + test_error(err, "Could not create command queue"); + + return semaphore_cross_queue_helper(device, context, queue_1, queue_2); + } + + cl_int Run() override + { + if (in_order) + return run_in_order(); + else + return run_out_of_order(); + } +}; + +template +struct SemaphoreOutOfOrderOps : public SemaphoreTestBase +{ + SemaphoreOutOfOrderOps(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + bool SetUp() + { + cl_int error = CL_SUCCESS; + + const char *kernel_str = + R"( + __kernel void copy(__global int* in, __global int* out) { + size_t id = get_global_id(0); + out[id] = in[id]; + })"; + + error = create_single_kernel_helper_create_program(context, &program, 1, + &kernel_str); + test_error(error, "Failed to create program with source"); + + error = clBuildProgram(program, 1, &device, nullptr, nullptr, nullptr); + test_error(error, "Failed to build program"); + + kernel = clCreateKernel(program, "copy", &error); + test_error(error, "Failed to create copy kernel"); + + // create producer/consumer out-of-order queues + producer_queue = clCreateCommandQueue( + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &error); + test_error(error, "Could not create command queue"); + + if (single_queue) + { + consumer_queue = producer_queue; + } + else + { + consumer_queue = clCreateCommandQueue( + context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, + &error); + test_error(error, "Could not create command queue"); + } + + // Create semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &error); + test_error(error, "Could not create semaphore"); + + // create memory resources + in_mem_A = clCreateBuffer(context, CL_MEM_READ_ONLY, + sizeof(cl_int) * num_elems, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + in_mem_B = clCreateBuffer(context, CL_MEM_READ_ONLY, + sizeof(cl_int) * num_elems, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + + out_mem_A = clCreateBuffer(context, CL_MEM_WRITE_ONLY, + sizeof(cl_int) * num_elems, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + out_mem_B = clCreateBuffer(context, CL_MEM_WRITE_ONLY, + sizeof(cl_int) * num_elems, nullptr, &error); + test_error(error, "clCreateBuffer failed"); + + error = clSetKernelArg(kernel, 0, sizeof(in_mem_A), &in_mem_A); + test_error(error, "clSetKernelArg failed"); + + error = clSetKernelArg(kernel, 1, sizeof(out_mem_A), &out_mem_A); + test_error(error, "clSetKernelArg failed"); + + return CL_SUCCESS; + } + + cl_int Run() override + { + cl_int err = SetUp(); + test_error(err, "SetUp failed"); + + const cl_int pattern_A = 42; + const cl_int pattern_B = 0xACDC; + + // enqueue producer operations + err = clEnqueueFillBuffer(producer_queue, in_mem_A, &pattern_A, + sizeof(cl_int), 0, sizeof(cl_int) * num_elems, + 0, nullptr, nullptr); + test_error(err, "clEnqueueReadBuffer failed"); + + err = clEnqueueFillBuffer(producer_queue, in_mem_B, &pattern_B, + sizeof(cl_int), 0, sizeof(cl_int) * num_elems, + 0, nullptr, nullptr); + test_error(err, "clEnqueueReadBuffer failed"); + + // The semaphore cannot be signaled until the barrier is complete + err = clEnqueueBarrierWithWaitList(producer_queue, 0, nullptr, nullptr); + test_error(err, " clEnqueueBarrierWithWaitList "); + + if (single_queue) + { + clEventWrapper sema_wait_event; + + // signal/wait with event dependency + err = clEnqueueSignalSemaphoresKHR(producer_queue, 1, semaphore, + nullptr, 0, nullptr, + &sema_wait_event); + test_error(err, "Could not signal semaphore"); + + // consumer and producer queues in sync through wait event + err = clEnqueueWaitSemaphoresKHR(consumer_queue, 1, semaphore, + nullptr, 1, &sema_wait_event, + nullptr); + test_error(err, "Could not wait semaphore"); + } + else + { + err = clEnqueueSignalSemaphoresKHR(producer_queue, 1, semaphore, + nullptr, 0, nullptr, nullptr); + test_error(err, "Could not signal semaphore"); + + err = clEnqueueWaitSemaphoresKHR(consumer_queue, 1, semaphore, + nullptr, 0, nullptr, nullptr); + test_error(err, "Could not wait semaphore"); + } + + err = clEnqueueBarrierWithWaitList(consumer_queue, 0, nullptr, nullptr); + test_error(err, " clEnqueueBarrierWithWaitList "); + + // enqueue consumer operations + size_t threads = (size_t)num_elems; + err = clEnqueueNDRangeKernel(consumer_queue, kernel, 1, nullptr, + &threads, nullptr, 0, nullptr, nullptr); + test_error(err, "clEnqueueNDRangeKernel failed"); + + err = clSetKernelArg(kernel, 0, sizeof(in_mem_B), &in_mem_B); + test_error(err, "clSetKernelArg failed"); + + err = clSetKernelArg(kernel, 1, sizeof(out_mem_B), &out_mem_B); + test_error(err, "clSetKernelArg failed"); + + err = clEnqueueNDRangeKernel(consumer_queue, kernel, 1, nullptr, + &threads, nullptr, 0, nullptr, nullptr); + test_error(err, "clEnqueueNDRangeKernel failed"); + + err = clEnqueueBarrierWithWaitList(consumer_queue, 0, nullptr, nullptr); + test_error(err, " clEnqueueBarrierWithWaitList "); + + std::vector host_buffer(num_elems, 0); + auto verify_result = [&](const cl_mem &out_mem, const cl_int pattern) { + err = clEnqueueReadBuffer(consumer_queue, out_mem, CL_TRUE, 0, + sizeof(cl_int) * num_elems, + host_buffer.data(), 0, nullptr, nullptr); + test_error_ret(err, "clEnqueueReadBuffer failed", false); + + for (int i = 0; i < num_elems; i++) + { + if (pattern != host_buffer[i]) + { + log_error("Expected %d was %d at index %zu\n", pattern, + host_buffer[i], i); + return false; + } + } + return true; + }; + + if (!verify_result(out_mem_A, pattern_A)) return TEST_FAIL; + + if (!verify_result(out_mem_B, pattern_B)) return TEST_FAIL; + + return CL_SUCCESS; + } + + clKernelWrapper kernel = nullptr; + clProgramWrapper program = nullptr; + clMemWrapper in_mem_A = nullptr, in_mem_B = nullptr, out_mem_A = nullptr, + out_mem_B = nullptr; + clCommandQueueWrapper producer_queue = nullptr; + clCommandQueueWrapper consumer_queue = nullptr; +}; + +} // anonymous namespace + +// Confirm that a semaphore works across different ooo queues +int test_semaphores_cross_queues_ooo(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +// Confirm that a semaphore works across different in-order queues +int test_semaphores_cross_queues_io(cl_device_id deviceID, cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +// Confirm that we can synchronize signal/wait commands in single out-of-order +// queue +int test_semaphores_ooo_ops_single_queue(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} + +// Confirm that we can synchronize signal/wait commands across two out-of-order +// queues +int test_semaphores_ooo_ops_cross_queue(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest>( + deviceID, context, defaultQueue, num_elements); +} diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp index 753e6f42f1..566e5e16b5 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_create.cpp @@ -20,7 +20,6 @@ #include #include #include -#include namespace { @@ -28,8 +27,8 @@ namespace { struct CreateInvalidContext : public SemaphoreTestBase { CreateInvalidContext(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -51,34 +50,14 @@ struct CreateInvalidContext : public SemaphoreTestBase } }; -// scope guard helper to ensure proper releasing of sub devices -struct SubDevicesScopeGuarded -{ - SubDevicesScopeGuarded(const cl_int dev_count) - { - sub_devices.resize(dev_count); - } - ~SubDevicesScopeGuarded() - { - for (auto& device : sub_devices) - { - cl_int err = clReleaseDevice(device); - if (err != CL_SUCCESS) - log_error("\n Releasing sub-device failed \n"); - } - } - - std::vector sub_devices; -}; - // (1) property name in sema_props is not a supported property name, // (2) value specified for a supported property name is not valid, // (3) the same property name is specified more than once. struct CreateInvalidProperty : public SemaphoreTestBase { CreateInvalidProperty(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -151,8 +130,8 @@ struct CreateInvalidProperty : public SemaphoreTestBase struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase { CreateInvalidMultiDeviceProperty(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -165,7 +144,8 @@ struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase test_error(err, "Unable to get maximal number of compute units"); cl_device_partition_property partitionProp[] = { - CL_DEVICE_PARTITION_EQUALLY, maxComputeUnits / 2, 0 + CL_DEVICE_PARTITION_EQUALLY, + static_cast(maxComputeUnits / 2), 0 }; cl_uint deviceCount = 0; @@ -224,8 +204,8 @@ struct CreateInvalidMultiDeviceProperty : public SemaphoreTestBase struct CreateInvalidDevice : public SemaphoreTestBase { CreateInvalidDevice(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -238,7 +218,8 @@ struct CreateInvalidDevice : public SemaphoreTestBase test_error(err, "Unable to get maximal number of compute units"); cl_device_partition_property partitionProp[] = { - CL_DEVICE_PARTITION_EQUALLY, maxComputeUnits / 2, 0 + CL_DEVICE_PARTITION_EQUALLY, + static_cast(maxComputeUnits / 2), 0 }; cl_uint deviceCount = 0; @@ -331,8 +312,9 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase { CreateImportExternalWithInvalidDevice(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue), semaphore_second(this) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems), + semaphore_second(this) {} cl_int Run() override @@ -342,7 +324,7 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase { log_info( "cl_khr_external_semaphore_opaque_fd is not supported on this " - "platoform. Skipping test.\n"); + "platform. Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -474,8 +456,8 @@ struct CreateImportExternalWithInvalidDevice : public SemaphoreTestBase struct CreateInvalidValue : public SemaphoreTestBase { CreateInvalidValue(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -504,7 +486,7 @@ struct CreateInvalidValue : public SemaphoreTestBase { log_info("cl_khr_external_semaphore_opaque_fd is not supported " "on this " - "platoform. Skipping test.\n"); + "platform. Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -536,8 +518,9 @@ struct CreateInvalidValue : public SemaphoreTestBase struct CreateInvalidOperation : public SemaphoreTestBase { CreateInvalidOperation(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue), semaphore_second(this) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems), + semaphore_second(this) {} cl_int Run() override @@ -547,7 +530,7 @@ struct CreateInvalidOperation : public SemaphoreTestBase { log_info( "cl_khr_external_semaphore_opaque_fd is not supported on this " - "platoform. Skipping test.\n"); + "platform. Skipping test.\n"); return TEST_SKIPPED_ITSELF; } @@ -622,7 +605,8 @@ int test_semaphores_negative_create_invalid_context(cl_device_id device, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } // Confirm that creation semaphore with invalid properties return @@ -632,7 +616,8 @@ int test_semaphores_negative_create_invalid_property(cl_device_id device, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } // Confirm that creation semaphore with multi device property return @@ -641,8 +626,8 @@ int test_semaphores_negative_create_multi_device_property( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, - queue); + return MakeAndRunTest( + device, context, queue, num_elements); } // Confirm that creation semaphore with invalid device(s) return @@ -652,7 +637,8 @@ int test_semaphores_negative_create_invalid_device(cl_device_id device, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } // Confirm that creation semaphore with invalid device(s) return @@ -662,7 +648,7 @@ int test_semaphores_negative_create_import_invalid_device( int num_elements) { return MakeAndRunTest( - device, context, queue); + device, context, queue, num_elements); } // Confirm that creation semaphore with invalid props values return @@ -672,7 +658,8 @@ int test_semaphores_negative_create_invalid_value(cl_device_id device, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } // Confirm that creation semaphore with invalid props values return @@ -682,5 +669,6 @@ int test_semaphores_negative_create_invalid_operation(cl_device_id device, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_getinfo.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_getinfo.cpp index 0cf8bb0faf..155dc84e39 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_getinfo.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_getinfo.cpp @@ -25,8 +25,8 @@ namespace { struct GetInfoInvalidSemaphore : public SemaphoreTestBase { GetInfoInvalidSemaphore(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -53,8 +53,8 @@ struct GetInfoInvalidSemaphore : public SemaphoreTestBase struct GetInfoInvalidValue : public SemaphoreTestBase { GetInfoInvalidValue(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -90,7 +90,7 @@ struct GetInfoInvalidValue : public SemaphoreTestBase // make sure that first test provides too small param size if (size != sizeof(sema_props)) - test_fail("Error: expected size %d, returned %d", + test_fail("Error: expected size %zu, returned %zu", sizeof(sema_props), size); // first test with non-zero property size but not enough @@ -118,7 +118,8 @@ int test_semaphores_negative_get_info_invalid_semaphore(cl_device_id device, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } int test_semaphores_negative_get_info_invalid_value(cl_device_id device, @@ -126,5 +127,6 @@ int test_semaphores_negative_get_info_invalid_value(cl_device_id device, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_release_retain.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_release_retain.cpp index ea6139de28..88d7b925ff 100644 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_release_retain.cpp +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_release_retain.cpp @@ -29,8 +29,8 @@ namespace { struct ReleaseInvalidSemaphore : public SemaphoreTestBase { ReleaseInvalidSemaphore(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -53,8 +53,8 @@ struct ReleaseInvalidSemaphore : public SemaphoreTestBase struct RetainInvalidSemaphore : public SemaphoreTestBase { RetainInvalidSemaphore(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) {} cl_int Run() override @@ -79,11 +79,13 @@ struct RetainInvalidSemaphore : public SemaphoreTestBase int test_semaphores_negative_release(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } int test_semaphores_negative_retain(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements) { - return MakeAndRunTest(device, context, queue); + return MakeAndRunTest(device, context, queue, + num_elements); } diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait.cpp deleted file mode 100644 index dab28d96cc..0000000000 --- a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait.cpp +++ /dev/null @@ -1,395 +0,0 @@ -// -// Copyright (c) 2024 The Khronos Group Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "semaphore_base.h" - -#include "harness/errorHelpers.h" -#include -#include -#include -#include - -namespace { - -// the device associated with command_queue is not same as one of the devices -// specified by CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR at the time of creating one -// or more of sema_objects. - -struct WaitInvalidCommandQueue : public SemaphoreTestBase -{ - WaitInvalidCommandQueue(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - cl_int Run() override - { - // Create semaphore - cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - static_cast( - CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), - (cl_semaphore_properties_khr)device, - CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, - 0 - }; - - cl_int err = CL_SUCCESS; - semaphore = - clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_error(err, "Could not create semaphore"); - - // find other device - cl_platform_id platform_id = 0; - // find out what platform the harness is using. - err = clGetDeviceInfo(device, CL_DEVICE_PLATFORM, - sizeof(cl_platform_id), &platform_id, nullptr); - test_error(err, "clGetDeviceInfo failed"); - - cl_uint num_platforms = 0; - err = clGetPlatformIDs(16, nullptr, &num_platforms); - test_error(err, "clGetPlatformIDs failed"); - - std::vector platforms(num_platforms); - - err = clGetPlatformIDs(num_platforms, platforms.data(), &num_platforms); - test_error(err, "clGetPlatformIDs failed"); - - cl_device_id device_sec = nullptr; - cl_uint num_devices = 0; - for (int p = 0; p < (int)num_platforms; p++) - { - if (platform_id == platforms[p]) continue; - - err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, 0, nullptr, - &num_devices); - test_error(err, "clGetDeviceIDs failed"); - - std::vector devices(num_devices); - err = clGetDeviceIDs(platforms[p], CL_DEVICE_TYPE_ALL, num_devices, - devices.data(), nullptr); - test_error(err, "clGetDeviceIDs failed"); - - device_sec = devices.front(); - break; - } - - if (device_sec == nullptr) - { - log_info("Can't find needed resources. Skipping the test.\n"); - return TEST_SKIPPED_ITSELF; - } - - // Create secondary context - clContextWrapper context_sec = - clCreateContext(0, 1, &device_sec, nullptr, nullptr, &err); - test_error(err, "Failed to create context"); - - // Create secondary queue - clCommandQueueWrapper queue_sec = - clCreateCommandQueue(context_sec, device_sec, 0, &err); - test_error(err, "Could not create command queue"); - - // Signal semaphore - err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, - nullptr, nullptr); - test_error(err, "Could not signal semaphore"); - - // Wait semaphore - err = clEnqueueWaitSemaphoresKHR(queue_sec, 1, semaphore, nullptr, 0, - nullptr, nullptr); - test_failure_error(err, CL_INVALID_COMMAND_QUEUE, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - return TEST_PASS; - } -}; - - -// num_sema_objects is 0. - -struct WaitInvalidValue : public SemaphoreTestBase -{ - WaitInvalidValue(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - cl_int Run() override - { - // Wait semaphore - cl_int err = CL_SUCCESS; - err = clEnqueueWaitSemaphoresKHR(queue, 0, semaphore, nullptr, 0, - nullptr, nullptr); - test_failure_error(err, CL_INVALID_VALUE, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - return CL_SUCCESS; - } -}; - -// any of the semaphore objects specified by sema_objects is not valid. - -struct WaitInvalidSemaphore : public SemaphoreTestBase -{ - WaitInvalidSemaphore(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - cl_int Run() override - { - // Wait semaphore - cl_semaphore_khr sema_objects[] = { nullptr, nullptr, nullptr }; - cl_int err = CL_SUCCESS; - err = clEnqueueWaitSemaphoresKHR( - queue, sizeof(sema_objects) / sizeof(sema_objects[0]), sema_objects, - nullptr, 0, nullptr, nullptr); - test_failure_error(err, CL_INVALID_SEMAPHORE_KHR, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - return CL_SUCCESS; - } -}; - -// 1) the context associated with command_queue and any of the semaphore objects -// in sema_objects are not the same, or -// 2) the context associated with command_queue and that associated with events -// in event_wait_list are not the same. - -struct WaitInvalidContext : public SemaphoreTestBase -{ - WaitInvalidContext(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - cl_int Run() override - { - // Create semaphore - cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - 0 - }; - - cl_int err = CL_SUCCESS; - semaphore = - clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_error(err, "Could not create semaphore"); - - // Create secondary context - clContextWrapper context_sec = - clCreateContext(0, 1, &device, nullptr, nullptr, &err); - test_error(err, "Failed to create context"); - - // Create secondary queue - clCommandQueueWrapper queue_sec = - clCreateCommandQueue(context_sec, device, 0, &err); - test_error(err, "Could not create command queue"); - - // Signal semaphore - err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, - nullptr, nullptr); - test_error(err, "Could not signal semaphore"); - - // (1) Wait semaphore - err = clEnqueueWaitSemaphoresKHR(queue_sec, 1, semaphore, nullptr, 0, - nullptr, nullptr); - test_failure_error(err, CL_INVALID_CONTEXT, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - // Create user event - clEventWrapper user_event = clCreateUserEvent(context_sec, &err); - test_error(err, "Could not create user event"); - - // (2) Wait semaphore - err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 1, - &user_event, nullptr); - - cl_int signal_error = clSetUserEventStatus(user_event, CL_COMPLETE); - test_error(signal_error, "clSetUserEventStatus failed"); - - test_failure_error(err, CL_INVALID_CONTEXT, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - return TEST_PASS; - } -}; - -// (1) event_wait_list is NULL and num_events_in_wait_list is not 0, or -// (2) event_wait_list is not NULL and num_events_in_wait_list is 0, or -// (3) event objects in event_wait_list are not valid events. - -struct WaitInvalidEventWaitList : public SemaphoreTestBase -{ - WaitInvalidEventWaitList(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - cl_int Run() override - { - // Create semaphore - cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - 0 - }; - - cl_int err = CL_SUCCESS; - semaphore = - clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_error(err, "Could not create semaphore"); - - - // Signal semaphore - err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, - nullptr, nullptr); - test_error(err, "Could not signal semaphore"); - - // (1) Wait semaphore - err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 1, - nullptr, nullptr); - test_failure_error(err, CL_INVALID_EVENT_WAIT_LIST, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - // Create user event - clEventWrapper user_event = clCreateUserEvent(context, &err); - test_error(err, "Could not create user event"); - - // (2) Wait semaphore - err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 0, - &user_event, nullptr); - - cl_int signal_error = clSetUserEventStatus(user_event, CL_COMPLETE); - test_error(signal_error, "clSetUserEventStatus failed"); - - test_failure_error(err, CL_INVALID_EVENT_WAIT_LIST, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - // (3) Wait semaphore - cl_event wait_list[] = { nullptr, nullptr, nullptr }; - err = clEnqueueWaitSemaphoresKHR( - queue, 1, semaphore, nullptr, - sizeof(wait_list) / sizeof(wait_list[0]), wait_list, nullptr); - test_failure_error(err, CL_INVALID_EVENT_WAIT_LIST, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - return CL_SUCCESS; - } -}; - -// the execution status of any of the events in event_wait_list is a negative -// integer value. - -struct WaitInvalidEventStatus : public SemaphoreTestBase -{ - WaitInvalidEventStatus(cl_device_id device, cl_context context, - cl_command_queue queue) - : SemaphoreTestBase(device, context, queue) - {} - - cl_int Run() override - { - // Create semaphore - cl_semaphore_properties_khr sema_props[] = { - static_cast(CL_SEMAPHORE_TYPE_KHR), - static_cast( - CL_SEMAPHORE_TYPE_BINARY_KHR), - 0 - }; - - cl_int err = CL_SUCCESS; - semaphore = - clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); - test_error(err, "Could not create semaphore"); - - // Signal semaphore - err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, - nullptr, nullptr); - test_error(err, "Could not signal semaphore"); - - // Create user event - clEventWrapper user_event = clCreateUserEvent(context, &err); - test_error(err, "Could not create user event"); - - // Now release the user event, which will allow our actual action to run - err = clSetUserEventStatus(user_event, -1); - test_error(err, "Unable to set event status"); - - // Wait semaphore - err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 1, - &user_event, nullptr); - test_failure_error(err, CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST, - "Unexpected clEnqueueWaitSemaphoresKHR return"); - - return CL_SUCCESS; - } -}; - -} - -int test_semaphores_negative_wait_invalid_command_queue(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) -{ - return MakeAndRunTest(device, context, queue); -} - -int test_semaphores_negative_wait_invalid_value(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) -{ - return MakeAndRunTest(device, context, queue); -} - -int test_semaphores_negative_wait_invalid_semaphore(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) -{ - return MakeAndRunTest(device, context, queue); -} - -int test_semaphores_negative_wait_invalid_context(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) -{ - return MakeAndRunTest(device, context, queue); -} - -int test_semaphores_negative_wait_invalid_event_wait_list( - cl_device_id device, cl_context context, cl_command_queue queue, - int num_elements) -{ - return MakeAndRunTest(device, context, queue); -} - -int test_semaphores_negative_wait_invalid_event_status(cl_device_id device, - cl_context context, - cl_command_queue queue, - int num_elements) -{ - return MakeAndRunTest(device, context, queue); -} diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait_signal.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait_signal.cpp new file mode 100644 index 0000000000..0559abae1c --- /dev/null +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_negative_wait_signal.cpp @@ -0,0 +1,600 @@ +// +// Copyright (c) 2024 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "semaphore_base.h" + +#include "harness/errorHelpers.h" +#include +#include +#include +#include + +namespace { + +enum class RunMode +{ + RM_WAIT = 0, + RM_SIGNAL +}; + +// scope guard helper to ensure proper releasing of sub devices +struct SubDevicesScopeGuarded +{ + SubDevicesScopeGuarded(const cl_int dev_count) + { + sub_devices.resize(dev_count); + } + ~SubDevicesScopeGuarded() + { + for (auto& device : sub_devices) + { + cl_int err = clReleaseDevice(device); + if (err != CL_SUCCESS) + log_error("\n Releasing sub-device failed \n"); + } + } + + std::vector sub_devices; +}; + +// the device associated with command_queue is not same as one of the devices +// specified by CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR at the time of creating one +// or more of sema_objects. + +template struct InvalidCommandQueue : public SemaphoreTestBase +{ + InvalidCommandQueue(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + cl_int err = CL_SUCCESS; + + // Below test makes sense only if semaphore and command queue share the + // same context, otherwise CL_INVALID_CONTEXT could be the result. Thus, + // multi device context must be created, then semaphore and command + // queue with the same associated context but different devices. + + // partition device and create new context if possible + cl_uint maxComputeUnits = 0; + err = clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(maxComputeUnits), &maxComputeUnits, NULL); + test_error(err, "Unable to get maximal number of compute units"); + + cl_uint maxSubDevices = 0; + err = clGetDeviceInfo(device, CL_DEVICE_PARTITION_MAX_SUB_DEVICES, + sizeof(maxSubDevices), &maxSubDevices, NULL); + test_error(err, "Unable to get maximal number of sub-devices"); + + if (maxSubDevices < 2) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_device_partition_property partitionProp[] = { + CL_DEVICE_PARTITION_EQUALLY, + static_cast(maxComputeUnits / 2), 0 + }; + + cl_uint deviceCount = 0; + // how many sub-devices can we create? + err = + clCreateSubDevices(device, partitionProp, 0, nullptr, &deviceCount); + if (err != CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + if (deviceCount < 2) + test_error_ret( + CL_INVALID_VALUE, + "Multi context test for CL_INVALID_COMMAND_QUEUE not supported", + TEST_SKIPPED_ITSELF); + + // get the list of subDevices + SubDevicesScopeGuarded scope_guard(deviceCount); + err = clCreateSubDevices(device, partitionProp, deviceCount, + scope_guard.sub_devices.data(), &deviceCount); + if (err != CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + /* Create a multi device context */ + clContextWrapper multi_device_context = clCreateContext( + NULL, (cl_uint)deviceCount, scope_guard.sub_devices.data(), nullptr, + nullptr, &err); + test_error_ret(err, "Unable to create testing context", CL_SUCCESS); + + // Create semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)scope_guard.sub_devices.front(), + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + 0 + }; + + semaphore = clCreateSemaphoreWithPropertiesKHR(multi_device_context, + sema_props, &err); + test_error(err, "Could not create semaphore"); + + // Create secondary queue associated with device not the same as one + // associated with semaphore + clCommandQueueWrapper queue_sec = clCreateCommandQueue( + multi_device_context, scope_guard.sub_devices.back(), 0, &err); + test_error(err, "Could not create command queue"); + + if (mode == RunMode::RM_SIGNAL) + { + // Signal semaphore + err = clEnqueueSignalSemaphoresKHR(queue_sec, 1, semaphore, nullptr, + 0, nullptr, nullptr); + test_failure_error( + err, CL_INVALID_COMMAND_QUEUE, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + } + else + { + // Signal semaphore + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + nullptr, nullptr); + test_error(err, "Could not signal semaphore"); + + // Wait semaphore + err = clEnqueueWaitSemaphoresKHR(queue_sec, 1, semaphore, nullptr, + 0, nullptr, nullptr); + test_failure_error(err, CL_INVALID_COMMAND_QUEUE, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + } + + return TEST_PASS; + } +}; + + +// num_sema_objects is 0. + +template struct InvalidValue : public SemaphoreTestBase +{ + InvalidValue(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + if (mode == RunMode::RM_SIGNAL) + { + // Signal semaphore + cl_int err = CL_SUCCESS; + err = clEnqueueSignalSemaphoresKHR(queue, 0, semaphore, nullptr, 0, + nullptr, nullptr); + test_failure_error( + err, CL_INVALID_VALUE, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + } + else + { + // Wait semaphore + cl_int err = CL_SUCCESS; + err = clEnqueueWaitSemaphoresKHR(queue, 0, semaphore, nullptr, 0, + nullptr, nullptr); + test_failure_error(err, CL_INVALID_VALUE, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + } + + return CL_SUCCESS; + } +}; + +// any of the semaphore objects specified by sema_objects is not valid. + +template struct InvalidSemaphore : public SemaphoreTestBase +{ + InvalidSemaphore(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + cl_semaphore_khr sema_objects[] = { nullptr, nullptr, nullptr }; + cl_int err = CL_SUCCESS; + + if (mode == RunMode::RM_SIGNAL) + { + // Signal semaphore + err = clEnqueueSignalSemaphoresKHR( + queue, sizeof(sema_objects) / sizeof(sema_objects[0]), + sema_objects, nullptr, 0, nullptr, nullptr); + test_failure_error( + err, CL_INVALID_SEMAPHORE_KHR, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + } + else + { + // Wait semaphore + err = clEnqueueWaitSemaphoresKHR( + queue, sizeof(sema_objects) / sizeof(sema_objects[0]), + sema_objects, nullptr, 0, nullptr, nullptr); + test_failure_error(err, CL_INVALID_SEMAPHORE_KHR, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + } + + return CL_SUCCESS; + } +}; + +// (1) the context associated with command_queue and any of the semaphore +// objects in sema_objects are not the same, or (2) the context associated with +// command_queue and that associated with events in event_wait_list are not the +// same. + +template struct InvalidContext : public SemaphoreTestBase +{ + InvalidContext(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + // Create semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + + cl_int err = CL_SUCCESS; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_error(err, "Could not create semaphore"); + + // Create secondary context + clContextWrapper context_sec = + clCreateContext(0, 1, &device, nullptr, nullptr, &err); + test_error(err, "Failed to create context"); + + // Create secondary queue + clCommandQueueWrapper queue_sec = + clCreateCommandQueue(context_sec, device, 0, &err); + test_error(err, "Could not create command queue"); + + // Create user event + clEventWrapper user_event = clCreateUserEvent(context_sec, &err); + test_error(err, "Could not create user event"); + + if (mode == RunMode::RM_SIGNAL) + { + // (1) + err = clEnqueueSignalSemaphoresKHR(queue_sec, 1, semaphore, nullptr, + 0, nullptr, nullptr); + test_failure_error( + err, CL_INVALID_CONTEXT, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + + // (2) + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 1, + &user_event, nullptr); + + cl_int signal_error = clSetUserEventStatus(user_event, CL_COMPLETE); + test_error(signal_error, "clSetUserEventStatus failed"); + + test_failure_error( + err, CL_INVALID_CONTEXT, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + } + else + { + // Signal semaphore + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + nullptr, nullptr); + test_error(err, "Could not signal semaphore"); + + // (1) + err = clEnqueueWaitSemaphoresKHR(queue_sec, 1, semaphore, nullptr, + 0, nullptr, nullptr); + test_failure_error(err, CL_INVALID_CONTEXT, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + + // (2) + err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 1, + &user_event, nullptr); + + cl_int signal_error = clSetUserEventStatus(user_event, CL_COMPLETE); + test_error(signal_error, "clSetUserEventStatus failed"); + + test_failure_error(err, CL_INVALID_CONTEXT, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + } + + return TEST_PASS; + } +}; + +// (1) event_wait_list is NULL and num_events_in_wait_list is not 0, or +// (2) event_wait_list is not NULL and num_events_in_wait_list is 0, or +// (3) event objects in event_wait_list are not valid events. + +template struct InvalidEventWaitList : public SemaphoreTestBase +{ + InvalidEventWaitList(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + // Create semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + + cl_int err = CL_SUCCESS; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_error(err, "Could not create semaphore"); + + // Create user event + clEventWrapper user_event = clCreateUserEvent(context, &err); + test_error(err, "Could not create user event"); + + cl_event wait_list[] = { nullptr, nullptr, nullptr }; + + if (mode == RunMode::RM_SIGNAL) + { + // (1) + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 1, + nullptr, nullptr); + test_failure_error( + err, CL_INVALID_EVENT_WAIT_LIST, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + + // (2) + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + &user_event, nullptr); + + cl_int signal_error = clSetUserEventStatus(user_event, CL_COMPLETE); + test_error(signal_error, "clSetUserEventStatus failed"); + + test_failure_error( + err, CL_INVALID_EVENT_WAIT_LIST, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + + // (3) + err = clEnqueueSignalSemaphoresKHR( + queue, 1, semaphore, nullptr, + sizeof(wait_list) / sizeof(wait_list[0]), wait_list, nullptr); + test_failure_error( + err, CL_INVALID_EVENT_WAIT_LIST, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + } + else + { + // Signal semaphore + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + nullptr, nullptr); + test_error(err, "Could not signal semaphore"); + + // (1) + err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 1, + nullptr, nullptr); + test_failure_error(err, CL_INVALID_EVENT_WAIT_LIST, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + + // (2) + err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + &user_event, nullptr); + + cl_int signal_error = clSetUserEventStatus(user_event, CL_COMPLETE); + test_error(signal_error, "clSetUserEventStatus failed"); + + test_failure_error(err, CL_INVALID_EVENT_WAIT_LIST, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + + // (3) + err = clEnqueueWaitSemaphoresKHR( + queue, 1, semaphore, nullptr, + sizeof(wait_list) / sizeof(wait_list[0]), wait_list, nullptr); + test_failure_error(err, CL_INVALID_EVENT_WAIT_LIST, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + } + + return CL_SUCCESS; + } +}; + +// the execution status of any of the events in event_wait_list is a negative +// integer value. + +template struct InvalidEventStatus : public SemaphoreTestBase +{ + InvalidEventStatus(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + // Create semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + + cl_int err = CL_SUCCESS; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_error(err, "Could not create semaphore"); + + // Create user event + clEventWrapper user_event = clCreateUserEvent(context, &err); + test_error(err, "Could not create user event"); + + // set the negative integer value status of the event in event_wait_list + err = clSetUserEventStatus(user_event, -1); + test_error(err, "Unable to set event status"); + + if (mode == RunMode::RM_SIGNAL) + { + // Signal semaphore + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 1, + &user_event, nullptr); + test_failure_error( + err, CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST, + "Unexpected clEnqueueSignalSemaphoresKHR return"); + } + else + { + // Signal semaphore + err = clEnqueueSignalSemaphoresKHR(queue, 1, semaphore, nullptr, 0, + nullptr, nullptr); + test_error(err, "Could not signal semaphore"); + + // Wait semaphore + err = clEnqueueWaitSemaphoresKHR(queue, 1, semaphore, nullptr, 1, + &user_event, nullptr); + test_failure_error(err, + CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST, + "Unexpected clEnqueueWaitSemaphoresKHR return"); + } + + return CL_SUCCESS; + } +}; + +} + +int test_semaphores_negative_wait_invalid_command_queue(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_wait_invalid_value(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>(device, context, + queue, num_elements); +} + +int test_semaphores_negative_wait_invalid_semaphore(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_wait_invalid_context(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_wait_invalid_event_wait_list( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_wait_invalid_event_status(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_signal_invalid_command_queue( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_signal_invalid_value(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_signal_invalid_semaphore(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_signal_invalid_context(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_signal_invalid_event_wait_list( + cl_device_id device, cl_context context, cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} + +int test_semaphores_negative_signal_invalid_event_status(cl_device_id device, + cl_context context, + cl_command_queue queue, + int num_elements) +{ + return MakeAndRunTest>( + device, context, queue, num_elements); +} diff --git a/test_conformance/extensions/cl_khr_semaphore/test_semaphores_queries.cpp b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_queries.cpp new file mode 100644 index 0000000000..5f226509d9 --- /dev/null +++ b/test_conformance/extensions/cl_khr_semaphore/test_semaphores_queries.cpp @@ -0,0 +1,286 @@ +// +// 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 +#include "semaphore_base.h" + +#define FLUSH_DELAY_S 5 + +#define SEMAPHORE_PARAM_TEST(param_name, param_type, format, expected) \ + do \ + { \ + param_type value; \ + size_t size; \ + cl_int error = clGetSemaphoreInfoKHR(semaphore, param_name, \ + sizeof(value), &value, &size); \ + test_error(error, "Unable to get " #param_name " from semaphore"); \ + if (value != expected) \ + { \ + test_fail( \ + "ERROR: Parameter %s did not validate! (expected " format ", " \ + "got " format ")\n", \ + #param_name, expected, value); \ + } \ + if (size != sizeof(value)) \ + { \ + test_fail( \ + "ERROR: Returned size of parameter %s does not validate! " \ + "(expected %d, got %d)\n", \ + #param_name, (int)sizeof(value), (int)size); \ + } \ + } while (false) + +#define SEMAPHORE_PARAM_TEST_ARRAY(param_name, param_type, num_params, \ + expected) \ + do \ + { \ + param_type value[num_params]; \ + size_t size; \ + cl_int error = clGetSemaphoreInfoKHR(semaphore, param_name, \ + sizeof(value), &value, &size); \ + test_error(error, "Unable to get " #param_name " from semaphore"); \ + if (size != sizeof(value)) \ + { \ + test_fail( \ + "ERROR: Returned size of parameter %s does not validate! " \ + "(expected %d, got %d)\n", \ + #param_name, (int)sizeof(value), (int)size); \ + } \ + if (memcmp(value, expected, size) != 0) \ + { \ + test_fail("ERROR: Parameter %s did not validate!\n", #param_name); \ + } \ + } while (false) + +namespace { + +struct SemaphoreWithDeviceListQueries : public SemaphoreTestBase +{ + SemaphoreWithDeviceListQueries(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + cl_int err = CL_SUCCESS; + + // Query binary semaphore created with + // CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR + + // Create binary semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + static_cast( + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)device, + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + 0 + }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_error(err, "Could not create semaphore"); + + // Confirm that querying CL_SEMAPHORE_TYPE_KHR returns + // CL_SEMAPHORE_TYPE_BINARY_KHR + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr, "%d", + CL_SEMAPHORE_TYPE_BINARY_KHR); + + // Confirm that querying CL_SEMAPHORE_CONTEXT_KHR returns the right + // context + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_CONTEXT_KHR, cl_context, "%p", + context); + + // Confirm that querying CL_SEMAPHORE_REFERENCE_COUNT_KHR returns the + // right value + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, "%u", + 1); + + err = clRetainSemaphoreKHR(semaphore); + test_error(err, "Could not retain semaphore"); + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, "%u", + 2); + + err = clReleaseSemaphoreKHR(semaphore); + test_error(err, "Could not release semaphore"); + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, "%u", + 1); + + // Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns the + // same device id the semaphore was created with + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id, + "%p", device); + + // Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the same + // properties the semaphore was created with + SEMAPHORE_PARAM_TEST_ARRAY(CL_SEMAPHORE_PROPERTIES_KHR, + cl_semaphore_properties_khr, 6, sema_props); + + // Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled + // state + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr, + "%" PRIu64, + static_cast(0)); + + return TEST_PASS; + } +}; + +struct SemaphoreNoDeviceListQueries : public SemaphoreTestBase +{ + SemaphoreNoDeviceListQueries(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + cl_int err = CL_SUCCESS; + + // Query binary semaphore created without + // CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR + + // Create binary semaphore + cl_semaphore_properties_khr sema_props[] = { + static_cast(CL_SEMAPHORE_TYPE_KHR), + static_cast( + CL_SEMAPHORE_TYPE_BINARY_KHR), + 0 + }; + semaphore = + clCreateSemaphoreWithPropertiesKHR(context, sema_props, &err); + test_error(err, "Could not create semaphore"); + + // Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns + // device id the semaphore was created with + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id, + "%p", device); + + return TEST_PASS; + } +}; + +struct SemaphoreMultiDeviceContextQueries : public SemaphoreTestBase +{ + SemaphoreMultiDeviceContextQueries(cl_device_id device, cl_context context, + cl_command_queue queue, cl_int nelems) + : SemaphoreTestBase(device, context, queue, nelems) + {} + + cl_int Run() override + { + // partition device and create new context if possible + cl_uint maxComputeUnits = 0; + cl_int err = + clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, + sizeof(maxComputeUnits), &maxComputeUnits, NULL); + test_error(err, "Unable to get maximal number of compute units"); + + cl_device_partition_property partitionProp[] = { + CL_DEVICE_PARTITION_EQUALLY, + static_cast(maxComputeUnits / 2), 0 + }; + + cl_uint deviceCount = 0; + // how many sub-devices can we create? + err = + clCreateSubDevices(device, partitionProp, 0, nullptr, &deviceCount); + if (err != CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + if (deviceCount < 2) + test_error_ret( + CL_INVALID_VALUE, + "Multi context test for CL_INVALID_PROPERTY not supported", + TEST_SKIPPED_ITSELF); + + // get the list of subDevices + SubDevicesScopeGuarded scope_guard(deviceCount); + err = clCreateSubDevices(device, partitionProp, deviceCount, + scope_guard.sub_devices.data(), &deviceCount); + if (err != CL_SUCCESS) + { + log_info("Can't partition device, test not supported\n"); + return TEST_SKIPPED_ITSELF; + } + + /* Create a multi device context */ + clContextWrapper multi_device_context = clCreateContext( + NULL, (cl_uint)deviceCount, scope_guard.sub_devices.data(), nullptr, + nullptr, &err); + test_error_ret(err, "Unable to create testing context", CL_SUCCESS); + + cl_semaphore_properties_khr sema_props[] = { + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_KHR, + (cl_semaphore_properties_khr)CL_SEMAPHORE_TYPE_BINARY_KHR, + static_cast( + CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR), + (cl_semaphore_properties_khr)scope_guard.sub_devices[0], + CL_SEMAPHORE_DEVICE_HANDLE_LIST_END_KHR, + 0 + }; + + // Try to create semaphore with multi device context + semaphore = clCreateSemaphoreWithPropertiesKHR(multi_device_context, + sema_props, &err); + test_error(err, "Unable to create semaphore with properties"); + + // Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns + // the same device id the semaphore was created with + SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id, + "%p", scope_guard.sub_devices[0]); + + return TEST_PASS; + } +}; + +} // anonymous namespace + +// Confirm the semaphore with device list can be successfully queried +int test_semaphores_device_list_queries(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); +} + +// Confirm the semaphore without device list can be successfully queried +int test_semaphores_no_device_list_queries(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); +} + +// Confirm the semaphore created with multi-device context can be successfully +// queried +int test_semaphores_multi_device_context_queries(cl_device_id deviceID, + cl_context context, + cl_command_queue defaultQueue, + int num_elements) +{ + return MakeAndRunTest( + deviceID, context, defaultQueue, num_elements); +} diff --git a/test_conformance/generic_address_space/main.cpp b/test_conformance/generic_address_space/main.cpp index a7897367ba..4d4dea46c6 100644 --- a/test_conformance/generic_address_space/main.cpp +++ b/test_conformance/generic_address_space/main.cpp @@ -92,7 +92,8 @@ test_status InitCL(cl_device_id device) { if (version >= Version(3, 0)) { cl_int error; - cl_bool support_generic; + cl_bool support_generic = CL_FALSE; + size_t max_gvar_size = 0; error = clGetDeviceInfo(device, CL_DEVICE_GENERIC_ADDRESS_SPACE_SUPPORT, sizeof(support_generic), &support_generic, NULL); @@ -106,6 +107,20 @@ test_status InitCL(cl_device_id device) { { return TEST_SKIP; } + + error = clGetDeviceInfo(device, CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE, + sizeof(max_gvar_size), &max_gvar_size, NULL); + if (error != CL_SUCCESS) + { + print_error(error, + "Unable to query CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE."); + return TEST_FAIL; + } + + if (!max_gvar_size) + { + return TEST_SKIP; + } } return TEST_PASS; diff --git a/test_conformance/gl/test_image_methods.cpp b/test_conformance/gl/test_image_methods.cpp index 1bf8f561f5..66db163b1f 100644 --- a/test_conformance/gl/test_image_methods.cpp +++ b/test_conformance/gl/test_image_methods.cpp @@ -17,8 +17,6 @@ #include -using namespace std; - struct image_kernel_data { cl_int width; @@ -383,17 +381,18 @@ int test_image_methods_depth(cl_device_id device, cl_context context, glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize); glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers); - size = min(maxTextureSize, maxTextureRectangleSize); + size = std::min(maxTextureSize, maxTextureRectangleSize); RandomSeed seed(gRandomSeed); // Generate some random sizes (within reasonable ranges) for (size_t i = 0; i < nsizes; i++) { - sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed); - sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed); + sizes[i].width = random_in_range(2, std::min(size, 1 << (i + 4)), seed); + sizes[i].height = + random_in_range(2, std::min(size, 1 << (i + 4)), seed); sizes[i].depth = - random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureLayers, 1 << (i + 4)), seed); } for (size_t i = 0; i < nsizes; i++) @@ -440,11 +439,11 @@ int test_image_methods_multisample(cl_device_id device, cl_context context, for (size_t i = 0; i < nsizes; i++) { sizes[i].width = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].height = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].depth = - random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureLayers, 1 << (i + 4)), seed); } glEnable(GL_MULTISAMPLE); diff --git a/test_conformance/gl/test_images_1D.cpp b/test_conformance/gl/test_images_1D.cpp index 4ccf86bccf..895e13a751 100644 --- a/test_conformance/gl/test_images_1D.cpp +++ b/test_conformance/gl/test_images_1D.cpp @@ -24,8 +24,6 @@ #endif #include -using namespace std; - void calc_test_size_descriptors(sizevec_t* sizes, size_t nsizes) { // Need to limit array size according to GL device properties @@ -33,14 +31,14 @@ void calc_test_size_descriptors(sizevec_t* sizes, size_t nsizes) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &maxTextureBufferSize); - size = min(maxTextureSize, maxTextureBufferSize); + size = std::min(maxTextureSize, maxTextureBufferSize); RandomSeed seed(gRandomSeed); // Generate some random sizes (within reasonable ranges) for (size_t i = 0; i < nsizes; i++) { - sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed); + sizes[i].width = random_in_range(2, std::min(size, 1 << (i + 4)), seed); sizes[i].height = 1; sizes[i].depth = 1; } diff --git a/test_conformance/gl/test_images_1Darray.cpp b/test_conformance/gl/test_images_1Darray.cpp index daa2efa8b1..d64e840462 100644 --- a/test_conformance/gl/test_images_1Darray.cpp +++ b/test_conformance/gl/test_images_1Darray.cpp @@ -24,7 +24,6 @@ #endif #include -using namespace std; void calc_1D_array_size_descriptors(sizevec_t* sizes, size_t nsizes) { // Need to limit array size according to GL device properties @@ -38,9 +37,9 @@ void calc_1D_array_size_descriptors(sizevec_t* sizes, size_t nsizes) for (size_t i = 0; i < nsizes; i++) { sizes[i].width = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].height = - random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureLayers, 1 << (i + 4)), seed); sizes[i].depth = 1; } } diff --git a/test_conformance/gl/test_images_2D.cpp b/test_conformance/gl/test_images_2D.cpp index 63ea31e2fd..cbdf3b9af3 100644 --- a/test_conformance/gl/test_images_2D.cpp +++ b/test_conformance/gl/test_images_2D.cpp @@ -24,11 +24,6 @@ #endif #include -using namespace std; - -#pragma mark - -#pragma mark _2D read tests - void calc_2D_test_size_descriptors(sizevec_t* sizes, size_t nsizes) { // Need to limit array size according to GL device properties @@ -37,15 +32,16 @@ void calc_2D_test_size_descriptors(sizevec_t* sizes, size_t nsizes) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize); - size = min(maxTextureSize, maxTextureRectangleSize); + size = std::min(maxTextureSize, maxTextureRectangleSize); RandomSeed seed(gRandomSeed); // Generate some random sizes (within reasonable ranges) for (size_t i = 0; i < nsizes; i++) { - sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed); - sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed); + sizes[i].width = random_in_range(2, std::min(size, 1 << (i + 4)), seed); + sizes[i].height = + random_in_range(2, std::min(size, 1 << (i + 4)), seed); sizes[i].depth = 1; } } @@ -63,7 +59,7 @@ void calc_cube_test_size_descriptors(sizevec_t* sizes, size_t nsizes) for (size_t i = 0; i < nsizes; i++) { sizes[i].width = sizes[i].height = - random_in_range(2, min(maxQubeMapSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxQubeMapSize, 1 << (i + 4)), seed); sizes[i].depth = 1; } } diff --git a/test_conformance/gl/test_images_2Darray.cpp b/test_conformance/gl/test_images_2Darray.cpp index 20ca71447c..c851ca302b 100644 --- a/test_conformance/gl/test_images_2Darray.cpp +++ b/test_conformance/gl/test_images_2Darray.cpp @@ -24,8 +24,6 @@ #endif #include -using namespace std; - void calc_2D_array_size_descriptors(sizevec_t* sizes, size_t nsizes) { // Need to limit array size according to GL device properties @@ -39,11 +37,11 @@ void calc_2D_array_size_descriptors(sizevec_t* sizes, size_t nsizes) for (size_t i = 0; i < nsizes; i++) { sizes[i].width = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].height = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].depth = - random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureLayers, 1 << (i + 4)), seed); } } diff --git a/test_conformance/gl/test_images_3D.cpp b/test_conformance/gl/test_images_3D.cpp index 220cd0ca04..68036a1a22 100644 --- a/test_conformance/gl/test_images_3D.cpp +++ b/test_conformance/gl/test_images_3D.cpp @@ -24,11 +24,6 @@ #endif #include -using namespace std; - -#pragma mark - -#pragma mark _3D read test - void calc_3D_size_descriptors(sizevec_t* sizes, size_t nsizes) { // Need to limit array size according to GL device properties @@ -41,11 +36,11 @@ void calc_3D_size_descriptors(sizevec_t* sizes, size_t nsizes) for (size_t i = 0; i < nsizes; i++) { sizes[i].width = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].height = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].depth = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); } } diff --git a/test_conformance/gl/test_images_depth.cpp b/test_conformance/gl/test_images_depth.cpp index 05265cc62d..743d004fce 100644 --- a/test_conformance/gl/test_images_depth.cpp +++ b/test_conformance/gl/test_images_depth.cpp @@ -25,11 +25,6 @@ #include -using namespace std; - -#pragma mark - -#pragma mark _2D depth read tests - void calc_depth_size_descriptors(sizevec_t* sizes, size_t nsizes) { // Need to limit texture size according to GL device properties @@ -37,15 +32,16 @@ void calc_depth_size_descriptors(sizevec_t* sizes, size_t nsizes) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize); - size = min(maxTextureSize, maxTextureRectangleSize); + size = std::min(maxTextureSize, maxTextureRectangleSize); RandomSeed seed(gRandomSeed); // Generate some random sizes (within reasonable ranges) for (size_t i = 0; i < nsizes; i++) { - sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed); - sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed); + sizes[i].width = random_in_range(2, std::min(size, 1 << (i + 4)), seed); + sizes[i].height = + random_in_range(2, std::min(size, 1 << (i + 4)), seed); sizes[i].depth = 1; } } @@ -59,17 +55,18 @@ void calc_depth_array_size_descriptors(sizevec_t* sizes, size_t nsizes) glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize); glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers); - size = min(maxTextureSize, maxTextureRectangleSize); + size = std::min(maxTextureSize, maxTextureRectangleSize); RandomSeed seed(gRandomSeed); // Generate some random sizes (within reasonable ranges) for (size_t i = 0; i < nsizes; i++) { - sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed); - sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed); + sizes[i].width = random_in_range(2, std::min(size, 1 << (i + 4)), seed); + sizes[i].height = + random_in_range(2, std::min(size, 1 << (i + 4)), seed); sizes[i].depth = - random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureLayers, 1 << (i + 4)), seed); } } diff --git a/test_conformance/gl/test_images_multisample.cpp b/test_conformance/gl/test_images_multisample.cpp index bfb04ab6e0..d104937b42 100644 --- a/test_conformance/gl/test_images_multisample.cpp +++ b/test_conformance/gl/test_images_multisample.cpp @@ -25,8 +25,6 @@ #include -using namespace std; - void calc_2D_multisample_size_descriptors(sizevec_t* sizes, size_t nsizes) { // Need to limit texture size according to GL device properties @@ -39,9 +37,9 @@ void calc_2D_multisample_size_descriptors(sizevec_t* sizes, size_t nsizes) for (size_t i = 0; i < nsizes; i++) { sizes[i].width = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].height = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].depth = 1; } } @@ -59,11 +57,11 @@ void calc_2D_array_multisample_size_descriptors(sizevec_t* sizes, size_t nsizes) for (size_t i = 0; i < nsizes; i++) { sizes[i].width = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].height = - random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureSize, 1 << (i + 4)), seed); sizes[i].depth = - random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed); + random_in_range(2, std::min(maxTextureLayers, 1 << (i + 4)), seed); } } diff --git a/test_conformance/gl/test_images_write_common.cpp b/test_conformance/gl/test_images_write_common.cpp index 65e3b23a10..6f1f51e7ca 100644 --- a/test_conformance/gl/test_images_write_common.cpp +++ b/test_conformance/gl/test_images_write_common.cpp @@ -37,11 +37,10 @@ static const char *kernelpattern_image_write_1D = "}\n"; static const char *kernelpattern_image_write_1D_half = -"#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n" -"__kernel void sample_test( __global half4 *source, write_only image1d_t dest )\n" +"__kernel void sample_test( __global half *source, write_only image1d_t dest )\n" "{\n" " uint index = get_global_id(0);\n" -" write_imagef( dest, index, vload_half4(index, (__global half *)source));\n" +" write_imagef( dest, index, vload_half4(index, source));\n" "}\n"; static const char *kernelpattern_image_write_1D_buffer = @@ -53,11 +52,10 @@ static const char *kernelpattern_image_write_1D_buffer = "}\n"; static const char *kernelpattern_image_write_1D_buffer_half = -"#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n" -"__kernel void sample_test( __global half4 *source, write_only image1d_buffer_t dest )\n" +"__kernel void sample_test( __global half *source, write_only image1d_buffer_t dest )\n" "{\n" " uint index = get_global_id(0);\n" -" write_imagef( dest, index, vload_half4(index, (__global half *)source));\n" +" write_imagef( dest, index, vload_half4(index, source));\n" "}\n"; static const char *kernelpattern_image_write_2D = @@ -71,13 +69,12 @@ static const char *kernelpattern_image_write_2D = "}\n"; static const char *kernelpattern_image_write_2D_half = -"#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n" -"__kernel void sample_test( __global half4 *source, write_only image2d_t dest )\n" +"__kernel void sample_test( __global half *source, write_only image2d_t dest )\n" "{\n" " int tidX = get_global_id(0);\n" " int tidY = get_global_id(1);\n" " uint index = tidY * get_image_width( dest ) + tidX;\n" -" write_imagef( dest, (int2)( tidX, tidY ), vload_half4(index, (__global half *)source));\n" +" write_imagef( dest, (int2)( tidX, tidY ), vload_half4(index, source));\n" "}\n"; static const char *kernelpattern_image_write_1Darray = @@ -91,13 +88,12 @@ static const char *kernelpattern_image_write_1Darray = "}\n"; static const char *kernelpattern_image_write_1Darray_half = -"#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n" -"__kernel void sample_test( __global half4 *source, write_only image1d_array_t dest )\n" +"__kernel void sample_test( __global half *source, write_only image1d_array_t dest )\n" "{\n" " int tidX = get_global_id(0);\n" " int tidY = get_global_id(1);\n" " uint index = tidY * get_image_width( dest ) + tidX;\n" -" write_imagef( dest, (int2)( tidX, tidY ), vload_half4(index, (__global half *)source));\n" +" write_imagef( dest, (int2)( tidX, tidY ), vload_half4(index, source));\n" "}\n"; static const char *kernelpattern_image_write_3D = @@ -115,9 +111,8 @@ static const char *kernelpattern_image_write_3D = "}\n"; static const char *kernelpattern_image_write_3D_half = -"#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n" "#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable\n" -"__kernel void sample_test( __global half4 *source, write_only image3d_t dest )\n" +"__kernel void sample_test( __global half *source, write_only image3d_t dest )\n" "{\n" " int tidX = get_global_id(0);\n" " int tidY = get_global_id(1);\n" @@ -125,7 +120,7 @@ static const char *kernelpattern_image_write_3D_half = " int width = get_image_width( dest );\n" " int height = get_image_height( dest );\n" " int index = tidZ * width * height + tidY * width + tidX;\n" -" write_imagef( dest, (int4)( tidX, tidY, tidZ, 0 ), vload_half4(index, (__global half *)source));\n" +" write_imagef( dest, (int4)( tidX, tidY, tidZ, 0 ), vload_half4(index, source));\n" "}\n"; static const char *kernelpattern_image_write_2Darray = @@ -142,8 +137,7 @@ static const char *kernelpattern_image_write_2Darray = "}\n"; static const char *kernelpattern_image_write_2Darray_half = -"#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n" -"__kernel void sample_test( __global half4 *source, write_only image2d_array_t dest )\n" +"__kernel void sample_test( __global half *source, write_only image2d_array_t dest )\n" "{\n" " int tidX = get_global_id(0);\n" " int tidY = get_global_id(1);\n" @@ -151,7 +145,7 @@ static const char *kernelpattern_image_write_2Darray_half = " int width = get_image_width( dest );\n" " int height = get_image_height( dest );\n" " int index = tidZ * width * height + tidY * width + tidX;\n" -" write_imagef( dest, (int4)( tidX, tidY, tidZ, 0 ), vload_half4(index, (__global half *)source));\n" +" write_imagef( dest, (int4)( tidX, tidY, tidZ, 0 ), vload_half4(index, source));\n" "}\n"; #ifdef GL_VERSION_3_2 @@ -310,8 +304,7 @@ void set_dimensions_by_target(GLenum target, size_t *dims, size_t sizes[3], int test_cl_image_write(cl_context context, cl_command_queue queue, GLenum target, cl_mem clImage, size_t width, size_t height, size_t depth, cl_image_format *outFormat, - ExplicitType *outType, void **outSourceBuffer, MTdata d, - bool supports_half) + ExplicitType *outType, void **outSourceBuffer, MTdata d) { size_t global_dims, global_sizes[3]; clProgramWrapper program; @@ -335,11 +328,6 @@ int test_cl_image_write(cl_context context, cl_command_queue queue, const char *appropriateKernel = get_appropriate_write_kernel( target, *outType, outFormat->image_channel_order); - if (*outType == kHalf && !supports_half) - { - log_info("cl_khr_fp16 isn't supported. Skip this test.\n"); - return 0; - } const char *suffix = get_kernel_suffix(outFormat); const char *convert = get_write_conversion(outFormat, *outType); @@ -429,8 +417,7 @@ static int test_image_write(cl_context context, cl_command_queue queue, GLenum glTarget, GLuint glTexture, size_t width, size_t height, size_t depth, cl_image_format *outFormat, ExplicitType *outType, - void **outSourceBuffer, MTdata d, - bool supports_half) + void **outSourceBuffer, MTdata d) { int error; @@ -450,8 +437,7 @@ static int test_image_write(cl_context context, cl_command_queue queue, } return test_cl_image_write(context, queue, glTarget, image, width, height, - depth, outFormat, outType, outSourceBuffer, d, - supports_half); + depth, outFormat, outType, outSourceBuffer, d); } int supportsHalf(cl_context context, bool *supports_half) @@ -616,15 +602,11 @@ static int test_image_format_write(cl_context context, cl_command_queue queue, globj = glRenderbuffer; } - bool supports_half = false; - error = supportsHalf(context, &supports_half); - if (error != 0) return error; - - error = test_image_write(context, queue, target, globj, width, height, - depth, &clFormat, &sourceType, - (void **)&outSourceBuffer, d, supports_half); + error = + test_image_write(context, queue, target, globj, width, height, depth, + &clFormat, &sourceType, (void **)&outSourceBuffer, d); - if (error != 0 || ((sourceType == kHalf) && !supports_half)) + if (error != 0) { if (outSourceBuffer) free(outSourceBuffer); return error; diff --git a/test_conformance/gl/test_renderbuffer.cpp b/test_conformance/gl/test_renderbuffer.cpp index 422b5a3d6a..1b5709d4b5 100644 --- a/test_conformance/gl/test_renderbuffer.cpp +++ b/test_conformance/gl/test_renderbuffer.cpp @@ -55,7 +55,7 @@ extern int test_cl_image_write(cl_context context, cl_command_queue queue, size_t height, size_t depth, cl_image_format *outFormat, ExplicitType *outType, void **outSourceBuffer, - MTdata d, bool supports_half); + MTdata d); extern int test_cl_image_read(cl_context context, cl_command_queue queue, GLenum gl_target, cl_mem image, size_t width, @@ -299,7 +299,7 @@ int test_attach_renderbuffer_write_to_image( cl_context context, cl_command_queue queue, GLenum glTarget, GLuint glRenderbuffer, size_t imageWidth, size_t imageHeight, cl_image_format *outFormat, ExplicitType *outType, MTdata d, - void **outSourceBuffer, bool supports_half) + void **outSourceBuffer) { int error; @@ -314,7 +314,7 @@ int test_attach_renderbuffer_write_to_image( return test_cl_image_write(context, queue, glTarget, image, imageWidth, imageHeight, 1, outFormat, outType, - outSourceBuffer, d, supports_half); + outSourceBuffer, d); } int test_renderbuffer_image_write(cl_context context, cl_command_queue queue, @@ -355,14 +355,10 @@ int test_renderbuffer_image_write(cl_context context, cl_command_queue queue, ExplicitType validationType; void *outSourceBuffer; - bool supports_half = false; - error = supportsHalf(context, &supports_half); - if (error != 0) return error; - error = test_attach_renderbuffer_write_to_image( context, queue, attachment, glRenderbuffer, width, height, &clFormat, - &sourceType, d, (void **)&outSourceBuffer, supports_half); - if (error != 0 || ((sourceType == kHalf) && !supports_half)) return error; + &sourceType, d, (void **)&outSourceBuffer); + if (error != 0) return error; // If actual source type was half, convert to float for validation. if (sourceType == kHalf) diff --git a/test_conformance/images/clCopyImage/test_copy_1D.cpp b/test_conformance/images/clCopyImage/test_copy_1D.cpp index 0f6f3ce4d6..b4ae830850 100644 --- a/test_conformance/images/clCopyImage/test_copy_1D.cpp +++ b/test_conformance/images/clCopyImage/test_copy_1D.cpp @@ -213,7 +213,7 @@ int test_copy_image_set_1D( cl_device_id device, cl_context context, cl_command_ { log_info( " at size %d (row pitch %d) out of %d\n", (int)imageInfo.width, (int)imageInfo.rowPitch, (int)maxWidth ); if ( gTestMipmaps ) - log_info( " and %llu mip levels\n", (size_t) imageInfo.num_mip_levels ); + log_info(" and %u mip levels\n", imageInfo.num_mip_levels); } int ret = test_copy_image_size_1D( context, queue, &imageInfo, seed ); diff --git a/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp b/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp index f8f14bd442..f74e60a974 100644 --- a/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp +++ b/test_conformance/images/clCopyImage/test_copy_1D_buffer.cpp @@ -182,7 +182,7 @@ int test_copy_image_set_1D_buffer(cl_device_id device, cl_context context, do { imageInfo.width = - (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + (size_t)random_log_in_range(16, (int)(maxWidth / 32), seed); imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; diff --git a/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp b/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp index e3079c4678..dad389ae00 100644 --- a/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp +++ b/test_conformance/images/clFillImage/test_fill_1D_buffer.cpp @@ -171,7 +171,7 @@ int test_fill_image_set_1D_buffer(cl_device_id device, cl_context context, do { imageInfo.width = - (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + (size_t)random_log_in_range(16, (int)(maxWidth / 32), seed); imageInfo.rowPitch = imageInfo.width * pixelSize + rowPadding; diff --git a/test_conformance/images/clGetInfo/test_1D_buffer.cpp b/test_conformance/images/clGetInfo/test_1D_buffer.cpp index 7b0c2d1c6d..45842b1d2e 100644 --- a/test_conformance/images/clGetInfo/test_1D_buffer.cpp +++ b/test_conformance/images/clGetInfo/test_1D_buffer.cpp @@ -99,7 +99,7 @@ int test_get_image_info_1D_buffer(cl_device_id device, cl_context context, do { imageInfo.width = - (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + (size_t)random_log_in_range(16, (int)(maxWidth / 32), seed); imageInfo.rowPitch = imageInfo.width * pixelSize; size_t extraWidth = (int)random_log_in_range(0, 64, seed); diff --git a/test_conformance/images/clReadWriteImage/test_read_1D_buffer.cpp b/test_conformance/images/clReadWriteImage/test_read_1D_buffer.cpp index 01dd80dc39..4b1aa14f4c 100644 --- a/test_conformance/images/clReadWriteImage/test_read_1D_buffer.cpp +++ b/test_conformance/images/clReadWriteImage/test_read_1D_buffer.cpp @@ -230,7 +230,7 @@ int test_read_image_set_1D_buffer(cl_device_id device, cl_context context, do { imageInfo.width = - (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + (size_t)random_log_in_range(16, (int)(maxWidth / 32), seed); imageInfo.rowPitch = imageInfo.width * pixelSize; if (gEnablePitch) diff --git a/test_conformance/images/common.cpp b/test_conformance/images/common.cpp index 0b2c956cc6..178f962f4d 100644 --- a/test_conformance/images/common.cpp +++ b/test_conformance/images/common.cpp @@ -16,12 +16,21 @@ #include "common.h" cl_channel_type floatFormats[] = { - CL_UNORM_SHORT_565, CL_UNORM_SHORT_555, CL_UNORM_INT_101010, + CL_UNORM_SHORT_565, + CL_UNORM_SHORT_555, + CL_UNORM_INT_101010, + CL_UNORM_INT_101010_2, + CL_UNORM_INT_2_101010_EXT, #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_image_methods/test_1D_buffer.cpp b/test_conformance/images/kernel_image_methods/test_1D_buffer.cpp index 1885cbd63e..c8f73a34e6 100644 --- a/test_conformance/images/kernel_image_methods/test_1D_buffer.cpp +++ b/test_conformance/images/kernel_image_methods/test_1D_buffer.cpp @@ -67,9 +67,7 @@ static int test_get_1Dimage_buffer_info_single(cl_context context, if (gDebugTrace) log_info(" - Creating 1D image %d ...\n", (int)imageInfo->width); - buffer = clCreateBuffer( - context, flags, imageInfo->width * get_pixel_size(imageInfo->format), - NULL, &error); + buffer = clCreateBuffer(context, flags, imageInfo->rowPitch, NULL, &error); if (error != CL_SUCCESS) { log_error("ERROR: Unable to create buffer for 1D image buffer of size " @@ -252,7 +250,7 @@ int test_get_image_info_1D_buffer(cl_device_id device, cl_context context, do { imageInfo.width = - (size_t)random_log_in_range(16, (int)maxWidth / 32, seed); + (size_t)random_log_in_range(16, (int)(maxWidth / 32), seed); imageInfo.rowPitch = imageInfo.width * pixelSize; size_t extraWidth = (int)random_log_in_range(0, 64, seed); @@ -264,8 +262,7 @@ int test_get_image_info_1D_buffer(cl_device_id device, cl_context context, imageInfo.rowPitch += extraWidth; } while ((imageInfo.rowPitch % pixelSize) != 0); - size = (cl_ulong)imageInfo.rowPitch * (cl_ulong)imageInfo.height - * 4; + size = (cl_ulong)imageInfo.rowPitch * 4; } while (size > maxAllocSize || (size * 3) > memSize); if (gDebugTrace) diff --git a/test_conformance/images/kernel_read_write/test_common.cpp b/test_conformance/images/kernel_read_write/test_common.cpp index 9b2bfe9246..7ed280b0a1 100644 --- a/test_conformance/images/kernel_read_write/test_common.cpp +++ b/test_conformance/images/kernel_read_write/test_common.cpp @@ -2144,6 +2144,10 @@ int filter_rounding_errors(int forceCorrectlyRoundedWrites, if (0 == forceCorrectlyRoundedWrites && (imageInfo->format->image_channel_data_type == CL_UNORM_INT8 || imageInfo->format->image_channel_data_type == CL_UNORM_INT_101010 + || imageInfo->format->image_channel_data_type + == CL_UNORM_INT_101010_2 + || imageInfo->format->image_channel_data_type + == CL_UNORM_INT_2_101010_EXT || imageInfo->format->image_channel_data_type == CL_UNORM_INT16 || imageInfo->format->image_channel_data_type == CL_SNORM_INT8 || imageInfo->format->image_channel_data_type == CL_SNORM_INT16 diff --git a/test_conformance/images/kernel_read_write/test_loops.cpp b/test_conformance/images/kernel_read_write/test_loops.cpp index ea1e1c7c0a..60144e056d 100644 --- a/test_conformance/images/kernel_read_write/test_loops.cpp +++ b/test_conformance/images/kernel_read_write/test_loops.cpp @@ -175,6 +175,18 @@ int test_read_image_formats(cl_device_id device, cl_context context, bool flipFlop[2] = { false, true }; int normalizedIdx, floatCoordIdx; + if (gTestMipmaps) + { + if (0 == is_extension_available(device, "cl_khr_mipmap_image")) + { + log_info("-----------------------------------------------------\n"); + log_info("This device does not support " + "cl_khr_mipmap_image.\nSkipping mipmapped image test. \n"); + log_info( + "-----------------------------------------------------\n\n"); + return 0; + } + } // Use this run if we were told to only run a certain filter mode if (gFilterModeToUse != (cl_filter_mode)-1 diff --git a/test_conformance/images/samplerlessReads/test_read_1D_array.cpp b/test_conformance/images/samplerlessReads/test_read_1D_array.cpp index 677eb9f12a..a751ad08d7 100644 --- a/test_conformance/images/samplerlessReads/test_read_1D_array.cpp +++ b/test_conformance/images/samplerlessReads/test_read_1D_array.cpp @@ -160,7 +160,9 @@ int test_read_image_1D_array( cl_context context, cl_command_queue queue, cl_ker } if ( !allZeroes ) { - log_error( " Sampler-less reads differ from reads with sampler at index %lu.\n", ic ); + log_error(" Sampler-less reads differ from reads with sampler at index " + "%zu.\n", + ic); return -1; } diff --git a/test_conformance/images/samplerlessReads/test_read_3D.cpp b/test_conformance/images/samplerlessReads/test_read_3D.cpp index 0df46c8643..1facc79459 100644 --- a/test_conformance/images/samplerlessReads/test_read_3D.cpp +++ b/test_conformance/images/samplerlessReads/test_read_3D.cpp @@ -149,7 +149,9 @@ int test_read_image_3D( cl_context context, cl_command_queue queue, cl_kernel ke } if ( !allZeroes ) { - log_error( " Sampler-less reads differ from reads with sampler at index %lu.\n", ic ); + log_error(" Sampler-less reads differ from reads with sampler at index " + "%zu.\n", + ic); return -1; } diff --git a/test_conformance/integer_ops/CMakeLists.txt b/test_conformance/integer_ops/CMakeLists.txt index 7bc991f8d5..9966ca6fe4 100644 --- a/test_conformance/integer_ops/CMakeLists.txt +++ b/test_conformance/integer_ops/CMakeLists.txt @@ -1,5 +1,9 @@ set(MODULE_NAME INTEGER_OPS) +if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") + add_cxx_flag_if_supported(-Wno-narrowing) +endif() + set(${MODULE_NAME}_SOURCES main.cpp test_int_basic_ops.cpp diff --git a/test_conformance/math_brute_force/CMakeLists.txt b/test_conformance/math_brute_force/CMakeLists.txt index d53911e433..35d4e0b3ab 100644 --- a/test_conformance/math_brute_force/CMakeLists.txt +++ b/test_conformance/math_brute_force/CMakeLists.txt @@ -54,10 +54,6 @@ set(${MODULE_NAME}_SOURCES utility.h ) -# math_brute_force compiles cleanly with -Wall (except for a few remaining -# warnings), but other tests not (yet); so enable -Wall locally. -set_gnulike_module_compile_flags("-Wall -Wno-strict-aliasing -Wno-unknown-pragmas") - add_cxx_flag_if_supported(-ffp-contract=off) include(../CMakeCommon.txt) diff --git a/test_conformance/math_brute_force/binary_float.cpp b/test_conformance/math_brute_force/binary_float.cpp index 3bab4057b8..deea1ce969 100644 --- a/test_conformance/math_brute_force/binary_float.cpp +++ b/test_conformance/math_brute_force/binary_float.cpp @@ -201,7 +201,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) fptr func = job->f->func; int ftz = job->ftz; bool relaxedMode = job->relaxedMode; - float ulps = getAllowedUlpError(job->f, relaxedMode); + float ulps = getAllowedUlpError(job->f, kfloat, relaxedMode); MTdata d = tinfo->d; cl_int error; std::vector overflow(buffer_elements, false); diff --git a/test_conformance/math_brute_force/binary_half.cpp b/test_conformance/math_brute_force/binary_half.cpp index 897bd6e7c6..180034ba7d 100644 --- a/test_conformance/math_brute_force/binary_half.cpp +++ b/test_conformance/math_brute_force/binary_half.cpp @@ -653,7 +653,7 @@ int TestFunc_Half_Half_Half_common(const Func *f, MTdata d, int isNextafter, } test_info.f = f; - test_info.ulps = f->half_ulps; + test_info.ulps = getAllowedUlpError(f, khalf, relaxedMode); test_info.ftz = f->ftz || gForceFTZ || 0 == (CL_FP_DENORM & gHalfCapabilities); diff --git a/test_conformance/math_brute_force/binary_i_half.cpp b/test_conformance/math_brute_force/binary_i_half.cpp index 2d6e827fdf..0f167fc9f5 100644 --- a/test_conformance/math_brute_force/binary_i_half.cpp +++ b/test_conformance/math_brute_force/binary_i_half.cpp @@ -427,7 +427,7 @@ int TestFunc_Half_Half_Int(const Func *f, MTdata d, bool relaxedMode) } test_info.f = f; - test_info.ulps = f->half_ulps; + test_info.ulps = getAllowedUlpError(f, khalf, relaxedMode); test_info.ftz = f->ftz || gForceFTZ || 0 == (CL_FP_DENORM & gHalfCapabilities); diff --git a/test_conformance/math_brute_force/binary_operator_float.cpp b/test_conformance/math_brute_force/binary_operator_float.cpp index 741c396ca8..6f5a364521 100644 --- a/test_conformance/math_brute_force/binary_operator_float.cpp +++ b/test_conformance/math_brute_force/binary_operator_float.cpp @@ -197,7 +197,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) fptr func = job->f->func; int ftz = job->ftz; bool relaxedMode = job->relaxedMode; - float ulps = getAllowedUlpError(job->f, relaxedMode); + float ulps = getAllowedUlpError(job->f, kfloat, relaxedMode); MTdata d = tinfo->d; cl_int error; std::vector overflow(buffer_elements, false); diff --git a/test_conformance/math_brute_force/binary_operator_half.cpp b/test_conformance/math_brute_force/binary_operator_half.cpp index 366e63e8b1..b4abf49058 100644 --- a/test_conformance/math_brute_force/binary_operator_half.cpp +++ b/test_conformance/math_brute_force/binary_operator_half.cpp @@ -564,7 +564,7 @@ int TestFunc_Half_Half_Half_Operator(const Func *f, MTdata d, bool relaxedMode) } test_info.f = f; - test_info.ulps = f->half_ulps; + test_info.ulps = getAllowedUlpError(f, khalf, relaxedMode); test_info.ftz = f->ftz || gForceFTZ || 0 == (CL_FP_DENORM & gHalfCapabilities); diff --git a/test_conformance/math_brute_force/binary_two_results_i_half.cpp b/test_conformance/math_brute_force/binary_two_results_i_half.cpp index c5efabe58b..3c3ef71a94 100644 --- a/test_conformance/math_brute_force/binary_two_results_i_half.cpp +++ b/test_conformance/math_brute_force/binary_two_results_i_half.cpp @@ -91,7 +91,7 @@ int TestFunc_HalfI_Half_Half(const Func *f, MTdata d, bool relaxedMode) cl_uint threadCount = GetThreadCount(); - float half_ulps = f->half_ulps; + float half_ulps = getAllowedUlpError(f, khalf, relaxedMode); int testingRemquo = !strcmp(f->name, "remquo"); @@ -304,7 +304,7 @@ int TestFunc_HalfI_Half_Half(const Func *f, MTdata d, bool relaxedMode) // retry per section 6.5.3.2 if (IsHalfResultSubnormal(correct, half_ulps)) { - fail = fail && !(test == 0.0f && iErr == 0); + fail = fail && !((HTF(test) == 0.0f) && iErr == 0); if (!fail) err = 0.0f; } diff --git a/test_conformance/math_brute_force/function_list.cpp b/test_conformance/math_brute_force/function_list.cpp index cb5d5a33aa..5f7b8ea0e2 100644 --- a/test_conformance/math_brute_force/function_list.cpp +++ b/test_conformance/math_brute_force/function_list.cpp @@ -280,8 +280,8 @@ const Func functionList[] = { ENTRY(cosh, 4.0f, 4.0f, 2.f, FTZ_OFF, unaryF), ENTRY_EXT(cospi, 4.0f, 4.0f, 2.f, 0.00048828125f, FTZ_OFF, unaryF, 0.00048828125f), // relaxed ulp 2^-11 - //ENTRY(erfc, 16.0f, 16.0f, FTZ_OFF, unaryF), //disabled for 1.0 due to lack of reference implementation - //ENTRY(erf, 16.0f, 16.0f, FTZ_OFF, unaryF), //disabled for 1.0 due to lack of reference implementation + ENTRY(erfc, 16.0f, 16.0f, 4.0f, FTZ_OFF, unaryF), + ENTRY(erf, 16.0f, 16.0f, 4.0f, FTZ_OFF, unaryF), // relaxed error is overwritten in unary.c as it is 3+floor(fabs(2*x)) ENTRY_EXT(exp, 3.0f, 4.0f, 2.f, 3.0f, FTZ_OFF, unaryF, 4.0f), diff --git a/test_conformance/math_brute_force/main.cpp b/test_conformance/math_brute_force/main.cpp index e1ea4c2544..ec504e6030 100644 --- a/test_conformance/math_brute_force/main.cpp +++ b/test_conformance/math_brute_force/main.cpp @@ -310,7 +310,7 @@ static test_definition test_list[] = { ADD_TEST(half_sin), ADD_TEST(half_sqrt), ADD_TEST(half_tan), ADD_TEST(add), ADD_TEST(subtract), ADD_TEST(divide), ADD_TEST(divide_cr), ADD_TEST(multiply), ADD_TEST(assignment), - ADD_TEST(not), + ADD_TEST(not ), ADD_TEST(erf), ADD_TEST(erfc), }; #undef ADD_TEST diff --git a/test_conformance/math_brute_force/reference_math.cpp b/test_conformance/math_brute_force/reference_math.cpp index 3912fd7973..049f2013b4 100644 --- a/test_conformance/math_brute_force/reference_math.cpp +++ b/test_conformance/math_brute_force/reference_math.cpp @@ -3196,7 +3196,7 @@ int reference_isgreaterequall(long double x, long double y) { return x >= y; } int reference_isinfl(long double x) { return 0 != isinf(x); } int reference_islessl(long double x, long double y) { return x < y; } int reference_islessequall(long double x, long double y) { return x <= y; } -#if defined(__INTEL_COMPILER) +#if defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) int reference_islessgreaterl(long double x, long double y) { return 0 != islessgreaterl(x, y); @@ -3218,7 +3218,7 @@ int reference_isunorderedl(long double x, long double y) { return isnan(x) || isnan(y); } -#if defined(__INTEL_COMPILER) +#if defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER) int reference_signbitl(long double x) { return 0 != signbitl(x); } #else int reference_signbitl(long double x) { return 0 != signbit(x); } @@ -3582,7 +3582,8 @@ long double reference_exp2l(long double z) long double reference_expm1l(long double x) { -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) \ + && !defined(__INTEL_LLVM_COMPILER) // unimplemented return x; #else @@ -3667,7 +3668,8 @@ long double reference_log2l(long double x) long double reference_log1pl(long double x) { -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) \ + && !defined(__INTEL_LLVM_COMPILER) // unimplemented return x; #elif defined(__PPC__) @@ -5764,3 +5766,9 @@ int reference_notl(long double x) int r = !x; return r; } + +long double reference_erfcl(long double x) { return erfc(x); } +long double reference_erfl(long double x) { return erf(x); } + +double reference_erfc(double x) { return erfc(x); } +double reference_erf(double x) { return erf(x); } \ No newline at end of file diff --git a/test_conformance/math_brute_force/reference_math.h b/test_conformance/math_brute_force/reference_math.h index aef8d2eaf8..b740787ff5 100644 --- a/test_conformance/math_brute_force/reference_math.h +++ b/test_conformance/math_brute_force/reference_math.h @@ -236,4 +236,8 @@ long double reference_ldexpl(long double x, int n); long double reference_assignmentl(long double x); int reference_notl(long double x); +long double reference_erfcl(long double x); +long double reference_erfl(long double x); +double reference_erfc(double x); +double reference_erf(double x); #endif diff --git a/test_conformance/math_brute_force/ternary_half.cpp b/test_conformance/math_brute_force/ternary_half.cpp index 5cb858d43a..856fa67d19 100644 --- a/test_conformance/math_brute_force/ternary_half.cpp +++ b/test_conformance/math_brute_force/ternary_half.cpp @@ -80,7 +80,7 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) constexpr size_t bufferElements = BUFFER_SIZE / sizeof(cl_half); std::vector overflow(bufferElements); - float half_ulps = f->half_ulps; + float half_ulps = getAllowedUlpError(f, khalf, relaxedMode); int skipNanInf = (0 == strcmp("fma", f->nameInCode)); logFunctionInfo(f->name, sizeof(cl_half), relaxedMode); @@ -300,10 +300,10 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) if (fail && ftz) { // retry per section 6.5.3.2 with flushing on - if (0.0f == test - && 0.0f - == f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]), - HTF(hp2[j]), FLUSHED)) + float r = f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]), + HTF(hp2[j]), FLUSHED); + cl_half c = HFF(r); + if (0.0f == HTF(test) && IsHalfSubnormal(c)) { fail = 0; err = 0.0f; @@ -349,13 +349,15 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) if (fabsf(err3) < fabsf(err)) err = err3; // retry per section 6.5.3.4 - if (0.0f == test - && (0.0f - == f->func.f_fma(0.0f, HTF(hp1[j]), - HTF(hp2[j]), FLUSHED) - || 0.0f - == f->func.f_fma(-0.0f, HTF(hp1[j]), - HTF(hp2[j]), FLUSHED))) + float r3 = f->func.f_fma(0.0f, HTF(hp1[j]), + HTF(hp2[j]), FLUSHED); + float r4 = f->func.f_fma(-0.0f, HTF(hp1[j]), + HTF(hp2[j]), FLUSHED); + cl_half c3 = HFF(r3); + cl_half c4 = HFF(r4); + + if (0.0f == HTF(test) + && (IsHalfSubnormal(c3) || IsHalfSubnormal(c4))) { fail = 0; err = 0.0f; @@ -424,28 +426,28 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) if (fabsf(err5) < fabsf(err)) err = err5; // retry per section 6.5.3.4 - if (0.0f == test - && (0.0f - == f->func.f_fma(0.0f, 0.0f, - HTF(hp2[j]), - FLUSHED) - || 0.0f - == f->func.f_fma(-0.0f, 0.0f, - HTF(hp2[j]), - FLUSHED) - || 0.0f - == f->func.f_fma(0.0f, -0.0f, - HTF(hp2[j]), - FLUSHED) - || 0.0f - == f->func.f_fma(-0.0f, -0.0f, - HTF(hp2[j]), - FLUSHED))) + float r5 = f->func.f_fma(0.0f, 0.0f, + HTF(hp2[j]), FLUSHED); + float r6 = f->func.f_fma(-0.0f, 0.0f, + HTF(hp2[j]), FLUSHED); + float r7 = f->func.f_fma(0.0f, -0.0f, + HTF(hp2[j]), FLUSHED); + float r8 = f->func.f_fma(-0.0f, -0.0f, + HTF(hp2[j]), FLUSHED); + + cl_half c5 = HFF(r5); + cl_half c6 = HFF(r6); + cl_half c7 = HFF(r7); + cl_half c8 = HFF(r8); + if (0.0f == HTF(test) + && (IsHalfSubnormal(c5) + || IsHalfSubnormal(c6) + || IsHalfSubnormal(c7) + || IsHalfSubnormal(c8))) { fail = 0; err = 0.0f; } - if (IsHalfSubnormal(hp2[j])) { if (test == 0.0f) // 0*0+0 is 0 @@ -517,19 +519,24 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) if (fabsf(err5) < fabsf(err)) err = err5; // retry per section 6.5.3.4 - if (0.0f == test - && (0.0f - == f->func.f_fma(0.0f, HTF(hp1[j]), - 0.0f, FLUSHED) - || 0.0f - == f->func.f_fma(-0.0f, HTF(hp1[j]), - 0.0f, FLUSHED) - || 0.0f - == f->func.f_fma(0.0f, HTF(hp1[j]), - -0.0f, FLUSHED) - || 0.0f - == f->func.f_fma(-0.0f, HTF(hp1[j]), - -0.0f, FLUSHED))) + float r9 = f->func.f_fma(0.0f, HTF(hp1[j]), + 0.0f, FLUSHED); + float r10 = f->func.f_fma(-0.0f, HTF(hp1[j]), + 0.0f, FLUSHED); + float r11 = f->func.f_fma(0.0f, HTF(hp1[j]), + -0.0f, FLUSHED); + float r12 = f->func.f_fma(-0.0f, HTF(hp1[j]), + -0.0f, FLUSHED); + + cl_half c9 = HFF(r9); + cl_half c10 = HFF(r10); + cl_half c11 = HFF(r11); + cl_half c12 = HFF(r12); + if (0.0f == HTF(test) + && (IsHalfSubnormal(c9) + || IsHalfSubnormal(c10) + || IsHalfSubnormal(c11) + || IsHalfSubnormal(c12))) { fail = 0; err = 0.0f; @@ -575,13 +582,14 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) if (fabsf(err3) < fabsf(err)) err = err3; // retry per section 6.5.3.4 - if (0.0f == test - && (0.0f - == f->func.f_fma(HTF(hp0[j]), 0.0f, - HTF(hp2[j]), FLUSHED) - || 0.0f - == f->func.f_fma(HTF(hp0[j]), -0.0f, - HTF(hp2[j]), FLUSHED))) + float r7 = f->func.f_fma(HTF(hp0[j]), 0.0f, + HTF(hp2[j]), FLUSHED); + float r8 = f->func.f_fma(HTF(hp0[j]), -0.0f, + HTF(hp2[j]), FLUSHED); + cl_half c7 = HFF(r7); + cl_half c8 = HFF(r8); + if (0.0f == HTF(test) + && (IsHalfSubnormal(c7) || IsHalfSubnormal(c8))) { fail = 0; err = 0.0f; @@ -650,19 +658,24 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) if (fabsf(err5) < fabsf(err)) err = err5; // retry per section 6.5.3.4 - if (0.0f == test - && (0.0f - == f->func.f_fma(HTF(hp0[j]), 0.0f, - 0.0f, FLUSHED) - || 0.0f - == f->func.f_fma(HTF(hp0[j]), -0.0f, - 0.0f, FLUSHED) - || 0.0f - == f->func.f_fma(HTF(hp0[j]), 0.0f, - -0.0f, FLUSHED) - || 0.0f - == f->func.f_fma(HTF(hp0[j]), -0.0f, - -0.0f, FLUSHED))) + float r13 = f->func.f_fma(HTF(hp0[j]), 0.0f, + 0.0f, FLUSHED); + float r14 = f->func.f_fma(HTF(hp0[j]), -0.0f, + 0.0f, FLUSHED); + float r15 = f->func.f_fma(HTF(hp0[j]), 0.0f, + -0.0f, FLUSHED); + float r16 = f->func.f_fma(HTF(hp0[j]), -0.0f, + -0.0f, FLUSHED); + + cl_half c9 = HFF(r13); + cl_half c10 = HFF(r14); + cl_half c11 = HFF(r15); + cl_half c12 = HFF(r16); + if (0.0f == HTF(test) + && (IsHalfSubnormal(c9) + || IsHalfSubnormal(c10) + || IsHalfSubnormal(c11) + || IsHalfSubnormal(c12))) { fail = 0; err = 0.0f; @@ -707,15 +720,15 @@ int TestFunc_Half_Half_Half_Half(const Func *f, MTdata d, bool relaxedMode) if (fabsf(err3) < fabsf(err)) err = err3; // retry per section 6.5.3.4 - if (0.0f == test - && (0.0f - == f->func.f_fma(HTF(hp0[j]), - HTF(hp1[j]), 0.0f, - FLUSHED) - || 0.0f - == f->func.f_fma(HTF(hp0[j]), - HTF(hp1[j]), -0.0f, - FLUSHED))) + float r17 = f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]), + 0.0f, FLUSHED); + float r18 = f->func.f_fma(HTF(hp0[j]), HTF(hp1[j]), + -0.0f, FLUSHED); + cl_half c13 = HFF(r17); + cl_half c14 = HFF(r18); + if (0.0f == HTF(test) + && (IsHalfSubnormal(c13) + || IsHalfSubnormal(c14))) { fail = 0; err = 0.0f; diff --git a/test_conformance/math_brute_force/unary_float.cpp b/test_conformance/math_brute_force/unary_float.cpp index cd93d3c972..7d1f6cdafc 100644 --- a/test_conformance/math_brute_force/unary_float.cpp +++ b/test_conformance/math_brute_force/unary_float.cpp @@ -88,7 +88,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data) fptr func = job->f->func; const char *fname = job->f->name; bool relaxedMode = job->relaxedMode; - float ulps = getAllowedUlpError(job->f, relaxedMode); + float ulps = getAllowedUlpError(job->f, kfloat, relaxedMode); if (relaxedMode) { func = job->f->rfunc; diff --git a/test_conformance/math_brute_force/unary_half.cpp b/test_conformance/math_brute_force/unary_half.cpp index 7af16e7386..83cdd01f4b 100644 --- a/test_conformance/math_brute_force/unary_half.cpp +++ b/test_conformance/math_brute_force/unary_half.cpp @@ -362,7 +362,7 @@ int TestFunc_Half_Half(const Func *f, MTdata d, bool relaxedMode) } test_info.f = f; - test_info.ulps = f->half_ulps; + test_info.ulps = getAllowedUlpError(f, khalf, relaxedMode); test_info.ftz = f->ftz || gForceFTZ || 0 == (CL_FP_DENORM & gHalfCapabilities); diff --git a/test_conformance/math_brute_force/unary_two_results_float.cpp b/test_conformance/math_brute_force/unary_two_results_float.cpp index 8a5d3000a6..3fd16cd3ff 100644 --- a/test_conformance/math_brute_force/unary_two_results_float.cpp +++ b/test_conformance/math_brute_force/unary_two_results_float.cpp @@ -57,7 +57,7 @@ int TestFunc_Float2_Float(const Func *f, MTdata d, bool relaxedMode) logFunctionInfo(f->name, sizeof(cl_float), relaxedMode); - float float_ulps = getAllowedUlpError(f, relaxedMode); + float float_ulps = getAllowedUlpError(f, kfloat, relaxedMode); // Init the kernels BuildKernelInfo build_info{ 1, kernels, programs, f->nameInCode, relaxedMode }; diff --git a/test_conformance/math_brute_force/unary_two_results_half.cpp b/test_conformance/math_brute_force/unary_two_results_half.cpp index 7593191c60..2bf351426e 100644 --- a/test_conformance/math_brute_force/unary_two_results_half.cpp +++ b/test_conformance/math_brute_force/unary_two_results_half.cpp @@ -61,7 +61,7 @@ int TestFunc_Half2_Half(const Func *f, MTdata d, bool relaxedMode) logFunctionInfo(f->name, sizeof(cl_half), relaxedMode); - float half_ulps = f->half_ulps; + float half_ulps = getAllowedUlpError(f, khalf, relaxedMode); // Init the kernels BuildKernelInfo build_info{ 1, kernels, programs, f->nameInCode }; diff --git a/test_conformance/math_brute_force/unary_two_results_i_half.cpp b/test_conformance/math_brute_force/unary_two_results_i_half.cpp index df404b8a4c..7b3431ab9f 100644 --- a/test_conformance/math_brute_force/unary_two_results_i_half.cpp +++ b/test_conformance/math_brute_force/unary_two_results_i_half.cpp @@ -71,7 +71,7 @@ int TestFunc_HalfI_Half(const Func *f, MTdata d, bool relaxedMode) logFunctionInfo(f->name, sizeof(cl_half), relaxedMode); - float half_ulps = f->half_ulps; + float half_ulps = getAllowedUlpError(f, khalf, relaxedMode); maxiError = half_ulps == INFINITY ? CL_ULONG_MAX : 0; diff --git a/test_conformance/math_brute_force/unary_u_half.cpp b/test_conformance/math_brute_force/unary_u_half.cpp index c9eef431de..2970403fc6 100644 --- a/test_conformance/math_brute_force/unary_u_half.cpp +++ b/test_conformance/math_brute_force/unary_u_half.cpp @@ -54,7 +54,7 @@ int TestFunc_Half_UShort(const Func *f, MTdata d, bool relaxedMode) size_t bufferSize = bufferElements * sizeof(cl_half); logFunctionInfo(f->name, sizeof(cl_half), relaxedMode); const char *name = f->name; - float half_ulps = f->half_ulps; + float half_ulps = getAllowedUlpError(f, khalf, relaxedMode); // Init the kernels BuildKernelInfo build_info = { 1, kernels, programs, f->nameInCode }; diff --git a/test_conformance/math_brute_force/utility.cpp b/test_conformance/math_brute_force/utility.cpp index 9b0191ab36..53dd928c0e 100644 --- a/test_conformance/math_brute_force/utility.cpp +++ b/test_conformance/math_brute_force/utility.cpp @@ -15,6 +15,9 @@ // #include "utility.h" + +#include + #include "function_list.h" #if defined(__PPC__) @@ -161,32 +164,42 @@ void logFunctionInfo(const char *fname, unsigned int float_size, vlog("%15s %4s %4s", fname, fpSizeStr, fpFastRelaxedStr); } -float getAllowedUlpError(const Func *f, const bool relaxed) +float getAllowedUlpError(const Func *f, Type t, const bool relaxed) { - float ulp; - - if (relaxed) + switch (t) { - if (gIsEmbedded) - { - ulp = f->relaxed_embedded_error; - } - else - { - ulp = f->relaxed_error; - } + case kfloat: + if (relaxed) + { + if (gIsEmbedded) + { + return f->relaxed_embedded_error; + } + else + { + return f->relaxed_error; + } + } + else + { + if (gIsEmbedded) + { + return f->float_embedded_ulps; + } + else + { + return f->float_ulps; + } + } + case kdouble: + // TODO: distinguish between embedded and full profile. + return f->double_ulps; + case khalf: + // TODO: distinguish between embedded and full profile. + return f->half_ulps; + default: + assert(false && "unsupported type in getAllowedUlpError"); + // Return a negative value which will make any test fail. + return -1.f; } - else - { - if (gIsEmbedded) - { - ulp = f->float_embedded_ulps; - } - else - { - ulp = f->float_ulps; - } - } - - return ulp; } diff --git a/test_conformance/math_brute_force/utility.h b/test_conformance/math_brute_force/utility.h index 8e9b3a1ad9..74cacc46d5 100644 --- a/test_conformance/math_brute_force/utility.h +++ b/test_conformance/math_brute_force/utility.h @@ -215,7 +215,8 @@ inline void Force64BitFPUPrecision(void) __asm__ __volatile__("fstcw %0" : "=m"(orig_cw)); new_cw = orig_cw | 0x0300; // set precision to 64-bit __asm__ __volatile__("fldcw %0" ::"m"(new_cw)); -#elif defined(_WIN32) && defined(__INTEL_COMPILER) +#elif defined(_WIN32) \ + && (defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)) // Unfortunately, usual method (`_controlfp( _PC_64, _MCW_PC );') does *not* // work on win.x64: > On the x64 architecture, changing the floating point // precision is not supported. (Taken from @@ -257,7 +258,7 @@ int compareDoubles(double x, double y); void logFunctionInfo(const char *fname, unsigned int float_size, unsigned int isFastRelaxed); -float getAllowedUlpError(const Func *f, const bool relaxed); +float getAllowedUlpError(const Func *f, Type t, const bool relaxed); inline cl_uint getTestScale(size_t typeSize) { diff --git a/test_conformance/mem_host_flags/checker_mem_host_no_access.hpp b/test_conformance/mem_host_flags/checker_mem_host_no_access.hpp index eb3341a8fa..b5f9acc310 100644 --- a/test_conformance/mem_host_flags/checker_mem_host_no_access.hpp +++ b/test_conformance/mem_host_flags/checker_mem_host_no_access.hpp @@ -81,10 +81,9 @@ cl_int cBuffer_check_mem_host_no_access::Setup_Test_Environment() template cl_int cBuffer_check_mem_host_no_access::verify_RW_Buffer() { - cl_event event; cl_int err = clEnqueueReadBuffer( this->m_queue, this->m_buffer, this->m_blocking, 0, - this->get_block_size_bytes(), this->host_m_1.pData, 0, NULL, &event); + this->get_block_size_bytes(), this->host_m_1.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -102,7 +101,7 @@ cl_int cBuffer_check_mem_host_no_access::verify_RW_Buffer() err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0, this->get_block_size_bytes(), - this->host_m_1.pData, 0, NULL, &event); + this->host_m_1.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -125,14 +124,13 @@ template cl_int cBuffer_check_mem_host_no_access::verify_RW_Buffer_rect() { this->Init_rect(); - cl_event event; cl_int err = CL_SUCCESS; err = clEnqueueReadBufferRect( this->m_queue, this->m_buffer, this->m_blocking, this->buffer_origin_bytes, this->host_origin_bytes, this->region_bytes, this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes, this->host_row_pitch_bytes, this->host_slice_pitch_bytes, - this->host_m_2.pData, 0, NULL, &event); + this->host_m_2.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -153,7 +151,7 @@ cl_int cBuffer_check_mem_host_no_access::verify_RW_Buffer_rect() this->buffer_origin_bytes, this->host_origin_bytes, this->region_bytes, this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes, this->host_row_pitch_bytes, this->host_slice_pitch_bytes, - this->host_m_2.pData, 0, NULL, &event); + this->host_m_2.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -175,13 +173,12 @@ cl_int cBuffer_check_mem_host_no_access::verify_RW_Buffer_rect() template cl_int cBuffer_check_mem_host_no_access::verify_RW_Buffer_mapping() { - cl_event event; cl_int err; void *dataPtr; dataPtr = clEnqueueMapBuffer( this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_READ, 0, - this->get_block_size_bytes(), 0, NULL, &event, &err); + this->get_block_size_bytes(), 0, NULL, NULL, &err); if (err == CL_SUCCESS) { log_error("Calling clEnqueueMapBuffer (CL_MAP_READ) on a memory object " @@ -206,7 +203,7 @@ cl_int cBuffer_check_mem_host_no_access::verify_RW_Buffer_mapping() dataPtr = clEnqueueMapBuffer( this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_WRITE, 0, - this->get_block_size_bytes(), 0, NULL, &event, &err); + this->get_block_size_bytes(), 0, NULL, NULL, &err); if (err == CL_SUCCESS) { log_error("Calling clEnqueueMapBuffer (CL_MAP_WRITE) on a memory " diff --git a/test_conformance/mem_host_flags/checker_mem_host_read_only.hpp b/test_conformance/mem_host_flags/checker_mem_host_read_only.hpp index ea23ae5ae6..f14f86cfbb 100644 --- a/test_conformance/mem_host_flags/checker_mem_host_read_only.hpp +++ b/test_conformance/mem_host_flags/checker_mem_host_read_only.hpp @@ -152,7 +152,7 @@ cl_int cBuffer_check_mem_host_read_only::verify_RW_Buffer() // test write err = clEnqueueWriteBuffer(this->m_queue, this->m_buffer, this->m_blocking, 0, this->get_block_size_bytes(), - this->host_m_2.pData, 0, NULL, &event); + this->host_m_2.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -211,7 +211,7 @@ cl_int cBuffer_check_mem_host_read_only::verify_RW_Buffer_rect() this->buffer_origin_bytes, this->host_origin_bytes, this->region_bytes, this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes, this->host_row_pitch_bytes, this->host_slice_pitch_bytes, - this->host_m_2.pData, 0, NULL, &event); + this->host_m_2.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -270,7 +270,7 @@ cl_int cBuffer_check_mem_host_read_only::verify_RW_Buffer_mapping() // test blocking map read clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_WRITE, 0, this->get_block_size_bytes(), 0, NULL, - &event, &err); + NULL, &err); if (err == CL_SUCCESS) { diff --git a/test_conformance/mem_host_flags/checker_mem_host_write_only.hpp b/test_conformance/mem_host_flags/checker_mem_host_write_only.hpp index 6c7b12da54..c9e4dcbe61 100644 --- a/test_conformance/mem_host_flags/checker_mem_host_write_only.hpp +++ b/test_conformance/mem_host_flags/checker_mem_host_write_only.hpp @@ -167,7 +167,7 @@ cl_int cBuffer_check_mem_host_write_only::verify_RW_Buffer() err = clEnqueueReadBuffer(this->m_queue, this->m_buffer, CL_TRUE, 0, this->get_block_size_bytes(), - this->host_m_2.pData, 0, NULL, &event); + this->host_m_2.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -257,7 +257,7 @@ cl_int cBuffer_check_mem_host_write_only::verify_RW_Buffer_rect() this->buffer_origin_bytes, this->host_origin_bytes, this->region_bytes, this->buffer_row_pitch_bytes, this->buffer_slice_pitch_bytes, this->host_row_pitch_bytes, this->host_slice_pitch_bytes, - this->host_m_2.pData, 0, NULL, &event); + this->host_m_2.pData, 0, NULL, NULL); if (err == CL_SUCCESS) { @@ -349,7 +349,7 @@ cl_int cBuffer_check_mem_host_write_only::verify_RW_Buffer_mapping() // test map read clEnqueueMapBuffer(this->m_queue, this->m_buffer, this->m_blocking, CL_MAP_READ, 0, this->get_block_size_bytes(), 0, NULL, - &event, &err); + NULL, &err); if (err == CL_SUCCESS) { diff --git a/test_conformance/non_uniform_work_group/CMakeLists.txt b/test_conformance/non_uniform_work_group/CMakeLists.txt index 30c3a84610..7db5bcbb11 100644 --- a/test_conformance/non_uniform_work_group/CMakeLists.txt +++ b/test_conformance/non_uniform_work_group/CMakeLists.txt @@ -1,5 +1,9 @@ set(MODULE_NAME NON_UNIFORM_WORK_GROUP) +if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") + add_cxx_flag_if_supported(-Wno-narrowing) +endif() + set(${MODULE_NAME}_SOURCES main.cpp test_advanced_2d.cpp diff --git a/test_conformance/non_uniform_work_group/TestNonUniformWorkGroup.cpp b/test_conformance/non_uniform_work_group/TestNonUniformWorkGroup.cpp index 44781ca82b..6106e0ab13 100644 --- a/test_conformance/non_uniform_work_group/TestNonUniformWorkGroup.cpp +++ b/test_conformance/non_uniform_work_group/TestNonUniformWorkGroup.cpp @@ -299,7 +299,7 @@ TestNonUniformWorkGroup::TestNonUniformWorkGroup( auto global_size_rounded = global_size_before + (localSize[dim] - global_size_before % localSize[dim]); globalSize[dim] = global_size_rounded; - log_info("Rounding globalSize[%d] = %d -> %d\n", dim, + log_info("Rounding globalSize[%d] = %zu -> %zu\n", dim, global_size_before, global_size_rounded); } } @@ -665,8 +665,8 @@ void TestNonUniformWorkGroup::showTestInfo () { if (!_localSize_IsNull) { log_info ("\tATTENTION: strict mode applies only NULL local work group size\n"); } else { - log_info ("\t\tExpected value of local work group size is %ld.\n", - TestNonUniformWorkGroup::getMaxLocalWorkgroupSize(_device)); + log_info("\t\tExpected value of local work group size is %zu.\n", + TestNonUniformWorkGroup::getMaxLocalWorkgroupSize(_device)); } } @@ -687,7 +687,8 @@ size_t TestNonUniformWorkGroup::adjustLocalArraySize (size_t localArraySize) { if (kernelLocalMemSize + localArraySize > deviceLocalMemSize) { size_t adjustedLocalArraySize = deviceLocalMemSize - kernelLocalMemSize; - log_info("localArraySize was adjusted from %lu to %lu\n", localArraySize, adjustedLocalArraySize); + log_info("localArraySize was adjusted from %zu to %zu\n", localArraySize, + adjustedLocalArraySize); localArraySize = adjustedLocalArraySize; } @@ -706,7 +707,8 @@ size_t TestNonUniformWorkGroup::adjustGlobalBufferSize(size_t globalBufferSize) size_t adjustedGlobalBufferSize = globalBufferSize; if (deviceMaxAllocObjSize < globalBufferSize) { adjustedGlobalBufferSize = deviceMaxAllocObjSize; - log_info("globalBufferSize was adjusted from %lu to %lu\n", globalBufferSize, adjustedGlobalBufferSize); + log_info("globalBufferSize was adjusted from %zu to %zu\n", + globalBufferSize, adjustedGlobalBufferSize); } return adjustedGlobalBufferSize; diff --git a/test_conformance/opencl_conformance_tests_d3d.csv b/test_conformance/opencl_conformance_tests_d3d.csv index 29d2267e2f..053f742418 100644 --- a/test_conformance/opencl_conformance_tests_d3d.csv +++ b/test_conformance/opencl_conformance_tests_d3d.csv @@ -4,4 +4,6 @@ DX9 media sharing,media_sharing\test_media_surface_sharing D3D10,d3d10\test_d3d10 -D3D11,d3d11\test_d3d11 \ No newline at end of file +D3D11,d3d11\test_d3d11 + +cl_khr_dx9_media_sharing, extensions/cl_khr_dx9_media_sharing/test_cl_khr_dx9_media_sharing diff --git a/test_conformance/opencl_conformance_tests_full.csv b/test_conformance/opencl_conformance_tests_full.csv index 2b0dc8aa12..27916c73ca 100644 --- a/test_conformance/opencl_conformance_tests_full.csv +++ b/test_conformance/opencl_conformance_tests_full.csv @@ -105,3 +105,8 @@ Mipmaps (Kernel),images/kernel_read_write/test_image_streams test_mipmaps CL_FIL Mipmaps (clCopyImage),images/clCopyImage/test_cl_copy_images test_mipmaps Mipmaps (clReadWriteImage),images/clReadWriteImage/test_cl_read_write_images test_mipmaps Subgroups,subgroups/test_subgroups +cl_ext_cxx_for_opencl,extensions/cl_ext_cxx_for_opencl/test_cl_ext_cxx_for_opencl +cl_khr_semaphore,extensions/cl_khr_semaphore/test_cl_khr_semaphore +cl_khr_command_buffer,extensions/cl_khr_command_buffer/test_cl_khr_command_buffer +cl_khr_command_buffer_mutable_dispatch,extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/test_cl_khr_mutable_dispatch +cl_khr_kernel_clock,extensions/cl_khr_kernel_clock/test_cl_khr_kernel_clock diff --git a/test_conformance/opencl_conformance_tests_full_binary.csv b/test_conformance/opencl_conformance_tests_full_binary.csv index 348f32eb86..596cb81fec 100644 --- a/test_conformance/opencl_conformance_tests_full_binary.csv +++ b/test_conformance/opencl_conformance_tests_full_binary.csv @@ -105,3 +105,8 @@ Mipmaps (Kernel),images/kernel_read_write/test_image_streams test_mipmaps CL_FIL Mipmaps (clCopyImage),images/clCopyImage/test_cl_copy_images test_mipmaps --compilation-mode binary --compilation-cache-path . Mipmaps (clReadWriteImage),images/clReadWriteImage/test_cl_read_write_images test_mipmaps --compilation-mode binary --compilation-cache-path . Subgroups,subgroups/test_subgroups --compilation-mode binary --compilation-cache-path . +cl_ext_cxx_for_opencl,extensions/cl_ext_cxx_for_opencl/test_cl_ext_cxx_for_opencl --compilation-mode binary --compilation-cache-path . +cl_khr_semaphore,extensions/cl_khr_semaphore/test_cl_khr_semaphore --compilation-mode binary --compilation-cache-path . +cl_khr_command_buffer,extensions/cl_khr_command_buffer/test_cl_khr_command_buffer --compilation-mode binary --compilation-cache-path . +cl_khr_command_buffer_mutable_dispatch,extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/test_cl_khr_mutable_dispatch --compilation-mode binary --compilation-cache-path . +cl_khr_kernel_clock,extensions/cl_khr_kernel_clock/test_cl_khr_kernel_clock --compilation-mode binary --compilation-cache-path . diff --git a/test_conformance/opencl_conformance_tests_full_no_math_or_conversions.csv b/test_conformance/opencl_conformance_tests_full_no_math_or_conversions.csv index 89d4490724..06e98215d6 100644 --- a/test_conformance/opencl_conformance_tests_full_no_math_or_conversions.csv +++ b/test_conformance/opencl_conformance_tests_full_no_math_or_conversions.csv @@ -103,3 +103,8 @@ Mipmaps (Kernel),images/kernel_read_write/test_image_streams test_mipmaps CL_FIL Mipmaps (clCopyImage),images/clCopyImage/test_cl_copy_images test_mipmaps Mipmaps (clReadWriteImage),images/clReadWriteImage/test_cl_read_write_images test_mipmaps Subgroups,subgroups/test_subgroups +cl_ext_cxx_for_opencl,extensions/cl_ext_cxx_for_opencl/test_cl_ext_cxx_for_opencl +cl_khr_semaphore,extensions/cl_khr_semaphore/test_cl_khr_semaphore +cl_khr_command_buffer,extensions/cl_khr_command_buffer/test_cl_khr_command_buffer +cl_khr_command_buffer_mutable_dispatch,extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/test_cl_khr_mutable_dispatch +cl_khr_kernel_clock,extensions/cl_khr_kernel_clock/test_cl_khr_kernel_clock diff --git a/test_conformance/opencl_conformance_tests_full_spirv.csv b/test_conformance/opencl_conformance_tests_full_spirv.csv index 24b41865b2..484a7d72a8 100644 --- a/test_conformance/opencl_conformance_tests_full_spirv.csv +++ b/test_conformance/opencl_conformance_tests_full_spirv.csv @@ -105,3 +105,8 @@ Mipmaps (Kernel),images/kernel_read_write/test_image_streams test_mipmaps CL_FIL Mipmaps (clCopyImage),images/clCopyImage/test_cl_copy_images test_mipmaps --compilation-mode spir-v --compilation-cache-path . Mipmaps (clReadWriteImage),images/clReadWriteImage/test_cl_read_write_images test_mipmaps --compilation-mode spir-v --compilation-cache-path . Subgroups,subgroups/test_subgroups --compilation-mode spir-v --compilation-cache-path . +cl_ext_cxx_for_opencl,extensions/cl_ext_cxx_for_opencl/test_cl_ext_cxx_for_opencl --compilation-mode spir-v --compilation-cache-path . +cl_khr_semaphore,extensions/cl_khr_semaphore/test_cl_khr_semaphore --compilation-mode spir-v --compilation-cache-path . +cl_khr_command_buffer,extensions/cl_khr_command_buffer/test_cl_khr_command_buffer --compilation-mode spir-v --compilation-cache-path . +cl_khr_command_buffer_mutable_dispatch,extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/test_cl_khr_mutable_dispatch --compilation-mode spir-v --compilation-cache-path . +cl_khr_kernel_clock,extensions/cl_khr_kernel_clock/test_cl_khr_kernel_clock --compilation-mode spir-v --compilation-cache-path . diff --git a/test_conformance/opencl_conformance_tests_quick.csv b/test_conformance/opencl_conformance_tests_quick.csv index 043df8214c..b82c0da034 100644 --- a/test_conformance/opencl_conformance_tests_quick.csv +++ b/test_conformance/opencl_conformance_tests_quick.csv @@ -105,3 +105,8 @@ Mipmaps (Kernel),images/kernel_read_write/test_image_streams test_mipmaps CL_FIL Mipmaps (clCopyImage),images/clCopyImage/test_cl_copy_images test_mipmaps Mipmaps (clReadWriteImage),images/clReadWriteImage/test_cl_read_write_images test_mipmaps Subgroups,subgroups/test_subgroups +cl_ext_cxx_for_opencl,extensions/cl_ext_cxx_for_opencl/test_cl_ext_cxx_for_opencl +cl_khr_semaphore,extensions/cl_khr_semaphore/test_cl_khr_semaphore +cl_khr_command_buffer,extensions/cl_khr_command_buffer/test_cl_khr_command_buffer +cl_khr_command_buffer_mutable_dispatch,extensions/cl_khr_command_buffer/cl_khr_command_buffer_mutable_dispatch/test_cl_khr_mutable_dispatch +cl_khr_kernel_clock,extensions/cl_khr_kernel_clock/test_cl_khr_kernel_clock diff --git a/test_conformance/opencl_conformance_tests_vulkan.csv b/test_conformance/opencl_conformance_tests_vulkan.csv new file mode 100644 index 0000000000..5b4fd8c0ea --- /dev/null +++ b/test_conformance/opencl_conformance_tests_vulkan.csv @@ -0,0 +1,5 @@ +# +# OpenCL Conformance Tests requiring Vulkan SDK +# + +cl_khr_external_semaphore,extensions/cl_khr_external_semaphore/test_cl_khr_external_semaphore diff --git a/test_conformance/pipes/test_pipe_info.cpp b/test_conformance/pipes/test_pipe_info.cpp index e7b486dbe9..b230a4c40b 100644 --- a/test_conformance/pipes/test_pipe_info.cpp +++ b/test_conformance/pipes/test_pipe_info.cpp @@ -13,6 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. // + +#include + #include "procs.h" #include "harness/parseParameters.h" @@ -73,7 +76,7 @@ int test_pipe_info( cl_device_id deviceID, cl_context context, cl_command_queue test_error_fail(err, "clGetKernelArgInfo failed"); if (arg_type_qualifier != CL_KERNEL_ARG_TYPE_PIPE) { - test_fail("ERROR: Incorrect type qualifier: %i\n", + test_fail("ERROR: Incorrect type qualifier: 0x%" PRIx64 "\n", arg_type_qualifier); } } diff --git a/test_conformance/printf/test_printf.cpp b/test_conformance/printf/test_printf.cpp index d59e06825b..0d5dfa7bf3 100644 --- a/test_conformance/printf/test_printf.cpp +++ b/test_conformance/printf/test_printf.cpp @@ -698,6 +698,12 @@ int doTest(cl_command_queue queue, cl_context context, return TEST_SKIPPED_ITSELF; } + if ((allTestCase[testId]->_type == TYPE_LONG) && !isLongSupported(device)) + { + log_info("Skipping long because long is not supported.\n"); + return TEST_SKIPPED_ITSELF; + } + if ((allTestCase[testId]->_type == TYPE_DOUBLE || allTestCase[testId]->_type == TYPE_DOUBLE_LIMITS) && !is_extension_available(device, "cl_khr_fp64")) @@ -927,6 +933,12 @@ int test_int(cl_device_id deviceID, cl_context context, cl_command_queue queue, return doTest(gQueue, gContext, TYPE_INT, deviceID); } +int test_long(cl_device_id deviceID, cl_context context, cl_command_queue queue, + int num_elements) +{ + return doTest(gQueue, gContext, TYPE_LONG, deviceID); +} + int test_half(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { @@ -1017,6 +1029,12 @@ int test_mixed_format_random(cl_device_id deviceID, cl_context context, return doTest(gQueue, gContext, TYPE_MIXED_FORMAT_RANDOM, deviceID); } +int test_length_specifier(cl_device_id deviceID, cl_context context, + cl_command_queue queue, int num_elements) +{ + return doTest(gQueue, gContext, TYPE_LENGTH_SPECIFIER, deviceID); +} + int test_buffer_size(cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements) { @@ -1044,6 +1062,7 @@ int test_buffer_size(cl_device_id deviceID, cl_context context, test_definition test_list[] = { ADD_TEST(int), + ADD_TEST(long), ADD_TEST(half), ADD_TEST(half_limits), ADD_TEST(float), @@ -1060,6 +1079,7 @@ test_definition test_list[] = { ADD_TEST(address_space), ADD_TEST(buffer_size), ADD_TEST(mixed_format_random), + ADD_TEST(length_specifier), }; const int test_num = ARRAY_SIZE( test_list ); diff --git a/test_conformance/printf/test_printf.h b/test_conformance/printf/test_printf.h index 51f351170f..993a612635 100644 --- a/test_conformance/printf/test_printf.h +++ b/test_conformance/printf/test_printf.h @@ -46,6 +46,7 @@ enum PrintfTestType { TYPE_INT, + TYPE_LONG, TYPE_HALF, TYPE_HALF_LIMITS, TYPE_FLOAT, @@ -61,6 +62,7 @@ enum PrintfTestType TYPE_VECTOR, TYPE_ADDRESS_SPACE, TYPE_MIXED_FORMAT_RANDOM, + TYPE_LENGTH_SPECIFIER, TYPE_COUNT }; diff --git a/test_conformance/printf/util_printf.cpp b/test_conformance/printf/util_printf.cpp index 5b96e8683d..cd84c01ac1 100644 --- a/test_conformance/printf/util_printf.cpp +++ b/test_conformance/printf/util_printf.cpp @@ -111,6 +111,100 @@ testCase testCaseInt = { }; +//================================== + +// long + +//================================== + +//------------------------------------------------------ + +// [string] format | [string] int-data representation | + +//------------------------------------------------------ + +std::vector printLongGenParameters = { + + //(Minimum) fifteen-wide,default(right)-justified + + { { "%5ld" }, "10000000000L" }, + + //(Minimum) fifteen-wide,left-justified + + { { "%-15ld" }, "-10000000000L" }, + + //(Minimum) fifteen-wide,default(right)-justified,zero-filled + + { { "%015ld" }, "10000000000L" }, + + //(Minimum) fifteen-wide,default(right)-justified,with sign + + { { "%+15ld" }, "-10000000000L" }, + + //(Minimum) fifteen-wide ,left-justified,with sign + + { { "%-+15ld" }, "10000000000L" }, + + //(Minimum) fifteen-digit(zero-filled in absent + // digits),default(right)-justified + + { { "%.15li" }, "10000000000L" }, + + //(Minimum)Sixteen-wide, fifteen-digit(zero-filled in absent + // digits),default(right)-justified + + { { "%-+16.15li" }, "-10000000000L" }, + +}; + +//-------------------------------------------------------- + +// Lookup table - [string]long-correct buffer | + +//-------------------------------------------------------- + +// The table below is used to accommodate differences in `printf` output when +// using the `%ld` format specifier in 32-bit versus 64-bit compiled binaries + +std::vector correctBufferLong = { + + "10000000000", + + "-10000000000 ", + + "000010000000000", + + " -10000000000", + + "+10000000000 ", + + "000010000000000", + + "-000010000000000" + +}; + +//----------------------------------------------- + +// test case for long | + +//----------------------------------------------- + +testCase testCaseLong = { + + TYPE_LONG, + + correctBufferLong, + + printLongGenParameters, + + NULL, + + klong + +}; + + //============================================== // half @@ -1179,7 +1273,7 @@ std::vector printVectorGenParameters = { // Four component vector in hexadecimal floating point, lowercase format - { { "" }, "(0.25f,0.5f,1.f,1.5f)", "%", "hla", "float", "4" }, + { { "" }, "(0.25f,0.5f,1.f,1.5f)", "%.1", "hla", "float", "4" }, // Eight component vector in the shortest float representation @@ -1231,7 +1325,7 @@ std::vector correctBufferVector = { "1.23e+03,9.88e+05,5.00e-04", - "0x1p-2,0x1p-1,0x1p+0,0x1.8p+0", + "0x1.0p-2,0x1.0p-1,0x1.0p+0,0x1.8p+0", "1,2,3,4,1.5,3.14,2.5,3.5", @@ -1397,6 +1491,116 @@ testCase testCaseMixedFormat = { TYPE_MIXED_FORMAT_RANDOM, correctBufferMixedFormat, printMixedFormatGenParameters, NULL }; + +//============================================================= + +// length sub-specifier format + +//============================================================= + +std::vector printLenSpecGenParameters = { + + { { "%hd" }, "32767" }, + + { { "%hhd" }, "127" }, + + { { "%ld" }, "9223372036854775807L" }, + + { { "%hd" }, "-32767" }, + + { { "%hhd" }, "-128" }, + + { { "%ld" }, "-9223372036854775807L" }, + + { { "%hx" }, "32767" }, + + { { "%hhx" }, "127" }, + + { { "%lx" }, "9223372036854775807L" }, + + { { "%hx" }, "-32767" }, + + { { "%hhx" }, "-128" }, + + { { "%lx" }, "-9223372036854775807L" }, + + { { "%ho" }, "32767" }, + + { { "%hho" }, "127" }, + + { { "%lo" }, "9223372036854775807L" }, + + { { "%ho" }, "-32767" }, + + { { "%hho" }, "-128" }, + + { { "%lo" }, "-9223372036854775807L" }, +}; + +//--------------------------------------------------------- + +// Lookup table -[string] length specified correct buffer + +//--------------------------------------------------------- + +std::vector correctBufferLenSpec = { + + "32767", + + "127", + + "9223372036854775807", + + "-32767", + + "-128", + + "-9223372036854775807", + + "7fff", + + "7f", + + "7fffffffffffffff", + + "8001", + + "80", + + "8000000000000001", + + "77777", + + "177", + + "777777777777777777777", + + "100001", + + "200", + + "1000000000000000000001", +}; + + +//---------------------------------------------------------- + +// Test case for length specified values + +//---------------------------------------------------------- + +testCase testCaseLenSpec = { + + TYPE_LENGTH_SPECIFIER, + + correctBufferLenSpec, + + printLenSpecGenParameters, + + NULL + +}; + //------------------------------------------------------------------------------- //All Test cases | @@ -1404,12 +1608,12 @@ testCase testCaseMixedFormat = { TYPE_MIXED_FORMAT_RANDOM, //------------------------------------------------------------------------------- std::vector allTestCase = { - &testCaseInt, &testCaseHalf, &testCaseHalfLimits, - &testCaseFloat, &testCaseFloatLimits, &testCaseDouble, - &testCaseDoubleLimits, &testCaseOctal, &testCaseUnsigned, - &testCaseHexadecimal, &testCaseChar, &testCaseString, - &testCaseFormatString, &testCaseVector, &testCaseAddrSpace, - &testCaseMixedFormat + &testCaseInt, &testCaseLong, &testCaseHalf, + &testCaseHalfLimits, &testCaseFloat, &testCaseFloatLimits, + &testCaseDouble, &testCaseDoubleLimits, &testCaseOctal, + &testCaseUnsigned, &testCaseHexadecimal, &testCaseChar, + &testCaseString, &testCaseFormatString, &testCaseVector, + &testCaseAddrSpace, &testCaseMixedFormat, &testCaseLenSpec }; //----------------------------------------- diff --git a/test_conformance/profiling/CMakeLists.txt b/test_conformance/profiling/CMakeLists.txt index 036de05be1..657729856b 100644 --- a/test_conformance/profiling/CMakeLists.txt +++ b/test_conformance/profiling/CMakeLists.txt @@ -9,6 +9,7 @@ set(${MODULE_NAME}_SOURCES copy.cpp execute.cpp execute_multipass.cpp + profiling_timebase.cpp ) include(../CMakeCommon.txt) diff --git a/test_conformance/profiling/execute.cpp b/test_conformance/profiling/execute.cpp index 44b1bcd4bf..d4fd51e390 100644 --- a/test_conformance/profiling/execute.cpp +++ b/test_conformance/profiling/execute.cpp @@ -314,7 +314,7 @@ static int kernelFilter( cl_device_id device, cl_context context, cl_command_que // read output image size_t origin[3] = { 0, 0, 0 }; - size_t region[3] = { w, h, 1 }; + size_t region[3] = { (size_t)w, (size_t)h, 1 }; err = clEnqueueReadImage( queue, memobjs[1], true, origin, region, 0, 0, outptr, 0, NULL, NULL); if( err != CL_SUCCESS ){ print_error( err, "clReadImage failed\n" ); diff --git a/test_conformance/profiling/main.cpp b/test_conformance/profiling/main.cpp index 0498472836..012786ccd2 100644 --- a/test_conformance/profiling/main.cpp +++ b/test_conformance/profiling/main.cpp @@ -26,37 +26,38 @@ // the following variables (): test_definition test_list[] = { - ADD_TEST( read_array_int ), - ADD_TEST( read_array_uint ), - ADD_TEST( read_array_long ), - ADD_TEST( read_array_ulong ), - ADD_TEST( read_array_short ), - ADD_TEST( read_array_ushort ), - ADD_TEST( read_array_float ), - ADD_TEST( read_array_char ), - ADD_TEST( read_array_uchar ), - ADD_TEST( read_array_struct ), - ADD_TEST( write_array_int ), - ADD_TEST( write_array_uint ), - ADD_TEST( write_array_long ), - ADD_TEST( write_array_ulong ), - ADD_TEST( write_array_short ), - ADD_TEST( write_array_ushort ), - ADD_TEST( write_array_float ), - ADD_TEST( write_array_char ), - ADD_TEST( write_array_uchar ), - ADD_TEST( write_array_struct ), - ADD_TEST( read_image_float ), - ADD_TEST( read_image_char ), - ADD_TEST( read_image_uchar ), - ADD_TEST( write_image_float ), - ADD_TEST( write_image_char ), - ADD_TEST( write_image_uchar ), - ADD_TEST( copy_array ), - ADD_TEST( copy_partial_array ), - ADD_TEST( copy_image ), - ADD_TEST( copy_array_to_image ), - ADD_TEST( execute ), + ADD_TEST(read_array_int), + ADD_TEST(read_array_uint), + ADD_TEST(read_array_long), + ADD_TEST(read_array_ulong), + ADD_TEST(read_array_short), + ADD_TEST(read_array_ushort), + ADD_TEST(read_array_float), + ADD_TEST(read_array_char), + ADD_TEST(read_array_uchar), + ADD_TEST(read_array_struct), + ADD_TEST(write_array_int), + ADD_TEST(write_array_uint), + ADD_TEST(write_array_long), + ADD_TEST(write_array_ulong), + ADD_TEST(write_array_short), + ADD_TEST(write_array_ushort), + ADD_TEST(write_array_float), + ADD_TEST(write_array_char), + ADD_TEST(write_array_uchar), + ADD_TEST(write_array_struct), + ADD_TEST(read_image_float), + ADD_TEST(read_image_char), + ADD_TEST(read_image_uchar), + ADD_TEST(write_image_float), + ADD_TEST(write_image_char), + ADD_TEST(write_image_uchar), + ADD_TEST(copy_array), + ADD_TEST(copy_partial_array), + ADD_TEST(copy_image), + ADD_TEST(copy_array_to_image), + ADD_TEST(execute), + ADD_TEST_VERSION(profiling_timebase, Version(2, 1)), }; const int test_num = ARRAY_SIZE( test_list ); diff --git a/test_conformance/profiling/procs.h b/test_conformance/profiling/procs.h index cc7083d0ce..aa91a75199 100644 --- a/test_conformance/profiling/procs.h +++ b/test_conformance/profiling/procs.h @@ -58,6 +58,8 @@ extern int test_copy_image( cl_device_id device, cl_context context, cl_c extern int test_copy_array_to_image( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); extern int test_execute( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); extern int test_parallel_kernels( cl_device_id device, cl_context context, cl_command_queue queue, int num_elements ); +extern int test_profiling_timebase(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements); #endif // #ifndef __PROCS_H__ diff --git a/test_conformance/profiling/profiling_timebase.cpp b/test_conformance/profiling/profiling_timebase.cpp new file mode 100644 index 0000000000..1b12464c59 --- /dev/null +++ b/test_conformance/profiling/profiling_timebase.cpp @@ -0,0 +1,101 @@ +// +// Copyright (c) 2021 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "procs.h" + +const char *kernelCode = "__kernel void kernel_empty(){}"; + +int test_profiling_timebase(cl_device_id device, cl_context context, + cl_command_queue queue, int num_elements) +{ + Version version = get_device_cl_version(device); + cl_platform_id platform = getPlatformFromDevice(device); + cl_ulong timer_resolution = 0; + cl_int err = + clGetPlatformInfo(platform, CL_PLATFORM_HOST_TIMER_RESOLUTION, + sizeof(timer_resolution), &timer_resolution, NULL); + test_error(err, "Unable to query CL_PLATFORM_HOST_TIMER_RESOLUTION"); + + // If CL_PLATFORM_HOST_TIMER_RESOLUTION returns 0, clGetDeviceAndHostTimer + // is not a supported feature + if (timer_resolution == 0 && version >= Version(3, 0)) + { + return TEST_SKIPPED_ITSELF; + } + + cl_ulong hostTime; + clProgramWrapper program; + clKernelWrapper kernel; + clEventWrapper kEvent; + + clEventWrapper uEvent = clCreateUserEvent(context, &err); + test_error(err, "Failed to create user event"); + + err = create_single_kernel_helper(context, &program, &kernel, 1, + &kernelCode, "kernel_empty"); + test_error(err, "Failed to create kernel"); + + cl_ulong deviceTimeBeforeQueue; + err = clGetDeviceAndHostTimer(device, &deviceTimeBeforeQueue, &hostTime); + test_error(err, "Unable to get starting device time"); + + err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, NULL, NULL, 1, &uEvent, + &kEvent); + test_error(err, "clEnqueueNDRangeKernel failed"); + + cl_ulong deviceTimeAfterQueue; + err = clGetDeviceAndHostTimer(device, &deviceTimeAfterQueue, &hostTime); + test_error(err, "Unable to get queue device time"); + + err = clFlush(queue); + test_error(err, "clFlush failed"); + + err = clSetUserEventStatus(uEvent, CL_COMPLETE); + test_error(err, "Unable to complete user event"); + + err = clWaitForEvents(1, &kEvent); + test_error(err, "clWaitForEvents failed"); + + cl_ulong deviceTimeAfterCompletion; + err = + clGetDeviceAndHostTimer(device, &deviceTimeAfterCompletion, &hostTime); + test_error(err, "Unable to get finishing device time"); + + cl_ulong eventQueue, eventSubmit, eventStart, eventEnd; + err = clGetEventProfilingInfo(kEvent, CL_PROFILING_COMMAND_QUEUED, + sizeof(cl_ulong), &eventQueue, NULL); + test_error(err, "clGetEventProfilingInfo failed"); + err = clGetEventProfilingInfo(kEvent, CL_PROFILING_COMMAND_SUBMIT, + sizeof(cl_ulong), &eventSubmit, NULL); + test_error(err, "clGetEventProfilingInfo failed"); + err = clGetEventProfilingInfo(kEvent, CL_PROFILING_COMMAND_START, + sizeof(cl_ulong), &eventStart, NULL); + test_error(err, "clGetEventProfilingInfo failed"); + err = clGetEventProfilingInfo(kEvent, CL_PROFILING_COMMAND_END, + sizeof(cl_ulong), &eventEnd, NULL); + test_error(err, "clGetEventProfilingInfo failed"); + + test_assert_error(deviceTimeBeforeQueue < eventQueue, + "Device timestamp was taken before kernel was queued"); + test_assert_error(eventQueue < deviceTimeAfterQueue, + "Device timestamp was taken after kernel was queued"); + test_assert_error(eventSubmit < deviceTimeAfterCompletion, + "Device timestamp was taken after kernel was submitted"); + test_assert_error((eventStart < deviceTimeAfterCompletion) + && (eventEnd < deviceTimeAfterCompletion), + "Device timestamp was taken after kernel was executed"); + return TEST_PASS; +} diff --git a/test_conformance/profiling/readImage.cpp b/test_conformance/profiling/readImage.cpp index 9ba6b472e7..fd4da128e1 100644 --- a/test_conformance/profiling/readImage.cpp +++ b/test_conformance/profiling/readImage.cpp @@ -233,7 +233,7 @@ int read_image( cl_device_id device, cl_context context, cl_command_queue queue, } size_t origin[3] = { 0, 0, 0 }; - size_t region[3] = { w, h, 1 }; + size_t region[3] = { (size_t)w, (size_t)h, 1 }; err = clEnqueueReadImage( queue, memobjs[0], false, origin, region, 0, 0, dst, 0, NULL, &readEvent ); if( err != CL_SUCCESS ){ print_error( err, "clReadImage2D failed" ); diff --git a/test_conformance/profiling/writeImage.cpp b/test_conformance/profiling/writeImage.cpp index ec2fbdaf3b..e2a6dd5935 100644 --- a/test_conformance/profiling/writeImage.cpp +++ b/test_conformance/profiling/writeImage.cpp @@ -472,7 +472,7 @@ int write_image( cl_device_id device, cl_context context, cl_command_queue queue } size_t origin[3] = { 0, 0, 0 }; - size_t region[3] = { w, h, 1 }; + size_t region[3] = { (size_t)w, (size_t)h, 1 }; err = clEnqueueWriteImage( queue, memobjs[0], false, origin, region, 0, 0, inptr, 0, NULL, &writeEvent ); if( err != CL_SUCCESS ){ clReleaseMemObject(memobjs[0]); diff --git a/test_conformance/relationals/test_comparisons_fp.cpp b/test_conformance/relationals/test_comparisons_fp.cpp index 73ff3dd9ed..6c4890d74a 100644 --- a/test_conformance/relationals/test_comparisons_fp.cpp +++ b/test_conformance/relationals/test_comparisons_fp.cpp @@ -309,7 +309,7 @@ int RelationalsFPTest::test_equiv_kernel(unsigned int vecSize, sstr << "ERROR: Data sample " << i << ":" << j << " at size " << vs << " does not validate! Expected " << e << ", got " << o << ", source " << iA << ":" << iB << std::endl; - log_error(sstr.str().c_str()); + log_error("%s", sstr.str().c_str()); }; /* And verify! */ diff --git a/test_conformance/relationals/test_shuffles.cpp b/test_conformance/relationals/test_shuffles.cpp index 2fb8ab3be6..ba6a0aec1e 100644 --- a/test_conformance/relationals/test_shuffles.cpp +++ b/test_conformance/relationals/test_shuffles.cpp @@ -324,7 +324,7 @@ void generate_shuffle_mask( char *outMaskString, size_t maskSize, const ShuffleO for( size_t jj = 0; jj < maskSize; jj++ ) { char thisMask[ 16 ]; - sprintf( thisMask, "%s%ld", ( jj == 0 ) ? "" : ", ", jj ); + sprintf(thisMask, "%s%zu", (jj == 0) ? "" : ", ", jj); strcat( outMaskString, thisMask ); } } @@ -347,7 +347,7 @@ static int create_shuffle_kernel( cl_context context, cl_program *outProgram, cl if( inVecSize == 1 ) //|| (inVecSize == 3)) // just have arrays if we go with size 3 inSizeName[ 0 ] = 0; else - sprintf( inSizeName, "%ld", inVecSize ); + sprintf(inSizeName, "%zu", inVecSize); if( inVecSize == 3 ) inSizeArgName[ 0 ] = 0; else diff --git a/test_conformance/spir/main.cpp b/test_conformance/spir/main.cpp index ca02e5c21b..9a13b405c6 100644 --- a/test_conformance/spir/main.cpp +++ b/test_conformance/spir/main.cpp @@ -155,7 +155,8 @@ static void get_spir_version(cl_device_id device, { auto major = v[v.find('.') - 1]; auto minor = v[v.find('.') + 1]; - versions.push_back(Version{ major - '0', minor - '0' }); + versions.push_back( + Version{ (cl_uint)(major - '0'), (cl_uint)(minor - '0') }); } } diff --git a/test_conformance/spirv_new/CMakeLists.txt b/test_conformance/spirv_new/CMakeLists.txt index 16a61b4075..67faecf895 100644 --- a/test_conformance/spirv_new/CMakeLists.txt +++ b/test_conformance/spirv_new/CMakeLists.txt @@ -4,10 +4,10 @@ set(${MODULE_NAME}_SOURCES main.cpp test_basic_versions.cpp test_cl_khr_expect_assume.cpp - test_cl_khr_spirv_no_integer_wrap_decoration.cpp test_decorate.cpp test_get_program_il.cpp test_linkage.cpp + test_no_integer_wrap_decoration.cpp test_op_atomic.cpp test_op_branch_conditional.cpp test_op_branch.cpp @@ -27,6 +27,7 @@ set(${MODULE_NAME}_SOURCES test_op_vector_extract.cpp test_op_vector_insert.cpp test_op_vector_times_scalar.cpp + test_spirv_14.cpp ) set(TEST_HARNESS_SOURCES @@ -34,6 +35,10 @@ set(TEST_HARNESS_SOURCES ../../test_conformance/math_brute_force/utility.cpp ) +if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") + add_cxx_flag_if_supported(-Wno-narrowing) +endif() + set(${MODULE_NAME}_SOURCES ${SPIRV_NEW_SOURCES} ${TEST_HARNESS_SOURCES}) include(../CMakeCommon.txt) diff --git a/test_conformance/spirv_new/main.cpp b/test_conformance/spirv_new/main.cpp index fc3c0bec7f..e3640b1253 100644 --- a/test_conformance/spirv_new/main.cpp +++ b/test_conformance/spirv_new/main.cpp @@ -42,16 +42,15 @@ const std::string spvVersionSkipArg = "--skip-spirv-version-check"; std::vector readBinary(const char *file_name) { - using namespace std; - - ifstream file(file_name, ios::in | ios::binary | ios::ate); + std::ifstream file(file_name, + std::ios::in | std::ios::binary | std::ios::ate); std::vector tmpBuffer(0); if (file.is_open()) { size_t size = file.tellg(); tmpBuffer.resize(size); - file.seekg(0, ios::beg); + file.seekg(0, std::ios::beg); file.read(&tmpBuffer[0], size); file.close(); } else { @@ -70,34 +69,6 @@ std::vector readSPIRV(const char *file_name) return readBinary(full_name_str.c_str()); } -test_definition *spirvTestsRegistry::getTestDefinitions() -{ - return &testDefinitions[0]; -} - -size_t spirvTestsRegistry::getNumTests() -{ - return testDefinitions.size(); -} - -void spirvTestsRegistry::addTestClass(baseTestClass *test, const char *testName, - Version version) -{ - - testClasses.push_back(test); - test_definition testDef; - testDef.func = test->getFunction(); - testDef.name = testName; - testDef.min_version = version; - testDefinitions.push_back(testDef); -} - -spirvTestsRegistry& spirvTestsRegistry::getInstance() -{ - static spirvTestsRegistry instance; - return instance; -} - static int offline_get_program_with_il(clProgramWrapper &prog, const cl_device_id deviceID, const cl_context context, @@ -271,7 +242,6 @@ int main(int argc, const char *argv[]) } return runTestHarnessWithCheck( - argc, argv, spirvTestsRegistry::getInstance().getNumTests(), - spirvTestsRegistry::getInstance().getTestDefinitions(), false, 0, - InitCL); + argc, argv, test_registry::getInstance().num_tests(), + test_registry::getInstance().definitions(), false, 0, InitCL); } diff --git a/test_conformance/spirv_new/procs.h b/test_conformance/spirv_new/procs.h index a80d4edc85..3211da08ff 100644 --- a/test_conformance/spirv_new/procs.h +++ b/test_conformance/spirv_new/procs.h @@ -36,56 +36,6 @@ return -1; \ } while (0) - -class baseTestClass { -public: - baseTestClass() {} - virtual test_function_pointer getFunction() = 0; -}; - -class spirvTestsRegistry { -private: - std::vector testClasses; - std::vector testDefinitions; - -public: - static spirvTestsRegistry &getInstance(); - - test_definition *getTestDefinitions(); - - size_t getNumTests(); - - void addTestClass(baseTestClass *test, const char *testName, - Version version); - spirvTestsRegistry() {} -}; - -template T *createAndRegister(const char *name, Version version) -{ - T *testClass = new T(); - spirvTestsRegistry::getInstance().addTestClass((baseTestClass *)testClass, - name, version); - return testClass; -} - -#define TEST_SPIRV_FUNC_VERSION(name, version) \ - extern int test_##name(cl_device_id deviceID, cl_context context, \ - cl_command_queue queue, int num_elements); \ - class test_##name##_class : public baseTestClass { \ - private: \ - test_function_pointer fn; \ - \ - public: \ - test_##name##_class(): fn(test_##name) {} \ - test_function_pointer getFunction() { return fn; } \ - }; \ - test_##name##_class *var_##name = \ - createAndRegister(#name, version); \ - int test_##name(cl_device_id deviceID, cl_context context, \ - cl_command_queue queue, int num_elements) - -#define TEST_SPIRV_FUNC(name) TEST_SPIRV_FUNC_VERSION(name, Version(1, 2)) - struct spec_const { spec_const(cl_int id = 0, size_t sizet = 0, const void *value = NULL) diff --git a/test_conformance/spirv_new/spirvInfo.hpp b/test_conformance/spirv_new/spirvInfo.hpp new file mode 100644 index 0000000000..ed4d6c794c --- /dev/null +++ b/test_conformance/spirv_new/spirvInfo.hpp @@ -0,0 +1,41 @@ +// +// Copyright (c) 2024 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#pragma once + +#include "harness/compat.h" + +#include + +extern bool gVersionSkip; + +static bool is_spirv_version_supported(cl_device_id deviceID, + const char* version) +{ + std::string ilVersions = get_device_il_version_string(deviceID); + + if (gVersionSkip) + { + log_info(" Skipping version check for %s.\n", version); + return true; + } + else if (ilVersions.find(version) == std::string::npos) + { + return false; + } + + return true; +} diff --git a/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm32 b/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm32 index 5b5991a5d2..a3e23ae211 100644 --- a/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm32 @@ -39,7 +39,7 @@ %21 = OpLoad %uint %20 Aligned 4 %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %19 %23 = OpLoad %uint %22 Aligned 4 - %24 = OpSLessThan %bool %21 %23 + %24 = OpULessThan %bool %21 %23 OpBranchConditional %24 %25 %26 %25 = OpLabel %27 = OpISub %uint %23 %21 diff --git a/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm64 b/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm64 index 41983a1af1..dd7c5cbd38 100644 --- a/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/branch_conditional.spvasm64 @@ -45,7 +45,7 @@ %26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 %27 = OpLoad %uint %26 Aligned 4 OpStore %19 %uint_0 - %28 = OpSLessThan %bool %25 %27 + %28 = OpULessThan %bool %25 %27 OpBranchConditional %28 %29 %30 %29 = OpLabel %31 = OpISub %uint %27 %25 diff --git a/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm32 b/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm32 index daeba30b24..db820d326e 100644 --- a/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm32 @@ -39,7 +39,7 @@ %21 = OpLoad %uint %20 Aligned 4 %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %19 %23 = OpLoad %uint %22 Aligned 4 - %24 = OpSLessThan %bool %21 %23 + %24 = OpULessThan %bool %21 %23 OpBranchConditional %24 %25 %26 4 6 %25 = OpLabel %27 = OpISub %uint %23 %21 diff --git a/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm64 b/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm64 index 5238726f92..c0ea8bd1f8 100644 --- a/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/branch_conditional_weighted.spvasm64 @@ -45,7 +45,7 @@ %26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 %27 = OpLoad %uint %26 Aligned 4 OpStore %19 %uint_0 - %28 = OpSLessThan %bool %25 %27 + %28 = OpULessThan %bool %25 %27 OpBranchConditional %28 %29 %30 4 6 %29 = OpLabel %31 = OpISub %uint %27 %25 diff --git a/test_conformance/spirv_new/spirv_asm/phi_2.spvasm32 b/test_conformance/spirv_new/spirv_asm/phi_2.spvasm32 index 7a6311a78b..49337ad58c 100644 --- a/test_conformance/spirv_new/spirv_asm/phi_2.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/phi_2.spvasm32 @@ -36,7 +36,7 @@ %18 = OpLoad %uint %17 Aligned 4 %19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %16 %20 = OpLoad %uint %19 Aligned 4 - %21 = OpSLessThan %bool %18 %20 + %21 = OpULessThan %bool %18 %20 OpBranchConditional %21 %22 %23 %22 = OpLabel %24 = OpISub %uint %20 %18 diff --git a/test_conformance/spirv_new/spirv_asm/phi_2.spvasm64 b/test_conformance/spirv_new/spirv_asm/phi_2.spvasm64 index 538c5f71f8..7539115dd4 100644 --- a/test_conformance/spirv_new/spirv_asm/phi_2.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/phi_2.spvasm64 @@ -41,7 +41,7 @@ %22 = OpLoad %uint %21 Aligned 4 %23 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %20 %24 = OpLoad %uint %23 Aligned 4 - %25 = OpSLessThan %bool %22 %24 + %25 = OpULessThan %bool %22 %24 OpBranchConditional %25 %26 %27 %26 = OpLabel %28 = OpISub %uint %24 %22 diff --git a/test_conformance/spirv_new/spirv_asm/phi_3.spvasm32 b/test_conformance/spirv_new/spirv_asm/phi_3.spvasm32 index fef5c24349..107edb9ba1 100644 --- a/test_conformance/spirv_new/spirv_asm/phi_3.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/phi_3.spvasm32 @@ -23,6 +23,7 @@ %bool = OpTypeBool %void = OpTypeVoid %uint_0 = OpConstant %uint 0 + %uint_65535 = OpConstant %uint 65535 %_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input @@ -37,10 +38,10 @@ %19 = OpLoad %uint %18 Aligned 4 %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 %21 = OpLoad %uint %20 Aligned 4 - %22 = OpSLessThan %bool %19 %21 + %22 = OpULessThan %bool %19 %21 OpBranchConditional %22 %23 %24 %23 = OpLabel - %25 = OpSLessThan %bool %19 %uint_0 + %25 = OpULessThan %bool %19 %uint_65535 OpBranchConditional %25 %26 %27 %26 = OpLabel %28 = OpISub %uint %uint_0 %19 diff --git a/test_conformance/spirv_new/spirv_asm/phi_3.spvasm64 b/test_conformance/spirv_new/spirv_asm/phi_3.spvasm64 index 9ea0fc86c6..cbd10d2433 100644 --- a/test_conformance/spirv_new/spirv_asm/phi_3.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/phi_3.spvasm64 @@ -26,6 +26,7 @@ %void = OpTypeVoid %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 + %uint_65535 = OpConstant %uint 65535 %_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input @@ -42,10 +43,10 @@ %23 = OpLoad %uint %22 Aligned 4 %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %21 %25 = OpLoad %uint %24 Aligned 4 - %26 = OpSLessThan %bool %23 %25 + %26 = OpULessThan %bool %23 %25 OpBranchConditional %26 %27 %28 %27 = OpLabel - %29 = OpSLessThan %bool %23 %uint_0 + %29 = OpULessThan %bool %23 %uint_65535 OpBranchConditional %29 %30 %31 %30 = OpLabel %32 = OpISub %uint %uint_0 %23 diff --git a/test_conformance/spirv_new/spirv_asm/phi_4.spvasm32 b/test_conformance/spirv_new/spirv_asm/phi_4.spvasm32 index 575ff3d3b5..c71af71472 100644 --- a/test_conformance/spirv_new/spirv_asm/phi_4.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/phi_4.spvasm32 @@ -23,6 +23,7 @@ %bool = OpTypeBool %void = OpTypeVoid %uint_0 = OpConstant %uint 0 + %uint_65535 = OpConstant %uint 65535 %_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input @@ -37,10 +38,10 @@ %19 = OpLoad %uint %18 Aligned 4 %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 %21 = OpLoad %uint %20 Aligned 4 - %22 = OpSLessThan %bool %19 %21 + %22 = OpULessThan %bool %19 %21 OpBranchConditional %22 %23 %24 %23 = OpLabel - %25 = OpSLessThan %bool %19 %uint_0 + %25 = OpULessThan %bool %19 %uint_65535 OpBranchConditional %25 %26 %27 %26 = OpLabel %28 = OpISub %uint %uint_0 %19 @@ -49,7 +50,7 @@ %30 = OpISub %uint %19 %uint_0 OpBranch %29 %24 = OpLabel - %31 = OpSLessThan %bool %21 %uint_0 + %31 = OpULessThan %bool %21 %uint_65535 OpBranchConditional %31 %32 %33 %32 = OpLabel %34 = OpISub %uint %uint_0 %21 diff --git a/test_conformance/spirv_new/spirv_asm/phi_4.spvasm64 b/test_conformance/spirv_new/spirv_asm/phi_4.spvasm64 index ffa1fc11d6..2f38f7380a 100644 --- a/test_conformance/spirv_new/spirv_asm/phi_4.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/phi_4.spvasm64 @@ -26,6 +26,7 @@ %void = OpTypeVoid %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 + %uint_65535 = OpConstant %uint 65535 %_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input @@ -42,10 +43,10 @@ %23 = OpLoad %uint %22 Aligned 4 %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %21 %25 = OpLoad %uint %24 Aligned 4 - %26 = OpSLessThan %bool %23 %25 + %26 = OpULessThan %bool %23 %25 OpBranchConditional %26 %27 %28 %27 = OpLabel - %29 = OpSLessThan %bool %23 %uint_0 + %29 = OpULessThan %bool %23 %uint_65535 OpBranchConditional %29 %30 %31 %30 = OpLabel %32 = OpISub %uint %uint_0 %23 @@ -54,7 +55,7 @@ %34 = OpISub %uint %23 %uint_0 OpBranch %33 %28 = OpLabel - %35 = OpSLessThan %bool %25 %uint_0 + %35 = OpULessThan %bool %25 %uint_65535 OpBranchConditional %35 %36 %37 %36 = OpLabel %38 = OpISub %uint %uint_0 %25 diff --git a/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm32 b/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm32 index 53883e345e..7cfd4ec147 100644 --- a/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm32 @@ -39,7 +39,7 @@ %21 = OpLoad %uint %20 Aligned 4 %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %19 %23 = OpLoad %uint %22 Aligned 4 - %24 = OpSLessThan %bool %21 %23 + %24 = OpULessThan %bool %21 %23 OpSelectionMerge %25 DontFlatten OpBranchConditional %24 %26 %27 %26 = OpLabel diff --git a/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm64 b/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm64 index 5939b7133d..87e6f509b0 100644 --- a/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/select_if_dont_flatten.spvasm64 @@ -45,7 +45,7 @@ %26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 %27 = OpLoad %uint %26 Aligned 4 OpStore %19 %uint_0 - %28 = OpSLessThan %bool %25 %27 + %28 = OpULessThan %bool %25 %27 OpSelectionMerge %29 DontFlatten OpBranchConditional %28 %30 %31 %30 = OpLabel diff --git a/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm32 b/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm32 index 0b05732267..18f4470a49 100644 --- a/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm32 @@ -39,7 +39,7 @@ %21 = OpLoad %uint %20 Aligned 4 %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %19 %23 = OpLoad %uint %22 Aligned 4 - %24 = OpSLessThan %bool %21 %23 + %24 = OpULessThan %bool %21 %23 OpSelectionMerge %25 Flatten OpBranchConditional %24 %26 %27 %26 = OpLabel diff --git a/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm64 b/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm64 index e3e4cf98c0..719f0e2f09 100644 --- a/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/select_if_flatten.spvasm64 @@ -45,7 +45,7 @@ %26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 %27 = OpLoad %uint %26 Aligned 4 OpStore %19 %uint_0 - %28 = OpSLessThan %bool %25 %27 + %28 = OpULessThan %bool %25 %27 OpSelectionMerge %29 Flatten OpBranchConditional %28 %30 %31 %30 = OpLabel diff --git a/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm32 b/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm32 index b8217880ea..1feea59f87 100644 --- a/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm32 +++ b/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm32 @@ -39,7 +39,7 @@ %21 = OpLoad %uint %20 Aligned 4 %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %19 %23 = OpLoad %uint %22 Aligned 4 - %24 = OpSLessThan %bool %21 %23 + %24 = OpULessThan %bool %21 %23 OpSelectionMerge %25 None OpBranchConditional %24 %26 %27 %26 = OpLabel diff --git a/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm64 b/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm64 index 6a45bce6a8..365b6612e2 100644 --- a/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm64 +++ b/test_conformance/spirv_new/spirv_asm/select_if_none.spvasm64 @@ -45,7 +45,7 @@ %26 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 %27 = OpLoad %uint %26 Aligned 4 OpStore %19 %uint_0 - %28 = OpSLessThan %bool %25 %27 + %28 = OpULessThan %bool %25 %27 OpSelectionMerge %29 None OpBranchConditional %28 %30 %31 %30 = OpLabel diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/copylogical_struct.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/copylogical_struct.spvasm32 new file mode 100644 index 0000000000..3076a06713 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/copylogical_struct.spvasm32 @@ -0,0 +1,24 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "copylogical_test" + %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %void = OpTypeVoid + %struct_a = OpTypeStruct %uint %float +%ptr_struct_a = OpTypePointer CrossWorkgroup %struct_a + %struct_b = OpTypeStruct %uint %float +%ptr_struct_b = OpTypePointer CrossWorkgroup %struct_b + %kernel_sig = OpTypeFunction %void %ptr_struct_b + %uint_1024 = OpConstant %uint 1024 + %float_pi = OpConstant %float 3.1415 +%struct_a_src = OpConstantComposite %struct_a %uint_1024 %float_pi + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %ptr_struct_b + %entry = OpLabel +%struct_b_dst = OpCopyLogical %struct_b %struct_a_src + OpStore %dst %struct_b_dst + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/copylogical_struct.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/copylogical_struct.spvasm64 new file mode 100644 index 0000000000..2e6247a825 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/copylogical_struct.spvasm64 @@ -0,0 +1,24 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "copylogical_test" + %uint = OpTypeInt 32 0 + %float = OpTypeFloat 32 + %void = OpTypeVoid + %struct_a = OpTypeStruct %uint %float +%ptr_struct_a = OpTypePointer CrossWorkgroup %struct_a + %struct_b = OpTypeStruct %uint %float +%ptr_struct_b = OpTypePointer CrossWorkgroup %struct_b + %kernel_sig = OpTypeFunction %void %ptr_struct_b + %uint_1024 = OpConstant %uint 1024 + %float_pi = OpConstant %float 3.1415 +%struct_a_src = OpConstantComposite %struct_a %uint_1024 %float_pi + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %ptr_struct_b + %entry = OpLabel +%struct_b_dst = OpCopyLogical %struct_b %struct_a_src + OpStore %dst %struct_b_dst + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/copymemory_memory_operands.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/copymemory_memory_operands.spvasm32 new file mode 100644 index 0000000000..f4d82f4876 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/copymemory_memory_operands.spvasm32 @@ -0,0 +1,34 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "copymemory_test" + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %gptr_int = OpTypePointer CrossWorkgroup %uint + %pptr_int = OpTypePointer Function %uint + %kernel_sig = OpTypeFunction %void %gptr_int + %uint_42 = OpConstant %uint 42 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %uint_4 = OpConstant %uint 4 + %uint_5 = OpConstant %uint 5 + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %gptr_int + %entry = OpLabel + %pvalue = OpVariable %pptr_int Function %uint_42 + OpCopyMemory %dst %pvalue ; no memory operands + %dst1 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_1 + OpCopyMemory %dst1 %pvalue Volatile ; one memory operand + %dst2 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_2 + OpCopyMemory %dst2 %pvalue Volatile Volatile ; two memory operands + %dst3 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_3 + OpCopyMemorySized %dst3 %pvalue %uint_4 ; no memory operands + %dst4 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_4 + OpCopyMemorySized %dst4 %pvalue %uint_4 Volatile ; one memory operand + %dst5 = OpInBoundsPtrAccessChain %gptr_int %dst %uint_5 + OpCopyMemorySized %dst5 %pvalue %uint_4 Volatile Volatile ; two memory operands + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/copymemory_memory_operands.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/copymemory_memory_operands.spvasm64 new file mode 100644 index 0000000000..c615213f3f --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/copymemory_memory_operands.spvasm64 @@ -0,0 +1,36 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "copymemory_test" + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %void = OpTypeVoid + %gptr_int = OpTypePointer CrossWorkgroup %uint + %pptr_int = OpTypePointer Function %uint + %kernel_sig = OpTypeFunction %void %gptr_int + %uint_42 = OpConstant %uint 42 + %ulong_1 = OpConstant %ulong 1 + %ulong_2 = OpConstant %ulong 2 + %ulong_3 = OpConstant %ulong 3 + %ulong_4 = OpConstant %ulong 4 + %ulong_5 = OpConstant %ulong 5 + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %gptr_int + %entry = OpLabel + %pvalue = OpVariable %pptr_int Function %uint_42 + OpCopyMemory %dst %pvalue ; no memory operands + %dst1 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_1 + OpCopyMemory %dst1 %pvalue Volatile ; one memory operand + %dst2 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_2 + OpCopyMemory %dst2 %pvalue Volatile Volatile ; two memory operands + %dst3 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_3 + OpCopyMemorySized %dst3 %pvalue %ulong_4 ; no memory operands + %dst4 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_4 + OpCopyMemorySized %dst4 %pvalue %ulong_4 Volatile ; one memory operand + %dst5 = OpInBoundsPtrAccessChain %gptr_int %dst %ulong_5 + OpCopyMemorySized %dst5 %pvalue %ulong_4 Volatile Volatile ; two memory operands + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_signextend.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_signextend.spvasm32 new file mode 100644 index 0000000000..a00e66ebe3 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_signextend.spvasm32 @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 31 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability ImageBasic + OpCapability LiteralSampler + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %read_image_test "read_image_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %index_0 = OpConstant %uint 0 + %void = OpTypeVoid + %v4uint = OpTypeVector %uint 4 +%_ptr_CrossWorkgroup_v4uint = OpTypePointer CrossWorkgroup %v4uint + %image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly + %7 = OpTypeFunction %void %_ptr_CrossWorkgroup_v4uint %image2d_t + %sampler_t = OpTypeSampler +%sampledimage_t = OpTypeSampledImage %image2d_t + %v2uint = OpTypeVector %uint 2 + %float = OpTypeFloat 32 + %sampler = OpConstantSampler %sampler_t None 0 Nearest + %coord_0_0 = OpConstantNull %v2uint + %float_0 = OpConstant %float 0 +%read_image_test = OpFunction %void None %7 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_v4uint + %image = OpFunctionParameter %image2d_t + %entry = OpLabel +%TempSampledImage = OpSampledImage %sampledimage_t %image %sampler + %call = OpImageSampleExplicitLod %v4uint %TempSampledImage %coord_0_0 Lod|SignExtend %float_0 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v4uint %dst %index_0 + OpStore %arrayidx %call Aligned 16 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_signextend.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_signextend.spvasm64 new file mode 100644 index 0000000000..316eb17a50 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_signextend.spvasm64 @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 31 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability ImageBasic + OpCapability LiteralSampler + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %read_image_test "read_image_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %index_0 = OpConstant %ulong 0 + %void = OpTypeVoid + %v4uint = OpTypeVector %uint 4 +%_ptr_CrossWorkgroup_v4uint = OpTypePointer CrossWorkgroup %v4uint + %image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly + %7 = OpTypeFunction %void %_ptr_CrossWorkgroup_v4uint %image2d_t + %sampler_t = OpTypeSampler +%sampledimage_t = OpTypeSampledImage %image2d_t + %v2uint = OpTypeVector %uint 2 + %float = OpTypeFloat 32 + %sampler = OpConstantSampler %sampler_t None 0 Nearest + %coord_0_0 = OpConstantNull %v2uint + %float_0 = OpConstant %float 0 +%read_image_test = OpFunction %void None %7 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_v4uint + %image = OpFunctionParameter %image2d_t + %entry = OpLabel +%TempSampledImage = OpSampledImage %sampledimage_t %image %sampler + %call = OpImageSampleExplicitLod %v4uint %TempSampledImage %coord_0_0 Lod|SignExtend %float_0 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v4uint %dst %index_0 + OpStore %arrayidx %call Aligned 16 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_zeroextend.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_zeroextend.spvasm32 new file mode 100644 index 0000000000..c763af6bf9 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_zeroextend.spvasm32 @@ -0,0 +1,37 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 31 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability ImageBasic + OpCapability LiteralSampler + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %read_image_test "read_image_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %index_0 = OpConstant %uint 0 + %void = OpTypeVoid + %v4uint = OpTypeVector %uint 4 +%_ptr_CrossWorkgroup_v4uint = OpTypePointer CrossWorkgroup %v4uint + %image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly + %7 = OpTypeFunction %void %_ptr_CrossWorkgroup_v4uint %image2d_t + %sampler_t = OpTypeSampler +%sampledimage_t = OpTypeSampledImage %image2d_t + %v2uint = OpTypeVector %uint 2 + %float = OpTypeFloat 32 + %sampler = OpConstantSampler %sampler_t None 0 Nearest + %coord_0_0 = OpConstantNull %v2uint + %float_0 = OpConstant %float 0 +%read_image_test = OpFunction %void None %7 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_v4uint + %image = OpFunctionParameter %image2d_t + %entry = OpLabel +%TempSampledImage = OpSampledImage %sampledimage_t %image %sampler + %call = OpImageSampleExplicitLod %v4uint %TempSampledImage %coord_0_0 Lod|ZeroExtend %float_0 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v4uint %dst %index_0 + OpStore %arrayidx %call Aligned 16 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_zeroextend.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_zeroextend.spvasm64 new file mode 100644 index 0000000000..64910cdff8 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/image_operand_zeroextend.spvasm64 @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 31 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpCapability ImageBasic + OpCapability LiteralSampler + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %read_image_test "read_image_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %index_0 = OpConstant %ulong 0 + %void = OpTypeVoid + %v4uint = OpTypeVector %uint 4 +%_ptr_CrossWorkgroup_v4uint = OpTypePointer CrossWorkgroup %v4uint + %image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly + %7 = OpTypeFunction %void %_ptr_CrossWorkgroup_v4uint %image2d_t + %sampler_t = OpTypeSampler +%sampledimage_t = OpTypeSampledImage %image2d_t + %v2uint = OpTypeVector %uint 2 + %float = OpTypeFloat 32 + %sampler = OpConstantSampler %sampler_t None 0 Nearest + %coord_0_0 = OpConstantNull %v2uint + %float_0 = OpConstant %float 0 +%read_image_test = OpFunction %void None %7 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_v4uint + %image = OpFunctionParameter %image2d_t + %entry = OpLabel +%TempSampledImage = OpSampledImage %sampledimage_t %image %sampler + %call = OpImageSampleExplicitLod %v4uint %TempSampledImage %coord_0_0 Lod|ZeroExtend %float_0 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_v4uint %dst %index_0 + OpStore %arrayidx %call Aligned 16 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_iterationmultiple.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_iterationmultiple.spvasm32 new file mode 100644 index 0000000000..2755ee446a --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_iterationmultiple.spvasm32 @@ -0,0 +1,43 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc IterationMultiple 2 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %uint_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_iterationmultiple.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_iterationmultiple.spvasm64 new file mode 100644 index 0000000000..80ffd20b48 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_iterationmultiple.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %ulong_0 = OpConstant %ulong 0 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc IterationMultiple 2 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %ulong_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_maxiterations.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_maxiterations.spvasm32 new file mode 100644 index 0000000000..c9220dce81 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_maxiterations.spvasm32 @@ -0,0 +1,43 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc MaxIterations 16 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %uint_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_maxiterations.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_maxiterations.spvasm64 new file mode 100644 index 0000000000..a9c4933f6e --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_maxiterations.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %ulong_0 = OpConstant %ulong 0 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc MaxIterations 16 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %ulong_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_miniterations.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_miniterations.spvasm32 new file mode 100644 index 0000000000..e2ec34d2a0 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_miniterations.spvasm32 @@ -0,0 +1,43 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc MinIterations 4 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %uint_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_miniterations.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_miniterations.spvasm64 new file mode 100644 index 0000000000..a19336a66a --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_miniterations.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %ulong_0 = OpConstant %ulong 0 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc MinIterations 4 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %ulong_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_partialcount.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_partialcount.spvasm32 new file mode 100644 index 0000000000..cbe8cceb29 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_partialcount.spvasm32 @@ -0,0 +1,43 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc PartialCount 2 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %uint_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_partialcount.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_partialcount.spvasm64 new file mode 100644 index 0000000000..51216f63e9 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_partialcount.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %ulong_0 = OpConstant %ulong 0 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc PartialCount 2 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %ulong_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_peelcount.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_peelcount.spvasm32 new file mode 100644 index 0000000000..ee3639ff6e --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_peelcount.spvasm32 @@ -0,0 +1,43 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc PeelCount 2 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %uint_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_peelcount.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_peelcount.spvasm64 new file mode 100644 index 0000000000..2d94190a52 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/loop_control_peelcount.spvasm64 @@ -0,0 +1,46 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 37 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %loop_control_test "loop_control_test" + OpSource OpenCL_C 102000 + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %ulong_0 = OpConstant %ulong 0 + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %5 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %uint %uint + %bool = OpTypeBool +%loop_control_test = OpFunction %void None %5 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %count = OpFunctionParameter %uint + %value = OpFunctionParameter %uint + %entry = OpLabel + OpBranch %for_cond + %for_cond = OpLabel + %sum_0 = OpPhi %uint %uint_0 %entry %add %for_inc + %i_0 = OpPhi %uint %uint_0 %entry %inc %for_inc + %cmp = OpSLessThan %bool %i_0 %count + OpLoopMerge %for_cond_cleanup %for_inc PeelCount 2 + OpBranchConditional %cmp %for_body %for_cond_cleanup +%for_cond_cleanup = OpLabel + OpBranch %for_end + %for_body = OpLabel + %add = OpIAdd %uint %sum_0 %value + OpBranch %for_inc + %for_inc = OpLabel + %inc = OpIAdd %uint %i_0 %uint_1 + OpBranch %for_cond + %for_end = OpLabel + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %ulong_0 + OpStore %arrayidx %sum_0 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_int.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_int.spvasm32 new file mode 100644 index 0000000000..557faae089 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_int.spvasm32 @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoSignedWrap + OpGroupDecorate %7 %lhs %rhs + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %14 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %15 = OpLabel + %16 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 + %21 = OpLoad %uint %20 Aligned 4 + %8 = OpIAdd %uint %19 %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %17 + OpStore %22 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_int.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_int.spvasm64 new file mode 100644 index 0000000000..4bc2c2a7cc --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_int.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoSignedWrap + OpGroupDecorate %7 %lhs %rhs + %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 + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %ulong %17 0 + %19 = OpUConvert %uint %18 + %20 = OpSConvert %ulong %19 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %20 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpSConvert %ulong %19 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 + %25 = OpLoad %uint %24 Aligned 4 + %8 = OpIAdd %uint %22 %25 + %26 = OpSConvert %ulong %19 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %26 + OpStore %27 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_uint.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_uint.spvasm32 new file mode 100644 index 0000000000..b858523c9d --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_uint.spvasm32 @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoUnsignedWrap + OpGroupDecorate %7 %lhs %rhs + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %14 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %15 = OpLabel + %16 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 + %21 = OpLoad %uint %20 Aligned 4 + %8 = OpIAdd %uint %19 %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %17 + OpStore %22 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_uint.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_uint.spvasm64 new file mode 100644 index 0000000000..a41f4f41e4 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fadd_uint.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoUnsignedWrap + OpGroupDecorate %7 %lhs %rhs + %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 + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %ulong %17 0 + %19 = OpUConvert %uint %18 + %20 = OpSConvert %ulong %19 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %20 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpSConvert %ulong %19 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 + %25 = OpLoad %uint %24 Aligned 4 + %8 = OpIAdd %uint %22 %25 + %26 = OpSConvert %ulong %19 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %26 + OpStore %27 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_int.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_int.spvasm32 new file mode 100644 index 0000000000..4886c01c43 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_int.spvasm32 @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoSignedWrap + OpGroupDecorate %7 %lhs %rhs + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %14 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %15 = OpLabel + %16 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 + %21 = OpLoad %uint %20 Aligned 4 + %8 = OpIMul %uint %19 %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %17 + OpStore %22 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_int.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_int.spvasm64 new file mode 100644 index 0000000000..ff6799e71a --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_int.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoSignedWrap + OpGroupDecorate %7 %lhs %rhs + %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 + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %ulong %17 0 + %19 = OpUConvert %uint %18 + %20 = OpSConvert %ulong %19 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %20 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpSConvert %ulong %19 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 + %25 = OpLoad %uint %24 Aligned 4 + %8 = OpIMul %uint %22 %25 + %26 = OpSConvert %ulong %19 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %26 + OpStore %27 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_uint.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_uint.spvasm32 new file mode 100644 index 0000000000..1993a13d17 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_uint.spvasm32 @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoUnsignedWrap + OpGroupDecorate %7 %lhs %rhs + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %14 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %15 = OpLabel + %16 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 + %21 = OpLoad %uint %20 Aligned 4 + %8 = OpIMul %uint %19 %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %17 + OpStore %22 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_uint.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_uint.spvasm64 new file mode 100644 index 0000000000..d17b9c292e --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fmul_uint.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.3 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoUnsignedWrap + OpGroupDecorate %7 %lhs %rhs + %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 + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %ulong %17 0 + %19 = OpUConvert %uint %18 + %20 = OpSConvert %ulong %19 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %20 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpSConvert %ulong %19 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 + %25 = OpLoad %uint %24 Aligned 4 + %8 = OpIMul %uint %22 %25 + %26 = OpSConvert %ulong %19 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %26 + OpStore %27 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fnegate_int.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fnegate_int.spvasm32 new file mode 100644 index 0000000000..ea9a85adbf --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fnegate_int.spvasm32 @@ -0,0 +1,44 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 22 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + OpDecorate %8 NoSignedWrap + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpGroupDecorate %7 %lhs %rhs + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %uint %17 0 + %19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %18 + %20 = OpLoad %uint %19 Aligned 4 + %8 = OpSNegate %uint %20 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %18 + OpStore %21 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fnegate_int.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fnegate_int.spvasm64 new file mode 100644 index 0000000000..2edfb49989 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fnegate_int.spvasm64 @@ -0,0 +1,49 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 26 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + OpDecorate %8 NoSignedWrap + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpGroupDecorate %7 %lhs %rhs + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %16 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %17 = OpLabel + %18 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %19 = OpCompositeExtract %ulong %18 0 + %20 = OpUConvert %uint %19 + %21 = OpSConvert %ulong %20 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %21 + %23 = OpLoad %uint %22 Aligned 4 + %8 = OpSNegate %uint %23 + %24 = OpSConvert %ulong %20 + %25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %24 + OpStore %25 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_int.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_int.spvasm32 new file mode 100644 index 0000000000..08b5ba7152 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_int.spvasm32 @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 25 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoSignedWrap + OpGroupDecorate %7 %lhs %rhs + %uint = OpTypeInt 32 0 + %uint_31 = OpConstant %uint 31 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %uint %17 0 + %19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %18 + %20 = OpLoad %uint %19 Aligned 4 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %18 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpBitwiseAnd %uint %22 %uint_31 + %8 = OpShiftLeftLogical %uint %20 %23 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %18 + OpStore %24 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_int.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_int.spvasm64 new file mode 100644 index 0000000000..3487dc46ea --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_int.spvasm64 @@ -0,0 +1,53 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoSignedWrap + OpGroupDecorate %7 %lhs %rhs + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %uint_31 = OpConstant %uint 31 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %16 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %17 = OpLabel + %18 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %19 = OpCompositeExtract %ulong %18 0 + %20 = OpUConvert %uint %19 + %21 = OpSConvert %ulong %20 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %21 + %23 = OpLoad %uint %22 Aligned 4 + %24 = OpSConvert %ulong %20 + %25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %24 + %26 = OpLoad %uint %25 Aligned 4 + %27 = OpBitwiseAnd %uint %26 %uint_31 + %8 = OpShiftLeftLogical %uint %23 %27 + %28 = OpSConvert %ulong %20 + %29 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %28 + OpStore %29 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_uint.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_uint.spvasm32 new file mode 100644 index 0000000000..ac01b182d1 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_uint.spvasm32 @@ -0,0 +1,47 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 25 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoUnsignedWrap + OpGroupDecorate %7 %lhs %rhs + %uint = OpTypeInt 32 0 + %uint_31 = OpConstant %uint 31 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %uint %17 0 + %19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %18 + %20 = OpLoad %uint %19 Aligned 4 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %18 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpBitwiseAnd %uint %22 %uint_31 + %8 = OpShiftLeftLogical %uint %20 %23 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %18 + OpStore %24 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_uint.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_uint.spvasm64 new file mode 100644 index 0000000000..a2d8ba698b --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fshiftleft_uint.spvasm64 @@ -0,0 +1,53 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 30 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpDecorate %8 NoUnsignedWrap + OpGroupDecorate %7 %lhs %rhs + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %uint_31 = OpConstant %uint 31 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %16 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %16 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %17 = OpLabel + %18 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %19 = OpCompositeExtract %ulong %18 0 + %20 = OpUConvert %uint %19 + %21 = OpSConvert %ulong %20 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %21 + %23 = OpLoad %uint %22 Aligned 4 + %24 = OpSConvert %ulong %20 + %25 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %24 + %26 = OpLoad %uint %25 Aligned 4 + %27 = OpBitwiseAnd %uint %26 %uint_31 + %8 = OpShiftLeftLogical %uint %23 %27 + %28 = OpSConvert %ulong %20 + %29 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %28 + OpStore %29 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_int.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_int.spvasm32 new file mode 100644 index 0000000000..946be21171 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_int.spvasm32 @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpGroupDecorate %7 %lhs %rhs + OpDecorate %8 NoSignedWrap + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %14 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %15 = OpLabel + %16 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 + %21 = OpLoad %uint %20 Aligned 4 + %8 = OpISub %uint %19 %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %17 + OpStore %22 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_int.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_int.spvasm64 new file mode 100644 index 0000000000..26ce619ef3 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_int.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpGroupDecorate %7 %lhs %rhs + OpDecorate %8 NoSignedWrap + %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 + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %ulong %17 0 + %19 = OpUConvert %uint %18 + %20 = OpSConvert %ulong %19 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %20 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpSConvert %ulong %19 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 + %25 = OpLoad %uint %24 Aligned 4 + %8 = OpISub %uint %22 %25 + %26 = OpSConvert %ulong %19 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %26 + OpStore %27 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_uint.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_uint.spvasm32 new file mode 100644 index 0000000000..013614f3c1 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_uint.spvasm32 @@ -0,0 +1,45 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpGroupDecorate %7 %lhs %rhs + OpDecorate %8 NoUnsignedWrap + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %14 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3uint Input + %2 = OpFunction %void None %14 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %15 = OpLabel + %16 = OpLoad %v3uint %__spirv_BuiltInGlobalInvocationId + %17 = OpCompositeExtract %uint %16 0 + %18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %17 + %19 = OpLoad %uint %18 Aligned 4 + %20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %17 + %21 = OpLoad %uint %20 Aligned 4 + %8 = OpISub %uint %19 %21 + %22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %17 + OpStore %22 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_uint.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_uint.spvasm64 new file mode 100644 index 0000000000..19df8b5faf --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/no_integer_wrap_decoration_fsub_uint.spvasm64 @@ -0,0 +1,51 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 28 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "fmath_cl" %__spirv_BuiltInGlobalInvocationId + OpSource OpenCL_C 200000 + OpName %__spirv_BuiltInGlobalInvocationId "__spirv_BuiltInGlobalInvocationId" + OpName %out "out" + OpName %lhs "lhs" + OpName %rhs "rhs" + OpDecorate %7 FuncParamAttr NoWrite + %7 = OpDecorationGroup + OpDecorate %__spirv_BuiltInGlobalInvocationId BuiltIn GlobalInvocationId + OpDecorate %__spirv_BuiltInGlobalInvocationId Constant + OpDecorate %__spirv_BuiltInGlobalInvocationId LinkageAttributes "__spirv_BuiltInGlobalInvocationId" Import + OpGroupDecorate %7 %lhs %rhs + OpDecorate %8 NoUnsignedWrap + %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 + %15 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint %_ptr_CrossWorkgroup_uint +%__spirv_BuiltInGlobalInvocationId = OpVariable %_ptr_Input_v3ulong Input + %2 = OpFunction %void None %15 + %out = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %lhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %rhs = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %16 = OpLabel + %17 = OpLoad %v3ulong %__spirv_BuiltInGlobalInvocationId + %18 = OpCompositeExtract %ulong %17 0 + %19 = OpUConvert %uint %18 + %20 = OpSConvert %ulong %19 + %21 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %lhs %20 + %22 = OpLoad %uint %21 Aligned 4 + %23 = OpSConvert %ulong %19 + %24 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %rhs %23 + %25 = OpLoad %uint %24 Aligned 4 + %8 = OpISub %uint %22 %25 + %26 = OpSConvert %ulong %19 + %27 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %out %26 + OpStore %27 %8 Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/nonwriteable_decoration_function_storage_class.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/nonwriteable_decoration_function_storage_class.spvasm32 new file mode 100644 index 0000000000..c94befbe65 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/nonwriteable_decoration_function_storage_class.spvasm32 @@ -0,0 +1,21 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "nonwriteable_test" + OpDecorate %pvalue NonWritable + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %gptr_int = OpTypePointer CrossWorkgroup %uint + %pptr_int = OpTypePointer Function %uint + %kernel_sig = OpTypeFunction %void %gptr_int + %uint_42 = OpConstant %uint 42 + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %gptr_int + %entry = OpLabel + %pvalue = OpVariable %pptr_int Function %uint_42 + %value = OpLoad %uint %pvalue + OpStore %dst %value + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/nonwriteable_decoration_function_storage_class.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/nonwriteable_decoration_function_storage_class.spvasm64 new file mode 100644 index 0000000000..7171438bd5 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/nonwriteable_decoration_function_storage_class.spvasm64 @@ -0,0 +1,21 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "nonwriteable_test" + OpDecorate %pvalue NonWritable + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %gptr_int = OpTypePointer CrossWorkgroup %uint + %pptr_int = OpTypePointer Function %uint + %kernel_sig = OpTypeFunction %void %gptr_int + %uint_42 = OpConstant %uint 42 + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %gptr_int + %entry = OpLabel + %pvalue = OpVariable %pptr_int Function %uint_42 + %value = OpLoad %uint %pvalue + OpStore %dst %value + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/ptrops.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/ptrops.spvasm32 new file mode 100644 index 0000000000..492cae2039 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/ptrops.spvasm32 @@ -0,0 +1,34 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 61 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "ptrops_test" + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_2 = OpConstant %uint 2 + %void = OpTypeVoid + %ptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %ptr_uint %ptr_uint + %bool = OpTypeBool + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %ptr_uint + %tst = OpFunctionParameter %ptr_uint + %entry = OpLabel + %cmp = OpPtrEqual %bool %dst %tst + %bool0 = OpSelect %uint %cmp %uint_1 %uint_0 + %dst0 = OpInBoundsPtrAccessChain %ptr_uint %dst %uint_0 + OpStore %dst0 %bool0 Aligned 4 + %cmp1 = OpPtrNotEqual %bool %dst %tst + %bool1 = OpSelect %uint %cmp1 %uint_1 %uint_0 + %dst1 = OpInBoundsPtrAccessChain %ptr_uint %dst %uint_1 + OpStore %dst1 %bool1 Aligned 4 + %delta = OpPtrDiff %uint %dst %tst + %dst2 = OpInBoundsPtrAccessChain %ptr_uint %dst %uint_2 + OpStore %dst2 %delta Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/ptrops.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/ptrops.spvasm64 new file mode 100644 index 0000000000..f9c5ae5a59 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/ptrops.spvasm64 @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.0 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 61 +; Schema: 0 + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "ptrops_test" + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %ulong_0 = OpConstant %ulong 0 + %ulong_1 = OpConstant %ulong 1 + %ulong_2 = OpConstant %ulong 2 + %void = OpTypeVoid + %ptr_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %ptr_uint %ptr_uint + %bool = OpTypeBool + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %ptr_uint + %tst = OpFunctionParameter %ptr_uint + %entry = OpLabel + %cmp = OpPtrEqual %bool %dst %tst + %bool0 = OpSelect %uint %cmp %uint_1 %uint_0 + %dst0 = OpInBoundsPtrAccessChain %ptr_uint %dst %ulong_0 + OpStore %dst0 %bool0 Aligned 4 + %cmp1 = OpPtrNotEqual %bool %dst %tst + %bool1 = OpSelect %uint %cmp1 %uint_1 %uint_0 + %dst1 = OpInBoundsPtrAccessChain %ptr_uint %dst %ulong_1 + OpStore %dst1 %bool1 Aligned 4 + %delta = OpPtrDiff %ulong %dst %tst + %deltaui = OpUConvert %uint %delta + %dst2 = OpInBoundsPtrAccessChain %ptr_uint %dst %ulong_2 + OpStore %dst2 %deltaui Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/select_struct.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/select_struct.spvasm32 new file mode 100644 index 0000000000..516a4107ba --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/select_struct.spvasm32 @@ -0,0 +1,38 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "select_struct_test" %pgid + OpDecorate %pgid BuiltIn GlobalInvocationId + OpDecorate %pgid Constant + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %float = OpTypeFloat 32 + %void = OpTypeVoid + %bool = OpTypeBool + %struct = OpTypeStruct %uint %float +%gptr_struct = OpTypePointer CrossWorkgroup %struct +%iptr_v3uint = OpTypePointer Input %v3uint + %kernel_sig = OpTypeFunction %void %gptr_struct + %uint_0 = OpConstant %uint 0 + %uint_1 = OpConstant %uint 1 + %uint_1024 = OpConstant %uint 1024 + %float_pi = OpConstant %float 3.1415 + %uint_2048 = OpConstant %uint 2048 + %float_e = OpConstant %float 2.7128 + %struct_a = OpConstantComposite %struct %uint_1024 %float_pi + %struct_b = OpConstantComposite %struct %uint_2048 %float_e + %pgid = OpVariable %iptr_v3uint Input + %kernel = OpFunction %void None %kernel_sig + %dst_base = OpFunctionParameter %gptr_struct + %entry = OpLabel + %gid = OpLoad %v3uint %pgid Aligned 32 + %gid0 = OpCompositeExtract %uint %gid 0 + %test = OpBitwiseAnd %uint %gid0 %uint_1 + %cond = OpIEqual %bool %test %uint_1 + %result = OpSelect %struct %cond %struct_a %struct_b + %dst = OpInBoundsPtrAccessChain %gptr_struct %dst_base %gid0 + OpStore %dst %result + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/select_struct.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/select_struct.spvasm64 new file mode 100644 index 0000000000..cbcbbba43c --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/select_struct.spvasm64 @@ -0,0 +1,40 @@ +; SPIR-V +; Version: 1.4 + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "select_struct_test" %pgid + OpDecorate %pgid BuiltIn GlobalInvocationId + OpDecorate %pgid Constant + %uint = OpTypeInt 32 0 + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 + %float = OpTypeFloat 32 + %void = OpTypeVoid + %bool = OpTypeBool + %struct = OpTypeStruct %uint %float +%gptr_struct = OpTypePointer CrossWorkgroup %struct +%iptr_v3ulong = OpTypePointer Input %v3ulong + %kernel_sig = OpTypeFunction %void %gptr_struct + %ulong_0 = OpConstant %ulong 0 + %ulong_1 = OpConstant %ulong 1 + %uint_1024 = OpConstant %uint 1024 + %float_pi = OpConstant %float 3.1415 + %uint_2048 = OpConstant %uint 2048 + %float_e = OpConstant %float 2.7128 + %struct_a = OpConstantComposite %struct %uint_1024 %float_pi + %struct_b = OpConstantComposite %struct %uint_2048 %float_e + %pgid = OpVariable %iptr_v3ulong Input + %kernel = OpFunction %void None %kernel_sig + %dst_base = OpFunctionParameter %gptr_struct + %entry = OpLabel + %gid = OpLoad %v3ulong %pgid Aligned 32 + %gid0 = OpCompositeExtract %ulong %gid 0 + %test = OpBitwiseAnd %ulong %gid0 %ulong_1 + %cond = OpIEqual %bool %test %ulong_1 + %result = OpSelect %struct %cond %struct_a %struct_b + %dst = OpInBoundsPtrAccessChain %gptr_struct %dst_base %gid0 + OpStore %dst %result + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_decoratestring.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_decoratestring.spvasm32 new file mode 100644 index 0000000000..9a85f39ce4 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_decoratestring.spvasm32 @@ -0,0 +1,35 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 24 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %usersemantic_test "usersemantic_test" %global_id + OpDecorate %global_id LinkageAttributes "global_id" Import + OpDecorate %global_id Constant + OpDecorate %global_id BuiltIn GlobalInvocationId + ; Basic decoration: + OpDecorateString %global_id UserSemantic "FOO" + ; Duplicate decorations are allowed as long as the string is different. + OpDecorateString %global_id UserSemantic "BAR" + ; Try one more string with punctuation. + OpDecorateString %global_id UserSemantic "FOO? BAR. BAZ!" + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %9 = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%global_id = OpVariable %_ptr_Input_v3uint Input +%usersemantic_test = OpFunction %void None %9 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel + %index = OpLoad %v3uint %global_id Aligned 32 + %call = OpCompositeExtract %uint %index 0 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %call + OpStore %arrayidx %call Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_decoratestring.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_decoratestring.spvasm64 new file mode 100644 index 0000000000..b97b46af22 --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_decoratestring.spvasm64 @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 24 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %usersemantic_test "usersemantic_test" %global_id + OpDecorate %global_id LinkageAttributes "global_id" Import + OpDecorate %global_id Constant + OpDecorate %global_id BuiltIn GlobalInvocationId + ; Basic decoration: + OpDecorateString %global_id UserSemantic "FOO" + ; Duplicate decorations are allowed as long as the string is different. + OpDecorateString %global_id UserSemantic "BAR" + ; Try one more string with punctuation. + OpDecorateString %global_id UserSemantic "FOO? BAR. BAZ!" + %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 +%global_id = OpVariable %_ptr_Input_v3ulong Input +%usersemantic_test = OpFunction %void None %9 + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel + %index = OpLoad %v3ulong %global_id Aligned 32 + %call = OpCompositeExtract %ulong %index 0 + %conv = OpUConvert %uint %call + %idxprom = OpSConvert %ulong %conv + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %idxprom + OpStore %arrayidx %conv Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_memberdecoratestring.spvasm32 b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_memberdecoratestring.spvasm32 new file mode 100644 index 0000000000..8b9a7ecfbc --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_memberdecoratestring.spvasm32 @@ -0,0 +1,39 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 60 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpMemoryModel Physical32 OpenCL + OpEntryPoint Kernel %kernel "usersemantic_test" %global_id + OpDecorate %global_id LinkageAttributes "global_id" Import + OpDecorate %global_id Constant + OpDecorate %global_id BuiltIn GlobalInvocationId + OpDecorate %s Alignment 4 + OpMemberDecorateString %struct 0 UserSemantic "foo" + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %v3uint = OpTypeVector %uint 3 +%_ptr_Input_v3uint = OpTypePointer Input %v3uint + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%struct = OpTypeStruct %uint +%_ptr_Function_struct = OpTypePointer Function %struct +%_ptr_Function_uint = OpTypePointer Function %uint + %global_id = OpVariable %_ptr_Input_v3uint Input + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel + %s = OpVariable %_ptr_Function_struct Function + %gid = OpLoad %v3uint %global_id Aligned 16 + %gid0 = OpCompositeExtract %uint %gid 0 + %x = OpInBoundsPtrAccessChain %_ptr_Function_uint %s %uint_0 %uint_0 + OpStore %x %gid0 Aligned 4 + %index = OpLoad %uint %x Aligned 4 + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %index + OpStore %arrayidx %index Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_memberdecoratestring.spvasm64 b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_memberdecoratestring.spvasm64 new file mode 100644 index 0000000000..7138c8578f --- /dev/null +++ b/test_conformance/spirv_new/spirv_asm/spv1.4/usersemantic_memberdecoratestring.spvasm64 @@ -0,0 +1,43 @@ +; SPIR-V +; Version: 1.4 +; Generator: Khronos LLVM/SPIR-V Translator; 14 +; Bound: 60 +; Schema: 0 + OpCapability Addresses + OpCapability Linkage + OpCapability Kernel + OpCapability Int64 + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %kernel "usersemantic_test" %global_id + OpDecorate %global_id LinkageAttributes "global_id" Import + OpDecorate %global_id Constant + OpDecorate %global_id BuiltIn GlobalInvocationId + OpDecorate %s Alignment 4 + OpMemberDecorateString %struct 0 UserSemantic "foo" + %ulong = OpTypeInt 64 0 + %uint = OpTypeInt 32 0 + %uint_0 = OpConstant %uint 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %void = OpTypeVoid +%_ptr_CrossWorkgroup_uint = OpTypePointer CrossWorkgroup %uint + %kernel_sig = OpTypeFunction %void %_ptr_CrossWorkgroup_uint +%struct = OpTypeStruct %uint +%_ptr_Function_struct = OpTypePointer Function %struct +%_ptr_Function_uint = OpTypePointer Function %uint + %global_id = OpVariable %_ptr_Input_v3ulong Input + %kernel = OpFunction %void None %kernel_sig + %dst = OpFunctionParameter %_ptr_CrossWorkgroup_uint + %entry = OpLabel + %s = OpVariable %_ptr_Function_struct Function + %gid = OpLoad %v3ulong %global_id Aligned 32 + %gid0 = OpCompositeExtract %ulong %gid 0 + %conv = OpUConvert %uint %gid0 + %x = OpInBoundsPtrAccessChain %_ptr_Function_uint %s %uint_0 %uint_0 + OpStore %x %conv Aligned 4 + %index = OpLoad %uint %x Aligned 4 + %idxprom = OpSConvert %ulong %index + %arrayidx = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_uint %dst %idxprom + OpStore %arrayidx %index Aligned 4 + OpReturn + OpFunctionEnd diff --git a/test_conformance/spirv_new/test_basic_versions.cpp b/test_conformance/spirv_new/test_basic_versions.cpp index afe173906a..011234c541 100644 --- a/test_conformance/spirv_new/test_basic_versions.cpp +++ b/test_conformance/spirv_new/test_basic_versions.cpp @@ -23,7 +23,7 @@ extern bool gVersionSkip; -TEST_SPIRV_FUNC(basic_versions) +REGISTER_TEST(basic_versions) { cl_int error = CL_SUCCESS; diff --git a/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp b/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp index 62a3c2baca..74a425c4ce 100644 --- a/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp +++ b/test_conformance/spirv_new/test_cl_khr_expect_assume.cpp @@ -117,7 +117,7 @@ static int test_expect_type(cl_device_id device, cl_context context, return TEST_PASS; } -TEST_SPIRV_FUNC(op_expect) +REGISTER_TEST(op_expect) { if (!is_extension_available(deviceID, "cl_khr_expect_assume")) { @@ -139,7 +139,7 @@ TEST_SPIRV_FUNC(op_expect) return result; } -TEST_SPIRV_FUNC(op_assume) +REGISTER_TEST(op_assume) { if (!is_extension_available(deviceID, "cl_khr_expect_assume")) { diff --git a/test_conformance/spirv_new/test_decorate.cpp b/test_conformance/spirv_new/test_decorate.cpp index b85419300d..8c76aa225a 100644 --- a/test_conformance/spirv_new/test_decorate.cpp +++ b/test_conformance/spirv_new/test_decorate.cpp @@ -110,29 +110,29 @@ int test_decorate_full(cl_device_id deviceID, return verify_results(deviceID, context, queue, name, prog); } -TEST_SPIRV_FUNC(decorate_restrict) +REGISTER_TEST(decorate_restrict) { return test_decorate_full(deviceID, context, queue, "decorate_restrict"); } -TEST_SPIRV_FUNC(decorate_aliased) +REGISTER_TEST(decorate_aliased) { return test_decorate_full(deviceID, context, queue, "decorate_aliased"); } -TEST_SPIRV_FUNC(decorate_alignment) +REGISTER_TEST(decorate_alignment) { //TODO: Check for results ? How to ensure buffers are aligned clProgramWrapper prog; return get_program_with_il(prog, deviceID, context, "decorate_alignment"); } -TEST_SPIRV_FUNC(decorate_constant) +REGISTER_TEST(decorate_constant) { return test_decorate_full(deviceID, context, queue, "decorate_constant"); } -TEST_SPIRV_FUNC(decorate_cpacked) +REGISTER_TEST(decorate_cpacked) { PACKED(struct packed_struct_t { cl_int ival; @@ -382,7 +382,7 @@ int test_saturate_full(cl_device_id deviceID, } #define TEST_SATURATED_CONVERSION(Ti, Tl, To) \ - TEST_SPIRV_FUNC(decorate_saturated_conversion_##Ti##_to_##To) \ + REGISTER_TEST(decorate_saturated_conversion_##Ti##_to_##To) \ { \ typedef cl_##Ti cl_Ti; \ typedef cl_##Tl cl_Tl; \ @@ -532,7 +532,7 @@ static inline Ti generate_fprounding_input(RandomSeed &seed) } #define TEST_SPIRV_FP_ROUNDING_DECORATE(name, func, Ti, To) \ - TEST_SPIRV_FUNC(decorate_fp_rounding_mode_##name##_##Ti##_##To) \ + REGISTER_TEST(decorate_fp_rounding_mode_##name##_##Ti##_##To) \ { \ typedef cl_##Ti clTi; \ typedef cl_##To clTo; \ diff --git a/test_conformance/spirv_new/test_get_program_il.cpp b/test_conformance/spirv_new/test_get_program_il.cpp index e84f224292..7c0d39dfea 100644 --- a/test_conformance/spirv_new/test_get_program_il.cpp +++ b/test_conformance/spirv_new/test_get_program_il.cpp @@ -26,7 +26,7 @@ const char *sample_kernel_code_single_line[] = { "}\n" }; -TEST_SPIRV_FUNC(get_program_il) +REGISTER_TEST(get_program_il) { clProgramWrapper source_program; size_t il_size = -1; @@ -68,8 +68,8 @@ TEST_SPIRV_FUNC(get_program_il) if (il_size != file_bytes) { test_fail("ERROR: Returned IL size is not the same as source IL " - "size (%lu " - "!= %lu)!\n", + "size (%zu " + "!= %zu)!\n", il_size, file_bytes); } diff --git a/test_conformance/spirv_new/test_linkage.cpp b/test_conformance/spirv_new/test_linkage.cpp index ea17040ad2..6e991bd701 100644 --- a/test_conformance/spirv_new/test_linkage.cpp +++ b/test_conformance/spirv_new/test_linkage.cpp @@ -77,19 +77,19 @@ static int test_linkage_compile(cl_device_id deviceID, return 0; } -TEST_SPIRV_FUNC(linkage_export_function_compile) +REGISTER_TEST(linkage_export_function_compile) { clProgramWrapper prog; return test_linkage_compile(deviceID, context, queue, "linkage_export", prog); } -TEST_SPIRV_FUNC(linkage_import_function_compile) +REGISTER_TEST(linkage_import_function_compile) { clProgramWrapper prog; return test_linkage_compile(deviceID, context, queue, "linkage_import", prog); } -TEST_SPIRV_FUNC(linkage_import_function_link) +REGISTER_TEST(linkage_import_function_link) { int err = 0; @@ -212,7 +212,7 @@ static int test_linkonce_odr_helper(cl_device_id deviceID, cl_context context, return TEST_PASS; } -TEST_SPIRV_FUNC(linkage_linkonce_odr) +REGISTER_TEST(linkage_linkonce_odr) { if (!is_extension_available(deviceID, "cl_khr_spirv_linkonce_odr")) { diff --git a/test_conformance/spirv_new/test_cl_khr_spirv_no_integer_wrap_decoration.cpp b/test_conformance/spirv_new/test_no_integer_wrap_decoration.cpp similarity index 54% rename from test_conformance/spirv_new/test_cl_khr_spirv_no_integer_wrap_decoration.cpp rename to test_conformance/spirv_new/test_no_integer_wrap_decoration.cpp index 95227b28ff..15088f5189 100644 --- a/test_conformance/spirv_new/test_cl_khr_spirv_no_integer_wrap_decoration.cpp +++ b/test_conformance/spirv_new/test_no_integer_wrap_decoration.cpp @@ -15,6 +15,7 @@ // #include "testBase.h" +#include "spirvInfo.hpp" #include "types.hpp" #include @@ -22,13 +23,10 @@ #include -template -int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, - cl_context context, - cl_command_queue queue, - const char *spvName, - const char *funcName, - const char *Tname) +template +int test_no_integer_wrap_decoration(cl_device_id deviceID, cl_context context, + cl_command_queue queue, const char *spvName, + const char *funcName, const char *Tname) { cl_int err = CL_SUCCESS; @@ -37,13 +35,10 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, std::vector h_rhs(num); std::vector expected_results(num); std::vector h_ref(num); - if (!is_extension_available(deviceID, "cl_khr_spirv_no_integer_wrap_decoration")) { - log_info("Extension cl_khr_spirv_no_integer_wrap_decoration not supported; skipping tests.\n"); - return 0; - } /*Test with some values that do not cause overflow*/ - if (std::is_signed::value == true) { + if (std::is_signed::value == true) + { h_lhs.push_back((T)-25000); h_lhs.push_back((T)-3333); h_lhs.push_back((T)-7); @@ -54,7 +49,9 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, h_lhs.push_back(2048); h_lhs.push_back(4094); h_lhs.push_back(10000); - } else { + } + else + { h_lhs.push_back(0); h_lhs.push_back(1); h_lhs.push_back(3); @@ -79,16 +76,20 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, h_rhs.push_back(9); size_t bytes = num * sizeof(T); - clMemWrapper lhs = clCreateBuffer(context, CL_MEM_READ_ONLY, bytes, NULL, &err); + clMemWrapper lhs = + clCreateBuffer(context, CL_MEM_READ_ONLY, bytes, NULL, &err); SPIRV_CHECK_ERROR(err, "Failed to create lhs buffer"); - err = clEnqueueWriteBuffer(queue, lhs, CL_TRUE, 0, bytes, &h_lhs[0], 0, NULL, NULL); + err = clEnqueueWriteBuffer(queue, lhs, CL_TRUE, 0, bytes, &h_lhs[0], 0, + NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to copy to lhs buffer"); - clMemWrapper rhs = clCreateBuffer(context, CL_MEM_READ_ONLY, bytes, NULL, &err); + clMemWrapper rhs = + clCreateBuffer(context, CL_MEM_READ_ONLY, bytes, NULL, &err); SPIRV_CHECK_ERROR(err, "Failed to create rhs buffer"); - err = clEnqueueWriteBuffer(queue, rhs, CL_TRUE, 0, bytes, &h_rhs[0], 0, NULL, NULL); + err = clEnqueueWriteBuffer(queue, rhs, CL_TRUE, 0, bytes, &h_rhs[0], 0, + NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to copy to rhs buffer"); std::string kernelStr; @@ -101,8 +102,8 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, kernelStream << "#define spirv_fshiftleft(a, b) (a) << (b) \n"; kernelStream << "#define spirv_fnegate(a, b) (-a) \n"; - kernelStream << "#define T " << Tname << "\n"; - kernelStream << "#define FUNC spirv_" << funcName << "\n"; + kernelStream << "#define T " << Tname << "\n"; + kernelStream << "#define FUNC spirv_" << funcName << "\n"; kernelStream << "__kernel void fmath_cl(__global T *out, \n"; kernelStream << "const __global T *lhs, const __global T *rhs) \n"; kernelStream << "{ \n"; @@ -114,16 +115,26 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, const char *kernelBuf = kernelStr.c_str(); - for (int i = 0; i < num; i++) { - if (std::string(funcName) == std::string("fadd")) { + for (int i = 0; i < num; i++) + { + if (std::string(funcName) == std::string("fadd")) + { expected_results[i] = h_lhs[i] + h_rhs[i]; - } else if (std::string(funcName) == std::string("fsub")) { + } + else if (std::string(funcName) == std::string("fsub")) + { expected_results[i] = h_lhs[i] - h_rhs[i]; - } else if (std::string(funcName) == std::string("fmul")) { + } + else if (std::string(funcName) == std::string("fmul")) + { expected_results[i] = h_lhs[i] * h_rhs[i]; - } else if (std::string(funcName) == std::string("fshiftleft")) { + } + else if (std::string(funcName) == std::string("fshiftleft")) + { expected_results[i] = h_lhs[i] << h_rhs[i]; - } else if (std::string(funcName) == std::string("fnegate")) { + } + else if (std::string(funcName) == std::string("fnegate")) + { expected_results[i] = 0 - h_lhs[i]; } } @@ -136,7 +147,8 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, &kernelBuf, "fmath_cl"); SPIRV_CHECK_ERROR(err, "Failed to create cl kernel"); - clMemWrapper ref = clCreateBuffer(context, CL_MEM_READ_WRITE, bytes, NULL, &err); + clMemWrapper ref = + clCreateBuffer(context, CL_MEM_READ_WRITE, bytes, NULL, &err); SPIRV_CHECK_ERROR(err, "Failed to create ref buffer"); err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &ref); @@ -149,16 +161,22 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, SPIRV_CHECK_ERROR(err, "Failed to set arg 2"); size_t global = num; - err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, NULL, NULL); + err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to enqueue cl kernel"); - err = clEnqueueReadBuffer(queue, ref, CL_TRUE, 0, bytes, &h_ref[0], 0, NULL, NULL); + err = clEnqueueReadBuffer(queue, ref, CL_TRUE, 0, bytes, &h_ref[0], 0, + NULL, NULL); SPIRV_CHECK_ERROR(err, "Failed to read from ref"); } - for (int i = 0; i < num; i++) { - if (expected_results[i] != h_ref[i]) { - log_error("Values do not match at index %d expected = %d got = %d\n", i, expected_results[i], h_ref[i]); + for (int i = 0; i < num; i++) + { + if (expected_results[i] != h_ref[i]) + { + log_error( + "Values do not match at index %d expected = %d got = %d\n", i, + expected_results[i], h_ref[i]); return -1; } } @@ -170,7 +188,8 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, clKernelWrapper kernel = clCreateKernel(prog, "fmath_cl", &err); SPIRV_CHECK_ERROR(err, "Failed to create spv kernel"); - clMemWrapper res = clCreateBuffer(context, CL_MEM_READ_WRITE, bytes, NULL, &err); + clMemWrapper res = + clCreateBuffer(context, CL_MEM_READ_WRITE, bytes, NULL, &err); SPIRV_CHECK_ERROR(err, "Failed to create res buffer"); err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &res); @@ -183,39 +202,75 @@ int test_ext_cl_khr_spirv_no_integer_wrap_decoration(cl_device_id deviceID, SPIRV_CHECK_ERROR(err, "Failed to set arg 2"); size_t global = num; - err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, NULL, NULL); + err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, NULL, + NULL); SPIRV_CHECK_ERROR(err, "Failed to enqueue cl kernel"); std::vector h_res(num); - err = clEnqueueReadBuffer(queue, res, CL_TRUE, 0, bytes, &h_res[0], 0, NULL, NULL); + err = clEnqueueReadBuffer(queue, res, CL_TRUE, 0, bytes, &h_res[0], 0, NULL, + NULL); SPIRV_CHECK_ERROR(err, "Failed to read from ref"); - for (int i = 0; i < num; i++) { - if (expected_results[i] != h_res[i]) { - log_error("Values do not match at location %d expected = %d got = %d\n", i, expected_results[i], h_res[i]); + for (int i = 0; i < num; i++) + { + if (expected_results[i] != h_res[i]) + { + log_error( + "Values do not match at location %d expected = %d got = %d\n", + i, expected_results[i], h_res[i]); return -1; } } - return 0; + return TEST_PASS; } -#define TEST_FMATH_FUNC(TYPE, FUNC) \ - TEST_SPIRV_FUNC(ext_cl_khr_spirv_no_integer_wrap_decoration_##FUNC##_##TYPE) \ - { \ - return test_ext_cl_khr_spirv_no_integer_wrap_decoration(deviceID, context, queue, \ - "ext_cl_khr_spirv_no_integer_wrap_decoration_"#FUNC"_"#TYPE, \ - #FUNC, \ - #TYPE \ - ); \ +#define TEST_FMATH_FUNC_KHR(TYPE, FUNC) \ + REGISTER_TEST(ext_cl_khr_spirv_no_integer_wrap_decoration_##FUNC##_##TYPE) \ + { \ + if (!is_extension_available( \ + deviceID, "cl_khr_spirv_no_integer_wrap_decoration")) \ + { \ + log_info("Extension cl_khr_spirv_no_integer_wrap_decoration not " \ + "supported; skipping tests.\n"); \ + return TEST_SKIPPED_ITSELF; \ + } \ + return test_no_integer_wrap_decoration( \ + deviceID, context, queue, \ + "ext_cl_khr_spirv_no_integer_wrap_decoration_" #FUNC "_" #TYPE, \ + #FUNC, #TYPE); \ + } + +TEST_FMATH_FUNC_KHR(int, fadd) +TEST_FMATH_FUNC_KHR(int, fsub) +TEST_FMATH_FUNC_KHR(int, fmul) +TEST_FMATH_FUNC_KHR(int, fshiftleft) +TEST_FMATH_FUNC_KHR(int, fnegate) +TEST_FMATH_FUNC_KHR(uint, fadd) +TEST_FMATH_FUNC_KHR(uint, fsub) +TEST_FMATH_FUNC_KHR(uint, fmul) +TEST_FMATH_FUNC_KHR(uint, fshiftleft) + +#define TEST_FMATH_FUNC_14(TYPE, FUNC) \ + REGISTER_TEST(spirv14_no_integer_wrap_decoration_##FUNC##_##TYPE) \ + { \ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) \ + { \ + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); \ + return TEST_SKIPPED_ITSELF; \ + } \ + return test_no_integer_wrap_decoration( \ + deviceID, context, queue, \ + "spv1.4/no_integer_wrap_decoration_" #FUNC "_" #TYPE, #FUNC, \ + #TYPE); \ } -TEST_FMATH_FUNC(int, fadd) -TEST_FMATH_FUNC(int, fsub) -TEST_FMATH_FUNC(int, fmul) -TEST_FMATH_FUNC(int, fshiftleft) -TEST_FMATH_FUNC(int, fnegate) -TEST_FMATH_FUNC(uint, fadd) -TEST_FMATH_FUNC(uint, fsub) -TEST_FMATH_FUNC(uint, fmul) -TEST_FMATH_FUNC(uint, fshiftleft) +TEST_FMATH_FUNC_14(int, fadd) +TEST_FMATH_FUNC_14(int, fsub) +TEST_FMATH_FUNC_14(int, fmul) +TEST_FMATH_FUNC_14(int, fshiftleft) +TEST_FMATH_FUNC_14(int, fnegate) +TEST_FMATH_FUNC_14(uint, fadd) +TEST_FMATH_FUNC_14(uint, fsub) +TEST_FMATH_FUNC_14(uint, fmul) +TEST_FMATH_FUNC_14(uint, fshiftleft) diff --git a/test_conformance/spirv_new/test_op_atomic.cpp b/test_conformance/spirv_new/test_op_atomic.cpp index 0ee2cfb0b1..dca310d7b1 100644 --- a/test_conformance/spirv_new/test_op_atomic.cpp +++ b/test_conformance/spirv_new/test_op_atomic.cpp @@ -87,14 +87,14 @@ int test_atomic(cl_device_id deviceID, cl_context context, return 0; } -TEST_SPIRV_FUNC(op_atomic_inc_global) +REGISTER_TEST(op_atomic_inc_global) { int num = 1 << 16; return test_atomic(deviceID, context, queue, "atomic_inc_global", num, true); } -TEST_SPIRV_FUNC(op_atomic_dec_global) +REGISTER_TEST(op_atomic_dec_global) { int num = 1 << 16; return test_atomic(deviceID, context, queue, diff --git a/test_conformance/spirv_new/test_op_branch.cpp b/test_conformance/spirv_new/test_op_branch.cpp index f87de6c60a..6ffeb5ed8f 100644 --- a/test_conformance/spirv_new/test_op_branch.cpp +++ b/test_conformance/spirv_new/test_op_branch.cpp @@ -65,19 +65,19 @@ int test_branch_simple(cl_device_id deviceID, cl_context context, return 0; } -#define TEST_BRANCH_SIMPLE(NAME) \ - TEST_SPIRV_FUNC(op_##NAME##_simple) \ - { \ - RandomSeed seed(gRandomSeed); \ - int num = 1 << 10; \ - std::vector results(num); \ - for (int i = 0; i < num; i++) { \ - results[i] = genrand(seed); \ - } \ - return test_branch_simple(deviceID, context, queue, \ - #NAME "_simple", \ - results); \ - } \ +#define TEST_BRANCH_SIMPLE(NAME) \ + REGISTER_TEST(op_##NAME##_simple) \ + { \ + RandomSeed seed(gRandomSeed); \ + int num = 1 << 10; \ + std::vector results(num); \ + for (int i = 0; i < num; i++) \ + { \ + results[i] = genrand(seed); \ + } \ + return test_branch_simple(deviceID, context, queue, #NAME "_simple", \ + results); \ + } TEST_BRANCH_SIMPLE(label) diff --git a/test_conformance/spirv_new/test_op_branch_conditional.cpp b/test_conformance/spirv_new/test_op_branch_conditional.cpp index 8f62879807..d7705e8b64 100644 --- a/test_conformance/spirv_new/test_op_branch_conditional.cpp +++ b/test_conformance/spirv_new/test_op_branch_conditional.cpp @@ -83,27 +83,26 @@ int test_branch_conditional(cl_device_id deviceID, return 0; } -#define TEST_BRANCH_CONDITIONAL(name) \ - TEST_SPIRV_FUNC(op_##name) \ - { \ - const int num = 1 << 10; \ - RandomSeed seed(gRandomSeed); \ - \ - std::vector lhs(num); \ - std::vector rhs(num); \ - std::vector out(num); \ - \ - for (int i = 0; i < num; i++) { \ - lhs[i] = genrand(seed); \ - rhs[i] = genrand(seed); \ - out[i] = lhs[i] < rhs[i] ? \ - (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); \ - } \ - \ - return test_branch_conditional(deviceID, context, queue, \ - #name, \ - lhs, rhs, out); \ - } \ +#define TEST_BRANCH_CONDITIONAL(name) \ + REGISTER_TEST(op_##name) \ + { \ + const int num = 1 << 10; \ + RandomSeed seed(gRandomSeed); \ + \ + std::vector lhs(num); \ + std::vector rhs(num); \ + std::vector out(num); \ + \ + for (int i = 0; i < num; i++) \ + { \ + lhs[i] = genrand(seed); \ + rhs[i] = genrand(seed); \ + out[i] = lhs[i] < rhs[i] ? (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); \ + } \ + \ + return test_branch_conditional(deviceID, context, queue, #name, lhs, \ + rhs, out); \ + } TEST_BRANCH_CONDITIONAL(branch_conditional) TEST_BRANCH_CONDITIONAL(branch_conditional_weighted) diff --git a/test_conformance/spirv_new/test_op_composite_construct.cpp b/test_conformance/spirv_new/test_op_composite_construct.cpp index 7ca8762611..3d8d450fd8 100644 --- a/test_conformance/spirv_new/test_op_composite_construct.cpp +++ b/test_conformance/spirv_new/test_op_composite_construct.cpp @@ -56,19 +56,19 @@ int test_composite_construct(cl_device_id deviceID, cl_context context, return 0; } -TEST_SPIRV_FUNC(op_composite_construct_int4) +REGISTER_TEST(op_composite_construct_int4) { cl_int4 value = { { 123, 122, 121, 119 } }; std::vector results(256, value); return test_composite_construct(deviceID, context, queue, "composite_construct_int4", results); } -TEST_SPIRV_FUNC(op_composite_construct_struct) +REGISTER_TEST(op_composite_construct_struct) { typedef AbstractStruct2 CustomType1; typedef AbstractStruct2 CustomType2; - CustomType1 value1 = {2100483600, 128}; + CustomType1 value1 = { 2100483600, (char)128 }; cl_int2 intvals = { { 2100480000, 2100480000 } }; CustomType2 value2 = {intvals, value1}; diff --git a/test_conformance/spirv_new/test_op_constant.cpp b/test_conformance/spirv_new/test_op_constant.cpp index c026fd42ff..abbee1ebb6 100644 --- a/test_conformance/spirv_new/test_op_constant.cpp +++ b/test_conformance/spirv_new/test_op_constant.cpp @@ -64,14 +64,13 @@ int test_constant(cl_device_id deviceID, cl_context context, return 0; } -#define TEST_CONSTANT(NAME, type, value) \ - TEST_SPIRV_FUNC(op_constant_##NAME##_simple) \ - { \ - std::vector results(1024, (type)value); \ - return test_constant(deviceID, context, queue, \ - "constant_" #NAME "_simple", \ - results); \ - } \ +#define TEST_CONSTANT(NAME, type, value) \ + REGISTER_TEST(op_constant_##NAME##_simple) \ + { \ + std::vector results(1024, (type)value); \ + return test_constant(deviceID, context, queue, \ + "constant_" #NAME "_simple", results); \ + } // Boolean tests TEST_CONSTANT(true , cl_int , 1 ) @@ -98,14 +97,14 @@ TEST_CONSTANT(short , cl_short , 32000 ) TEST_CONSTANT(float , cl_float , 3.1415927 ) TEST_CONSTANT(double , cl_double , 3.141592653589793) -TEST_SPIRV_FUNC(op_constant_int4_simple) +REGISTER_TEST(op_constant_int4_simple) { cl_int4 value = { { 123, 122, 121, 119 } }; std::vector results(256, value); return test_constant(deviceID, context, queue, "constant_int4_simple", results); } -TEST_SPIRV_FUNC(op_constant_int3_simple) +REGISTER_TEST(op_constant_int3_simple) { cl_int3 value = { { 123, 122, 121, 0 } }; std::vector results(256, value); @@ -113,26 +112,26 @@ TEST_SPIRV_FUNC(op_constant_int3_simple) results, isVectorNotEqual); } -TEST_SPIRV_FUNC(op_constant_struct_int_float_simple) +REGISTER_TEST(op_constant_struct_int_float_simple) { AbstractStruct2 value = {1024, 3.1415}; std::vector > results(256, value); return test_constant(deviceID, context, queue, "constant_struct_int_float_simple", results); } -TEST_SPIRV_FUNC(op_constant_struct_int_char_simple) +REGISTER_TEST(op_constant_struct_int_char_simple) { - AbstractStruct2 value = {2100483600, 128}; + AbstractStruct2 value = { 2100483600, (char)128 }; std::vector > results(256, value); return test_constant(deviceID, context, queue, "constant_struct_int_char_simple", results); } -TEST_SPIRV_FUNC(op_constant_struct_struct_simple) +REGISTER_TEST(op_constant_struct_struct_simple) { typedef AbstractStruct2 CustomType1; typedef AbstractStruct2 CustomType2; - CustomType1 value1 = {2100483600, 128}; + CustomType1 value1 = { 2100483600, (char)128 }; cl_int2 intvals = { { 2100480000, 2100480000 } }; CustomType2 value2 = {intvals, value1}; @@ -140,7 +139,7 @@ TEST_SPIRV_FUNC(op_constant_struct_struct_simple) return test_constant(deviceID, context, queue, "constant_struct_struct_simple", results); } -TEST_SPIRV_FUNC(op_constant_half_simple) +REGISTER_TEST(op_constant_half_simple) { PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); std::vector results(1024, 3.25); diff --git a/test_conformance/spirv_new/test_op_copy_object.cpp b/test_conformance/spirv_new/test_op_copy_object.cpp index b012960efc..fa76581cd9 100644 --- a/test_conformance/spirv_new/test_op_copy_object.cpp +++ b/test_conformance/spirv_new/test_op_copy_object.cpp @@ -64,14 +64,13 @@ int test_copy(cl_device_id deviceID, cl_context context, return 0; } -#define TEST_COPY(NAME, type, value) \ - TEST_SPIRV_FUNC(op_copy_##NAME##_simple) \ - { \ - std::vector results(1024, (type)value); \ - return test_copy(deviceID, context, queue, \ - "copy_" #NAME "_simple", \ - results); \ - } \ +#define TEST_COPY(NAME, type, value) \ + REGISTER_TEST(op_copy_##NAME##_simple) \ + { \ + std::vector results(1024, (type)value); \ + return test_copy(deviceID, context, queue, "copy_" #NAME "_simple", \ + results); \ + } // Integer tests TEST_COPY(int , cl_int , 123 ) @@ -94,14 +93,14 @@ TEST_COPY(short , cl_short , 32000 ) TEST_COPY(float , cl_float , 3.1415927 ) TEST_COPY(double , cl_double , 3.141592653589793) -TEST_SPIRV_FUNC(op_copy_int4_simple) +REGISTER_TEST(op_copy_int4_simple) { cl_int4 value = { { 123, 122, 121, 119 } }; std::vector results(256, value); return test_copy(deviceID, context, queue, "copy_int4_simple", results); } -TEST_SPIRV_FUNC(op_copy_int3_simple) +REGISTER_TEST(op_copy_int3_simple) { cl_int3 value = { { 123, 122, 121, 0 } }; std::vector results(256, value); @@ -109,26 +108,26 @@ TEST_SPIRV_FUNC(op_copy_int3_simple) results, isVectorNotEqual); } -TEST_SPIRV_FUNC(op_copy_struct_int_float_simple) +REGISTER_TEST(op_copy_struct_int_float_simple) { AbstractStruct2 value = {1024, 3.1415}; std::vector > results(256, value); return test_copy(deviceID, context, queue, "copy_struct_int_float_simple", results); } -TEST_SPIRV_FUNC(op_copy_struct_int_char_simple) +REGISTER_TEST(op_copy_struct_int_char_simple) { - AbstractStruct2 value = {2100483600, 128}; + AbstractStruct2 value = { 2100483600, (char)128 }; std::vector > results(256, value); return test_copy(deviceID, context, queue, "copy_struct_int_char_simple", results); } -TEST_SPIRV_FUNC(op_copy_struct_struct_simple) +REGISTER_TEST(op_copy_struct_struct_simple) { typedef AbstractStruct2 CustomType1; typedef AbstractStruct2 CustomType2; - CustomType1 value1 = {2100483600, 128}; + CustomType1 value1 = { 2100483600, (char)128 }; cl_int2 intvals = { { 2100480000, 2100480000 } }; CustomType2 value2 = {intvals, value1}; @@ -136,7 +135,7 @@ TEST_SPIRV_FUNC(op_copy_struct_struct_simple) return test_copy(deviceID, context, queue, "copy_struct_struct_simple", results); } -TEST_SPIRV_FUNC(op_copy_half_simple) +REGISTER_TEST(op_copy_half_simple) { PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); std::vector results(1024, 3.25); diff --git a/test_conformance/spirv_new/test_op_fmath.cpp b/test_conformance/spirv_new/test_op_fmath.cpp index de887bfee2..3dfe901497 100644 --- a/test_conformance/spirv_new/test_op_fmath.cpp +++ b/test_conformance/spirv_new/test_op_fmath.cpp @@ -150,30 +150,28 @@ int test_fmath(cl_device_id deviceID, return 0; } -#define TEST_FMATH_FUNC(TYPE, FUNC, MODE) \ - TEST_SPIRV_FUNC(op_##FUNC##_##TYPE##_##MODE) \ - { \ - if (sizeof(cl_##TYPE) == 2) { \ - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ - } \ - const int num = 1 << 20; \ - std::vector lhs(num); \ - std::vector rhs(num); \ - \ - RandomSeed seed(gRandomSeed); \ - \ - for (int i = 0; i < num; i++) { \ - lhs[i] = genrandReal(seed); \ - rhs[i] = genrandReal(seed); \ - } \ - \ - const char *mode = #MODE; \ - return test_fmath(deviceID, context, queue, \ - #FUNC "_" #TYPE, \ - #FUNC, \ - #TYPE, \ - mode[0] == 'f', \ - lhs, rhs); \ +#define TEST_FMATH_FUNC(TYPE, FUNC, MODE) \ + REGISTER_TEST(op_##FUNC##_##TYPE##_##MODE) \ + { \ + if (sizeof(cl_##TYPE) == 2) \ + { \ + PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ + } \ + const int num = 1 << 20; \ + std::vector lhs(num); \ + std::vector rhs(num); \ + \ + RandomSeed seed(gRandomSeed); \ + \ + for (int i = 0; i < num; i++) \ + { \ + lhs[i] = genrandReal(seed); \ + rhs[i] = genrandReal(seed); \ + } \ + \ + const char *mode = #MODE; \ + return test_fmath(deviceID, context, queue, #FUNC "_" #TYPE, #FUNC, \ + #TYPE, mode[0] == 'f', lhs, rhs); \ } #define TEST_FMATH_MODE(TYPE, MODE) \ diff --git a/test_conformance/spirv_new/test_op_function.cpp b/test_conformance/spirv_new/test_op_function.cpp index 4a0f4d2632..4f8c4442c9 100644 --- a/test_conformance/spirv_new/test_op_function.cpp +++ b/test_conformance/spirv_new/test_op_function.cpp @@ -67,21 +67,18 @@ int test_function(cl_device_id deviceID, } -#define TEST_FUNCTION(TYPE) \ - TEST_SPIRV_FUNC(function_##TYPE) \ - { \ - int num = 1 << 20; \ - std::vector in(num); \ - RandomSeed seed(gRandomSeed); \ - for (int i = 0; i < num; i++) { \ - in[i] = genrand(seed); \ - } \ - return test_function(deviceID, \ - context, \ - queue, \ - #TYPE, \ - in); \ - } \ +#define TEST_FUNCTION(TYPE) \ + REGISTER_TEST(function_##TYPE) \ + { \ + int num = 1 << 20; \ + std::vector in(num); \ + RandomSeed seed(gRandomSeed); \ + for (int i = 0; i < num; i++) \ + { \ + in[i] = genrand(seed); \ + } \ + return test_function(deviceID, context, queue, #TYPE, in); \ + } TEST_FUNCTION(none) TEST_FUNCTION(inline) diff --git a/test_conformance/spirv_new/test_op_lifetime.cpp b/test_conformance/spirv_new/test_op_lifetime.cpp index 86e7ce0661..f8b7dd5f40 100644 --- a/test_conformance/spirv_new/test_op_lifetime.cpp +++ b/test_conformance/spirv_new/test_op_lifetime.cpp @@ -83,25 +83,25 @@ int test_op_lifetime(cl_device_id deviceID, return 0; } -#define TEST_LIFETIME(name) \ - TEST_SPIRV_FUNC(op_##name) \ - { \ - const int num = 1 << 10; \ - RandomSeed seed(gRandomSeed); \ - \ - std::vector lhs(num); \ - std::vector rhs(num); \ - std::vector out(num); \ - \ - for (int i = 0; i < num; i++) { \ - lhs[i] = genrand(seed); \ - rhs[i] = genrand(seed); \ - out[i] = lhs[i] - rhs[i]; \ - } \ - \ - return test_op_lifetime(deviceID, context, queue, \ - #name, \ - lhs, rhs, out); \ - } \ +#define TEST_LIFETIME(name) \ + REGISTER_TEST(op_##name) \ + { \ + const int num = 1 << 10; \ + RandomSeed seed(gRandomSeed); \ + \ + std::vector lhs(num); \ + std::vector rhs(num); \ + std::vector out(num); \ + \ + for (int i = 0; i < num; i++) \ + { \ + lhs[i] = genrand(seed); \ + rhs[i] = genrand(seed); \ + out[i] = lhs[i] - rhs[i]; \ + } \ + \ + return test_op_lifetime(deviceID, context, queue, #name, lhs, rhs, \ + out); \ + } TEST_LIFETIME(lifetime_simple) diff --git a/test_conformance/spirv_new/test_op_loop_merge.cpp b/test_conformance/spirv_new/test_op_loop_merge.cpp index 3cac328471..2e9f65b0ce 100644 --- a/test_conformance/spirv_new/test_op_loop_merge.cpp +++ b/test_conformance/spirv_new/test_op_loop_merge.cpp @@ -81,30 +81,32 @@ int test_selection_merge(cl_device_id deviceID, return 0; } -#define TEST_LOOP_BRANCH(control) \ - TEST_SPIRV_FUNC(op_loop_merge_branch_##control) \ - { \ - const int num = 1 << 10; \ - RandomSeed seed(gRandomSeed); \ - \ - int rep = 4; \ - std::vector in(rep * num); \ - std::vector out(num); \ - \ - for (int i = 0; i < num; i++) { \ - int res = 0; \ - for (int j = 0; j < rep; j++) { \ - cl_int val = genrand(seed) % 1024; \ - res += val; \ - in[j * num + i] = val; \ - } \ - out[i] = res; \ - } \ - \ - return test_selection_merge(deviceID, context, queue, \ - "loop_merge_branch_" #control, \ - in, out, rep); \ - } \ +#define TEST_LOOP_BRANCH(control) \ + REGISTER_TEST(op_loop_merge_branch_##control) \ + { \ + const int num = 1 << 10; \ + RandomSeed seed(gRandomSeed); \ + \ + int rep = 4; \ + std::vector in(rep *num); \ + std::vector out(num); \ + \ + for (int i = 0; i < num; i++) \ + { \ + int res = 0; \ + for (int j = 0; j < rep; j++) \ + { \ + cl_int val = genrand(seed) % 1024; \ + res += val; \ + in[j * num + i] = val; \ + } \ + out[i] = res; \ + } \ + \ + return test_selection_merge(deviceID, context, queue, \ + "loop_merge_branch_" #control, in, out, \ + rep); \ + } TEST_LOOP_BRANCH(none) TEST_LOOP_BRANCH(unroll) diff --git a/test_conformance/spirv_new/test_op_negate.cpp b/test_conformance/spirv_new/test_op_negate.cpp index 281b1f8ce7..7ff2b844be 100644 --- a/test_conformance/spirv_new/test_op_negate.cpp +++ b/test_conformance/spirv_new/test_op_negate.cpp @@ -86,7 +86,7 @@ int test_negation(cl_device_id deviceID, } #define TEST_NEGATION(TYPE, Tv, OP, FUNC) \ - TEST_SPIRV_FUNC(OP##_##TYPE) \ + REGISTER_TEST(OP##_##TYPE) \ { \ int num = 1 << 20; \ std::vector in(num); \ diff --git a/test_conformance/spirv_new/test_op_opaque.cpp b/test_conformance/spirv_new/test_op_opaque.cpp index 52b54a25b8..19e3c3db7b 100644 --- a/test_conformance/spirv_new/test_op_opaque.cpp +++ b/test_conformance/spirv_new/test_op_opaque.cpp @@ -17,7 +17,7 @@ #include "testBase.h" #include "types.hpp" -TEST_SPIRV_FUNC(op_type_opaque_simple) +REGISTER_TEST(op_type_opaque_simple) { const char *name = "opaque"; cl_int err = CL_SUCCESS; diff --git a/test_conformance/spirv_new/test_op_phi.cpp b/test_conformance/spirv_new/test_op_phi.cpp index 77c1a57248..3f5e86c4dc 100644 --- a/test_conformance/spirv_new/test_op_phi.cpp +++ b/test_conformance/spirv_new/test_op_phi.cpp @@ -83,38 +83,38 @@ int test_phi(cl_device_id deviceID, return 0; } -TEST_SPIRV_FUNC(op_phi_2_blocks) +REGISTER_TEST(op_phi_2_blocks) { const int num = 1 << 10; RandomSeed seed(gRandomSeed); - std::vector lhs(num); - std::vector rhs(num); - std::vector out(num); + std::vector lhs(num); + std::vector rhs(num); + std::vector out(num); for (int i = 0; i < num; i++) { - lhs[i] = genrand(seed); - rhs[i] = genrand(seed); + lhs[i] = genrand(seed); + rhs[i] = genrand(seed); out[i] = lhs[i] < rhs[i] ? (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); } return test_phi(deviceID, context, queue, "phi_2", lhs, rhs, out); } -TEST_SPIRV_FUNC(op_phi_3_blocks) +REGISTER_TEST(op_phi_3_blocks) { const int num = 1 << 10; RandomSeed seed(gRandomSeed); - std::vector lhs(num); - std::vector rhs(num); - std::vector out(num); + std::vector lhs(num); + std::vector rhs(num); + std::vector out(num); for (int i = 0; i < num; i++) { - lhs[i] = genrand(seed); - rhs[i] = genrand(seed); + lhs[i] = genrand(seed); + rhs[i] = genrand(seed); if (lhs[i] < rhs[i]) { - out[i] = lhs[i] < 0 ? -lhs[i] : lhs[i]; + out[i] = lhs[i] < 65535 ? -lhs[i] : lhs[i]; } else { out[i] = lhs[i] - rhs[i]; } @@ -123,22 +123,22 @@ TEST_SPIRV_FUNC(op_phi_3_blocks) return test_phi(deviceID, context, queue, "phi_3", lhs, rhs, out); } -TEST_SPIRV_FUNC(op_phi_4_blocks) +REGISTER_TEST(op_phi_4_blocks) { const int num = 1 << 10; RandomSeed seed(gRandomSeed); - std::vector lhs(num); - std::vector rhs(num); - std::vector out(num); + std::vector lhs(num); + std::vector rhs(num); + std::vector out(num); for (int i = 0; i < num; i++) { - lhs[i] = genrand(seed); - rhs[i] = genrand(seed); + lhs[i] = genrand(seed); + rhs[i] = genrand(seed); if (lhs[i] < rhs[i]) { - out[i] = lhs[i] < 0 ? -lhs[i] : lhs[i]; + out[i] = lhs[i] < 65535 ? -lhs[i] : lhs[i]; } else { - out[i] = rhs[i] < 0 ? -rhs[i] : rhs[i]; + out[i] = rhs[i] < 65535 ? -rhs[i] : rhs[i]; } } diff --git a/test_conformance/spirv_new/test_op_selection_merge.cpp b/test_conformance/spirv_new/test_op_selection_merge.cpp index 2b06ce85c0..e719108575 100644 --- a/test_conformance/spirv_new/test_op_selection_merge.cpp +++ b/test_conformance/spirv_new/test_op_selection_merge.cpp @@ -83,52 +83,51 @@ int test_selection_merge(cl_device_id deviceID, return 0; } -#define TEST_SELECT_IF(control) \ - TEST_SPIRV_FUNC(op_selection_merge_if_##control) \ - { \ - const int num = 1 << 10; \ - RandomSeed seed(gRandomSeed); \ - \ - std::vector lhs(num); \ - std::vector rhs(num); \ - std::vector out(num); \ - \ - for (int i = 0; i < num; i++) { \ - lhs[i] = genrand(seed); \ - rhs[i] = genrand(seed); \ - out[i] = lhs[i] < rhs[i] ? \ - (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); \ - } \ - \ - return test_selection_merge(deviceID, context, queue, \ - "select_if_" #control, \ - lhs, rhs, out); \ - } \ +#define TEST_SELECT_IF(control) \ + REGISTER_TEST(op_selection_merge_if_##control) \ + { \ + const int num = 1 << 10; \ + RandomSeed seed(gRandomSeed); \ + \ + std::vector lhs(num); \ + std::vector rhs(num); \ + std::vector out(num); \ + \ + for (int i = 0; i < num; i++) \ + { \ + lhs[i] = genrand(seed); \ + rhs[i] = genrand(seed); \ + out[i] = lhs[i] < rhs[i] ? (rhs[i] - lhs[i]) : (lhs[i] - rhs[i]); \ + } \ + \ + return test_selection_merge(deviceID, context, queue, \ + "select_if_" #control, lhs, rhs, out); \ + } TEST_SELECT_IF(none) TEST_SELECT_IF(flatten) TEST_SELECT_IF(dont_flatten) -#define TEST_SELECT_SWITCH(control) \ - TEST_SPIRV_FUNC(op_selection_merge_swith_##control) \ - { \ - const int num = 1 << 10; \ - RandomSeed seed(gRandomSeed); \ - \ - std::vector lhs(num); \ - std::vector rhs(num); \ - std::vector out(num); \ - \ - for (int i = 0; i < num; i++) { \ - lhs[i] = genrand(seed); \ - rhs[i] = genrand(seed); \ - out[i] = (lhs[i] + rhs[i]) % 4; \ - } \ - \ - return test_selection_merge(deviceID, context, queue, \ - "select_switch_" #control, \ - lhs, rhs, out); \ - } \ +#define TEST_SELECT_SWITCH(control) \ + REGISTER_TEST(op_selection_merge_swith_##control) \ + { \ + const int num = 1 << 10; \ + RandomSeed seed(gRandomSeed); \ + \ + std::vector lhs(num); \ + std::vector rhs(num); \ + std::vector out(num); \ + \ + for (int i = 0; i < num; i++) \ + { \ + lhs[i] = genrand(seed); \ + rhs[i] = genrand(seed); \ + out[i] = (lhs[i] + rhs[i]) % 4; \ + } \ + \ + return test_selection_merge(deviceID, context, queue, \ + "select_switch_" #control, lhs, rhs, out); \ + } TEST_SELECT_SWITCH(none) TEST_SELECT_SWITCH(flatten) diff --git a/test_conformance/spirv_new/test_op_spec_constant.cpp b/test_conformance/spirv_new/test_op_spec_constant.cpp index 3b3b4d45db..3bf2e825ed 100644 --- a/test_conformance/spirv_new/test_op_spec_constant.cpp +++ b/test_conformance/spirv_new/test_op_spec_constant.cpp @@ -115,7 +115,7 @@ int test_spec_constant(cl_device_id deviceID, cl_context context, #define TEST_SPEC_CONSTANT(NAME, type, init_buffer, spec_constant_value) \ - TEST_SPIRV_FUNC_VERSION(op_spec_constant_##NAME##_simple, Version(2, 2)) \ + REGISTER_TEST_VERSION(op_spec_constant_##NAME##_simple, Version(2, 2)) \ { \ type init_value = init_buffer; \ type final_value = init_value + spec_constant_value; \ @@ -137,7 +137,7 @@ TEST_SPEC_CONSTANT(double, cl_double, 14534.53453, 1.53453) // documenation: 'If a specialization constant is a boolean // constant, spec_value should be a pointer to a cl_uchar value' -TEST_SPIRV_FUNC_VERSION(op_spec_constant_true_simple, Version(2, 2)) +REGISTER_TEST_VERSION(op_spec_constant_true_simple, Version(2, 2)) { // 1-st ndrange init_value is expected value (no change) // 2-nd ndrange sets spec const to 'false' so value = value + 1 @@ -149,7 +149,7 @@ TEST_SPIRV_FUNC_VERSION(op_spec_constant_true_simple, Version(2, 2)) init_value, 0, final_value); } -TEST_SPIRV_FUNC_VERSION(op_spec_constant_false_simple, Version(2, 2)) +REGISTER_TEST_VERSION(op_spec_constant_false_simple, Version(2, 2)) { // 1-st ndrange init_value is expected value (no change) // 2-nd ndrange sets spec const to 'true' so value = value + 1 diff --git a/test_conformance/spirv_new/test_op_undef.cpp b/test_conformance/spirv_new/test_op_undef.cpp index 43610f82b4..36cb66cc1d 100644 --- a/test_conformance/spirv_new/test_op_undef.cpp +++ b/test_conformance/spirv_new/test_op_undef.cpp @@ -57,12 +57,12 @@ int test_undef(cl_device_id deviceID, cl_context context, return 0; } -#define TEST_UNDEF(NAME, TYPE) \ - TEST_SPIRV_FUNC(op_undef_##NAME##_simple) \ - { \ - return test_undef(deviceID, context, queue, \ - "undef_" #NAME "_simple"); \ - } \ +#define TEST_UNDEF(NAME, TYPE) \ + REGISTER_TEST(op_undef_##NAME##_simple) \ + { \ + return test_undef(deviceID, context, queue, \ + "undef_" #NAME "_simple"); \ + } // Boolean tests TEST_UNDEF(true , cl_int ) @@ -92,26 +92,26 @@ TEST_UNDEF(int4 , cl_int4) TEST_UNDEF(int3 , cl_int3) -TEST_SPIRV_FUNC(op_undef_struct_int_float_simple) +REGISTER_TEST(op_undef_struct_int_float_simple) { typedef AbstractStruct2 CustomType; return test_undef(deviceID, context, queue, "undef_struct_int_float_simple"); } -TEST_SPIRV_FUNC(op_undef_struct_int_char_simple) +REGISTER_TEST(op_undef_struct_int_char_simple) { typedef AbstractStruct2 CustomType; return test_undef(deviceID, context, queue, "undef_struct_int_char_simple"); } -TEST_SPIRV_FUNC(op_undef_struct_struct_simple) +REGISTER_TEST(op_undef_struct_struct_simple) { typedef AbstractStruct2 CustomType1; typedef AbstractStruct2 CustomType2; return test_undef(deviceID, context, queue, "undef_struct_struct_simple"); } -TEST_SPIRV_FUNC(op_undef_half_simple) +REGISTER_TEST(op_undef_half_simple) { PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); return test_undef(deviceID, context, queue, diff --git a/test_conformance/spirv_new/test_op_vector_extract.cpp b/test_conformance/spirv_new/test_op_vector_extract.cpp index 62a155b407..9188a0a32d 100644 --- a/test_conformance/spirv_new/test_op_vector_extract.cpp +++ b/test_conformance/spirv_new/test_op_vector_extract.cpp @@ -91,7 +91,7 @@ int test_extract(cl_device_id deviceID, cl_context context, } #define TEST_VECTOR_EXTRACT(TYPE, N) \ - TEST_SPIRV_FUNC(op_vector_##TYPE##N##_extract) \ + REGISTER_TEST(op_vector_##TYPE##N##_extract) \ { \ if (sizeof(cl_##TYPE) == 2) \ { \ diff --git a/test_conformance/spirv_new/test_op_vector_insert.cpp b/test_conformance/spirv_new/test_op_vector_insert.cpp index ed47238557..32e883e3f5 100644 --- a/test_conformance/spirv_new/test_op_vector_insert.cpp +++ b/test_conformance/spirv_new/test_op_vector_insert.cpp @@ -109,7 +109,7 @@ int test_insert(cl_device_id deviceID, cl_context context, } #define TEST_VECTOR_INSERT(TYPE, N) \ - TEST_SPIRV_FUNC(op_vector_##TYPE##N##_insert) \ + REGISTER_TEST(op_vector_##TYPE##N##_insert) \ { \ if (sizeof(cl_##TYPE) == 2) \ { \ 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 da79d3bea3..de92438d94 100644 --- a/test_conformance/spirv_new/test_op_vector_times_scalar.cpp +++ b/test_conformance/spirv_new/test_op_vector_times_scalar.cpp @@ -161,29 +161,29 @@ int test_vector_times_scalar(cl_device_id deviceID, return 0; } -#define TEST_VECTOR_TIMES_SCALAR(TYPE, N) \ - TEST_SPIRV_FUNC(op_vector_times_scalar_##TYPE) \ - { \ - if (sizeof(cl_##TYPE) == 2) { \ - PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ - } \ - typedef cl_##TYPE##N Tv; \ - typedef cl_##TYPE Ts; \ - const int num = 1 << 20; \ - std::vector lhs(num); \ - std::vector rhs(num); \ - \ - RandomSeed seed(gRandomSeed); \ - \ - for (int i = 0; i < num; i++) { \ - lhs[i] = genrandReal(seed); \ - rhs[i] = genrandReal(seed); \ - } \ - \ - return test_vector_times_scalar(deviceID, \ - context, queue, \ - #TYPE, \ - lhs, rhs); \ +#define TEST_VECTOR_TIMES_SCALAR(TYPE, N) \ + REGISTER_TEST(op_vector_times_scalar_##TYPE) \ + { \ + if (sizeof(cl_##TYPE) == 2) \ + { \ + PASSIVE_REQUIRE_FP16_SUPPORT(deviceID); \ + } \ + typedef cl_##TYPE##N Tv; \ + typedef cl_##TYPE Ts; \ + const int num = 1 << 20; \ + std::vector lhs(num); \ + std::vector rhs(num); \ + \ + RandomSeed seed(gRandomSeed); \ + \ + for (int i = 0; i < num; i++) \ + { \ + lhs[i] = genrandReal(seed); \ + rhs[i] = genrandReal(seed); \ + } \ + \ + return test_vector_times_scalar(deviceID, context, queue, \ + #TYPE, lhs, rhs); \ } diff --git a/test_conformance/spirv_new/test_spirv_14.cpp b/test_conformance/spirv_new/test_spirv_14.cpp new file mode 100644 index 0000000000..360250597c --- /dev/null +++ b/test_conformance/spirv_new/test_spirv_14.cpp @@ -0,0 +1,561 @@ +// +// Copyright (c) 2024 The Khronos Group Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "testBase.h" +#include "spirvInfo.hpp" +#include "types.hpp" + +#include +#include + +static int test_image_operand_helper(cl_device_id deviceID, cl_context context, + cl_command_queue queue, bool signExtend) +{ + const char* filename = signExtend ? "spv1.4/image_operand_signextend" + : "spv1.4/image_operand_zeroextend"; + cl_image_format image_format = { + CL_RGBA, + signExtend ? CL_SIGNED_INT8 : CL_UNSIGNED_INT8, + }; + + cl_int error = CL_SUCCESS; + + std::vector imgData({ 0x1, 0x80, 0xFF, 0x0 }); + std::vector expected; + for (auto v : imgData) + { + if (signExtend) + { + expected.push_back((cl_int)(cl_char)v); + } + else + { + expected.push_back(v); + } + } + + clProgramWrapper prog; + error = get_program_with_il(prog, deviceID, context, filename); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "read_image_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + std::vector h_dst({ 0, 0, 0, 0 }); + clMemWrapper dst = + clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, + h_dst.size() * sizeof(cl_uint), h_dst.data(), &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + clMemWrapper src = + clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, + &image_format, 1, 1, 0, imgData.data(), &error); + SPIRV_CHECK_ERROR(error, "Failed to create src image"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + error |= clSetKernelArg(kernel, 1, sizeof(src), &src); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, + h_dst.size() * sizeof(cl_uint), h_dst.data(), 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + if (h_dst != expected) + { + log_error("Mismatch! Got: %u, %u, %u, %u, Wanted: %u, %u, %u, %u\n", + h_dst[0], h_dst[1], h_dst[2], h_dst[3], expected[0], + expected[1], expected[2], expected[3]); + return TEST_FAIL; + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv14_image_operand_signextend) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + return test_image_operand_helper(deviceID, context, queue, true); +} + +REGISTER_TEST(spirv14_image_operand_zeroextend) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + return test_image_operand_helper(deviceID, context, queue, false); +} + +static int test_loop_control_helper(cl_device_id deviceID, cl_context context, + cl_command_queue queue, + const char* filename) +{ + const int count = 10; + const int value = 5; + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + std::string full_filename = "spv1.4/" + std::string(filename); + error = get_program_with_il(prog, deviceID, context, full_filename.c_str()); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "loop_control_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + int h_dst = 0; + clMemWrapper dst = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, + sizeof(h_dst), &h_dst, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + error |= clSetKernelArg(kernel, 1, sizeof(count), &count); + error |= clSetKernelArg(kernel, 2, sizeof(value), &value); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, sizeof(h_dst), &h_dst, + 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + if (h_dst != count * value) + { + log_error("Mismatch! Got: %i, Wanted: %i\n", h_dst, count * value); + return TEST_FAIL; + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv14_loop_control_miniterations) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + return test_loop_control_helper(deviceID, context, queue, + "loop_control_miniterations"); +} + +REGISTER_TEST(spirv14_loop_control_maxiterations) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + return test_loop_control_helper(deviceID, context, queue, + "loop_control_maxiterations"); +} + +REGISTER_TEST(spirv14_loop_control_iterationmultiple) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + return test_loop_control_helper(deviceID, context, queue, + "loop_control_iterationmultiple"); +} + +REGISTER_TEST(spirv14_loop_control_peelcount) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + return test_loop_control_helper(deviceID, context, queue, + "loop_control_peelcount"); +} + +REGISTER_TEST(spirv14_loop_control_partialcount) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + return test_loop_control_helper(deviceID, context, queue, + "loop_control_partialcount"); +} + +REGISTER_TEST(spirv14_ptrops) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + error = get_program_with_il(prog, deviceID, context, "spv1.4/ptrops"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "ptrops_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + std::vector results(3); + + clMemWrapper dst = + clCreateBuffer(context, CL_MEM_READ_WRITE, + results.size() * sizeof(cl_int), NULL, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + clMemWrapper tst = clCreateBuffer(context, CL_MEM_READ_WRITE, + sizeof(cl_int), NULL, &error); + SPIRV_CHECK_ERROR(error, "Failed to create tst buffer"); + + // Test with different pointers: + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + error |= clSetKernelArg(kernel, 1, sizeof(tst), &tst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, + results.size() * sizeof(cl_int), results.data(), + 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + if (results[0] != (dst == tst) || results[1] != (dst != tst) + || results[2] == 0 /* dst - tst */) + { + log_error( + "Results mismatch with different pointers! Got: %i, %i, %i\n", + results[0], results[1], results[2]); + return TEST_FAIL; + } + + // Test with equal pointers: + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + error |= clSetKernelArg(kernel, 1, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, + results.size() * sizeof(cl_int), results.data(), + 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + if (results[0] != (dst == dst) || results[1] != (dst != dst) + || results[2] != 0 /* dst - dst */) + { + log_error("Results mismatch with equal pointers! Got: %i, %i, %i\n", + results[0], results[1], results[2]); + return TEST_FAIL; + } + + return TEST_PASS; +} + +static int test_usersemantic_decoration(cl_device_id deviceID, + cl_context context, + cl_command_queue queue, + bool test_memberdecoratestring) +{ + cl_int error = CL_SUCCESS; + + const char* filename = test_memberdecoratestring + ? "spv1.4/usersemantic_memberdecoratestring" + : "spv1.4/usersemantic_decoratestring"; + + clProgramWrapper prog; + error = get_program_with_il(prog, deviceID, context, filename); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "usersemantic_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + int h_dst = -1; + clMemWrapper dst = clCreateBuffer(context, CL_MEM_COPY_HOST_PTR, + sizeof(h_dst), &h_dst, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, sizeof(h_dst), &h_dst, + 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + if (h_dst != 0) + { + log_error("Mismatch! Got: %i, Wanted: %i\n", h_dst, 0); + return TEST_FAIL; + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv14_usersemantic_decoratestring) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + return test_usersemantic_decoration(deviceID, context, queue, false); +} + +REGISTER_TEST(spirv14_usersemantic_memberdecoratestring) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + return test_usersemantic_decoration(deviceID, context, queue, true); +} + +REGISTER_TEST(spirv14_nonwriteable_decoration) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + error = get_program_with_il( + prog, deviceID, context, + "spv1.4/nonwriteable_decoration_function_storage_class"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "nonwriteable_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + int result = 0; + clMemWrapper dst = clCreateBuffer(context, CL_MEM_READ_WRITE, + sizeof(result), nullptr, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &global, nullptr, + 0, nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, sizeof(result), &result, + 0, nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + int expected = 42; + if (result != expected) + { + log_error("Result mismatch! Got %d, Wanted %d\n", result, expected); + return TEST_FAIL; + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv14_copymemory_memory_operands) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + error = get_program_with_il(prog, deviceID, context, + "spv1.4/copymemory_memory_operands"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "copymemory_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + std::vector results(6); + clMemWrapper dst = + clCreateBuffer(context, CL_MEM_READ_WRITE, + results.size() * sizeof(results[0]), nullptr, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &global, nullptr, + 0, nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, + results.size() * sizeof(results[0]), + results.data(), 0, nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + const int expected = 42; + for (auto result : results) + { + if (result != expected) + { + log_error("Result mismatch! Got %d, Wanted %d\n", result, + expected); + return TEST_FAIL; + } + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv14_select_composite) +{ + constexpr size_t global_size = 16; + + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + + clProgramWrapper prog; + error = + get_program_with_il(prog, deviceID, context, "spv1.4/select_struct"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "select_struct_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + struct TestStruct + { + cl_int i; + cl_float f; + }; + + std::vector results(global_size); + clMemWrapper dst = + clCreateBuffer(context, CL_MEM_READ_WRITE, + results.size() * sizeof(results[0]), nullptr, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + error = clEnqueueNDRangeKernel(queue, kernel, 1, nullptr, &global_size, + nullptr, 0, nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, + results.size() * sizeof(results[0]), + results.data(), 0, nullptr, nullptr); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + const TestStruct struct_a{ 1024, 3.1415f }; + const TestStruct struct_b{ 2048, 2.7128f }; + + for (size_t i = 0; i < global_size; i++) + { + const TestStruct& expected = (i & 1) ? struct_a : struct_b; + if (results[i].i != expected.i || results[i].f != expected.f) + { + log_error("Result mismatch at index %zu! Got {%d, %f}, Wanted " + "{%d, %f}\n", + i, results[i].i, results[i].f, expected.i, expected.f); + return TEST_FAIL; + } + } + + return TEST_PASS; +} + +REGISTER_TEST(spirv14_copylogical) +{ + if (!is_spirv_version_supported(deviceID, "SPIR-V_1.4")) + { + log_info("SPIR-V 1.4 not supported; skipping tests.\n"); + return TEST_SKIPPED_ITSELF; + } + + cl_int error = CL_SUCCESS; + clProgramWrapper prog; + error = get_program_with_il(prog, deviceID, context, + "spv1.4/copylogical_struct"); + SPIRV_CHECK_ERROR(error, "Failed to compile spv program"); + + clKernelWrapper kernel = clCreateKernel(prog, "copylogical_test", &error); + SPIRV_CHECK_ERROR(error, "Failed to create spv kernel"); + + struct TestStruct + { + cl_int i; + cl_float f; + }; + TestStruct results{ 0, 0.0f }; + clMemWrapper dst = clCreateBuffer(context, CL_MEM_READ_WRITE, + sizeof(results), NULL, &error); + SPIRV_CHECK_ERROR(error, "Failed to create dst buffer"); + + error |= clSetKernelArg(kernel, 0, sizeof(dst), &dst); + SPIRV_CHECK_ERROR(error, "Failed to set kernel args"); + + size_t global = 1; + error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global, NULL, 0, + NULL, NULL); + SPIRV_CHECK_ERROR(error, "Failed to enqueue kernel"); + + error = clEnqueueReadBuffer(queue, dst, CL_TRUE, 0, sizeof(results), + &results, 0, NULL, NULL); + SPIRV_CHECK_ERROR(error, "Unable to read destination buffer"); + + if (results.i != 1024 || results.f != 3.1415f) + { + log_error("Results mismatch! Got: { %d, %f }\n", results.i, results.f); + return TEST_FAIL; + } + + return TEST_PASS; +} diff --git a/test_conformance/subgroups/subhelpers.h b/test_conformance/subgroups/subhelpers.h index 8600088e8b..a081bd098c 100644 --- a/test_conformance/subgroups/subhelpers.h +++ b/test_conformance/subgroups/subhelpers.h @@ -1447,7 +1447,7 @@ template class KernelExecutor { }; // Driver for testing a single built in function -template struct test +template struct subgroup_test { static test_status run(cl_device_id device, cl_context context, cl_command_queue queue, int num_elements, @@ -1688,9 +1688,9 @@ struct RunTestForType std::regex_replace(test_params_.get_kernel_source(function_name), std::regex("\\%s"), function_name); std::string kernel_name = "test_" + function_name; - error = - test::run(device_, context_, queue_, num_elements_, - kernel_name.c_str(), source.c_str(), test_params_); + error = subgroup_test::run(device_, context_, queue_, + num_elements_, kernel_name.c_str(), + source.c_str(), test_params_); // If we return TEST_SKIPPED_ITSELF here, then an entire suite may be // reported as having been skipped even if some tests within it diff --git a/test_conformance/subgroups/test_barrier.cpp b/test_conformance/subgroups/test_barrier.cpp index fb93ddb1ac..f97e2a33f7 100644 --- a/test_conformance/subgroups/test_barrier.cpp +++ b/test_conformance/subgroups/test_barrier.cpp @@ -164,9 +164,10 @@ int test_barrier_functions(cl_device_id device, cl_context context, constexpr size_t local_work_size = 200; WorkGroupParams test_params(global_work_size, local_work_size); test_params.use_core_subgroups = useCoreSubgroups; - error = test>::run(device, context, queue, num_elements, - "test_lbar", lbar_source, test_params); - error |= test, global_work_size>::run( + error = subgroup_test>::run(device, context, queue, + num_elements, "test_lbar", + lbar_source, test_params); + error |= subgroup_test, global_work_size>::run( device, context, queue, num_elements, "test_gbar", gbar_source, test_params); diff --git a/test_conformance/subgroups/test_ifp.cpp b/test_conformance/subgroups/test_ifp.cpp index f2bd5b9257..61c65673df 100644 --- a/test_conformance/subgroups/test_ifp.cpp +++ b/test_conformance/subgroups/test_ifp.cpp @@ -297,8 +297,9 @@ int test_ifp(cl_device_id device, cl_context context, cl_command_queue queue, WorkGroupParams test_params(global_work_size, local_work_size); test_params.use_core_subgroups = useCoreSubgroups; test_params.dynsc = NUM_LOC + 1; - error = test::run(device, context, queue, num_elements, - "test_ifp", ifp_source, test_params); + error = + subgroup_test::run(device, context, queue, num_elements, + "test_ifp", ifp_source, test_params); return error; } diff --git a/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp b/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp index 4e93e558f6..fddcce4ef8 100644 --- a/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp +++ b/test_conformance/subgroups/test_subgroup_clustered_reduce.cpp @@ -103,7 +103,8 @@ template struct RED_CLU int ii = j * ns; int n = ii + ns > nw ? nw - ii : ns; std::vector clusters_results; - int clusters_counter = ns / test_params.cluster_size; + int clusters_counter = (ns + test_params.cluster_size - 1) + / test_params.cluster_size; clusters_results.resize(clusters_counter); // Compute target diff --git a/test_conformance/thread_dimensions/test_thread_dimensions.cpp b/test_conformance/thread_dimensions/test_thread_dimensions.cpp index 8eec15c103..393f1e5e76 100644 --- a/test_conformance/thread_dimensions/test_thread_dimensions.cpp +++ b/test_conformance/thread_dimensions/test_thread_dimensions.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include "procs.h" #define ITERATIONS 4 @@ -245,10 +247,8 @@ static const char *thread_dimension_kernel_code_not_atomic_not_long = "\n" "}\n"; -char dim_str[128]; -char *print_dimensions(size_t x, size_t y, size_t z, cl_uint dim) +char *print_dimensions(char *dim_str, size_t x, size_t y, size_t z, cl_uint dim) { - // Not thread safe... if (dim == 1) { snprintf(dim_str, 128, "[%d]", (int)x); @@ -268,10 +268,9 @@ char *print_dimensions(size_t x, size_t y, size_t z, cl_uint 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(char *dim_str2, size_t x, size_t y, size_t z, + cl_uint dim) { - // Not thread safe... if (dim == 1) { snprintf(dim_str2, 128, "[%d]", (int)x); @@ -315,6 +314,9 @@ int run_test(cl_context context, cl_command_queue queue, cl_kernel kernel, global_size[2] = final_z_size; local_size[2] = local_z_size; + char dim_str[128]; + char dim_str2[128]; + 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 @@ -386,9 +388,11 @@ int run_test(cl_context context, cl_command_queue queue, cl_kernel kernel, 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), + "%d dim, start address %" PRIu64 + ", end address %" PRIu64 ".\n", + print_dimensions(dim_str, global_size[0], + global_size[1], global_size[2], + dimensions), dimensions, start_valid_memory_address, end_valid_memory_address); } @@ -398,14 +402,16 @@ int run_test(cl_context context, cl_command_queue queue, cl_kernel kernel, 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); + log_info( + "\t\t\tExecuting kernel with global %s, local %s, %d " + "dim, start address %" PRIu64 ", end address %" PRIu64 + ".\n", + print_dimensions(dim_str, global_size[0], global_size[1], + global_size[2], dimensions), + print_dimensions2(dim_str2, 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) { @@ -482,18 +488,15 @@ int run_test(cl_context context, cl_command_queue queue, cl_kernel kernel, } -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; -} +#define set_min(x, y, 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, @@ -512,6 +515,12 @@ int test_thread_dimensions(cl_device_id device, cl_context context, int use_atomics = 1; MTdata d; + char dim_str[128]; + char dim_str2[128]; + + 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; + if (getenv("CL_WIMPY_MODE") && !quick_test) { log_info("CL_WIMPY_MODE enabled, skipping test\n"); @@ -678,9 +687,6 @@ int test_thread_dimensions(cl_device_id device, cl_context context, cl_uint local_tests_per_size = 1 + dimensions + 2; 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; - if (dimensions > 3) { log_error("Invalid dimensions: %d\n", dimensions); @@ -700,7 +706,8 @@ int test_thread_dimensions(cl_device_id device, cl_context context, } log_info("Testing with dimensions up to %s.\n", - print_dimensions(max_x_size, max_y_size, max_z_size, dimensions)); + print_dimensions(dim_str, max_x_size, max_y_size, max_z_size, + dimensions)); if (bufferSize) { log_info("Testing with buffer size %d.\n", bufferSize); @@ -723,7 +730,8 @@ int test_thread_dimensions(cl_device_id device, cl_context context, { log_info("Base test size %s:\n", - print_dimensions(x_size, y_size, z_size, dimensions)); + print_dimensions(dim_str, x_size, y_size, z_size, + dimensions)); cl_uint sub_test; cl_uint final_x_size, final_y_size, final_z_size; @@ -736,10 +744,10 @@ int test_thread_dimensions(cl_device_id device, cl_context context, 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)); + log_info("\tTesting with base dimensions %s.\n", + print_dimensions( + dim_str, final_x_size, final_y_size, + final_z_size, dimensions)); } else if (quick_test) { @@ -749,12 +757,13 @@ int test_thread_dimensions(cl_device_id device, cl_context context, final_x_size--; final_y_size--; final_z_size--; - set_min(&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)); + print_dimensions(dim_str, final_x_size, + final_y_size, final_z_size, + dimensions)); } else if (sub_test <= dimensions * 2) { @@ -781,12 +790,13 @@ int test_thread_dimensions(cl_device_id device, cl_context context, dim_to_change); return -1; } - set_min(&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 one base dimension +/- 1 %s.\n", - print_dimensions(final_x_size, final_y_size, - final_z_size, dimensions)); + print_dimensions(dim_str, final_x_size, + final_y_size, final_z_size, + dimensions)); } else if (sub_test == (dimensions * 2 + 1)) { @@ -794,12 +804,13 @@ int test_thread_dimensions(cl_device_id device, cl_context context, final_x_size--; final_y_size--; final_z_size--; - set_min(&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)); + print_dimensions(dim_str, final_x_size, + final_y_size, final_z_size, + dimensions)); } else if (sub_test == (dimensions * 2 + 2)) { @@ -807,12 +818,13 @@ int test_thread_dimensions(cl_device_id device, cl_context context, final_x_size++; final_y_size++; final_z_size++; - set_min(&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)); + print_dimensions(dim_str, final_x_size, + final_y_size, final_z_size, + dimensions)); } else { @@ -828,12 +840,12 @@ int test_thread_dimensions(cl_device_id device, cl_context context, (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); + 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)); + log_info("\tTesting with random dimensions %s.\n", + print_dimensions( + dim_str, final_x_size, final_y_size, + final_z_size, dimensions)); } if (limit_size @@ -842,8 +854,9 @@ int test_thread_dimensions(cl_device_id device, cl_context context, { 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), + print_dimensions(dim_str, final_x_size, + final_y_size, final_z_size, + dimensions), MAX_TOTAL_GLOBAL_THREADS_FOR_TEST); continue; } @@ -993,26 +1006,27 @@ int test_thread_dimensions(cl_device_id device, cl_context context, } if (DEBUG) - log_info( - "\t\tTesting local size %s.\n", - print_dimensions(local_x_size, local_y_size, - local_z_size, dimensions)); + log_info("\t\tTesting local size %s.\n", + print_dimensions( + dim_str, 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)); + log_info("\tTesting global %s local [NULL]...\n", + print_dimensions( + dim_str, 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)); + log_info("\tTesting global %s local %s...\n", + print_dimensions(dim_str, final_x_size, + final_y_size, + final_z_size, dimensions), + print_dimensions2( + dim_str2, local_x_size, local_y_size, + local_z_size, dimensions)); } // Avoid running with very small local sizes on very @@ -1052,12 +1066,13 @@ int test_thread_dimensions(cl_device_id device, cl_context context, // 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)); + log_error("Test global %s local %s failed.\n", + print_dimensions( + dim_str, final_x_size, final_y_size, + final_z_size, dimensions), + print_dimensions2( + dim_str2, local_x_size, local_y_size, + local_z_size, dimensions)); errors++; clReleaseMemObject(array); clReleaseKernel(kernel); diff --git a/test_conformance/vectors/structs.cpp b/test_conformance/vectors/structs.cpp index fd93e23626..0098e41411 100644 --- a/test_conformance/vectors/structs.cpp +++ b/test_conformance/vectors/structs.cpp @@ -369,7 +369,7 @@ int checkCorrectnessStep(bufferStruct *pBufferStruct, clState *pClState, { if (targetArr[i] != targetSize) { - vlog_error("Error %ld (of %ld). Expected %d, got %d\n", i, + vlog_error("Error %zu (of %zu). Expected %d, got %d\n", i, pClState->m_numThreads, targetSize, targetArr[i]); return -1; } diff --git a/test_conformance/vectors/test_step.cpp b/test_conformance/vectors/test_step.cpp index c4f673f9c7..4549cf1ead 100644 --- a/test_conformance/vectors/test_step.cpp +++ b/test_conformance/vectors/test_step.cpp @@ -128,7 +128,7 @@ int test_step_internal(cl_device_id deviceID, cl_context context, err = runKernel(pClState, 1024); if (err != 0) { - vlog_error("%s: runKernel fail (%ld threads) %s%s\n", testName, + vlog_error("%s: runKernel fail (%zu threads) %s%s\n", testName, pClState->m_numThreads, g_arrTypeNames[typeIdx], g_arrVecSizeNames[vecSizeIdx]); destroyBufferStruct(pBuffers, pClState); diff --git a/test_conformance/vectors/test_vec_align.cpp b/test_conformance/vectors/test_vec_align.cpp index 2f392f5499..6c0d48b5a1 100644 --- a/test_conformance/vectors/test_vec_align.cpp +++ b/test_conformance/vectors/test_vec_align.cpp @@ -183,7 +183,7 @@ int test_vec_internal(cl_device_id deviceID, cl_context context, / (g_arrVecSizes[vecSizeIdx] * g_arrTypeSizes[typeIdx])); if (err != 0) { - vlog_error("%s: runKernel fail (%ld threads) %s%s\n", testName, + vlog_error("%s: runKernel fail (%zu threads) %s%s\n", testName, pClState->m_numThreads, g_arrTypeNames[typeIdx], g_arrVecSizeNames[vecSizeIdx]); destroyBufferStruct(pBuffers, pClState); diff --git a/test_conformance/vulkan/CMakeLists.txt b/test_conformance/vulkan/CMakeLists.txt index c970a77e38..61a6014923 100644 --- a/test_conformance/vulkan/CMakeLists.txt +++ b/test_conformance/vulkan/CMakeLists.txt @@ -25,20 +25,8 @@ set (${MODULE_NAME}_SOURCES test_vulkan_api_consistency_for_1dimages.cpp test_vulkan_platform_device_info.cpp vulkan_interop_common.cpp - ../../test_common/harness/genericThread.cpp - ../../test_common/harness/errorHelpers.cpp - ../../test_common/harness/testHarness.cpp - ../../test_common/harness/kernelHelpers.cpp - ../../test_common/harness/mt19937.cpp - ../../test_common/harness/msvc9.c - ../../test_common/harness/parseParameters.cpp - ../../test_common/harness/deviceInfo.cpp - ../../test_common/harness/crc32.cpp ) -set_source_files_properties( - ${${MODULE_NAME}_SOURCES} - PROPERTIES LANGUAGE CXX) include_directories("../common/vulkan_wrapper") add_subdirectory(shaders) diff --git a/test_conformance/vulkan/main.cpp b/test_conformance/vulkan/main.cpp index 4f560f96b2..7b1cf01c70 100644 --- a/test_conformance/vulkan/main.cpp +++ b/test_conformance/vulkan/main.cpp @@ -205,6 +205,18 @@ static void printUsage(const char *execName) log_info("\t--non_dedicated - Choose dedicated Vs. non_dedicated \n"); } +bool isDeviceSelection(const char *arg) +{ + + return strcmp(arg, "gpu") == 0 || strcmp(arg, "CL_DEVICE_TYPE_GPU") == 0 + || strcmp(arg, "cpu") == 0 || strcmp(arg, "CL_DEVICE_TYPE_CPU") == 0 + || strcmp(arg, "accelerator") == 0 + || strcmp(arg, "CL_DEVICE_TYPE_ACCELERATOR") == 0 + || strcmp(arg, "custom") == 0 + || strcmp(arg, "CL_DEVICE_TYPE_CUSTOM") == 0 + || strcmp(arg, "CL_DEVICE_TYPE_DEFAULT") == 0; +} + size_t parseParams(int argc, const char *argv[], const char **argList) { size_t argCount = 1; @@ -236,6 +248,16 @@ size_t parseParams(int argc, const char *argv[], const char **argList) break; } } + else if (isDeviceSelection(argv[i])) + { + if (strcmp(argv[i], "gpu") != 0 + && strcmp(argv[i], "CL_DEVICE_TYPE_GPU") != 0 + && strcmp(argv[i], "CL_DEVICE_TYPE_DEFAULT") != 0) + { + log_info("Vulkan tests can only run on a GPU device.\n"); + return 0; + } + } else { argList[argCount] = argv[i]; diff --git a/test_conformance/vulkan/shaders/CMakeLists.txt b/test_conformance/vulkan/shaders/CMakeLists.txt index 881b3f20d6..258075504b 100644 --- a/test_conformance/vulkan/shaders/CMakeLists.txt +++ b/test_conformance/vulkan/shaders/CMakeLists.txt @@ -18,6 +18,10 @@ else() file(READ ${IMAGE2D_SHADER_IN_FILE} IMAGE2D_SHADER_UNFORMAT_CONTENT) file(STRINGS ${IMAGE2D_FORMATS_LIST_IN_FILE} IMAGE2D_FORMATS_LIST) + if(NOT DEFINED VULKAN_TEST_RESOURCES) + set(VULKAN_TEST_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}) + endif() + foreach(IMAGE2D_FORMAT ${IMAGE2D_FORMATS_LIST}) list(GET IMAGE2D_FORMAT 1 GLSL_FORMAT) list(GET IMAGE2D_FORMAT 2 GLSL_TYPE_PREFIX) @@ -25,7 +29,7 @@ else() string(REPLACE "GLSL_TYPE_PREFIX" "${GLSL_TYPE_PREFIX}" IMAGE2D_SHADER_CONTENT "${IMAGE2D_SHADER_CONTENT}") file(WRITE ${IMAGE2D_SHADER_TMP_OUT_FILE} "${IMAGE2D_SHADER_CONTENT}") execute_process( - COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o image2D_${GLSL_FORMAT}.spv ${IMAGE2D_SHADER_TMP_OUT_FILE} + COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv ${IMAGE2D_SHADER_TMP_OUT_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE commandStatus OUTPUT_QUIET) @@ -34,7 +38,7 @@ else() endif() endforeach(IMAGE2D_FORMAT) execute_process( - COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${BUFFER_SHADER_IN_FILE}.spv ${BUFFER_SHADER_IN_FILE}.comp + COMMAND ${Vulkan_glslang_binary} --target-env vulkan1.0 -o ${VULKAN_TEST_RESOURCES}/${BUFFER_SHADER_IN_FILE}.spv ${BUFFER_SHADER_IN_FILE}.comp WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE commandStatus OUTPUT_QUIET) diff --git a/test_conformance/vulkan/test_vulkan_api_consistency.cpp b/test_conformance/vulkan/test_vulkan_api_consistency.cpp index fe06052e10..09e02981a6 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency.cpp @@ -517,9 +517,10 @@ int test_consistency_external_semaphore(cl_device_id deviceID, // Pass invalid object to release call errNum = clReleaseSemaphoreKHRptr(NULL); - test_failure_error(errNum, CL_INVALID_VALUE, - "clReleaseSemaphoreKHRptr fails with " - "CL_INVALID_VALUE when NULL semaphore object is passed"); + test_failure_error( + errNum, CL_INVALID_SEMAPHORE_KHR, + "clReleaseSemaphoreKHRptr fails with " + "CL_INVALID_SEMAPHORE_KHR when NULL semaphore object is passed"); // Release both semaphore objects errNum = clReleaseSemaphoreKHRptr(clVk2Clsemaphore); diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp index 2df210081c..aefdb41457 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_1dimages.cpp @@ -158,16 +158,6 @@ int test_consistency_external_for_1dimage(cl_device_id deviceID, test_error(errNum, "Unable to create Image with Properties"); image.reset(); - // Passing properties, image_desc and image_format all as NULL - image = clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, NULL, - NULL, NULL, &errNum); - test_failure_error( - errNum, CL_INVALID_IMAGE_DESCRIPTOR, - "Image creation must fail with CL_INVALID_IMAGE_DESCRIPTOR " - "when all are passed as NULL"); - - image.reset(); - // Passing NULL properties and a valid image_format and image_desc image = clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, diff --git a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp index f8a7861cec..a71fb9453d 100644 --- a/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp +++ b/test_conformance/vulkan/test_vulkan_api_consistency_for_3dimages.cpp @@ -162,16 +162,6 @@ int test_consistency_external_for_3dimage(cl_device_id deviceID, test_error(errNum, "Unable to create Image with Properties"); image.reset(); - // Passing properties, image_desc and image_format all as NULL - image = clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, NULL, - NULL, NULL, &errNum); - test_failure_error( - errNum, CL_INVALID_IMAGE_DESCRIPTOR, - "Image creation must fail with CL_INVALID_IMAGE_DESCRIPTOR " - "when all are passed as NULL"); - - image.reset(); - // Passing NULL properties and a valid image_format and image_desc image = clCreateImageWithProperties(context, NULL, CL_MEM_READ_WRITE, diff --git a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp index de350f7022..56fd485c77 100644 --- a/test_conformance/vulkan/test_vulkan_interop_buffer.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_buffer.cpp @@ -23,6 +23,7 @@ #include #include #include "harness/errorHelpers.h" +#include "harness/os_helpers.h" #include "deviceInfo.h" #define MAX_BUFFERS 5 @@ -115,7 +116,7 @@ int run_test_with_two_queue( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList; @@ -447,7 +448,8 @@ int run_test_with_one_queue( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); + VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList; vkDescriptorSetLayoutBindingList.addBinding( @@ -749,7 +751,7 @@ int run_test_with_multi_import_same_ctx( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList; @@ -1097,11 +1099,14 @@ int run_test_with_multi_import_diff_ctx( VulkanQueue &vkQueue = vkDevice.getQueue(); - std::vector vkBufferShader = readFile("buffer.spv"); + std::vector vkBufferShader = readFile("buffer.spv", exe_dir()); VulkanShaderModule vkBufferShaderModule(vkDevice, vkBufferShader); - VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList( - MAX_BUFFERS + 1, VULKAN_DESCRIPTOR_TYPE_STORAGE_BUFFER); + VulkanDescriptorSetLayoutBindingList vkDescriptorSetLayoutBindingList; + vkDescriptorSetLayoutBindingList.addBinding( + 0, VULKAN_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1); + vkDescriptorSetLayoutBindingList.addBinding( + 1, VULKAN_DESCRIPTOR_TYPE_STORAGE_BUFFER, MAX_BUFFERS); VulkanDescriptorSetLayout vkDescriptorSetLayout( vkDevice, vkDescriptorSetLayoutBindingList); VulkanPipelineLayout vkPipelineLayout(vkDevice, vkDescriptorSetLayout); @@ -1216,9 +1221,9 @@ int run_test_with_multi_import_diff_ctx( buffers2[bIdx][cl_bIdx] = externalMemory2[bIdx][cl_bIdx] ->getExternalMemoryBuffer(); } - vkDescriptorSet.update((uint32_t)bIdx + 1, vkBufferList[bIdx]); } + vkDescriptorSet.updateArray(1, numBuffers, vkBufferList); vkCommandBuffer.begin(); vkCommandBuffer.bindPipeline(vkComputePipeline); vkCommandBuffer.bindDescriptorSets( @@ -1380,7 +1385,7 @@ int run_test_with_multi_import_diff_ctx( "Failed to set kernel arg"); err = clEnqueueAcquireExternalMemObjectsKHRptr( - cmd_queue1, 1, &buffers2[i][launchIter], 0, + cmd_queue2, 1, &buffers2[i][launchIter], 0, nullptr, nullptr); test_error_and_cleanup(err, CLEANUP, "Failed to acquire buffers"); @@ -1400,7 +1405,7 @@ int run_test_with_multi_import_diff_ctx( for (int i = 0; i < numBuffers; i++) { err = clEnqueueReleaseExternalMemObjectsKHRptr( - cmd_queue1, 1, &buffers2[i][launchIter], 0, + cmd_queue2, 1, &buffers2[i][launchIter], 0, nullptr, nullptr); test_error_and_cleanup(err, CLEANUP, "Failed to release buffers"); diff --git a/test_conformance/vulkan/test_vulkan_interop_image.cpp b/test_conformance/vulkan/test_vulkan_interop_image.cpp index 4c5d44a024..a3c8de993c 100644 --- a/test_conformance/vulkan/test_vulkan_interop_image.cpp +++ b/test_conformance/vulkan/test_vulkan_interop_image.cpp @@ -17,6 +17,7 @@ #include #include #include "harness/errorHelpers.h" +#include "harness/os_helpers.h" #include #include "deviceInfo.h" @@ -272,8 +273,8 @@ int run_test_with_two_queue( std::string fileName = "image2D_" + std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv"; - log_info("Load %s file", fileName.c_str()); - vkImage2DShader = readFile(fileName); + log_info("Load file: %s\n", fileName.c_str()); + vkImage2DShader = readFile(fileName, exe_dir()); VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader); VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout, @@ -884,8 +885,8 @@ int run_test_with_one_queue( std::string fileName = "image2D_" + std::string(getVulkanFormatGLSLFormat(vkFormat)) + ".spv"; - log_info("Load %s file", fileName.c_str()); - vkImage2DShader = readFile(fileName); + log_info("Load file: %s\n", fileName.c_str()); + vkImage2DShader = readFile(fileName, exe_dir()); VulkanShaderModule vkImage2DShaderModule(vkDevice, vkImage2DShader); VulkanComputePipeline vkComputePipeline(vkDevice, vkPipelineLayout, @@ -1474,7 +1475,7 @@ int test_image_common(cl_device_id device_, cl_context context_, err = setMaxImageDimensions(deviceId, max_width, max_height); test_error_and_cleanup(err, CLEANUP, "error setting max image dimensions"); - log_info("Set max_width to %lu and max_height to %lu\n", max_width, + log_info("Set max_width to %zu and max_height to %zu\n", max_width, max_height); context = clCreateContextFromType(contextProperties, CL_DEVICE_TYPE_GPU, NULL, NULL, &err); diff --git a/test_conformance/vulkan/test_vulkan_platform_device_info.cpp b/test_conformance/vulkan/test_vulkan_platform_device_info.cpp index 12f373b5c5..1c25c0f58a 100644 --- a/test_conformance/vulkan/test_vulkan_platform_device_info.cpp +++ b/test_conformance/vulkan/test_vulkan_platform_device_info.cpp @@ -16,9 +16,11 @@ #include #include +#include "harness/deviceInfo.h" #include "harness/testHarness.h" #include #include +#include typedef struct { @@ -51,62 +53,81 @@ _info device_info_table[] = { int test_platform_info(cl_device_id deviceID, cl_context _context, cl_command_queue _queue, int num_elements) { - cl_uint num_platforms; - cl_uint i, j; - cl_platform_id *platforms; + cl_uint i; + cl_platform_id platform = getPlatformFromDevice(deviceID); cl_int errNum; cl_uint *handle_type; size_t handle_type_size = 0; cl_uint num_handles = 0; + cl_bool external_mem_extn_available = + is_platform_extension_available(platform, "cl_khr_external_semaphore"); + cl_bool external_sema_extn_available = + is_platform_extension_available(platform, "cl_khr_external_memory"); + cl_bool supports_atleast_one_sema_query = false; - // get total # of platforms - errNum = clGetPlatformIDs(0, NULL, &num_platforms); - test_error(errNum, "clGetPlatformIDs (getting count) failed"); - - platforms = - (cl_platform_id *)malloc(num_platforms * sizeof(cl_platform_id)); - if (!platforms) + if (!external_mem_extn_available && !external_sema_extn_available) { - printf("error allocating memory\n"); - exit(1); + log_info("Platform does not support 'cl_khr_external_semaphore' " + "and 'cl_khr_external_memory'. Skipping the test.\n"); + return TEST_SKIPPED_ITSELF; } - log_info("%d platforms available\n", num_platforms); - errNum = clGetPlatformIDs(num_platforms, platforms, NULL); - test_error(errNum, "clGetPlatformIDs (getting IDs) failed"); - for (i = 0; i < num_platforms; i++) + log_info("Platform (id %lu) info:\n", (unsigned long)platform); + + for (i = 0; + i < sizeof(platform_info_table) / sizeof(platform_info_table[0]); i++) { - log_info("Platform%d (id %lu) info:\n", i, (unsigned long)platforms[i]); - for (j = 0; - j < sizeof(platform_info_table) / sizeof(platform_info_table[0]); - j++) + errNum = clGetPlatformInfo(platform, platform_info_table[i].info, 0, + NULL, &handle_type_size); + test_error(errNum, "clGetPlatformInfo failed"); + + if (handle_type_size == 0) { - errNum = - clGetPlatformInfo(platforms[i], platform_info_table[j].info, 0, - NULL, &handle_type_size); - test_error(errNum, "clGetPlatformInfo failed"); - num_handles = handle_type_size / sizeof(cl_uint); - handle_type = (cl_uint *)malloc(handle_type_size); - errNum = - clGetPlatformInfo(platforms[i], platform_info_table[j].info, - handle_type_size, handle_type, NULL); - test_error(errNum, "clGetPlatformInfo failed"); - - log_info("%s: \n", platform_info_table[j].name); - while (num_handles--) - { - log_info("%x \n", handle_type[num_handles]); - } - if (handle_type) + if (platform_info_table[i].info + == CL_PLATFORM_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR + && external_mem_extn_available) { - free(handle_type); + test_fail( + "External memory import handle types should be reported if " + "cl_khr_external_memory is available.\n"); } + log_info("%s not supported. Skipping the query.\n", + platform_info_table[i].name); + continue; + } + + if ((platform_info_table[i].info + == CL_PLATFORM_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) + || (platform_info_table[i].info + == CL_PLATFORM_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) + { + supports_atleast_one_sema_query = true; + } + + num_handles = handle_type_size / sizeof(cl_uint); + handle_type = (cl_uint *)malloc(handle_type_size); + errNum = clGetPlatformInfo(platform, platform_info_table[i].info, + handle_type_size, handle_type, NULL); + test_error(errNum, "clGetPlatformInfo failed"); + + log_info("%s: \n", platform_info_table[i].name); + while (num_handles--) + { + log_info("%x \n", handle_type[num_handles]); + } + if (handle_type) + { + free(handle_type); } } - if (platforms) + + if (external_sema_extn_available && !supports_atleast_one_sema_query) { - free(platforms); + log_info("External semaphore import/export or both should be supported " + "if cl_khr_external_semaphore is available.\n"); + return TEST_FAIL; } + return TEST_PASS; } @@ -118,6 +139,19 @@ int test_device_info(cl_device_id deviceID, cl_context _context, size_t handle_type_size = 0; cl_uint num_handles = 0; cl_int errNum = CL_SUCCESS; + cl_bool external_mem_extn_available = + is_extension_available(deviceID, "cl_khr_external_memory"); + cl_bool external_sema_extn_available = + is_extension_available(deviceID, "cl_khr_external_semaphore"); + cl_bool supports_atleast_one_sema_query = false; + + if (!external_mem_extn_available && !external_sema_extn_available) + { + log_info("Device does not support 'cl_khr_external_semaphore' " + "and 'cl_khr_external_memory'. Skipping the test.\n"); + return TEST_SKIPPED_ITSELF; + } + for (j = 0; j < sizeof(device_info_table) / sizeof(device_info_table[0]); j++) { @@ -125,6 +159,29 @@ int test_device_info(cl_device_id deviceID, cl_context _context, &handle_type_size); test_error(errNum, "clGetDeviceInfo failed"); + if (handle_type_size == 0) + { + if (device_info_table[j].info + == CL_DEVICE_EXTERNAL_MEMORY_IMPORT_HANDLE_TYPES_KHR + && external_mem_extn_available) + { + test_fail( + "External memory import handle types should be reported if " + "cl_khr_external_memory is available.\n"); + } + log_info("%s not supported. Skipping the query.\n", + device_info_table[j].name); + continue; + } + + if ((device_info_table[j].info + == CL_DEVICE_SEMAPHORE_EXPORT_HANDLE_TYPES_KHR) + || (device_info_table[j].info + == CL_DEVICE_SEMAPHORE_IMPORT_HANDLE_TYPES_KHR)) + { + supports_atleast_one_sema_query = true; + } + num_handles = handle_type_size / sizeof(cl_uint); handle_type = (cl_uint *)malloc(handle_type_size); @@ -142,5 +199,13 @@ int test_device_info(cl_device_id deviceID, cl_context _context, free(handle_type); } } + + if (external_sema_extn_available && !supports_atleast_one_sema_query) + { + log_info("External semaphore import/export or both should be supported " + "if cl_khr_external_semaphore is available.\n"); + return TEST_FAIL; + } + return TEST_PASS; } diff --git a/test_conformance/workgroups/test_wg_all.cpp b/test_conformance/workgroups/test_wg_all.cpp index f9b574e454..7269f5cd74 100644 --- a/test_conformance/workgroups/test_wg_all.cpp +++ b/test_conformance/workgroups/test_wg_all.cpp @@ -54,7 +54,9 @@ verify_wg_all(float *inptr, int *outptr, size_t n, size_t wg_size) if ( (predicate_all && (outptr[i+j] == 0)) || ((predicate_all == 0) && outptr[i+j]) ) { - log_info("work_group_all: Error at %lu: expected = %d, got = %d\n", i+j, predicate_all, outptr[i+j]); + log_info( + "work_group_all: Error at %zu: expected = %d, got = %d\n", + i + j, predicate_all, outptr[i + j]); return -1; } } diff --git a/test_conformance/workgroups/test_wg_any.cpp b/test_conformance/workgroups/test_wg_any.cpp index f7ff899a33..66639302a8 100644 --- a/test_conformance/workgroups/test_wg_any.cpp +++ b/test_conformance/workgroups/test_wg_any.cpp @@ -54,7 +54,9 @@ verify_wg_any(float *inptr, int *outptr, size_t n, size_t wg_size) if ( (predicate_any && (outptr[i+j] == 0)) || ((predicate_any == 0) && outptr[i+j]) ) { - log_info("work_group_any: Error at %lu: expected = %d, got = %d\n", i+j, predicate_any, outptr[i+j]); + log_info( + "work_group_any: Error at %zu: expected = %d, got = %d\n", + i + j, predicate_any, outptr[i + j]); return -1; } }