Skip to content

Commit

Permalink
Merge pull request #1123 from aarongreig/aaron/usmLocationProps
Browse files Browse the repository at this point in the history
[OpenCL] Add ur_usm_alloc_location_desc struct and handle it in the CL adapter.
  • Loading branch information
kbenzie authored Dec 11, 2023
2 parents b25bb64 + b78f541 commit 69a56ea
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 72 deletions.
20 changes: 20 additions & 0 deletions include/ur.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class ur_structure_type_v(IntEnum):
KERNEL_EXEC_INFO_PROPERTIES = 31 ## ::ur_kernel_exec_info_properties_t
KERNEL_ARG_VALUE_PROPERTIES = 32 ## ::ur_kernel_arg_value_properties_t
KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t
USM_ALLOC_LOCATION_DESC = 35 ## ::ur_usm_alloc_location_desc_t
EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t
EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t
EXP_INTEROP_MEM_DESC = 0x2001 ## ::ur_exp_interop_mem_desc_t
Expand Down Expand Up @@ -1558,6 +1559,25 @@ class ur_usm_device_desc_t(Structure):
("flags", ur_usm_device_mem_flags_t) ## [in] device memory allocation flags.
]

###############################################################################
## @brief USM allocation location desc
##
## @details
## - Specify these properties in ::urUSMHostAlloc, ::urUSMDeviceAlloc and
## ::urUSMSharedAlloc via ::ur_usm_desc_t as part of a `pNext` chain.
##
## @remarks
## _Analogues_
## - cl_intel_mem_alloc_buffer_location
class ur_usm_alloc_location_desc_t(Structure):
_fields_ = [
("stype", ur_structure_type_t), ## [in] type of this structure, must be
## ::UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC
("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure
("location", c_ulong) ## [in] Identifies the ID of global memory partition to which the memory
## should be allocated.
]

###############################################################################
## @brief USM pool descriptor type
class ur_usm_pool_desc_t(Structure):
Expand Down
23 changes: 23 additions & 0 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ typedef enum ur_structure_type_t {
UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 31, ///< ::ur_kernel_exec_info_properties_t
UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 32, ///< ::ur_kernel_arg_value_properties_t
UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t
UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC = 35, ///< ::ur_usm_alloc_location_desc_t
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t
UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t
UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC = 0x2001, ///< ::ur_exp_interop_mem_desc_t
Expand Down Expand Up @@ -3287,6 +3288,25 @@ typedef struct ur_usm_device_desc_t {

} ur_usm_device_desc_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief USM allocation location desc
///
/// @details
/// - Specify these properties in ::urUSMHostAlloc, ::urUSMDeviceAlloc and
/// ::urUSMSharedAlloc via ::ur_usm_desc_t as part of a `pNext` chain.
///
/// @remarks
/// _Analogues_
/// - cl_intel_mem_alloc_buffer_location
typedef struct ur_usm_alloc_location_desc_t {
ur_structure_type_t stype; ///< [in] type of this structure, must be
///< ::UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC
const void *pNext; ///< [in][optional] pointer to extension-specific structure
uint32_t location; ///< [in] Identifies the ID of global memory partition to which the memory
///< should be allocated.

} ur_usm_alloc_location_desc_t;

///////////////////////////////////////////////////////////////////////////////
/// @brief USM pool descriptor type
typedef struct ur_usm_pool_desc_t {
Expand Down Expand Up @@ -3324,6 +3344,7 @@ typedef struct ur_usm_pool_limits_desc_t {
/// - Any flags/hints passed through pUSMDesc only affect the single
/// allocation.
/// - See also ::ur_usm_host_desc_t.
/// - See also ::ur_usm_alloc_location_desc_t.
///
/// @returns
/// - ::UR_RESULT_SUCCESS
Expand Down Expand Up @@ -3369,6 +3390,7 @@ urUSMHostAlloc(
/// - Any flags/hints passed through pUSMDesc only affect the single
/// allocation.
/// - See also ::ur_usm_device_desc_t.
/// - See also ::ur_usm_alloc_location_desc_t.
///
/// @returns
/// - ::UR_RESULT_SUCCESS
Expand Down Expand Up @@ -3417,6 +3439,7 @@ urUSMDeviceAlloc(
/// allocation.
/// - See also ::ur_usm_host_desc_t.
/// - See also ::ur_usm_device_desc_t.
/// - See also ::ur_usm_alloc_location_desc_t.
///
/// @returns
/// - ::UR_RESULT_SUCCESS
Expand Down
34 changes: 34 additions & 0 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ inline std::ostream &operator<<(std::ostream &os, ur_usm_advice_flag_t value);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_host_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_device_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_alloc_location_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_desc_t params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_limits_desc_t params);
inline std::ostream &operator<<(std::ostream &os, ur_usm_pool_info_t value);
Expand Down Expand Up @@ -993,6 +994,9 @@ inline std::ostream &operator<<(std::ostream &os, ur_structure_type_t value) {
case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES:
os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES";
break;
case UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC:
os << "UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC";
break;
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC:
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC";
break;
Expand Down Expand Up @@ -1204,6 +1208,11 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) {
printPtr(os, pstruct);
} break;

case UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC: {
const ur_usm_alloc_location_desc_t *pstruct = (const ur_usm_alloc_location_desc_t *)ptr;
printPtr(os, pstruct);
} break;

case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: {
const ur_exp_command_buffer_desc_t *pstruct = (const ur_exp_command_buffer_desc_t *)ptr;
printPtr(os, pstruct);
Expand Down Expand Up @@ -6537,6 +6546,31 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_usm_device_des
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_usm_alloc_location_desc_t type
/// @returns
/// std::ostream &
inline std::ostream &operator<<(std::ostream &os, const struct ur_usm_alloc_location_desc_t params) {
os << "(struct ur_usm_alloc_location_desc_t){";

os << ".stype = ";

os << (params.stype);

os << ", ";
os << ".pNext = ";

ur::details::printStruct(os,
(params.pNext));

os << ", ";
os << ".location = ";

os << (params.location);

os << "}";
return os;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Print operator for the ur_usm_pool_desc_t type
/// @returns
/// std::ostream &
Expand Down
3 changes: 3 additions & 0 deletions scripts/core/registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -666,3 +666,6 @@ etors:
- name: KERNEL_ARG_LOCAL_PROPERTIES
desc: $x_kernel_arg_local_properties_t
value: '33'
- name: USM_ALLOC_LOCATION_DESC
desc: $x_usm_alloc_location_desc_t
value: '35'
20 changes: 20 additions & 0 deletions scripts/core/usm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,23 @@ members:
desc: "[in] device memory allocation flags."
--- #--------------------------------------------------------------------------
type: struct
desc: "USM allocation location desc"
details:
- Specify these properties in $xUSMHostAlloc, $xUSMDeviceAlloc and
$xUSMSharedAlloc via $x_usm_desc_t as part of a `pNext` chain.
analogue:
- "cl_intel_mem_alloc_buffer_location"
class: $xUSM
name: $x_usm_alloc_location_desc_t
base: $x_base_desc_t
members:
- type: uint32_t
name: location
desc: >
[in] Identifies the ID of global memory partition to which the memory
should be allocated.
--- #--------------------------------------------------------------------------
type: struct
desc: "USM pool descriptor type"
class: $xUSM
name: $x_usm_pool_desc_t
Expand Down Expand Up @@ -212,6 +229,7 @@ details:
- "Allocations served from different memory pools must be isolated and must not reside on the same page."
- "Any flags/hints passed through pUSMDesc only affect the single allocation."
- "See also $x_usm_host_desc_t."
- "See also $x_usm_alloc_location_desc_t."
params:
- type: $x_context_handle_t
name: hContext
Expand Down Expand Up @@ -253,6 +271,7 @@ details:
- "Allocations served from different memory pools must be isolated and must not reside on the same page."
- "Any flags/hints passed through pUSMDesc only affect the single allocation."
- "See also $x_usm_device_desc_t."
- "See also $x_usm_alloc_location_desc_t."
params:
- type: $x_context_handle_t
name: hContext
Expand Down Expand Up @@ -298,6 +317,7 @@ details:
- "Any flags/hints passed through pUSMDesc only affect the single allocation."
- "See also $x_usm_host_desc_t."
- "See also $x_usm_device_desc_t."
- "See also $x_usm_alloc_location_desc_t."
params:
- type: $x_context_handle_t
name: hContext
Expand Down
Loading

0 comments on commit 69a56ea

Please sign in to comment.