Skip to content

Commit 69a56ea

Browse files
authored
Merge pull request #1123 from aarongreig/aaron/usmLocationProps
[OpenCL] Add ur_usm_alloc_location_desc struct and handle it in the CL adapter.
2 parents b25bb64 + b78f541 commit 69a56ea

File tree

9 files changed

+194
-72
lines changed

9 files changed

+194
-72
lines changed

include/ur.py

+20
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class ur_structure_type_v(IntEnum):
249249
KERNEL_EXEC_INFO_PROPERTIES = 31 ## ::ur_kernel_exec_info_properties_t
250250
KERNEL_ARG_VALUE_PROPERTIES = 32 ## ::ur_kernel_arg_value_properties_t
251251
KERNEL_ARG_LOCAL_PROPERTIES = 33 ## ::ur_kernel_arg_local_properties_t
252+
USM_ALLOC_LOCATION_DESC = 35 ## ::ur_usm_alloc_location_desc_t
252253
EXP_COMMAND_BUFFER_DESC = 0x1000 ## ::ur_exp_command_buffer_desc_t
253254
EXP_SAMPLER_MIP_PROPERTIES = 0x2000 ## ::ur_exp_sampler_mip_properties_t
254255
EXP_INTEROP_MEM_DESC = 0x2001 ## ::ur_exp_interop_mem_desc_t
@@ -1558,6 +1559,25 @@ class ur_usm_device_desc_t(Structure):
15581559
("flags", ur_usm_device_mem_flags_t) ## [in] device memory allocation flags.
15591560
]
15601561

1562+
###############################################################################
1563+
## @brief USM allocation location desc
1564+
##
1565+
## @details
1566+
## - Specify these properties in ::urUSMHostAlloc, ::urUSMDeviceAlloc and
1567+
## ::urUSMSharedAlloc via ::ur_usm_desc_t as part of a `pNext` chain.
1568+
##
1569+
## @remarks
1570+
## _Analogues_
1571+
## - cl_intel_mem_alloc_buffer_location
1572+
class ur_usm_alloc_location_desc_t(Structure):
1573+
_fields_ = [
1574+
("stype", ur_structure_type_t), ## [in] type of this structure, must be
1575+
## ::UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC
1576+
("pNext", c_void_p), ## [in][optional] pointer to extension-specific structure
1577+
("location", c_ulong) ## [in] Identifies the ID of global memory partition to which the memory
1578+
## should be allocated.
1579+
]
1580+
15611581
###############################################################################
15621582
## @brief USM pool descriptor type
15631583
class ur_usm_pool_desc_t(Structure):

include/ur_api.h

+23
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ typedef enum ur_structure_type_t {
258258
UR_STRUCTURE_TYPE_KERNEL_EXEC_INFO_PROPERTIES = 31, ///< ::ur_kernel_exec_info_properties_t
259259
UR_STRUCTURE_TYPE_KERNEL_ARG_VALUE_PROPERTIES = 32, ///< ::ur_kernel_arg_value_properties_t
260260
UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES = 33, ///< ::ur_kernel_arg_local_properties_t
261+
UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC = 35, ///< ::ur_usm_alloc_location_desc_t
261262
UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC = 0x1000, ///< ::ur_exp_command_buffer_desc_t
262263
UR_STRUCTURE_TYPE_EXP_SAMPLER_MIP_PROPERTIES = 0x2000, ///< ::ur_exp_sampler_mip_properties_t
263264
UR_STRUCTURE_TYPE_EXP_INTEROP_MEM_DESC = 0x2001, ///< ::ur_exp_interop_mem_desc_t
@@ -3287,6 +3288,25 @@ typedef struct ur_usm_device_desc_t {
32873288

32883289
} ur_usm_device_desc_t;
32893290

3291+
///////////////////////////////////////////////////////////////////////////////
3292+
/// @brief USM allocation location desc
3293+
///
3294+
/// @details
3295+
/// - Specify these properties in ::urUSMHostAlloc, ::urUSMDeviceAlloc and
3296+
/// ::urUSMSharedAlloc via ::ur_usm_desc_t as part of a `pNext` chain.
3297+
///
3298+
/// @remarks
3299+
/// _Analogues_
3300+
/// - cl_intel_mem_alloc_buffer_location
3301+
typedef struct ur_usm_alloc_location_desc_t {
3302+
ur_structure_type_t stype; ///< [in] type of this structure, must be
3303+
///< ::UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC
3304+
const void *pNext; ///< [in][optional] pointer to extension-specific structure
3305+
uint32_t location; ///< [in] Identifies the ID of global memory partition to which the memory
3306+
///< should be allocated.
3307+
3308+
} ur_usm_alloc_location_desc_t;
3309+
32903310
///////////////////////////////////////////////////////////////////////////////
32913311
/// @brief USM pool descriptor type
32923312
typedef struct ur_usm_pool_desc_t {
@@ -3324,6 +3344,7 @@ typedef struct ur_usm_pool_limits_desc_t {
33243344
/// - Any flags/hints passed through pUSMDesc only affect the single
33253345
/// allocation.
33263346
/// - See also ::ur_usm_host_desc_t.
3347+
/// - See also ::ur_usm_alloc_location_desc_t.
33273348
///
33283349
/// @returns
33293350
/// - ::UR_RESULT_SUCCESS
@@ -3369,6 +3390,7 @@ urUSMHostAlloc(
33693390
/// - Any flags/hints passed through pUSMDesc only affect the single
33703391
/// allocation.
33713392
/// - See also ::ur_usm_device_desc_t.
3393+
/// - See also ::ur_usm_alloc_location_desc_t.
33723394
///
33733395
/// @returns
33743396
/// - ::UR_RESULT_SUCCESS
@@ -3417,6 +3439,7 @@ urUSMDeviceAlloc(
34173439
/// allocation.
34183440
/// - See also ::ur_usm_host_desc_t.
34193441
/// - See also ::ur_usm_device_desc_t.
3442+
/// - See also ::ur_usm_alloc_location_desc_t.
34203443
///
34213444
/// @returns
34223445
/// - ::UR_RESULT_SUCCESS

include/ur_print.hpp

+34
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ inline std::ostream &operator<<(std::ostream &os, ur_usm_advice_flag_t value);
267267
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_desc_t params);
268268
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_host_desc_t params);
269269
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_device_desc_t params);
270+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_alloc_location_desc_t params);
270271
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_desc_t params);
271272
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_usm_pool_limits_desc_t params);
272273
inline std::ostream &operator<<(std::ostream &os, ur_usm_pool_info_t value);
@@ -993,6 +994,9 @@ inline std::ostream &operator<<(std::ostream &os, ur_structure_type_t value) {
993994
case UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES:
994995
os << "UR_STRUCTURE_TYPE_KERNEL_ARG_LOCAL_PROPERTIES";
995996
break;
997+
case UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC:
998+
os << "UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC";
999+
break;
9961000
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC:
9971001
os << "UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC";
9981002
break;
@@ -1204,6 +1208,11 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) {
12041208
printPtr(os, pstruct);
12051209
} break;
12061210

