Skip to content

Commit

Permalink
[ur] Allow native handles to be unsupported
Browse files Browse the repository at this point in the history
Some adapters do not map directly to Unified Runtime's set of API
objects and as such are unable to support getting the underlying native
handle or creating objects from native handles. This patch adds the
`UR_RESULT_ERROR_UNSUPPORTED_FEATURE` to all native handle entry-points
and updates the conformance tests to match.
  • Loading branch information
kbenzie committed Jul 17, 2023
1 parent c46db28 commit ac4c0cb
Show file tree
Hide file tree
Showing 30 changed files with 230 additions and 20 deletions.
38 changes: 38 additions & 0 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,8 @@ urPlatformGetApiVersion(
/// + `NULL == hPlatform`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativePlatform`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urPlatformGetNativeHandle(
ur_platform_handle_t hPlatform, ///< [in] handle of the platform.
Expand Down Expand Up @@ -760,6 +762,8 @@ typedef struct ur_platform_native_properties_t {
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phPlatform`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urPlatformCreateWithNativeHandle(
ur_native_handle_t hNativePlatform, ///< [in][nocheck] the native handle of the platform.
Expand Down Expand Up @@ -1529,6 +1533,8 @@ typedef enum ur_device_exec_capability_flag_t {
/// + `NULL == hDevice`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeDevice`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urDeviceGetNativeHandle(
ur_device_handle_t hDevice, ///< [in] handle of the device.
Expand Down Expand Up @@ -1565,6 +1571,8 @@ typedef struct ur_device_native_properties_t {
/// + `NULL == hPlatform`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevice`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urDeviceCreateWithNativeHandle(
ur_native_handle_t hNativeDevice, ///< [in][nocheck] the native handle of the device.
Expand Down Expand Up @@ -1864,6 +1872,8 @@ urContextGetInfo(
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeContext`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urContextGetNativeHandle(
ur_context_handle_t hContext, ///< [in] handle of the context.
Expand Down Expand Up @@ -1899,6 +1909,8 @@ typedef struct ur_context_native_properties_t {
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phDevices`
/// + `NULL == phContext`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urContextCreateWithNativeHandle(
ur_native_handle_t hNativeContext, ///< [in][nocheck] the native handle of the context.
Expand Down Expand Up @@ -2340,6 +2352,8 @@ urMemBufferPartition(
/// + `NULL == hMem`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeMem`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urMemGetNativeHandle(
ur_mem_handle_t hMem, ///< [in] handle of the mem.
Expand Down Expand Up @@ -2375,6 +2389,8 @@ typedef struct ur_mem_native_properties_t {
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phMem`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urMemBufferCreateWithNativeHandle(
ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory.
Expand Down Expand Up @@ -2402,6 +2418,8 @@ urMemBufferCreateWithNativeHandle(
/// + `NULL == pImageFormat`
/// + `NULL == pImageDesc`
/// + `NULL == phMem`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urMemImageCreateWithNativeHandle(
ur_native_handle_t hNativeMem, ///< [in][nocheck] the native handle to the memory.
Expand Down Expand Up @@ -2700,6 +2718,8 @@ urSamplerGetInfo(
/// + `NULL == hSampler`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeSampler`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urSamplerGetNativeHandle(
ur_sampler_handle_t hSampler, ///< [in] handle of the sampler.
Expand Down Expand Up @@ -2736,6 +2756,8 @@ typedef struct ur_sampler_native_properties_t {
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phSampler`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urSamplerCreateWithNativeHandle(
ur_native_handle_t hNativeSampler, ///< [in][nocheck] the native handle of the sampler.
Expand Down Expand Up @@ -4032,6 +4054,8 @@ urProgramSetSpecializationConstants(
/// + `NULL == hProgram`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeProgram`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urProgramGetNativeHandle(
ur_program_handle_t hProgram, ///< [in] handle of the program.
Expand Down Expand Up @@ -4068,6 +4092,8 @@ typedef struct ur_program_native_properties_t {
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phProgram`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urProgramCreateWithNativeHandle(
ur_native_handle_t hNativeProgram, ///< [in][nocheck] the native handle of the program.
Expand Down Expand Up @@ -4611,6 +4637,8 @@ urKernelSetSpecializationConstants(
/// + `NULL == hKernel`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeKernel`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urKernelGetNativeHandle(
ur_kernel_handle_t hKernel, ///< [in] handle of the kernel.
Expand Down Expand Up @@ -4648,6 +4676,8 @@ typedef struct ur_kernel_native_properties_t {
/// + `NULL == hProgram`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phKernel`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urKernelCreateWithNativeHandle(
ur_native_handle_t hNativeKernel, ///< [in][nocheck] the native handle of the kernel.
Expand Down Expand Up @@ -4902,6 +4932,8 @@ typedef struct ur_queue_native_desc_t {
/// + `NULL == hQueue`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeQueue`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urQueueGetNativeHandle(
ur_queue_handle_t hQueue, ///< [in] handle of the queue.
Expand Down Expand Up @@ -4940,6 +4972,8 @@ typedef struct ur_queue_native_properties_t {
/// + `NULL == hDevice`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phQueue`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urQueueCreateWithNativeHandle(
ur_native_handle_t hNativeQueue, ///< [in][nocheck] the native handle of the queue.
Expand Down Expand Up @@ -5264,6 +5298,8 @@ urEventRelease(
/// + `NULL == hEvent`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phNativeEvent`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urEventGetNativeHandle(
ur_event_handle_t hEvent, ///< [in] handle of the event.
Expand Down Expand Up @@ -5300,6 +5336,8 @@ typedef struct ur_event_native_properties_t {
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
/// + `NULL == phEvent`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
/// + If the adapter has no underlying equivalent handle.
UR_APIEXPORT ur_result_t UR_APICALL
urEventCreateWithNativeHandle(
ur_native_handle_t hNativeEvent, ///< [in][nocheck] the native handle of the event.
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ params:
name: phNativeContext
desc: |
[out] a pointer to the native handle of the context.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Properties for for $xContextCreateWithNativeHandle."
Expand Down Expand Up @@ -238,6 +241,9 @@ params:
name: phContext
desc: |
[out] pointer to the handle of the context object created.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: fptr_typedef
desc: "Context's extended deleter callback function with user data."
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ params:
name: phNativeDevice
desc: |
[out] a pointer to the native handle of the device.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Native device creation properties"
Expand Down Expand Up @@ -768,6 +771,9 @@ params:
- type: "$x_device_handle_t*"
name: phDevice
desc: "[out] pointer to the handle of the device object created."
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: function
desc: "Returns synchronized Host and Device global timestamps."
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/event.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ params:
name: phNativeEvent
desc: |
[out] a pointer to the native handle of the event.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Properties for for $xEventCreateWithNativeHandle."
Expand Down Expand Up @@ -305,6 +308,9 @@ params:
name: phEvent
desc: |
[out] pointer to the handle of the event object created.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: enum
desc: "Event states for all events."
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ params:
name: phNativeKernel
desc: |
[out] a pointer to the native handle of the kernel.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Properties for for $xKernelCreateWithNativeHandle."
Expand Down Expand Up @@ -529,3 +532,6 @@ params:
name: phKernel
desc: |
[out] pointer to the handle of the kernel object created.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
9 changes: 9 additions & 0 deletions scripts/core/memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ params:
name: phNativeMem
desc: |
[out] a pointer to the native handle of the mem.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Native memory object creation properties"
Expand Down Expand Up @@ -473,6 +476,9 @@ params:
- type: $x_mem_handle_t*
name: phMem
desc: "[out] pointer to handle of buffer memory object created."
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: function
desc: "Create runtime image memory object from native memory handle."
Expand Down Expand Up @@ -503,6 +509,9 @@ params:
- type: $x_mem_handle_t*
name: phMem
desc: "[out] pointer to handle of image memory object created."
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: function
desc: "Retrieve information about a memory object."
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ params:
name: phNativePlatform
desc: |
[out] a pointer to the native handle of the platform.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Native platform creation properties"
Expand Down Expand Up @@ -195,6 +198,9 @@ params:
- type: "$x_platform_handle_t*"
name: phPlatform
desc: "[out] pointer to the handle of the platform object created."
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: function
desc: "Get the platform specific compiler backend option from a generic frontend option."
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/program.yml
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ params:
name: phNativeProgram
desc: |
[out] a pointer to the native handle of the program.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Native program creation properties"
Expand Down Expand Up @@ -551,3 +554,6 @@ params:
- type: "$x_program_handle_t*"
name: phProgram
desc: "[out] pointer to the handle of the program object created."
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
6 changes: 6 additions & 0 deletions scripts/core/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ params:
name: phNativeQueue
desc: |
[out] a pointer to the native handle of the queue.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Properties for for $xQueueCreateWithNativeHandle."
Expand Down Expand Up @@ -286,6 +289,9 @@ params:
name: phQueue
desc: |
[out] pointer to the handle of the queue object created.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: function
desc: "Blocks until all previously issued commands to the command queue are finished."
Expand Down
6 changes: 6 additions & 0 deletions scripts/core/sampler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ params:
name: phNativeSampler
desc: |
[out] a pointer to the native handle of the sampler.
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
--- #--------------------------------------------------------------------------
type: struct
desc: "Native sampler creation properties"
Expand Down Expand Up @@ -231,3 +234,6 @@ params:
- type: "$x_sampler_handle_t*"
name: phSampler
desc: "[out] pointer to the handle of the sampler object created."
returns:
- $X_RESULT_ERROR_UNSUPPORTED_FEATURE:
- "If the adapter has no underlying equivalent handle."
Loading

0 comments on commit ac4c0cb

Please sign in to comment.