From 89102ff5235de471fad0f50e687ee78a6dfb0d43 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Thu, 23 Nov 2023 17:20:24 +0000 Subject: [PATCH 1/9] Add validation for a few image_desc_t members. Also removes these checks from the cuda and hip adapters since they should be caught by the validation layer now. The new validation rules bring image_desc_t in line with the CL struct it was derived from. We already had CTS coverage for them. --- include/ur_api.h | 8 ++++++-- scripts/core/memory.yml | 8 ++++++-- source/adapters/cuda/memory.cpp | 10 ---------- source/adapters/hip/memory.cpp | 10 ---------- source/loader/layers/validation/ur_valddi.cpp | 16 ++++++++++++++++ source/loader/ur_libapi.cpp | 4 ++++ source/ur_api.cpp | 4 ++++ .../memory/memory_adapter_native_cpu.match | 4 ---- 8 files changed, 36 insertions(+), 28 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 889ccbdf28..df919beb27 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -2556,8 +2556,8 @@ typedef struct ur_image_desc_t { size_t arraySize; ///< [in] image array size size_t rowPitch; ///< [in] image row pitch size_t slicePitch; ///< [in] image slice pitch - uint32_t numMipLevel; ///< [in] number of MIP levels - uint32_t numSamples; ///< [in] number of samples + uint32_t numMipLevel; ///< [in] number of MIP levels, must be `0` + uint32_t numSamples; ///< [in] number of samples, must be `0` } ur_image_desc_t; @@ -2601,6 +2601,10 @@ typedef struct ur_image_desc_t { /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type` +/// + `pImageDesc && pImageDesc->numMipLevel != 0` +/// + `pImageDesc && pImageDesc->numSamples != 0` +/// + `pImageDesc && pImageDesc->rowPitch != 0 && pHost == nullptr` +/// + `pImageDesc && pImageDesc->slicePitch != 0 && pHost == nullptr` /// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE /// - ::UR_RESULT_ERROR_INVALID_OPERATION /// - ::UR_RESULT_ERROR_INVALID_HOST_PTR diff --git a/scripts/core/memory.yml b/scripts/core/memory.yml index 21d8294519..d0a46f46a7 100644 --- a/scripts/core/memory.yml +++ b/scripts/core/memory.yml @@ -197,10 +197,10 @@ members: desc: "[in] image slice pitch" - type: uint32_t name: numMipLevel - desc: "[in] number of MIP levels" + desc: "[in] number of MIP levels, must be `0`" - type: uint32_t name: numSamples - desc: "[in] number of samples" + desc: "[in] number of samples, must be `0`" --- #-------------------------------------------------------------------------- type: function desc: "Create an image object" @@ -242,6 +242,10 @@ returns: - $X_RESULT_ERROR_INVALID_VALUE - $X_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: - "`pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type`" + - "`pImageDesc && pImageDesc->numMipLevel != 0`" + - "`pImageDesc && pImageDesc->numSamples != 0`" + - "`pImageDesc && pImageDesc->rowPitch != 0 && pHost == nullptr`" + - "`pImageDesc && pImageDesc->slicePitch != 0 && pHost == nullptr`" - $X_RESULT_ERROR_INVALID_IMAGE_SIZE - $X_RESULT_ERROR_INVALID_OPERATION - $X_RESULT_ERROR_INVALID_HOST_PTR: diff --git a/source/adapters/cuda/memory.cpp b/source/adapters/cuda/memory.cpp index 04b488a0f4..ed62099881 100644 --- a/source/adapters/cuda/memory.cpp +++ b/source/adapters/cuda/memory.cpp @@ -208,16 +208,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate( UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); UR_ASSERT(pImageDesc->type <= UR_MEM_TYPE_IMAGE1D_ARRAY, UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - UR_ASSERT(pImageDesc->numMipLevel == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - UR_ASSERT(pImageDesc->numSamples == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - if (!pHost) { - UR_ASSERT(pImageDesc->rowPitch == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - UR_ASSERT(pImageDesc->slicePitch == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - } // We only support RBGA channel order // TODO: check SYCL CTS and spec. May also have to support BGRA diff --git a/source/adapters/hip/memory.cpp b/source/adapters/hip/memory.cpp index 00f7e6a4b2..5f06567064 100644 --- a/source/adapters/hip/memory.cpp +++ b/source/adapters/hip/memory.cpp @@ -361,16 +361,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate( UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); UR_ASSERT(pImageDesc->type <= UR_MEM_TYPE_IMAGE1D_ARRAY, UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - UR_ASSERT(pImageDesc->numMipLevel == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - UR_ASSERT(pImageDesc->numSamples == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - if (!pHost) { - UR_ASSERT(pImageDesc->rowPitch == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - UR_ASSERT(pImageDesc->slicePitch == 0, - UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); - } // We only support RBGA channel order // TODO: check SYCL CTS and spec. May also have to support BGRA diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index bd6e20e7ad..2af3e74497 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -1082,6 +1082,22 @@ __urdlllocal ur_result_t UR_APICALL urMemImageCreate( return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR; } + if (pImageDesc && pImageDesc->numMipLevel != 0) { + return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR; + } + + if (pImageDesc && pImageDesc->numSamples != 0) { + return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR; + } + + if (pImageDesc && pImageDesc->rowPitch != 0 && pHost == nullptr) { + return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR; + } + + if (pImageDesc && pImageDesc->slicePitch != 0 && pHost == nullptr) { + return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR; + } + if (pHost == NULL && (flags & (UR_MEM_FLAG_USE_HOST_POINTER | UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) != 0) { diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 9d98d18d10..d8f25157dd 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -1512,6 +1512,10 @@ ur_result_t UR_APICALL urContextSetExtendedDeleter( /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type` +/// + `pImageDesc && pImageDesc->numMipLevel != 0` +/// + `pImageDesc && pImageDesc->numSamples != 0` +/// + `pImageDesc && pImageDesc->rowPitch != 0 && pHost == nullptr` +/// + `pImageDesc && pImageDesc->slicePitch != 0 && pHost == nullptr` /// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE /// - ::UR_RESULT_ERROR_INVALID_OPERATION /// - ::UR_RESULT_ERROR_INVALID_HOST_PTR diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 5cc020778c..577f3e2eac 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -1306,6 +1306,10 @@ ur_result_t UR_APICALL urContextSetExtendedDeleter( /// - ::UR_RESULT_ERROR_INVALID_VALUE /// - ::UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR /// + `pImageDesc && UR_MEM_TYPE_IMAGE1D_ARRAY < pImageDesc->type` +/// + `pImageDesc && pImageDesc->numMipLevel != 0` +/// + `pImageDesc && pImageDesc->numSamples != 0` +/// + `pImageDesc && pImageDesc->rowPitch != 0 && pHost == nullptr` +/// + `pImageDesc && pImageDesc->slicePitch != 0 && pHost == nullptr` /// - ::UR_RESULT_ERROR_INVALID_IMAGE_SIZE /// - ::UR_RESULT_ERROR_INVALID_OPERATION /// - ::UR_RESULT_ERROR_INVALID_HOST_PTR diff --git a/test/conformance/memory/memory_adapter_native_cpu.match b/test/conformance/memory/memory_adapter_native_cpu.match index 27e3d859e0..91218cbb01 100644 --- a/test/conformance/memory/memory_adapter_native_cpu.match +++ b/test/conformance/memory/memory_adapter_native_cpu.match @@ -7,10 +7,6 @@ urMemGetInfoTest.InvalidSizeSmall/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_MEM_INF urMemImageCreateTest.SuccessWith3DImageType/SYCL_NATIVE_CPU___SYCL_Native_CPU_ urMemImageCreateTest.InvalidSize/SYCL_NATIVE_CPU___SYCL_Native_CPU_ urMemImageCreateTest.InvalidImageDescStype/SYCL_NATIVE_CPU___SYCL_Native_CPU_ -urMemImageCreateTest.InvalidImageDescNumMipLevel/SYCL_NATIVE_CPU___SYCL_Native_CPU_ -urMemImageCreateTest.InvalidImageDescNumSamples/SYCL_NATIVE_CPU___SYCL_Native_CPU_ -urMemImageCreateTest.InvalidImageDescRowPitch/SYCL_NATIVE_CPU___SYCL_Native_CPU_ -urMemImageCreateTest.InvalidImageDescSlicePitch/SYCL_NATIVE_CPU___SYCL_Native_CPU_ urMemImageCreateTestWith1DMemoryTypeParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_MEM_TYPE_IMAGE1D urMemImageCreateTestWith1DMemoryTypeParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_MEM_TYPE_IMAGE1D_ARRAY urMemImageCreateTestWith2DMemoryTypeParam.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_MEM_TYPE_IMAGE2D From e0e7e91433b1bd668d57fd07dde237bfb5f03b88 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Wed, 15 Nov 2023 11:34:55 +0000 Subject: [PATCH 2/9] Make UR_KERNEL_INFO_NUM_ARGS uint32_t instead of size_t. This brings it in line with OpenCL, and with SYCL's expectations. Addresses #1038 --- include/ur_api.h | 2 +- include/ur_print.hpp | 6 +-- scripts/core/kernel.yml | 2 +- source/adapters/cuda/kernel.hpp | 4 +- source/adapters/opencl/kernel.cpp | 43 +++++++------------ .../kernel/kernel_adapter_level_zero.match | 7 --- test/conformance/kernel/urKernelGetInfo.cpp | 25 +++++++---- .../kernel/urKernelSetArgLocal.cpp | 2 +- .../kernel/urKernelSetArgMemObj.cpp | 2 +- .../kernel/urKernelSetArgPointer.cpp | 2 +- .../kernel/urKernelSetArgSampler.cpp | 2 +- .../kernel/urKernelSetArgValue.cpp | 2 +- 12 files changed, 45 insertions(+), 54 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index df919beb27..a3c617bb8c 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -4781,7 +4781,7 @@ urKernelSetArgLocal( /// @brief Get Kernel object information typedef enum ur_kernel_info_t { UR_KERNEL_INFO_FUNCTION_NAME = 0, ///< [char[]] Return null-terminated kernel function name. - UR_KERNEL_INFO_NUM_ARGS = 1, ///< [size_t] Return Kernel number of arguments. + UR_KERNEL_INFO_NUM_ARGS = 1, ///< [uint32_t] Return Kernel number of arguments. UR_KERNEL_INFO_REFERENCE_COUNT = 2, ///< [uint32_t] Reference count of the kernel object. ///< The reference count returned should be considered immediately stale. ///< It is unsuitable for general use in applications. This feature is diff --git a/include/ur_print.hpp b/include/ur_print.hpp index 57e0da2fa9..2591adf2ec 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -7855,9 +7855,9 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_kernel_info printPtr(os, tptr); } break; case UR_KERNEL_INFO_NUM_ARGS: { - const size_t *tptr = (const size_t *)ptr; - if (sizeof(size_t) > size) { - os << "invalid size (is: " << size << ", expected: >=" << sizeof(size_t) << ")"; + const uint32_t *tptr = (const uint32_t *)ptr; + if (sizeof(uint32_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" << sizeof(uint32_t) << ")"; return UR_RESULT_ERROR_INVALID_SIZE; } os << (const void *)(tptr) << " ("; diff --git a/scripts/core/kernel.yml b/scripts/core/kernel.yml index ed62f44c33..dda726c804 100644 --- a/scripts/core/kernel.yml +++ b/scripts/core/kernel.yml @@ -109,7 +109,7 @@ etors: - name: FUNCTION_NAME desc: "[char[]] Return null-terminated kernel function name." - name: NUM_ARGS - desc: "[size_t] Return Kernel number of arguments." + desc: "[uint32_t] Return Kernel number of arguments." - name: REFERENCE_COUNT desc: | [uint32_t] Reference count of the kernel object. diff --git a/source/adapters/cuda/kernel.hpp b/source/adapters/cuda/kernel.hpp index 808b1abe9e..c6761d8525 100644 --- a/source/adapters/cuda/kernel.hpp +++ b/source/adapters/cuda/kernel.hpp @@ -204,7 +204,9 @@ struct ur_kernel_handle_t_ { /// Note this only returns the current known number of arguments, not the /// real one required by the kernel, since this cannot be queried from /// the CUDA Driver API - size_t getNumArgs() const noexcept { return Args.Indices.size() - 1; } + uint32_t getNumArgs() const noexcept { + return static_cast(Args.Indices.size() - 1); + } void setKernelArg(int Index, size_t Size, const void *Arg) { Args.addArg(Index, Size, Arg); diff --git a/source/adapters/opencl/kernel.cpp b/source/adapters/opencl/kernel.cpp index 14caeee8e7..41c6d6de70 100644 --- a/source/adapters/opencl/kernel.cpp +++ b/source/adapters/opencl/kernel.cpp @@ -61,8 +61,8 @@ static cl_int mapURKernelInfoToCL(ur_kernel_info_t URPropName) { return CL_KERNEL_PROGRAM; case UR_KERNEL_INFO_ATTRIBUTES: return CL_KERNEL_ATTRIBUTES; + // NUM_REGS doesn't have a CL equivalent case UR_KERNEL_INFO_NUM_REGS: - return CL_KERNEL_NUM_ARGS; default: return -1; } @@ -73,33 +73,20 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel, size_t propSize, void *pPropValue, size_t *pPropSizeRet) { - // We need this little bit of ugliness because the UR NUM_ARGS property is - // size_t whereas the CL one is cl_uint. We should consider changing that see - // #1038 - if (propName == UR_KERNEL_INFO_NUM_ARGS) { - if (pPropSizeRet) - *pPropSizeRet = sizeof(size_t); - cl_uint NumArgs = 0; - CL_RETURN_ON_FAILURE(clGetKernelInfo(cl_adapter::cast(hKernel), - mapURKernelInfoToCL(propName), - sizeof(NumArgs), &NumArgs, nullptr)); - if (pPropValue) { - if (propSize != sizeof(size_t)) - return UR_RESULT_ERROR_INVALID_SIZE; - *static_cast(pPropValue) = static_cast(NumArgs); - } - } else { - size_t CheckPropSize = 0; - cl_int ClResult = clGetKernelInfo(cl_adapter::cast(hKernel), - mapURKernelInfoToCL(propName), propSize, - pPropValue, &CheckPropSize); - if (pPropValue && CheckPropSize != propSize) { - return UR_RESULT_ERROR_INVALID_SIZE; - } - CL_RETURN_ON_FAILURE(ClResult); - if (pPropSizeRet) { - *pPropSizeRet = CheckPropSize; - } + // OpenCL doesn't have a way to support this. + if (propName == UR_KERNEL_INFO_NUM_REGS) { + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; + } + size_t CheckPropSize = 0; + cl_int ClResult = clGetKernelInfo(cl_adapter::cast(hKernel), + mapURKernelInfoToCL(propName), propSize, + pPropValue, &CheckPropSize); + if (pPropValue && CheckPropSize != propSize) { + return UR_RESULT_ERROR_INVALID_SIZE; + } + CL_RETURN_ON_FAILURE(ClResult); + if (pPropSizeRet) { + *pPropSizeRet = CheckPropSize; } return UR_RESULT_SUCCESS; diff --git a/test/conformance/kernel/kernel_adapter_level_zero.match b/test/conformance/kernel/kernel_adapter_level_zero.match index 82c92e3f28..85f0fd6457 100644 --- a/test/conformance/kernel/kernel_adapter_level_zero.match +++ b/test/conformance/kernel/kernel_adapter_level_zero.match @@ -1,11 +1,4 @@ urKernelGetInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_NUM_REGS -urKernelGetInfoTest.InvalidSizeSmall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_FUNCTION_NAME -urKernelGetInfoTest.InvalidSizeSmall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_NUM_ARGS -urKernelGetInfoTest.InvalidSizeSmall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_REFERENCE_COUNT -urKernelGetInfoTest.InvalidSizeSmall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_CONTEXT -urKernelGetInfoTest.InvalidSizeSmall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_PROGRAM -urKernelGetInfoTest.InvalidSizeSmall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_ATTRIBUTES -urKernelGetInfoTest.InvalidSizeSmall/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_KERNEL_INFO_NUM_REGS urKernelSetArgLocalTest.InvalidKernelArgumentIndex/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urKernelSetArgMemObjTest.InvalidKernelArgumentIndex/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urKernelSetArgPointerNegativeTest.InvalidKernelArgumentIndex/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ diff --git a/test/conformance/kernel/urKernelGetInfo.cpp b/test/conformance/kernel/urKernelGetInfo.cpp index 69db683a02..f08e13d079 100644 --- a/test/conformance/kernel/urKernelGetInfo.cpp +++ b/test/conformance/kernel/urKernelGetInfo.cpp @@ -66,23 +66,32 @@ TEST_P(urKernelGetInfoTest, InvalidEnumeration) { } TEST_P(urKernelGetInfoTest, InvalidSizeZero) { - size_t n_args = 0; - ASSERT_EQ_RESULT( - urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, 0, &n_args, nullptr), - UR_RESULT_ERROR_INVALID_SIZE); + size_t query_size = 0; + ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, 0, nullptr, + &query_size)); + std::vector query_data(query_size); + ASSERT_EQ_RESULT(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, 0, + query_data.data(), nullptr), + UR_RESULT_ERROR_INVALID_SIZE); } TEST_P(urKernelGetInfoTest, InvalidSizeSmall) { - size_t n_args = 0; + size_t query_size = 0; + ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, 0, nullptr, + &query_size)); + std::vector query_data(query_size); ASSERT_EQ_RESULT(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, - sizeof(n_args) - 1, &n_args, nullptr), + query_data.size() - 1, query_data.data(), + nullptr), UR_RESULT_ERROR_INVALID_SIZE); } TEST_P(urKernelGetInfoTest, InvalidNullPointerPropValue) { - size_t n_args = 0; + size_t query_size = 0; + ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, 0, nullptr, + &query_size)); ASSERT_EQ_RESULT(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, - sizeof(n_args), nullptr, nullptr), + query_size, nullptr, nullptr), UR_RESULT_ERROR_INVALID_NULL_POINTER); } diff --git a/test/conformance/kernel/urKernelSetArgLocal.cpp b/test/conformance/kernel/urKernelSetArgLocal.cpp index 3b44c31ea7..1d3789bf3a 100644 --- a/test/conformance/kernel/urKernelSetArgLocal.cpp +++ b/test/conformance/kernel/urKernelSetArgLocal.cpp @@ -24,7 +24,7 @@ TEST_P(urKernelSetArgLocalTest, InvalidNullHandleKernel) { } TEST_P(urKernelSetArgLocalTest, InvalidKernelArgumentIndex) { - size_t num_kernel_args = 0; + uint32_t num_kernel_args = 0; ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, sizeof(num_kernel_args), &num_kernel_args, nullptr)); diff --git a/test/conformance/kernel/urKernelSetArgMemObj.cpp b/test/conformance/kernel/urKernelSetArgMemObj.cpp index 4c1eb6677f..0a83882465 100644 --- a/test/conformance/kernel/urKernelSetArgMemObj.cpp +++ b/test/conformance/kernel/urKernelSetArgMemObj.cpp @@ -35,7 +35,7 @@ TEST_P(urKernelSetArgMemObjTest, InvalidNullHandleKernel) { } TEST_P(urKernelSetArgMemObjTest, InvalidKernelArgumentIndex) { - size_t num_kernel_args = 0; + uint32_t num_kernel_args = 0; ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, sizeof(num_kernel_args), &num_kernel_args, nullptr)); diff --git a/test/conformance/kernel/urKernelSetArgPointer.cpp b/test/conformance/kernel/urKernelSetArgPointer.cpp index 92b93f7575..e037ada8f1 100644 --- a/test/conformance/kernel/urKernelSetArgPointer.cpp +++ b/test/conformance/kernel/urKernelSetArgPointer.cpp @@ -142,7 +142,7 @@ TEST_P(urKernelSetArgPointerNegativeTest, InvalidNullHandleKernel) { } TEST_P(urKernelSetArgPointerNegativeTest, InvalidKernelArgumentIndex) { - size_t num_kernel_args = 0; + uint32_t num_kernel_args = 0; ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, sizeof(num_kernel_args), &num_kernel_args, nullptr)); diff --git a/test/conformance/kernel/urKernelSetArgSampler.cpp b/test/conformance/kernel/urKernelSetArgSampler.cpp index 017c89ba14..824619874e 100644 --- a/test/conformance/kernel/urKernelSetArgSampler.cpp +++ b/test/conformance/kernel/urKernelSetArgSampler.cpp @@ -103,7 +103,7 @@ TEST_P(urKernelSetArgSamplerTest, InvalidNullHandleArgValue) { } TEST_P(urKernelSetArgSamplerTest, InvalidKernelArgumentIndex) { - size_t num_kernel_args = 0; + uint32_t num_kernel_args = 0; ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, sizeof(num_kernel_args), &num_kernel_args, nullptr)); diff --git a/test/conformance/kernel/urKernelSetArgValue.cpp b/test/conformance/kernel/urKernelSetArgValue.cpp index d66f76944b..84dd3ee86c 100644 --- a/test/conformance/kernel/urKernelSetArgValue.cpp +++ b/test/conformance/kernel/urKernelSetArgValue.cpp @@ -33,7 +33,7 @@ TEST_P(urKernelSetArgValueTest, InvalidNullPointerArgValue) { } TEST_P(urKernelSetArgValueTest, InvalidKernelArgumentIndex) { - size_t num_kernel_args = 0; + uint32_t num_kernel_args = 0; ASSERT_SUCCESS(urKernelGetInfo(kernel, UR_KERNEL_INFO_NUM_ARGS, sizeof(num_kernel_args), &num_kernel_args, nullptr)); From 646cc9ce78e57738898c9d19d32e3a48ddf3ad31 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Mon, 27 Nov 2023 13:55:39 +0000 Subject: [PATCH 3/9] Add a DeviceGetInfo test for DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS --- source/adapters/level_zero/device.cpp | 2 ++ source/adapters/opencl/device.cpp | 4 +++- test/conformance/device/urDeviceGetInfo.cpp | 3 ++- test/conformance/kernel/kernel_adapter_level_zero.match | 4 ---- test/conformance/kernel/kernel_adapter_opencl.match | 4 ---- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index 45eb85dd7a..33e3349df9 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -987,6 +987,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP: case UR_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP: case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP: + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: + return ReturnValue(false); default: logger::error("Unsupported ParamName in urGetDeviceInfo"); logger::error("ParamNameParamName={}(0x{})", ParamName, diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index 4445e84260..67cb1712a3 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -845,7 +845,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, case UR_DEVICE_INFO_COMPILER_AVAILABLE: case UR_DEVICE_INFO_LINKER_AVAILABLE: case UR_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC: - case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: case UR_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: { /* CL type: cl_bool * UR type: ur_bool_t */ @@ -978,6 +977,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(UUID); } + case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: { + return ReturnValue(false); + } /* TODO: Check regularly to see if support is enabled in OpenCL. Intel GPU * EU device-specific information extensions. Some of the queries are * enabled by cl_intel_device_attribute_query extension, but it's not yet in diff --git a/test/conformance/device/urDeviceGetInfo.cpp b/test/conformance/device/urDeviceGetInfo.cpp index d1a04d8a6a..14fedf728f 100644 --- a/test/conformance/device/urDeviceGetInfo.cpp +++ b/test/conformance/device/urDeviceGetInfo.cpp @@ -235,7 +235,8 @@ INSTANTIATE_TEST_SUITE_P( UR_DEVICE_INFO_MEM_CHANNEL_SUPPORT, // UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED, // UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP, // - UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT // + UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT, // + UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS // ), [](const ::testing::TestParamInfo &info) { std::stringstream ss; diff --git a/test/conformance/kernel/kernel_adapter_level_zero.match b/test/conformance/kernel/kernel_adapter_level_zero.match index 85f0fd6457..7b74766ac2 100644 --- a/test/conformance/kernel/kernel_adapter_level_zero.match +++ b/test/conformance/kernel/kernel_adapter_level_zero.match @@ -9,7 +9,3 @@ urKernelSetExecInfoTest.SuccessIndirectAccess/Intel_R__oneAPI_Unified_Runtime_ov urKernelSetExecInfoUSMPointersTest.SuccessHost/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urKernelSetExecInfoUSMPointersTest.SuccessDevice/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urKernelSetExecInfoUSMPointersTest.SuccessShared/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.InvalidNullHandleKernel/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.InvalidNullPointerSpecConstants/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ -urKernelSetSpecializationConstantsTest.InvalidSizeCount/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ diff --git a/test/conformance/kernel/kernel_adapter_opencl.match b/test/conformance/kernel/kernel_adapter_opencl.match index 9a71945c45..7ece0484df 100644 --- a/test/conformance/kernel/kernel_adapter_opencl.match +++ b/test/conformance/kernel/kernel_adapter_opencl.match @@ -1,5 +1 @@ urKernelSetArgValueTest.InvalidKernelArgumentSize/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.Success/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.InvalidNullHandleKernel/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.InvalidNullPointerSpecConstants/Intel_R__OpenCL___{{.*}} -urKernelSetSpecializationConstantsTest.InvalidSizeCount/Intel_R__OpenCL___{{.*}} From 40cd6faa6b2b453bac716e54d9d38998f48a50b9 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Fri, 1 Dec 2023 12:33:16 +0000 Subject: [PATCH 4/9] Add DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT device info query. This gates support for the EnqueueDeviceGlobalVariableRead and Write operations. The CTS tests for these now check for support before running, and all adapters report their support correctly. --- include/ur_api.h | 3 +++ include/ur_print.hpp | 15 +++++++++++++++ scripts/core/device.yml | 2 ++ source/adapters/cuda/device.cpp | 2 ++ source/adapters/hip/device.cpp | 2 ++ source/adapters/level_zero/device.cpp | 3 +++ source/adapters/opencl/device.cpp | 7 +++++++ test/conformance/testing/include/uur/fixtures.h | 7 +++++++ tools/urinfo/urinfo.hpp | 2 ++ 9 files changed, 43 insertions(+) diff --git a/include/ur_api.h b/include/ur_api.h index a3c617bb8c..800acac7b3 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1597,6 +1597,9 @@ typedef enum ur_device_info_t { ///< this composite device. UR_DEVICE_INFO_COMPOSITE_DEVICE = 117, ///< [::ur_device_handle_t] The composite device containing this component ///< device. + UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 118, ///< [::ur_bool_t] return true if the device supports the + ///< `EnqueueDeviceGlobalVariableWrite` and + ///< `EnqueueDeviceGlobalVariableRead` entry points. UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP = 0x1000, ///< [::ur_bool_t] Returns true if the device supports the use of ///< command-buffers. UR_DEVICE_INFO_COMMAND_BUFFER_UPDATE_SUPPORT_EXP = 0x1001, ///< [::ur_bool_t] Returns true if the device supports updating the kernel diff --git a/include/ur_print.hpp b/include/ur_print.hpp index 2591adf2ec..da85fa9a64 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -2524,6 +2524,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { case UR_DEVICE_INFO_COMPOSITE_DEVICE: os << "UR_DEVICE_INFO_COMPOSITE_DEVICE"; break; + case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: + os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT"; + break; case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: os << "UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP"; break; @@ -4008,6 +4011,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info os << ")"; } break; + case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return UR_RESULT_ERROR_INVALID_SIZE; + } + os << (const void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; case UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP: { const ur_bool_t *tptr = (const ur_bool_t *)ptr; if (sizeof(ur_bool_t) > size) { diff --git a/scripts/core/device.yml b/scripts/core/device.yml index f1861731d3..713e7ac5ec 100644 --- a/scripts/core/device.yml +++ b/scripts/core/device.yml @@ -439,6 +439,8 @@ etors: desc: "[$x_device_handle_t[]] The set of component devices contained by this composite device." - name: COMPOSITE_DEVICE desc: "[$x_device_handle_t] The composite device containing this component device." + - name: GLOBAL_VARIABLE_SUPPORT + desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points." --- #-------------------------------------------------------------------------- type: function desc: "Retrieves various information about device" diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index b076d11930..d60473adf2 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -1075,6 +1075,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(true); case UR_DEVICE_INFO_ESIMD_SUPPORT: return ReturnValue(false); + case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: + return ReturnValue(true); case UR_DEVICE_INFO_COMPONENT_DEVICES: case UR_DEVICE_INFO_COMPOSITE_DEVICE: case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS: diff --git a/source/adapters/hip/device.cpp b/source/adapters/hip/device.cpp index 971a37117b..9984820503 100644 --- a/source/adapters/hip/device.cpp +++ b/source/adapters/hip/device.cpp @@ -886,6 +886,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, return ReturnValue(true); } + case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: + return ReturnValue(false); // TODO: Investigate if this information is available on HIP. case UR_DEVICE_INFO_COMPONENT_DEVICES: case UR_DEVICE_INFO_COMPOSITE_DEVICE: diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index 33e3349df9..490c8e3c35 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -989,6 +989,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo( case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP: case UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS: return ReturnValue(false); + case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: + return ReturnValue(true); + default: logger::error("Unsupported ParamName in urGetDeviceInfo"); logger::error("ParamNameParamName={}(0x{})", ParamName, diff --git a/source/adapters/opencl/device.cpp b/source/adapters/opencl/device.cpp index 67cb1712a3..1ff4af9965 100644 --- a/source/adapters/opencl/device.cpp +++ b/source/adapters/opencl/device.cpp @@ -812,6 +812,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, {"cl_intel_program_scope_host_pipe"}, Supported)); return ReturnValue(Supported); } + case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: { + bool Supported = false; + CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions( + cl_adapter::cast(hDevice), + {"cl_intel_global_variable_access"}, Supported)); + return ReturnValue(Supported); + } case UR_DEVICE_INFO_QUEUE_PROPERTIES: case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: diff --git a/test/conformance/testing/include/uur/fixtures.h b/test/conformance/testing/include/uur/fixtures.h index bcdc94d524..872fad57b3 100644 --- a/test/conformance/testing/include/uur/fixtures.h +++ b/test/conformance/testing/include/uur/fixtures.h @@ -1486,6 +1486,13 @@ struct urGlobalVariableTest : uur::urKernelExecutionTest { UR_PROGRAM_METADATA_TYPE_BYTE_ARRAY, metadataData.size(), metadata_value}); UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp()); + bool global_var_support = false; + ASSERT_SUCCESS(urDeviceGetInfo( + device, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT, + sizeof(global_var_support), &global_var_support, nullptr)); + if (!global_var_support) { + GTEST_SKIP() << "Global variable access is not supported"; + } } /* We pad the first 8 bytes of the metadata since they are ignored */ diff --git a/tools/urinfo/urinfo.hpp b/tools/urinfo/urinfo.hpp index 5f3c8874fd..55c4c9859d 100644 --- a/tools/urinfo/urinfo.hpp +++ b/tools/urinfo/urinfo.hpp @@ -329,6 +329,8 @@ inline void printDeviceInfos(ur_device_handle_t hDevice, printDeviceInfo(hDevice, UR_DEVICE_INFO_COMPOSITE_DEVICE); std::cout << prefix; + printDeviceInfo(hDevice, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT); + std::cout << prefix; printDeviceInfo(hDevice, UR_DEVICE_INFO_COMMAND_BUFFER_SUPPORT_EXP); std::cout << prefix; From b4b2c722eecca9ef486acf138fdd65a091d795a8 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Fri, 2 Feb 2024 12:09:26 +0000 Subject: [PATCH 5/9] Native CPU Match file fixes The native CPU adapter has been added to CI since some of these PRs were reviewed, so inevitably we need to tack some match file fixes on here post scriptum. --- test/conformance/device/device_adapter_native_cpu.match | 1 + 1 file changed, 1 insertion(+) diff --git a/test/conformance/device/device_adapter_native_cpu.match b/test/conformance/device/device_adapter_native_cpu.match index 147a9a3dfd..f7068f210a 100644 --- a/test/conformance/device/device_adapter_native_cpu.match +++ b/test/conformance/device/device_adapter_native_cpu.match @@ -32,3 +32,4 @@ urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_WORK_GROUPS_3D urDeviceGetInfoTest.Success/UR_DEVICE_INFO_ASYNC_BARRIER urDeviceGetInfoTest.Success/UR_DEVICE_INFO_HOST_PIPE_READ_WRITE_SUPPORTED urDeviceGetInfoTest.Success/UR_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP +urDeviceGetInfoTest.Success/UR_DEVICE_INFO_KERNEL_SET_SPECIALIZATION_CONSTANTS From caab344b9e2c48096f4cc0721e98c5633c3e5ab6 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Tue, 2 Jan 2024 14:41:17 +0000 Subject: [PATCH 6/9] A few small changes to move towards empty match files for CL: * Return UNSUPPORTED_ENUMERATION in device info query when FP16 extension isn't supported * Add a mapping from CL_INVALID_ARG_SIZE to UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE * Remove a bunch of {{OPT}} entries from the enqueue match file, these should all be passing since bounds checking was added to the validation layer * Write in a special case for PROGRAM_INFO_BINARIES test - this query works pretty differently to the others --- source/adapters/opencl/common.cpp | 2 ++ .../enqueue/enqueue_adapter_opencl.match | 35 +------------------ .../kernel/kernel_adapter_opencl.match | 1 - .../program/program_adapter_opencl.match | 1 - test/conformance/program/urProgramGetInfo.cpp | 30 ++++++++++++---- 5 files changed, 27 insertions(+), 42 deletions(-) diff --git a/source/adapters/opencl/common.cpp b/source/adapters/opencl/common.cpp index dfba3c202c..03775fb87d 100644 --- a/source/adapters/opencl/common.cpp +++ b/source/adapters/opencl/common.cpp @@ -93,6 +93,8 @@ ur_result_t mapCLErrorToUR(cl_int Result) { return UR_RESULT_ERROR_INVALID_KERNEL_ARGS; case CL_INVALID_COMMAND_QUEUE: return UR_RESULT_ERROR_INVALID_QUEUE; + case CL_INVALID_ARG_SIZE: + return UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE; default: return UR_RESULT_ERROR_UNKNOWN; } diff --git a/test/conformance/enqueue/enqueue_adapter_opencl.match b/test/conformance/enqueue/enqueue_adapter_opencl.match index 0e751b8a25..7bb41276d4 100644 --- a/test/conformance/enqueue/enqueue_adapter_opencl.match +++ b/test/conformance/enqueue/enqueue_adapter_opencl.match @@ -1,37 +1,4 @@ -{{OPT}}urEnqueueMemBufferCopyRectTest.InvalidSize/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueMemBufferReadRectTest.InvalidSize/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueMemBufferWriteRectTest.InvalidSize/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DTestWithParam.Success/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMFill2DNegativeTest.OutOfBounds/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMAdviseTest.InvalidSizeTooLarge/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessNonBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessNonBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessNonBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessNonBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessNonBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DTestWithParam.SuccessNonBlocking/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DNegativeTest.InvalidNullHandleQueue/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DNegativeTest.InvalidNullPointer/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DNegativeTest.InvalidSize/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMMemcpy2DNegativeTest.InvalidEventWaitList/Intel_R__OpenCL___{{.*}} -{{OPT}}urEnqueueUSMPrefetchTest.InvalidSizeTooLarge/Intel_R__OpenCL___{{.*}} +{{OPT}}urEnqueueDeviceGetGlobalVariableReadTest.Success/Intel_R__OpenCL___{{.*}}_ urEnqueueKernelLaunchKernelWgSizeTest.Success/Intel_R__OpenCL___{{.*}}_ urEnqueueKernelLaunchKernelSubGroupTest.Success/Intel_R__OpenCL___{{.*}}_ {{OPT}}urEnqueueKernelLaunchUSMLinkedList.Success/Intel_R__OpenCL___{{.*}}_UsePoolEnabled diff --git a/test/conformance/kernel/kernel_adapter_opencl.match b/test/conformance/kernel/kernel_adapter_opencl.match index 7ece0484df..e69de29bb2 100644 --- a/test/conformance/kernel/kernel_adapter_opencl.match +++ b/test/conformance/kernel/kernel_adapter_opencl.match @@ -1 +0,0 @@ -urKernelSetArgValueTest.InvalidKernelArgumentSize/Intel_R__OpenCL___{{.*}} diff --git a/test/conformance/program/program_adapter_opencl.match b/test/conformance/program/program_adapter_opencl.match index d35966d283..2c596d966d 100644 --- a/test/conformance/program/program_adapter_opencl.match +++ b/test/conformance/program/program_adapter_opencl.match @@ -1,4 +1,3 @@ urProgramCreateWithILTest.BuildInvalidProgram/Intel_R__OpenCL___{{.*}}_ urProgramGetFunctionPointerTest.InvalidFunctionName/Intel_R__OpenCL___{{.*}}_ urProgramGetInfoTest.Success/Intel_R__OpenCL___{{.*}}___UR_PROGRAM_INFO_SOURCE -urProgramGetInfoTest.Success/Intel_R__OpenCL___{{.*}}___UR_PROGRAM_INFO_BINARIES diff --git a/test/conformance/program/urProgramGetInfo.cpp b/test/conformance/program/urProgramGetInfo.cpp index 09a6dd0302..2097b2c797 100644 --- a/test/conformance/program/urProgramGetInfo.cpp +++ b/test/conformance/program/urProgramGetInfo.cpp @@ -33,13 +33,31 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urProgramGetInfoSingleTest); TEST_P(urProgramGetInfoTest, Success) { auto property_name = getParam(); - size_t property_size = 0; std::vector property_value; - ASSERT_SUCCESS( - urProgramGetInfo(program, property_name, 0, nullptr, &property_size)); - property_value.resize(property_size); - ASSERT_SUCCESS(urProgramGetInfo(program, property_name, property_size, - property_value.data(), nullptr)); + size_t property_size = 0; + if (property_name == UR_PROGRAM_INFO_BINARIES) { + size_t binary_sizes_len = 0; + ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_BINARY_SIZES, + 0, nullptr, &binary_sizes_len)); + // Due to how the fixtures + env are set up we should only have one + // device associated with program, so one binary. + ASSERT_EQ(binary_sizes_len / sizeof(size_t), 1); + size_t binary_sizes[1] = {binary_sizes_len}; + ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_BINARY_SIZES, + binary_sizes_len, binary_sizes, + nullptr)); + property_value.resize(binary_sizes[0]); + char *binaries[1] = {property_value.data()}; + ASSERT_SUCCESS(urProgramGetInfo(program, UR_PROGRAM_INFO_BINARIES, + sizeof(binaries[0]), binaries, + nullptr)); + } else { + ASSERT_SUCCESS( + urProgramGetInfo(program, property_name, 0, nullptr, &property_size)); + property_value.resize(property_size); + ASSERT_SUCCESS(urProgramGetInfo(program, property_name, property_size, + property_value.data(), nullptr)); + } switch (property_name) { case UR_PROGRAM_INFO_REFERENCE_COUNT: { auto returned_reference_count = From a43376601f928bf7dfd9a5344d0af1a4cee52113 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Wed, 29 Nov 2023 12:00:52 +0000 Subject: [PATCH 7/9] Rename INVALID_FUNCTION_NAME to FUNCTION_ADDRESS_NOT_AVAILABLE. This lines up better with the original PI error code and what it was meant to convey. Also clarify the spec around return codes for urProgramGetFunctionPointer and update the relevant CTS test. --- include/ur_api.h | 11 ++++++++--- include/ur_print.hpp | 4 ++-- scripts/core/common.yml | 4 ++-- scripts/core/program.yml | 7 ++++++- source/adapters/cuda/program.cpp | 2 +- source/adapters/hip/program.cpp | 2 +- source/adapters/level_zero/common.cpp | 3 +-- source/adapters/level_zero/common.hpp | 4 ++-- source/adapters/level_zero/program.cpp | 2 +- source/adapters/opencl/program.cpp | 6 +----- source/loader/ur_libapi.cpp | 8 ++++++-- source/ur_api.cpp | 8 ++++++-- .../program/program_adapter_level_zero.match | 2 +- .../program/program_adapter_native_cpu.match | 2 +- test/conformance/program/program_adapter_opencl.match | 1 - .../program/urProgramGetFunctionPointer.cpp | 4 ++-- test/conformance/program/urProgramGetInfo.cpp | 4 ++-- 17 files changed, 43 insertions(+), 31 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 800acac7b3..c2f19f9ca2 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -481,7 +481,8 @@ typedef enum ur_result_t { UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT = 55, ///< [Validation] image format is not supported by the device UR_RESULT_ERROR_INVALID_NATIVE_BINARY = 56, ///< [Validation] native binary is not supported by the device UR_RESULT_ERROR_INVALID_GLOBAL_NAME = 57, ///< [Validation] global variable is not found in the program - UR_RESULT_ERROR_INVALID_FUNCTION_NAME = 58, ///< [Validation] function name is not found in the program + UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE = 58, ///< [Validation] function name is in the program but its address could not + ///< be determined UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION = 59, ///< [Validation] group size dimension is not valid for the kernel or ///< device UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION = 60, ///< [Validation] global width dimension is not valid for the kernel or @@ -4362,8 +4363,8 @@ urProgramRelease( /// @details /// - Retrieves a pointer to the functions with the given name and defined /// in the given program. -/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function -/// can not be obtained. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the +/// function can not be obtained. /// - The application may call this function from simultaneous threads for /// the same device. /// - The implementation of this function should be thread-safe. @@ -4383,6 +4384,10 @@ urProgramRelease( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pFunctionName` /// + `NULL == ppFunctionPointer` +/// - ::UR_RESULT_ERROR_INVALID_KERNEL_NAME +/// + If `pFunctionName` couldn't be found in `hProgram`. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE +/// + If `pFunctionName` could be located, but its address couldn't be retrieved. UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for. diff --git a/include/ur_print.hpp b/include/ur_print.hpp index da85fa9a64..0ccef6a382 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -1541,8 +1541,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_result_t value) { case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: os << "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; break; - case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: - os << "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + os << "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE"; break; case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: os << "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 8aeb8ea248..d06333eb07 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -251,8 +251,8 @@ etors: desc: "[Validation] native binary is not supported by the device" - name: ERROR_INVALID_GLOBAL_NAME desc: "[Validation] global variable is not found in the program" - - name: ERROR_INVALID_FUNCTION_NAME - desc: "[Validation] function name is not found in the program" + - name: ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE + desc: "[Validation] function name is in the program but its address could not be determined" - name: ERROR_INVALID_GROUP_SIZE_DIMENSION desc: "[Validation] group size dimension is not valid for the kernel or device" - name: ERROR_INVALID_GLOBAL_WIDTH_DIMENSION diff --git a/scripts/core/program.yml b/scripts/core/program.yml index 45f7710d68..1cdb4e7b6b 100644 --- a/scripts/core/program.yml +++ b/scripts/core/program.yml @@ -291,7 +291,7 @@ analogue: - "**clGetDeviceFunctionPointerINTEL**" details: - "Retrieves a pointer to the functions with the given name and defined in the given program." - - "$X_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function can not be obtained." + - "$X_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the function can not be obtained." - "The application may call this function from simultaneous threads for the same device." - "The implementation of this function should be thread-safe." params: @@ -313,6 +313,11 @@ params: name: ppFunctionPointer desc: | [out] Returns the pointer to the function if it is found in the program. +returns: + - $X_RESULT_ERROR_INVALID_KERNEL_NAME: + - "If `pFunctionName` couldn't be found in `hProgram`." + - $X_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + - "If `pFunctionName` could be located, but its address couldn't be retrieved." --- #-------------------------------------------------------------------------- type: function desc: "Retrieves a pointer to a device global variable." diff --git a/source/adapters/cuda/program.cpp b/source/adapters/cuda/program.cpp index de4e480491..f880a13981 100644 --- a/source/adapters/cuda/program.cpp +++ b/source/adapters/cuda/program.cpp @@ -503,7 +503,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( UR_CHECK_ERROR(Ret); if (Ret == CUDA_ERROR_NOT_FOUND) { *ppFunctionPointer = 0; - Result = UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + Result = UR_RESULT_ERROR_INVALID_KERNEL_NAME; } return Result; diff --git a/source/adapters/hip/program.cpp b/source/adapters/hip/program.cpp index 915f644cb3..6531947860 100644 --- a/source/adapters/hip/program.cpp +++ b/source/adapters/hip/program.cpp @@ -539,7 +539,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( UR_CHECK_ERROR(Ret); if (Ret == hipErrorNotFound) { *ppFunctionPointer = 0; - Result = UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + Result = UR_RESULT_ERROR_INVALID_KERNEL_NAME; } return Result; diff --git a/source/adapters/level_zero/common.cpp b/source/adapters/level_zero/common.cpp index 8571be298b..099ef2e729 100644 --- a/source/adapters/level_zero/common.cpp +++ b/source/adapters/level_zero/common.cpp @@ -46,9 +46,8 @@ ur_result_t ze2urResult(ze_result_t ZeResult) { case ZE_RESULT_ERROR_INVALID_NATIVE_BINARY: return UR_RESULT_ERROR_INVALID_BINARY; case ZE_RESULT_ERROR_INVALID_KERNEL_NAME: - return UR_RESULT_ERROR_INVALID_KERNEL_NAME; case ZE_RESULT_ERROR_INVALID_FUNCTION_NAME: - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + return UR_RESULT_ERROR_INVALID_KERNEL_NAME; case ZE_RESULT_ERROR_OVERLAPPING_REGIONS: return UR_RESULT_ERROR_INVALID_OPERATION; case ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: diff --git a/source/adapters/level_zero/common.hpp b/source/adapters/level_zero/common.hpp index eb92eba78e..962f146c16 100644 --- a/source/adapters/level_zero/common.hpp +++ b/source/adapters/level_zero/common.hpp @@ -145,8 +145,8 @@ static auto getUrResultString = [](ur_result_t Result) { return "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: return "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; - case UR_RESULT_ERROR_INVALID_FUNCTION_NAME: - return "UR_RESULT_ERROR_INVALID_FUNCTION_NAME"; + case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + return "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE"; case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: return "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: diff --git a/source/adapters/level_zero/program.cpp b/source/adapters/level_zero/program.cpp index 447721f004..c4b4451d75 100644 --- a/source/adapters/level_zero/program.cpp +++ b/source/adapters/level_zero/program.cpp @@ -570,7 +570,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( // exists ClResult.pop_back(); if (is_in_separated_string(ClResult, ';', std::string(FunctionName))) - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + return UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE; return UR_RESULT_ERROR_INVALID_KERNEL_NAME; } diff --git a/source/adapters/opencl/program.cpp b/source/adapters/opencl/program.cpp index 14f4da22ec..035a3c89a9 100644 --- a/source/adapters/opencl/program.cpp +++ b/source/adapters/opencl/program.cpp @@ -451,10 +451,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( CLContext, cl_ext::ExtFuncPtrCache->clGetDeviceFunctionPointerCache, cl_ext::GetDeviceFunctionPointerName, &FuncT)); - if (!FuncT) { - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; - } - // Check if the kernel name exists to prevent the OpenCL runtime from throwing // an exception with the cpu runtime. // TODO: Use fallback search method if the clGetDeviceFunctionPointerINTEL @@ -488,7 +484,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetFunctionPointer( // that the function name is invalid. if (CLResult == CL_INVALID_ARG_VALUE) { *ppFunctionPointer = 0; - return UR_RESULT_ERROR_INVALID_FUNCTION_NAME; + return UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE; } CL_RETURN_ON_FAILURE(CLResult); diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index d8f25157dd..67b266032e 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -3225,8 +3225,8 @@ ur_result_t UR_APICALL urProgramRelease( /// @details /// - Retrieves a pointer to the functions with the given name and defined /// in the given program. -/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function -/// can not be obtained. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the +/// function can not be obtained. /// - The application may call this function from simultaneous threads for /// the same device. /// - The implementation of this function should be thread-safe. @@ -3246,6 +3246,10 @@ ur_result_t UR_APICALL urProgramRelease( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pFunctionName` /// + `NULL == ppFunctionPointer` +/// - ::UR_RESULT_ERROR_INVALID_KERNEL_NAME +/// + If `pFunctionName` couldn't be found in `hProgram`. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE +/// + If `pFunctionName` could be located, but its address couldn't be retrieved. ur_result_t UR_APICALL urProgramGetFunctionPointer( ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for. diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 577f3e2eac..d591bee906 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -2749,8 +2749,8 @@ ur_result_t UR_APICALL urProgramRelease( /// @details /// - Retrieves a pointer to the functions with the given name and defined /// in the given program. -/// - ::UR_RESULT_ERROR_INVALID_FUNCTION_NAME is returned if the function -/// can not be obtained. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE is returned if the +/// function can not be obtained. /// - The application may call this function from simultaneous threads for /// the same device. /// - The implementation of this function should be thread-safe. @@ -2770,6 +2770,10 @@ ur_result_t UR_APICALL urProgramRelease( /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == pFunctionName` /// + `NULL == ppFunctionPointer` +/// - ::UR_RESULT_ERROR_INVALID_KERNEL_NAME +/// + If `pFunctionName` couldn't be found in `hProgram`. +/// - ::UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE +/// + If `pFunctionName` could be located, but its address couldn't be retrieved. ur_result_t UR_APICALL urProgramGetFunctionPointer( ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve pointer for. diff --git a/test/conformance/program/program_adapter_level_zero.match b/test/conformance/program/program_adapter_level_zero.match index 5bbdfd554c..9e902dca94 100644 --- a/test/conformance/program/program_adapter_level_zero.match +++ b/test/conformance/program/program_adapter_level_zero.match @@ -2,5 +2,5 @@ urProgramCreateWithNativeHandleTest.Success/Intel_R__oneAPI_Unified_Runtime_over urProgramCreateWithNativeHandleTest.InvalidNullHandleContext/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urProgramCreateWithNativeHandleTest.InvalidNullPointerProgram/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ urProgramGetBuildInfoTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_UR_PROGRAM_BUILD_INFO_STATUS -urProgramGetFunctionPointerTest.InvalidFunctionName/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ +urProgramGetFunctionPointerTest.InvalidKernelName/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_ Aborted diff --git a/test/conformance/program/program_adapter_native_cpu.match b/test/conformance/program/program_adapter_native_cpu.match index 9a5b0a9830..1c43238671 100644 --- a/test/conformance/program/program_adapter_native_cpu.match +++ b/test/conformance/program/program_adapter_native_cpu.match @@ -42,7 +42,7 @@ {{OPT}}urProgramGetBuildInfoTest.InvalidEnumeration/SYCL_NATIVE_CPU___SYCL_Native_CPU___UR_PROGRAM_BUILD_INFO_BINARY_TYPE {{OPT}}urProgramGetBuildInfoSingleTest.LogIsNullTerminated/SYCL_NATIVE_CPU___SYCL_Native_CPU_ {{OPT}}urProgramGetFunctionPointerTest.Success/SYCL_NATIVE_CPU___SYCL_Native_CPU_ -{{OPT}}urProgramGetFunctionPointerTest.InvalidFunctionName/SYCL_NATIVE_CPU___SYCL_Native_CPU_ +{{OPT}}urProgramGetFunctionPointerTest.InvalidKernelName/SYCL_NATIVE_CPU___SYCL_Native_CPU_ {{OPT}}urProgramGetFunctionPointerTest.InvalidNullHandleDevice/SYCL_NATIVE_CPU___SYCL_Native_CPU_ {{OPT}}urProgramGetFunctionPointerTest.InvalidNullHandleProgram/SYCL_NATIVE_CPU___SYCL_Native_CPU_ {{OPT}}urProgramGetFunctionPointerTest.InvalidNullPointerFunctionName/SYCL_NATIVE_CPU___SYCL_Native_CPU_ diff --git a/test/conformance/program/program_adapter_opencl.match b/test/conformance/program/program_adapter_opencl.match index 2c596d966d..a4b56d4f94 100644 --- a/test/conformance/program/program_adapter_opencl.match +++ b/test/conformance/program/program_adapter_opencl.match @@ -1,3 +1,2 @@ urProgramCreateWithILTest.BuildInvalidProgram/Intel_R__OpenCL___{{.*}}_ -urProgramGetFunctionPointerTest.InvalidFunctionName/Intel_R__OpenCL___{{.*}}_ urProgramGetInfoTest.Success/Intel_R__OpenCL___{{.*}}___UR_PROGRAM_INFO_SOURCE diff --git a/test/conformance/program/urProgramGetFunctionPointer.cpp b/test/conformance/program/urProgramGetFunctionPointer.cpp index 3eb00b991f..00f5ad74e0 100644 --- a/test/conformance/program/urProgramGetFunctionPointer.cpp +++ b/test/conformance/program/urProgramGetFunctionPointer.cpp @@ -26,10 +26,10 @@ TEST_P(urProgramGetFunctionPointerTest, Success) { ASSERT_NE(function_pointer, nullptr); } -TEST_P(urProgramGetFunctionPointerTest, InvalidFunctionName) { +TEST_P(urProgramGetFunctionPointerTest, InvalidKernelName) { void *function_pointer = nullptr; std::string missing_function = "aFakeFunctionName"; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_FUNCTION_NAME, + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_KERNEL_NAME, urProgramGetFunctionPointer(device, program, missing_function.data(), &function_pointer)); diff --git a/test/conformance/program/urProgramGetInfo.cpp b/test/conformance/program/urProgramGetInfo.cpp index 2097b2c797..c9cdb7b066 100644 --- a/test/conformance/program/urProgramGetInfo.cpp +++ b/test/conformance/program/urProgramGetInfo.cpp @@ -52,8 +52,8 @@ TEST_P(urProgramGetInfoTest, Success) { sizeof(binaries[0]), binaries, nullptr)); } else { - ASSERT_SUCCESS( - urProgramGetInfo(program, property_name, 0, nullptr, &property_size)); + ASSERT_SUCCESS(urProgramGetInfo(program, property_name, 0, nullptr, + &property_size)); property_value.resize(property_size); ASSERT_SUCCESS(urProgramGetInfo(program, property_name, property_size, property_value.data(), nullptr)); From 8e51a5dbba3f8cdb7063538ba87ae874beba139e Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Mon, 24 Jun 2024 16:48:19 +0100 Subject: [PATCH 8/9] Fix hip conflict wrt KERNEL_INFO_NUM_ARGS --- source/adapters/hip/kernel.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/adapters/hip/kernel.hpp b/source/adapters/hip/kernel.hpp index 1c84269a6a..afea69832b 100644 --- a/source/adapters/hip/kernel.hpp +++ b/source/adapters/hip/kernel.hpp @@ -201,7 +201,7 @@ struct ur_kernel_handle_t_ { /// offset. Note this only returns the current known number of arguments, /// not the real one required by the kernel, since this cannot be queried /// from the HIP Driver API - size_t getNumArgs() const noexcept { return Args.Indices.size() - 1; } + uint32_t getNumArgs() const noexcept { return Args.Indices.size() - 1; } void setKernelArg(int Index, size_t Size, const void *Arg) { Args.addArg(Index, Size, Arg); From 2f121cd8277b9caabe748cd67787589dd4abf219 Mon Sep 17 00:00:00 2001 From: Aaron Greig Date: Tue, 25 Jun 2024 10:19:35 +0100 Subject: [PATCH 9/9] Fix missed size_t kernel num args in sanitizer layer. --- source/loader/layers/sanitizer/ur_sanitizer_utils.cpp | 4 ++-- source/loader/layers/sanitizer/ur_sanitizer_utils.hpp | 2 +- test/conformance/kernel/kernel_adapter_opencl.match | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp b/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp index 3af2669f21..90dc435d84 100644 --- a/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp +++ b/source/loader/layers/sanitizer/ur_sanitizer_utils.cpp @@ -149,8 +149,8 @@ std::vector GetProgramDevices(ur_program_handle_t Program) { return Devices; } -size_t GetKernelNumArgs(ur_kernel_handle_t Kernel) { - size_t NumArgs = 0; +uint32_t GetKernelNumArgs(ur_kernel_handle_t Kernel) { + uint32_t NumArgs = 0; [[maybe_unused]] auto Res = context.urDdiTable.Kernel.pfnGetInfo( Kernel, UR_KERNEL_INFO_NUM_ARGS, sizeof(NumArgs), &NumArgs, nullptr); assert(Res == UR_RESULT_SUCCESS); diff --git a/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp b/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp index 199a0cd2cb..d53b83ea40 100644 --- a/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp +++ b/source/loader/layers/sanitizer/ur_sanitizer_utils.hpp @@ -41,7 +41,7 @@ ur_program_handle_t GetProgram(ur_kernel_handle_t Kernel); std::vector GetProgramDevices(ur_program_handle_t Program); ur_device_handle_t GetUSMAllocDevice(ur_context_handle_t Context, const void *MemPtr); -size_t GetKernelNumArgs(ur_kernel_handle_t Kernel); +uint32_t GetKernelNumArgs(ur_kernel_handle_t Kernel); size_t GetKernelLocalMemorySize(ur_kernel_handle_t Kernel, ur_device_handle_t Device); size_t GetKernelPrivateMemorySize(ur_kernel_handle_t Kernel, diff --git a/test/conformance/kernel/kernel_adapter_opencl.match b/test/conformance/kernel/kernel_adapter_opencl.match index e69de29bb2..dfc23cf5ee 100644 --- a/test/conformance/kernel/kernel_adapter_opencl.match +++ b/test/conformance/kernel/kernel_adapter_opencl.match @@ -0,0 +1 @@ +urKernelGetInfoTest.Success/Intel_R__OpenCL_{{.*}}_UR_KERNEL_INFO_NUM_REGS