1211+
case UR_STRUCTURE_TYPE_USM_ALLOC_LOCATION_DESC: {
1212+
const ur_usm_alloc_location_desc_t *pstruct = (const ur_usm_alloc_location_desc_t *)ptr;
1213+
printPtr(os, pstruct);
1214+
} break;
1215+
12071216
case UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC: {
12081217
const ur_exp_command_buffer_desc_t *pstruct = (const ur_exp_command_buffer_desc_t *)ptr;
12091218
printPtr(os, pstruct);
@@ -6537,6 +6546,31 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_usm_device_des
65376546
return os;
65386547
}
65396548
///////////////////////////////////////////////////////////////////////////////
6549+
/// @brief Print operator for the ur_usm_alloc_location_desc_t type
6550+
/// @returns
6551+
/// std::ostream &
6552+
inline std::ostream &operator<<(std::ostream &os, const struct ur_usm_alloc_location_desc_t params) {
6553+
os << "(struct ur_usm_alloc_location_desc_t){";
6554+
6555+
os << ".stype = ";
6556+
6557+
os << (params.stype);
6558+
6559+
os << ", ";
6560+
os << ".pNext = ";
6561+
6562+
ur::details::printStruct(os,
6563+
(params.pNext));
6564+
6565+
os << ", ";
6566+
os << ".location = ";
6567+
6568+
os << (params.location);
6569+
6570+
os << "}";
6571+
return os;
6572+
}
6573+
///////////////////////////////////////////////////////////////////////////////
65406574
/// @brief Print operator for the ur_usm_pool_desc_t type
65416575
/// @returns
65426576
/// std::ostream &

scripts/core/registry.yml

+3
Original file line numberDiff line numberDiff line change
@@ -666,3 +666,6 @@ etors:
666666
- name: KERNEL_ARG_LOCAL_PROPERTIES
667667
desc: $x_kernel_arg_local_properties_t
668668
value: '33'
669+
- name: USM_ALLOC_LOCATION_DESC
670+
desc: $x_usm_alloc_location_desc_t
671+
value: '35'

scripts/core/usm.yml

+20
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,23 @@ members:
175175
desc: "[in] device memory allocation flags."
176176
--- #--------------------------------------------------------------------------
177177
type: struct
178+
desc: "USM allocation location desc"
179+
details:
180+
- Specify these properties in $xUSMHostAlloc, $xUSMDeviceAlloc and
181+
$xUSMSharedAlloc via $x_usm_desc_t as part of a `pNext` chain.
182+
analogue:
183+
- "cl_intel_mem_alloc_buffer_location"
184+
class: $xUSM
185+
name: $x_usm_alloc_location_desc_t
186+
base: $x_base_desc_t
187+
members:
188+
- type: uint32_t
189+
name: location
190+
desc: >
191+
[in] Identifies the ID of global memory partition to which the memory
192+
should be allocated.
193+
--- #--------------------------------------------------------------------------
194+
type: struct
178195
desc: "USM pool descriptor type"
179196
class: $xUSM
180197
name: $x_usm_pool_desc_t
@@ -212,6 +229,7 @@ details:
212229
- "Allocations served from different memory pools must be isolated and must not reside on the same page."
213230
- "Any flags/hints passed through pUSMDesc only affect the single allocation."
214231
- "See also $x_usm_host_desc_t."
232+
- "See also $x_usm_alloc_location_desc_t."
215233
params:
216234
- type: $x_context_handle_t
217235
name: hContext
@@ -253,6 +271,7 @@ details:
253271
- "Allocations served from different memory pools must be isolated and must not reside on the same page."
254272
- "Any flags/hints passed through pUSMDesc only affect the single allocation."
255273
- "See also $x_usm_device_desc_t."
274+
- "See also $x_usm_alloc_location_desc_t."
256275
params:
257276
- type: $x_context_handle_t
258277
name: hContext
@@ -298,6 +317,7 @@ details:
298317
- "Any flags/hints passed through pUSMDesc only affect the single allocation."
299318
- "See also $x_usm_host_desc_t."
300319
- "See also $x_usm_device_desc_t."
320+
- "See also $x_usm_alloc_location_desc_t."
301321
params:
302322
- type: $x_context_handle_t
303323
name: hContext

0 commit comments

Comments
 (0)