@@ -233,6 +233,7 @@ typedef enum ur_structure_type_t {
233233 UR_STRUCTURE_TYPE_USM_DESC = 7 , ///< ::ur_usm_desc_t
234234 UR_STRUCTURE_TYPE_USM_POOL_DESC = 8 , ///< ::ur_usm_pool_desc_t
235235 UR_STRUCTURE_TYPE_USM_POOL_LIMITS_DESC = 9 , ///< ::ur_usm_pool_limits_desc_t
236+ UR_STRUCTURE_TYPE_DEVICE_BINARY = 10 , ///< ::ur_device_binary_t
236237 /// @cond
237238 UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff
238239 /// @endcond
@@ -548,6 +549,77 @@ urGetLastResult(
548549#if !defined(__GNUC__ )
549550#pragma region device
550551#endif
552+ ///////////////////////////////////////////////////////////////////////////////
553+ #ifndef UR_DEVICE_BINARY_TARGET_UNKNOWN
554+ /// @brief Target identification strings for
555+ /// ::ur_device_binary_t.pDeviceTargetSpec
556+ /// A device type represented by a particular target triple requires
557+ /// specific
558+ /// binary images. We need to map the image type onto the device target triple
559+ #define UR_DEVICE_BINARY_TARGET_UNKNOWN "<unknown>"
560+ #endif // UR_DEVICE_BINARY_TARGET_UNKNOWN
561+
562+ ///////////////////////////////////////////////////////////////////////////////
563+ #ifndef UR_DEVICE_BINARY_TARGET_SPIRV32
564+ /// @brief SPIR-V 32-bit image <-> "spir", 32-bit OpenCL device
565+ #define UR_DEVICE_BINARY_TARGET_SPIRV32 "spir"
566+ #endif // UR_DEVICE_BINARY_TARGET_SPIRV32
567+
568+ ///////////////////////////////////////////////////////////////////////////////
569+ #ifndef UR_DEVICE_BINARY_TARGET_SPIRV64
570+ /// @brief SPIR-V 64-bit image <-> "spir64", 64-bit OpenCL device
571+ #define UR_DEVICE_BINARY_TARGET_SPIRV64 "spir64"
572+ #endif // UR_DEVICE_BINARY_TARGET_SPIRV64
573+
574+ ///////////////////////////////////////////////////////////////////////////////
575+ #ifndef UR_DEVICE_BINARY_TARGET_SPIRV64_X86_64
576+ /// @brief Device-specific binary images produced from SPIR-V 64-bit <-> various
577+ /// "spir64_*" triples for specific 64-bit OpenCL CPU devices
578+ #define UR_DEVICE_BINARY_TARGET_SPIRV64_X86_64 "spir64_x86_64"
579+ #endif // UR_DEVICE_BINARY_TARGET_SPIRV64_X86_64
580+
581+ ///////////////////////////////////////////////////////////////////////////////
582+ #ifndef UR_DEVICE_BINARY_TARGET_SPIRV64_GEN
583+ /// @brief Generic GPU device (64-bit OpenCL)
584+ #define UR_DEVICE_BINARY_TARGET_SPIRV64_GEN "spir64_gen"
585+ #endif // UR_DEVICE_BINARY_TARGET_SPIRV64_GEN
586+
587+ ///////////////////////////////////////////////////////////////////////////////
588+ #ifndef UR_DEVICE_BINARY_TARGET_SPIRV64_FPGA
589+ /// @brief 64-bit OpenCL FPGA device
590+ #define UR_DEVICE_BINARY_TARGET_SPIRV64_FPGA "spir64_fpga"
591+ #endif // UR_DEVICE_BINARY_TARGET_SPIRV64_FPGA
592+
593+ ///////////////////////////////////////////////////////////////////////////////
594+ #ifndef UR_DEVICE_BINARY_TARGET_NVPTX64
595+ /// @brief PTX 64-bit image <-> "nvptx64", 64-bit NVIDIA PTX device
596+ #define UR_DEVICE_BINARY_TARGET_NVPTX64 "nvptx64"
597+ #endif // UR_DEVICE_BINARY_TARGET_NVPTX64
598+
599+ ///////////////////////////////////////////////////////////////////////////////
600+ #ifndef UR_DEVICE_BINARY_TARGET_AMDGCN
601+ /// @brief AMD GCN
602+ #define UR_DEVICE_BINARY_TARGET_AMDGCN "amdgcn"
603+ #endif // UR_DEVICE_BINARY_TARGET_AMDGCN
604+
605+ ///////////////////////////////////////////////////////////////////////////////
606+ /// @brief Device Binary Type
607+ typedef struct ur_device_binary_t {
608+ ur_structure_type_t stype ; ///< [in] type of this structure, must be ::UR_STRUCTURE_TYPE_DEVICE_BINARY
609+ const void * pNext ; ///< [in][optional] pointer to extension-specific structure
610+ const char * pDeviceTargetSpec ; ///< [in] null-terminated string representation of the device's target architecture.
611+ ///< For example:
612+ ///< + ::UR_DEVICE_BINARY_TARGET_UNKNOWN
613+ ///< + ::UR_DEVICE_BINARY_TARGET_SPIRV32
614+ ///< + ::UR_DEVICE_BINARY_TARGET_SPIRV64
615+ ///< + ::UR_DEVICE_BINARY_TARGET_SPIRV64_X86_64
616+ ///< + ::UR_DEVICE_BINARY_TARGET_SPIRV64_GEN
617+ ///< + ::UR_DEVICE_BINARY_TARGET_SPIRV64_FPGA
618+ ///< + ::UR_DEVICE_BINARY_TARGET_NVPTX64
619+ ///< + ::UR_DEVICE_BINARY_TARGET_AMDGCN
620+
621+ } ur_device_binary_t ;
622+
551623///////////////////////////////////////////////////////////////////////////////
552624/// @brief Supported device types
553625typedef enum ur_device_type_t {
@@ -896,18 +968,19 @@ urDevicePartition(
896968/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
897969/// + `NULL == hDevice`
898970/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
899- /// + `NULL == ppBinaries `
971+ /// + `NULL == pBinaries `
900972/// + `NULL == pSelectedBinary`
901- /// - ::UR_RESULT_ERROR_INVALID_VALUE
973+ /// - ::UR_RESULT_ERROR_INVALID_SIZE
974+ /// + `NumBinaries == 0`
902975UR_APIEXPORT ur_result_t UR_APICALL
903976urDeviceSelectBinary (
904- ur_device_handle_t hDevice , ///< [in] handle of the device to select binary for.
905- const uint8_t * * ppBinaries , ///< [in] the array of binaries to select from.
906- uint32_t NumBinaries , ///< [in] the number of binaries passed in ppBinaries.
907- ///< Must greater than or equal to zero otherwise
908- ///< ::UR_RESULT_ERROR_INVALID_VALUE is returned.
909- uint32_t * pSelectedBinary ///< [out] the index of the selected binary in the input array of binaries.
910- ///< If a suitable binary was not found the function returns ${X}_INVALID_BINARY .
977+ ur_device_handle_t hDevice , ///< [in] handle of the device to select binary for.
978+ const ur_device_binary_t * pBinaries , ///< [in] the array of binaries to select from.
979+ uint32_t NumBinaries , ///< [in] the number of binaries passed in ppBinaries.
980+ ///< Must greater than or equal to zero otherwise
981+ ///< ::UR_RESULT_ERROR_INVALID_VALUE is returned.
982+ uint32_t * pSelectedBinary ///< [out] the index of the selected binary in the input array of binaries.
983+ ///< If a suitable binary was not found the function returns ::UR_RESULT_ERROR_INVALID_BINARY .
911984);
912985
913986///////////////////////////////////////////////////////////////////////////////
@@ -7922,7 +7995,7 @@ typedef void(UR_APICALL *ur_pfnDevicePartitionCb_t)(
79227995/// allowing the callback the ability to modify the parameter's value
79237996typedef struct ur_device_select_binary_params_t {
79247997 ur_device_handle_t * phDevice ;
7925- const uint8_t * * * pppBinaries ;
7998+ const ur_device_binary_t * * ppBinaries ;
79267999 uint32_t * pNumBinaries ;
79278000 uint32_t * * ppSelectedBinary ;
79288001} ur_device_select_binary_params_t ;
0 commit comments