From d41108aa140269ee846bcd78c6404d61194c6166 Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Fri, 7 Apr 2023 14:55:01 -0700 Subject: [PATCH 1/3] Expand urContextGetNativeHandle Add needed members for PI: NumDevices Devices OwnNativeHandle Signed-off-by: Jaime Arteaga --- include/ur.py | 17 +++++- include/ur_api.h | 25 ++++++++- include/ur_ddi.h | 3 ++ scripts/core/common.yml | 2 + scripts/core/context.yml | 22 ++++++++ source/common/ur_params.hpp | 53 +++++++++++++++++++ source/drivers/null/ur_nullddi.cpp | 11 +++- source/loader/layers/tracing/ur_trcddi.cpp | 15 ++++-- source/loader/layers/validation/ur_valddi.cpp | 18 ++++++- source/loader/ur_ldrddi.cpp | 18 ++++++- source/loader/ur_libapi.cpp | 12 ++++- source/ur_api.cpp | 9 +++- .../urContextCreateWithNativeHandle.cpp | 6 ++- .../context/urContextGetNativeHandle.cpp | 4 +- 14 files changed, 195 insertions(+), 20 deletions(-) diff --git a/include/ur.py b/include/ur.py index 0a6279e796..692cbc53d9 100644 --- a/include/ur.py +++ b/include/ur.py @@ -215,6 +215,7 @@ class ur_structure_type_v(IntEnum): SAMPLER_DESC = 13 ## ::ur_sampler_desc_t QUEUE_PROPERTIES = 14 ## ::ur_queue_properties_t QUEUE_INDEX_PROPERTIES = 15 ## ::ur_queue_properties_t + CONTEXT_NATIVE_DESC = 16 ## ::ur_context_native_desc_t class ur_structure_type_t(c_int): def __str__(self): @@ -706,6 +707,18 @@ def __str__(self): return str(ur_context_info_v(self.value)) +############################################################################### +## @brief Descriptor for ::urContextCreateWithNativeHandle. +class ur_context_native_desc_t(Structure): + _fields_ = [ + ("stype", ur_structure_type_t), ## [in] type of this structure, must be + ## ::UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC + ("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure + ("isNativeHandleOwned", c_bool) ## [in] Indicates UR owns the native handle or if it came from an interoperability + ## operation in the application that asked to not transfer the ownership to + ## the unified-runtime. + ] + ############################################################################### ## @brief Context's extended deleter callback function with user data. def ur_context_extended_deleter_t(user_defined_callback): @@ -1715,9 +1728,9 @@ class ur_platform_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urContextCreateWithNativeHandle if __use_win_types: - _urContextCreateWithNativeHandle_t = WINFUNCTYPE( ur_result_t, ur_native_handle_t, POINTER(ur_context_handle_t) ) + _urContextCreateWithNativeHandle_t = WINFUNCTYPE( ur_result_t, ur_native_handle_t, c_ulong, POINTER(ur_device_handle_t), POINTER(ur_context_native_desc_t), POINTER(ur_context_handle_t) ) else: - _urContextCreateWithNativeHandle_t = CFUNCTYPE( ur_result_t, ur_native_handle_t, POINTER(ur_context_handle_t) ) + _urContextCreateWithNativeHandle_t = CFUNCTYPE( ur_result_t, ur_native_handle_t, c_ulong, POINTER(ur_device_handle_t), POINTER(ur_context_native_desc_t), POINTER(ur_context_handle_t) ) ############################################################################### ## @brief Function-pointer for urContextSetExtendedDeleter diff --git a/include/ur_api.h b/include/ur_api.h index 61027ff8f4..4d126f1e31 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -239,6 +239,7 @@ typedef enum ur_structure_type_t { UR_STRUCTURE_TYPE_SAMPLER_DESC = 13, ///< ::ur_sampler_desc_t UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 14, ///< ::ur_queue_properties_t UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 15, ///< ::ur_queue_properties_t + UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC = 16, ///< ::ur_context_native_desc_t /// @cond UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -1456,6 +1457,18 @@ urContextGetNativeHandle( ur_native_handle_t *phNativeContext ///< [out] a pointer to the native handle of the context. ); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Descriptor for ::urContextCreateWithNativeHandle. +typedef struct ur_context_native_desc_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC + const void *pNext; ///< [in][optional] pointer to extension-specific structure + bool isNativeHandleOwned; ///< [in] Indicates UR owns the native handle or if it came from an interoperability + ///< operation in the application that asked to not transfer the ownership to + ///< the unified-runtime. + +} ur_context_native_desc_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Create runtime context object from native context handle. /// @@ -1472,11 +1485,16 @@ urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phDevices` +/// + `NULL == pContextNativeDesc` /// + `NULL == phContext` UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle( - ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. - ur_context_handle_t *phContext ///< [out] pointer to the handle of the context object created. + ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_desc_t *pContextNativeDesc, ///< [in] pointer to descriptor + ur_context_handle_t *phContext ///< [out] pointer to the handle of the context object created. ); /////////////////////////////////////////////////////////////////////////////// @@ -5732,6 +5750,9 @@ typedef void(UR_APICALL *ur_pfnContextGetNativeHandleCb_t)( /// allowing the callback the ability to modify the parameter's value typedef struct ur_context_create_with_native_handle_params_t { ur_native_handle_t *phNativeContext; + uint32_t *pnumDevices; + const ur_device_handle_t **pphDevices; + const ur_context_native_desc_t **ppContextNativeDesc; ur_context_handle_t **pphContext; } ur_context_create_with_native_handle_params_t; diff --git a/include/ur_ddi.h b/include/ur_ddi.h index 12f522080d..da19b0d399 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -129,6 +129,9 @@ typedef ur_result_t(UR_APICALL *ur_pfnContextGetNativeHandle_t)( /// @brief Function-pointer for urContextCreateWithNativeHandle typedef ur_result_t(UR_APICALL *ur_pfnContextCreateWithNativeHandle_t)( ur_native_handle_t, + uint32_t, + const ur_device_handle_t *, + const ur_context_native_desc_t *, ur_context_handle_t *); /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/common.yml b/scripts/core/common.yml index e14e01d200..d12c1addda 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -294,6 +294,8 @@ etors: desc: $x_queue_properties_t - name: QUEUE_INDEX_PROPERTIES desc: $x_queue_properties_t + - name: CONTEXT_NATIVE_DESC + desc: $x_context_native_desc_t --- #-------------------------------------------------------------------------- type: struct desc: "Base for all properties types" diff --git a/scripts/core/context.yml b/scripts/core/context.yml index 78d6e1b91d..93a00320d4 100644 --- a/scripts/core/context.yml +++ b/scripts/core/context.yml @@ -183,6 +183,19 @@ params: desc: | [out] a pointer to the native handle of the context. --- #-------------------------------------------------------------------------- +type: struct +desc: "Descriptor for $xContextCreateWithNativeHandle." +class: $xContext +name: $x_context_native_desc_t +base: $x_base_desc_t +members: + - type: bool + name: isNativeHandleOwned + desc: | + [in] Indicates UR owns the native handle or if it came from an interoperability + operation in the application that asked to not transfer the ownership to + the unified-runtime. +--- #-------------------------------------------------------------------------- type: function desc: "Create runtime context object from native context handle." class: $xContext @@ -198,6 +211,15 @@ params: name: hNativeContext desc: | [in] the native handle of the context. + - type: uint32_t + name: numDevices + desc: "[in] number of devices associated with the context" + - type: "const $x_device_handle_t*" + name: phDevices + desc: "[in][range(0, numDevices)] list of devices associated with the context" + - type: "const $x_context_native_desc_t*" + name: pContextNativeDesc + desc: "[in] pointer to descriptor" - type: "$x_context_handle_t*" name: phContext desc: | diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 9e3141b84f..844b44822b 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -605,6 +605,10 @@ inline std::ostream &operator<<(std::ostream &os, case UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES: os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; break; + + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC: + os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC"; + break; default: os << "unknown enumerator"; break; @@ -708,6 +712,12 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { (const ur_queue_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; + + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC: { + const ur_context_native_desc_t *pstruct = + (const ur_context_native_desc_t *)ptr; + ur_params::serializePtr(os, pstruct); + } break; default: os << "unknown enumerator"; break; @@ -3747,6 +3757,27 @@ inline void serializeTaggedTyped_ur_context_info_t(std::ostream &os, } } } // namespace ur_params +inline std::ostream &operator<<(std::ostream &os, + const struct ur_context_native_desc_t params) { + os << "(struct ur_context_native_desc_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur_params::serializeStruct(os, (params.pNext)); + + os << ", "; + os << ".isNativeHandleOwned = "; + + os << (params.isNativeHandleOwned); + + os << "}"; + return os; +} inline std::ostream &operator<<(std::ostream &os, enum ur_mem_flag_t value) { switch (value) { @@ -7515,6 +7546,28 @@ operator<<(std::ostream &os, ur_params::serializePtr(os, *(params->phNativeContext)); + os << ", "; + os << ".numDevices = "; + + os << *(params->pnumDevices); + + os << ", "; + os << ".phDevices = ["; + for (size_t i = 0; + *(params->pphDevices) != NULL && i < *params->pnumDevices; ++i) { + if (i != 0) { + os << ", "; + } + + ur_params::serializePtr(os, (*(params->pphDevices))[i]); + } + os << "]"; + + os << ", "; + os << ".pContextNativeDesc = "; + + ur_params::serializePtr(os, *(params->ppContextNativeDesc)); + os << ", "; os << ".phContext = "; diff --git a/source/drivers/null/ur_nullddi.cpp b/source/drivers/null/ur_nullddi.cpp index e594323845..6ec6cc942b 100644 --- a/source/drivers/null/ur_nullddi.cpp +++ b/source/drivers/null/ur_nullddi.cpp @@ -570,7 +570,12 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t * + phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_desc_t + *pContextNativeDesc, ///< [in] pointer to descriptor ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -580,7 +585,9 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( auto pfnCreateWithNativeHandle = d_context.urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr != pfnCreateWithNativeHandle) { - result = pfnCreateWithNativeHandle(hNativeContext, phContext); + result = + pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, + pContextNativeDesc, phContext); } else { // generic implementation *phContext = reinterpret_cast(d_context.get()); diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index 1ecc61b894..9ca4346a2c 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -694,7 +694,12 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t * + phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_desc_t + *pContextNativeDesc, ///< [in] pointer to descriptor ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -705,13 +710,15 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } - ur_context_create_with_native_handle_params_t params = {&hNativeContext, - &phContext}; + ur_context_create_with_native_handle_params_t params = { + &hNativeContext, &numDevices, &phDevices, &pContextNativeDesc, + &phContext}; uint64_t instance = context.notify_begin(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, "urContextCreateWithNativeHandle", ¶ms); - ur_result_t result = pfnCreateWithNativeHandle(hNativeContext, phContext); + ur_result_t result = pfnCreateWithNativeHandle( + hNativeContext, numDevices, phDevices, pContextNativeDesc, phContext); context.notify_end(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, "urContextCreateWithNativeHandle", ¶ms, &result, diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 8c6c18f462..b1ff92769f 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -747,7 +747,12 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t * + phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_desc_t + *pContextNativeDesc, ///< [in] pointer to descriptor ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -763,12 +768,21 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( return UR_RESULT_ERROR_INVALID_NULL_HANDLE; } + if (NULL == phDevices) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + + if (NULL == pContextNativeDesc) { + return UR_RESULT_ERROR_INVALID_NULL_POINTER; + } + if (NULL == phContext) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } } - ur_result_t result = pfnCreateWithNativeHandle(hNativeContext, phContext); + ur_result_t result = pfnCreateWithNativeHandle( + hNativeContext, numDevices, phDevices, pContextNativeDesc, phContext); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phContext); diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 4881567567..1923fbc92c 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -821,7 +821,12 @@ __urdlllocal ur_result_t UR_APICALL urContextGetNativeHandle( /// @brief Intercept function for urContextCreateWithNativeHandle __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t * + phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_desc_t + *pContextNativeDesc, ///< [in] pointer to descriptor ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -840,8 +845,17 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( hNativeContext = reinterpret_cast(hNativeContext)->handle; + // convert loader handles to platform handles + auto phDevicesLocal = new ur_device_handle_t[numDevices]; + for (size_t i = 0; (nullptr != phDevices) && (i < numDevices); ++i) { + phDevicesLocal[i] = + reinterpret_cast(phDevices[i])->handle; + } + // forward to device-platform - result = pfnCreateWithNativeHandle(hNativeContext, phContext); + result = pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, + pContextNativeDesc, phContext); + delete[] phDevicesLocal; if (UR_RESULT_SUCCESS != result) { return result; diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 727c96fb9f..d3d6109285 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -881,10 +881,17 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phDevices` +/// + `NULL == pContextNativeDesc` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t * + phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_desc_t + *pContextNativeDesc, ///< [in] pointer to descriptor ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -894,7 +901,8 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( return UR_RESULT_ERROR_UNINITIALIZED; } - return pfnCreateWithNativeHandle(hNativeContext, phContext); + return pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, + pContextNativeDesc, phContext); } /////////////////////////////////////////////////////////////////////////////// diff --git a/source/ur_api.cpp b/source/ur_api.cpp index f47ecfbfd1..f993e7e37c 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -768,10 +768,17 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER +/// + `NULL == phDevices` +/// + `NULL == pContextNativeDesc` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t - hNativeContext, ///< [in] the native handle of the context. + hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t * + phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_desc_t + *pContextNativeDesc, ///< [in] pointer to descriptor ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { diff --git a/test/conformance/context/urContextCreateWithNativeHandle.cpp b/test/conformance/context/urContextCreateWithNativeHandle.cpp index d2802996e0..8059083218 100644 --- a/test/conformance/context/urContextCreateWithNativeHandle.cpp +++ b/test/conformance/context/urContextCreateWithNativeHandle.cpp @@ -9,6 +9,8 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest); TEST_P(urContextCreateWithNativeHandleTest, InvalidNullHandleNativeHandle) { ur_context_handle_t context = nullptr; - ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urContextCreateWithNativeHandle(nullptr, &context)); + ur_context_native_desc_t desc{}; + ASSERT_EQ_RESULT( + UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urContextCreateWithNativeHandle(nullptr, 0u, nullptr, &desc, &context)); } diff --git a/test/conformance/context/urContextGetNativeHandle.cpp b/test/conformance/context/urContextGetNativeHandle.cpp index 1254291de6..0f74a09692 100644 --- a/test/conformance/context/urContextGetNativeHandle.cpp +++ b/test/conformance/context/urContextGetNativeHandle.cpp @@ -16,7 +16,9 @@ TEST_P(urContextGetNativeHandleTest, Success) { // We can however convert the native_handle back into a unified-runtime handle // and perform some query on it to verify that it works. ur_context_handle_t ctx = nullptr; - ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, &ctx)); + ur_context_native_desc_t desc{}; + ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, 0, nullptr, + &desc, &ctx)); ASSERT_NE(ctx, nullptr); uint32_t n_devices = 0; From a12d475e0f8b962d41cec955459a4130c9eee26a Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Wed, 12 Apr 2023 09:45:19 -0700 Subject: [PATCH 2/3] Change from desc to properties Signed-off-by: Jaime Arteaga --- include/ur.py | 14 +++++----- include/ur_api.h | 26 +++++++++---------- include/ur_ddi.h | 2 +- scripts/core/common.yml | 4 +-- scripts/core/context.yml | 12 ++++----- source/common/ur_params.hpp | 24 ++++++++++------- source/drivers/null/ur_nullddi.cpp | 6 ++--- source/loader/layers/tracing/ur_trcddi.cpp | 11 ++++---- source/loader/layers/validation/ur_valddi.cpp | 11 ++++---- source/loader/ur_ldrddi.cpp | 6 ++--- source/loader/ur_libapi.cpp | 8 +++--- source/ur_api.cpp | 6 ++--- .../urContextCreateWithNativeHandle.cpp | 8 +++--- .../context/urContextGetNativeHandle.cpp | 4 +-- 14 files changed, 74 insertions(+), 68 deletions(-) diff --git a/include/ur.py b/include/ur.py index 692cbc53d9..01f4821f87 100644 --- a/include/ur.py +++ b/include/ur.py @@ -215,7 +215,7 @@ class ur_structure_type_v(IntEnum): SAMPLER_DESC = 13 ## ::ur_sampler_desc_t QUEUE_PROPERTIES = 14 ## ::ur_queue_properties_t QUEUE_INDEX_PROPERTIES = 15 ## ::ur_queue_properties_t - CONTEXT_NATIVE_DESC = 16 ## ::ur_context_native_desc_t + CONTEXT_NATIVE_PROPERTIES = 16 ## ::ur_context_native_properties_t class ur_structure_type_t(c_int): def __str__(self): @@ -708,12 +708,12 @@ def __str__(self): ############################################################################### -## @brief Descriptor for ::urContextCreateWithNativeHandle. -class ur_context_native_desc_t(Structure): +## @brief Properties for for ::urContextCreateWithNativeHandle. +class ur_context_native_properties_t(Structure): _fields_ = [ ("stype", ur_structure_type_t), ## [in] type of this structure, must be - ## ::UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC - ("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure + ## ::UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES + ("pNext", c_void_p), ## [in,out][optional] pointer to extension-specific structure ("isNativeHandleOwned", c_bool) ## [in] Indicates UR owns the native handle or if it came from an interoperability ## operation in the application that asked to not transfer the ownership to ## the unified-runtime. @@ -1728,9 +1728,9 @@ class ur_platform_dditable_t(Structure): ############################################################################### ## @brief Function-pointer for urContextCreateWithNativeHandle if __use_win_types: - _urContextCreateWithNativeHandle_t = WINFUNCTYPE( ur_result_t, ur_native_handle_t, c_ulong, POINTER(ur_device_handle_t), POINTER(ur_context_native_desc_t), POINTER(ur_context_handle_t) ) + _urContextCreateWithNativeHandle_t = WINFUNCTYPE( ur_result_t, ur_native_handle_t, c_ulong, POINTER(ur_device_handle_t), POINTER(ur_context_native_properties_t), POINTER(ur_context_handle_t) ) else: - _urContextCreateWithNativeHandle_t = CFUNCTYPE( ur_result_t, ur_native_handle_t, c_ulong, POINTER(ur_device_handle_t), POINTER(ur_context_native_desc_t), POINTER(ur_context_handle_t) ) + _urContextCreateWithNativeHandle_t = CFUNCTYPE( ur_result_t, ur_native_handle_t, c_ulong, POINTER(ur_device_handle_t), POINTER(ur_context_native_properties_t), POINTER(ur_context_handle_t) ) ############################################################################### ## @brief Function-pointer for urContextSetExtendedDeleter diff --git a/include/ur_api.h b/include/ur_api.h index 4d126f1e31..234f6a6a9a 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -239,7 +239,7 @@ typedef enum ur_structure_type_t { UR_STRUCTURE_TYPE_SAMPLER_DESC = 13, ///< ::ur_sampler_desc_t UR_STRUCTURE_TYPE_QUEUE_PROPERTIES = 14, ///< ::ur_queue_properties_t UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES = 15, ///< ::ur_queue_properties_t - UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC = 16, ///< ::ur_context_native_desc_t + UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES = 16, ///< ::ur_context_native_properties_t /// @cond UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -1458,16 +1458,16 @@ urContextGetNativeHandle( ); /////////////////////////////////////////////////////////////////////////////// -/// @brief Descriptor for ::urContextCreateWithNativeHandle. -typedef struct ur_context_native_desc_t { +/// @brief Properties for for ::urContextCreateWithNativeHandle. +typedef struct ur_context_native_properties_t { ur_structure_type_t stype; ///< [in] type of this structure, must be - ///< ::UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC - const void *pNext; ///< [in][optional] pointer to extension-specific structure + ///< ::UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES + void *pNext; ///< [in,out][optional] pointer to extension-specific structure bool isNativeHandleOwned; ///< [in] Indicates UR owns the native handle or if it came from an interoperability ///< operation in the application that asked to not transfer the ownership to ///< the unified-runtime. -} ur_context_native_desc_t; +} ur_context_native_properties_t; /////////////////////////////////////////////////////////////////////////////// /// @brief Create runtime context object from native context handle. @@ -1486,15 +1486,15 @@ typedef struct ur_context_native_desc_t { /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` -/// + `NULL == pContextNativeDesc` +/// + `NULL == pContextNativeProperties` /// + `NULL == phContext` UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle( - ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. - uint32_t numDevices, ///< [in] number of devices associated with the context - const ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_desc_t *pContextNativeDesc, ///< [in] pointer to descriptor - ur_context_handle_t *phContext ///< [out] pointer to the handle of the context object created. + ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_properties_t *pContextNativeProperties, ///< [in] pointer to properties struct + ur_context_handle_t *phContext ///< [out] pointer to the handle of the context object created. ); /////////////////////////////////////////////////////////////////////////////// @@ -5752,7 +5752,7 @@ typedef struct ur_context_create_with_native_handle_params_t { ur_native_handle_t *phNativeContext; uint32_t *pnumDevices; const ur_device_handle_t **pphDevices; - const ur_context_native_desc_t **ppContextNativeDesc; + const ur_context_native_properties_t **ppContextNativeProperties; ur_context_handle_t **pphContext; } ur_context_create_with_native_handle_params_t; diff --git a/include/ur_ddi.h b/include/ur_ddi.h index da19b0d399..38ecfcbf10 100644 --- a/include/ur_ddi.h +++ b/include/ur_ddi.h @@ -131,7 +131,7 @@ typedef ur_result_t(UR_APICALL *ur_pfnContextCreateWithNativeHandle_t)( ur_native_handle_t, uint32_t, const ur_device_handle_t *, - const ur_context_native_desc_t *, + const ur_context_native_properties_t *, ur_context_handle_t *); /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/common.yml b/scripts/core/common.yml index d12c1addda..072b2971c1 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -294,8 +294,8 @@ etors: desc: $x_queue_properties_t - name: QUEUE_INDEX_PROPERTIES desc: $x_queue_properties_t - - name: CONTEXT_NATIVE_DESC - desc: $x_context_native_desc_t + - name: CONTEXT_NATIVE_PROPERTIES + desc: $x_context_native_properties_t --- #-------------------------------------------------------------------------- type: struct desc: "Base for all properties types" diff --git a/scripts/core/context.yml b/scripts/core/context.yml index 93a00320d4..aa11a1172d 100644 --- a/scripts/core/context.yml +++ b/scripts/core/context.yml @@ -184,10 +184,10 @@ params: [out] a pointer to the native handle of the context. --- #-------------------------------------------------------------------------- type: struct -desc: "Descriptor for $xContextCreateWithNativeHandle." +desc: "Properties for for $xContextCreateWithNativeHandle." class: $xContext -name: $x_context_native_desc_t -base: $x_base_desc_t +name: $x_context_native_properties_t +base: $x_base_properties_t members: - type: bool name: isNativeHandleOwned @@ -217,9 +217,9 @@ params: - type: "const $x_device_handle_t*" name: phDevices desc: "[in][range(0, numDevices)] list of devices associated with the context" - - type: "const $x_context_native_desc_t*" - name: pContextNativeDesc - desc: "[in] pointer to descriptor" + - type: "const $x_context_native_properties_t*" + name: pContextNativeProperties + desc: "[in] pointer to properties struct" - type: "$x_context_handle_t*" name: phContext desc: | diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 844b44822b..1b9482a80d 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -156,6 +156,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_context_flag_t value); inline std::ostream &operator<<(std::ostream &os, const struct ur_context_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_context_info_t value); +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_context_native_properties_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_mem_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_mem_type_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_mem_info_t value); @@ -606,8 +609,8 @@ inline std::ostream &operator<<(std::ostream &os, os << "UR_STRUCTURE_TYPE_QUEUE_INDEX_PROPERTIES"; break; - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC: - os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC"; + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: + os << "UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES"; break; default: os << "unknown enumerator"; @@ -713,9 +716,9 @@ inline void serializeStruct(std::ostream &os, const void *ptr) { ur_params::serializePtr(os, pstruct); } break; - case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_DESC: { - const ur_context_native_desc_t *pstruct = - (const ur_context_native_desc_t *)ptr; + case UR_STRUCTURE_TYPE_CONTEXT_NATIVE_PROPERTIES: { + const ur_context_native_properties_t *pstruct = + (const ur_context_native_properties_t *)ptr; ur_params::serializePtr(os, pstruct); } break; default: @@ -3757,9 +3760,10 @@ inline void serializeTaggedTyped_ur_context_info_t(std::ostream &os, } } } // namespace ur_params -inline std::ostream &operator<<(std::ostream &os, - const struct ur_context_native_desc_t params) { - os << "(struct ur_context_native_desc_t){"; +inline std::ostream & +operator<<(std::ostream &os, + const struct ur_context_native_properties_t params) { + os << "(struct ur_context_native_properties_t){"; os << ".stype = "; @@ -7564,9 +7568,9 @@ operator<<(std::ostream &os, os << "]"; os << ", "; - os << ".pContextNativeDesc = "; + os << ".pContextNativeProperties = "; - ur_params::serializePtr(os, *(params->ppContextNativeDesc)); + ur_params::serializePtr(os, *(params->ppContextNativeProperties)); os << ", "; os << ".phContext = "; diff --git a/source/drivers/null/ur_nullddi.cpp b/source/drivers/null/ur_nullddi.cpp index 6ec6cc942b..1484d9ad0e 100644 --- a/source/drivers/null/ur_nullddi.cpp +++ b/source/drivers/null/ur_nullddi.cpp @@ -574,8 +574,8 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_desc_t - *pContextNativeDesc, ///< [in] pointer to descriptor + const ur_context_native_properties_t + *pContextNativeProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -587,7 +587,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( if (nullptr != pfnCreateWithNativeHandle) { result = pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeDesc, phContext); + pContextNativeProperties, phContext); } else { // generic implementation *phContext = reinterpret_cast(d_context.get()); diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index 9ca4346a2c..df3893061b 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -698,8 +698,8 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_desc_t - *pContextNativeDesc, ///< [in] pointer to descriptor + const ur_context_native_properties_t + *pContextNativeProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -711,14 +711,15 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( } ur_context_create_with_native_handle_params_t params = { - &hNativeContext, &numDevices, &phDevices, &pContextNativeDesc, + &hNativeContext, &numDevices, &phDevices, &pContextNativeProperties, &phContext}; uint64_t instance = context.notify_begin(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, "urContextCreateWithNativeHandle", ¶ms); - ur_result_t result = pfnCreateWithNativeHandle( - hNativeContext, numDevices, phDevices, pContextNativeDesc, phContext); + ur_result_t result = + pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, + pContextNativeProperties, phContext); context.notify_end(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, "urContextCreateWithNativeHandle", ¶ms, &result, diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index b1ff92769f..0a225e3067 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -751,8 +751,8 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_desc_t - *pContextNativeDesc, ///< [in] pointer to descriptor + const ur_context_native_properties_t + *pContextNativeProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -772,7 +772,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (NULL == pContextNativeDesc) { + if (NULL == pContextNativeProperties) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -781,8 +781,9 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( } } - ur_result_t result = pfnCreateWithNativeHandle( - hNativeContext, numDevices, phDevices, pContextNativeDesc, phContext); + ur_result_t result = + pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, + pContextNativeProperties, phContext); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phContext); diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index 1923fbc92c..e77e462a65 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -825,8 +825,8 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_desc_t - *pContextNativeDesc, ///< [in] pointer to descriptor + const ur_context_native_properties_t + *pContextNativeProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -854,7 +854,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( // forward to device-platform result = pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeDesc, phContext); + pContextNativeProperties, phContext); delete[] phDevicesLocal; if (UR_RESULT_SUCCESS != result) { diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index d3d6109285..55a30a9924 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -882,7 +882,7 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` -/// + `NULL == pContextNativeDesc` +/// + `NULL == pContextNativeProperties` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t @@ -890,8 +890,8 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_desc_t - *pContextNativeDesc, ///< [in] pointer to descriptor + const ur_context_native_properties_t + *pContextNativeProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -902,7 +902,7 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( } return pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeDesc, phContext); + pContextNativeProperties, phContext); } /////////////////////////////////////////////////////////////////////////////// diff --git a/source/ur_api.cpp b/source/ur_api.cpp index f993e7e37c..e04ad0285d 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -769,7 +769,7 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` -/// + `NULL == pContextNativeDesc` +/// + `NULL == pContextNativeProperties` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t @@ -777,8 +777,8 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( uint32_t numDevices, ///< [in] number of devices associated with the context const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_desc_t - *pContextNativeDesc, ///< [in] pointer to descriptor + const ur_context_native_properties_t + *pContextNativeProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { diff --git a/test/conformance/context/urContextCreateWithNativeHandle.cpp b/test/conformance/context/urContextCreateWithNativeHandle.cpp index 8059083218..04cc7f04fd 100644 --- a/test/conformance/context/urContextCreateWithNativeHandle.cpp +++ b/test/conformance/context/urContextCreateWithNativeHandle.cpp @@ -9,8 +9,8 @@ UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urContextCreateWithNativeHandleTest); TEST_P(urContextCreateWithNativeHandleTest, InvalidNullHandleNativeHandle) { ur_context_handle_t context = nullptr; - ur_context_native_desc_t desc{}; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_NULL_HANDLE, - urContextCreateWithNativeHandle(nullptr, 0u, nullptr, &desc, &context)); + ur_context_native_properties_t props{}; + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE, + urContextCreateWithNativeHandle(nullptr, 0u, nullptr, + &props, &context)); } diff --git a/test/conformance/context/urContextGetNativeHandle.cpp b/test/conformance/context/urContextGetNativeHandle.cpp index 0f74a09692..f3801b4b7e 100644 --- a/test/conformance/context/urContextGetNativeHandle.cpp +++ b/test/conformance/context/urContextGetNativeHandle.cpp @@ -16,9 +16,9 @@ TEST_P(urContextGetNativeHandleTest, Success) { // We can however convert the native_handle back into a unified-runtime handle // and perform some query on it to verify that it works. ur_context_handle_t ctx = nullptr; - ur_context_native_desc_t desc{}; + ur_context_native_properties_t props{}; ASSERT_SUCCESS(urContextCreateWithNativeHandle(native_context, 0, nullptr, - &desc, &ctx)); + &props, &ctx)); ASSERT_NE(ctx, nullptr); uint32_t n_devices = 0; From 1cfe415577b8a71c6042ead217fd62e3cef4fe63 Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Tue, 18 Apr 2023 10:09:43 -0700 Subject: [PATCH 3/3] Address comments Signed-off-by: Jaime Arteaga --- include/ur_api.h | 14 +++++++------- scripts/core/context.yml | 2 +- source/common/ur_params.hpp | 4 ++-- source/drivers/null/ur_nullddi.cpp | 7 +++---- source/loader/layers/tracing/ur_trcddi.cpp | 10 ++++------ source/loader/layers/validation/ur_valddi.cpp | 9 ++++----- source/loader/ur_ldrddi.cpp | 4 ++-- source/loader/ur_libapi.cpp | 6 +++--- source/ur_api.cpp | 4 ++-- 9 files changed, 28 insertions(+), 32 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 234f6a6a9a..7f79226ddf 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -1486,15 +1486,15 @@ typedef struct ur_context_native_properties_t { /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` -/// + `NULL == pContextNativeProperties` +/// + `NULL == pProperties` /// + `NULL == phContext` UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle( - ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. - uint32_t numDevices, ///< [in] number of devices associated with the context - const ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context - const ur_context_native_properties_t *pContextNativeProperties, ///< [in] pointer to properties struct - ur_context_handle_t *phContext ///< [out] pointer to the handle of the context object created. + ur_native_handle_t hNativeContext, ///< [in] the native handle of the context. + uint32_t numDevices, ///< [in] number of devices associated with the context + const ur_device_handle_t *phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context + const ur_context_native_properties_t *pProperties, ///< [in] pointer to properties struct + ur_context_handle_t *phContext ///< [out] pointer to the handle of the context object created. ); /////////////////////////////////////////////////////////////////////////////// @@ -5752,7 +5752,7 @@ typedef struct ur_context_create_with_native_handle_params_t { ur_native_handle_t *phNativeContext; uint32_t *pnumDevices; const ur_device_handle_t **pphDevices; - const ur_context_native_properties_t **ppContextNativeProperties; + const ur_context_native_properties_t **ppProperties; ur_context_handle_t **pphContext; } ur_context_create_with_native_handle_params_t; diff --git a/scripts/core/context.yml b/scripts/core/context.yml index aa11a1172d..7712cdd6f3 100644 --- a/scripts/core/context.yml +++ b/scripts/core/context.yml @@ -218,7 +218,7 @@ params: name: phDevices desc: "[in][range(0, numDevices)] list of devices associated with the context" - type: "const $x_context_native_properties_t*" - name: pContextNativeProperties + name: pProperties desc: "[in] pointer to properties struct" - type: "$x_context_handle_t*" name: phContext diff --git a/source/common/ur_params.hpp b/source/common/ur_params.hpp index 1b9482a80d..5f03d208b5 100644 --- a/source/common/ur_params.hpp +++ b/source/common/ur_params.hpp @@ -7568,9 +7568,9 @@ operator<<(std::ostream &os, os << "]"; os << ", "; - os << ".pContextNativeProperties = "; + os << ".pProperties = "; - ur_params::serializePtr(os, *(params->ppContextNativeProperties)); + ur_params::serializePtr(os, *(params->ppProperties)); os << ", "; os << ".phContext = "; diff --git a/source/drivers/null/ur_nullddi.cpp b/source/drivers/null/ur_nullddi.cpp index 1484d9ad0e..5fc73b83f8 100644 --- a/source/drivers/null/ur_nullddi.cpp +++ b/source/drivers/null/ur_nullddi.cpp @@ -575,7 +575,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t - *pContextNativeProperties, ///< [in] pointer to properties struct + *pProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -585,9 +585,8 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( auto pfnCreateWithNativeHandle = d_context.urDdiTable.Context.pfnCreateWithNativeHandle; if (nullptr != pfnCreateWithNativeHandle) { - result = - pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeProperties, phContext); + result = pfnCreateWithNativeHandle(hNativeContext, numDevices, + phDevices, pProperties, phContext); } else { // generic implementation *phContext = reinterpret_cast(d_context.get()); diff --git a/source/loader/layers/tracing/ur_trcddi.cpp b/source/loader/layers/tracing/ur_trcddi.cpp index df3893061b..2fa0e00617 100644 --- a/source/loader/layers/tracing/ur_trcddi.cpp +++ b/source/loader/layers/tracing/ur_trcddi.cpp @@ -699,7 +699,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t - *pContextNativeProperties, ///< [in] pointer to properties struct + *pProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -711,15 +711,13 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( } ur_context_create_with_native_handle_params_t params = { - &hNativeContext, &numDevices, &phDevices, &pContextNativeProperties, - &phContext}; + &hNativeContext, &numDevices, &phDevices, &pProperties, &phContext}; uint64_t instance = context.notify_begin(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, "urContextCreateWithNativeHandle", ¶ms); - ur_result_t result = - pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeProperties, phContext); + ur_result_t result = pfnCreateWithNativeHandle( + hNativeContext, numDevices, phDevices, pProperties, phContext); context.notify_end(UR_FUNCTION_CONTEXT_CREATE_WITH_NATIVE_HANDLE, "urContextCreateWithNativeHandle", ¶ms, &result, diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 0a225e3067..5bb8b9f4b8 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -752,7 +752,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t - *pContextNativeProperties, ///< [in] pointer to properties struct + *pProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -772,7 +772,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (NULL == pContextNativeProperties) { + if (NULL == pProperties) { return UR_RESULT_ERROR_INVALID_NULL_POINTER; } @@ -781,9 +781,8 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( } } - ur_result_t result = - pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeProperties, phContext); + ur_result_t result = pfnCreateWithNativeHandle( + hNativeContext, numDevices, phDevices, pProperties, phContext); if (context.enableLeakChecking && result == UR_RESULT_SUCCESS) { refCountContext.createRefCount(*phContext); diff --git a/source/loader/ur_ldrddi.cpp b/source/loader/ur_ldrddi.cpp index e77e462a65..b449f49fa5 100644 --- a/source/loader/ur_ldrddi.cpp +++ b/source/loader/ur_ldrddi.cpp @@ -826,7 +826,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t - *pContextNativeProperties, ///< [in] pointer to properties struct + *pProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -854,7 +854,7 @@ __urdlllocal ur_result_t UR_APICALL urContextCreateWithNativeHandle( // forward to device-platform result = pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeProperties, phContext); + pProperties, phContext); delete[] phDevicesLocal; if (UR_RESULT_SUCCESS != result) { diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 55a30a9924..a32970e428 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -882,7 +882,7 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` -/// + `NULL == pContextNativeProperties` +/// + `NULL == pProperties` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t @@ -891,7 +891,7 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t - *pContextNativeProperties, ///< [in] pointer to properties struct + *pProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) { @@ -902,7 +902,7 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( } return pfnCreateWithNativeHandle(hNativeContext, numDevices, phDevices, - pContextNativeProperties, phContext); + pProperties, phContext); } /////////////////////////////////////////////////////////////////////////////// diff --git a/source/ur_api.cpp b/source/ur_api.cpp index e04ad0285d..94aaa549b2 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -769,7 +769,7 @@ ur_result_t UR_APICALL urContextGetNativeHandle( /// + `NULL == hNativeContext` /// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER /// + `NULL == phDevices` -/// + `NULL == pContextNativeProperties` +/// + `NULL == pProperties` /// + `NULL == phContext` ur_result_t UR_APICALL urContextCreateWithNativeHandle( ur_native_handle_t @@ -778,7 +778,7 @@ ur_result_t UR_APICALL urContextCreateWithNativeHandle( const ur_device_handle_t * phDevices, ///< [in][range(0, numDevices)] list of devices associated with the context const ur_context_native_properties_t - *pContextNativeProperties, ///< [in] pointer to properties struct + *pProperties, ///< [in] pointer to properties struct ur_context_handle_t * phContext ///< [out] pointer to the handle of the context object created. ) {