Skip to content

Commit 198e3ac

Browse files
Merge branch 'main' into steffen/make_ext_func_fail_unsupported
2 parents 4dc773c + 4d0183a commit 198e3ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+892
-116
lines changed

include/ur_api.h

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ typedef enum ur_function_t {
196196
UR_FUNCTION_ADAPTER_RETAIN = 179, ///< Enumerator for ::urAdapterRetain
197197
UR_FUNCTION_ADAPTER_GET_LAST_ERROR = 180, ///< Enumerator for ::urAdapterGetLastError
198198
UR_FUNCTION_ADAPTER_GET_INFO = 181, ///< Enumerator for ::urAdapterGetInfo
199-
UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP = 182, ///< Enumerator for ::urCommandBufferUpdateKernelLaunchExp
200199
UR_FUNCTION_PROGRAM_BUILD_EXP = 197, ///< Enumerator for ::urProgramBuildExp
201200
UR_FUNCTION_PROGRAM_COMPILE_EXP = 198, ///< Enumerator for ::urProgramCompileExp
202201
UR_FUNCTION_PROGRAM_LINK_EXP = 199, ///< Enumerator for ::urProgramLinkExp
@@ -216,11 +215,13 @@ typedef enum ur_function_t {
216215
UR_FUNCTION_COMMAND_BUFFER_APPEND_USM_ADVISE_EXP = 213, ///< Enumerator for ::urCommandBufferAppendUSMAdviseExp
217216
UR_FUNCTION_ENQUEUE_COOPERATIVE_KERNEL_LAUNCH_EXP = 214, ///< Enumerator for ::urEnqueueCooperativeKernelLaunchExp
218217
UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP = 215, ///< Enumerator for ::urKernelSuggestMaxCooperativeGroupCountExp
219-
UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP = 216, ///< Enumerator for ::urCommandBufferRetainCommandExp
220-
UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP = 217, ///< Enumerator for ::urCommandBufferReleaseCommandExp
221-
UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP = 218, ///< Enumerator for ::urCommandBufferGetInfoExp
222-
UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP = 219, ///< Enumerator for ::urCommandBufferCommandGetInfoExp
223-
UR_FUNCTION_DEVICE_GET_SELECTED = 220, ///< Enumerator for ::urDeviceGetSelected
218+
UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER = 216, ///< Enumerator for ::urProgramGetGlobalVariablePointer
219+
UR_FUNCTION_DEVICE_GET_SELECTED = 217, ///< Enumerator for ::urDeviceGetSelected
220+
UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP = 218, ///< Enumerator for ::urCommandBufferRetainCommandExp
221+
UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP = 219, ///< Enumerator for ::urCommandBufferReleaseCommandExp
222+
UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP = 220, ///< Enumerator for ::urCommandBufferUpdateKernelLaunchExp
223+
UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP = 221, ///< Enumerator for ::urCommandBufferGetInfoExp
224+
UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP = 222, ///< Enumerator for ::urCommandBufferCommandGetInfoExp
224225
/// @cond
225226
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
226227
/// @endcond
@@ -4327,6 +4328,42 @@ urProgramGetFunctionPointer(
43274328
void **ppFunctionPointer ///< [out] Returns the pointer to the function if it is found in the program.
43284329
);
43294330

4331+
///////////////////////////////////////////////////////////////////////////////
4332+
/// @brief Retrieves a pointer to a device global variable.
4333+
///
4334+
/// @details
4335+
/// - Retrieves a pointer to a device global variable.
4336+
/// - The application may call this function from simultaneous threads for
4337+
/// the same device.
4338+
/// - The implementation of this function should be thread-safe.
4339+
///
4340+
/// @remarks
4341+
/// _Analogues_
4342+
/// - **clGetDeviceGlobalVariablePointerINTEL**
4343+
///
4344+
/// @returns
4345+
/// - ::UR_RESULT_SUCCESS
4346+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
4347+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
4348+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
4349+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
4350+
/// + `NULL == hDevice`
4351+
/// + `NULL == hProgram`
4352+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
4353+
/// + `NULL == pGlobalVariableName`
4354+
/// + `NULL == ppGlobalVariablePointerRet`
4355+
/// - ::UR_RESULT_ERROR_INVALID_VALUE
4356+
/// + `name` is not a valid variable in the program.
4357+
UR_APIEXPORT ur_result_t UR_APICALL
4358+
urProgramGetGlobalVariablePointer(
4359+
ur_device_handle_t hDevice, ///< [in] handle of the device to retrieve the pointer for.
4360+
ur_program_handle_t hProgram, ///< [in] handle of the program where the global variable is.
4361+
const char *pGlobalVariableName, ///< [in] mangled name of the global variable to retrieve the pointer for.
4362+
size_t *pGlobalVariableSizeRet, ///< [out][optional] Returns the size of the global variable if it is found
4363+
///< in the program.
4364+
void **ppGlobalVariablePointerRet ///< [out] Returns the pointer to the global variable if it is found in the program.
4365+
);
4366+
43304367
///////////////////////////////////////////////////////////////////////////////
43314368
/// @brief Get Program object information
43324369
typedef enum ur_program_info_t {
@@ -8927,6 +8964,13 @@ urUSMReleaseExp(
89278964
#if !defined(__GNUC__)
89288965
#pragma region usm p2p(experimental)
89298966
#endif
8967+
///////////////////////////////////////////////////////////////////////////////
8968+
#ifndef UR_USM_P2P_EXTENSION_STRING_EXP
8969+
/// @brief The extension string that defines support for USM P2P which is
8970+
/// returned when querying device extensions.
8971+
#define UR_USM_P2P_EXTENSION_STRING_EXP "ur_exp_usm_p2p"
8972+
#endif // UR_USM_P2P_EXTENSION_STRING_EXP
8973+
89308974
///////////////////////////////////////////////////////////////////////////////
89318975
/// @brief Supported peer info
89328976
typedef enum ur_exp_peer_info_t {
@@ -9463,6 +9507,18 @@ typedef struct ur_program_get_function_pointer_params_t {
94639507
void ***pppFunctionPointer;
94649508
} ur_program_get_function_pointer_params_t;
94659509

9510+
///////////////////////////////////////////////////////////////////////////////
9511+
/// @brief Function parameters for urProgramGetGlobalVariablePointer
9512+
/// @details Each entry is a pointer to the parameter passed to the function;
9513+
/// allowing the callback the ability to modify the parameter's value
9514+
typedef struct ur_program_get_global_variable_pointer_params_t {
9515+
ur_device_handle_t *phDevice;
9516+
ur_program_handle_t *phProgram;
9517+
const char **ppGlobalVariableName;
9518+
size_t **ppGlobalVariableSizeRet;
9519+
void ***pppGlobalVariablePointerRet;
9520+
} ur_program_get_global_variable_pointer_params_t;
9521+
94669522
///////////////////////////////////////////////////////////////////////////////
94679523
/// @brief Function parameters for urProgramGetInfo
94689524
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_ddi.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,15 @@ typedef ur_result_t(UR_APICALL *ur_pfnProgramGetFunctionPointer_t)(
329329
const char *,
330330
void **);
331331

332+
///////////////////////////////////////////////////////////////////////////////
333+
/// @brief Function-pointer for urProgramGetGlobalVariablePointer
334+
typedef ur_result_t(UR_APICALL *ur_pfnProgramGetGlobalVariablePointer_t)(
335+
ur_device_handle_t,
336+
ur_program_handle_t,
337+
const char *,
338+
size_t *,
339+
void **);
340+
332341
///////////////////////////////////////////////////////////////////////////////
333342
/// @brief Function-pointer for urProgramGetInfo
334343
typedef ur_result_t(UR_APICALL *ur_pfnProgramGetInfo_t)(
@@ -380,6 +389,7 @@ typedef struct ur_program_dditable_t {
380389
ur_pfnProgramRetain_t pfnRetain;
381390
ur_pfnProgramRelease_t pfnRelease;
382391
ur_pfnProgramGetFunctionPointer_t pfnGetFunctionPointer;
392+
ur_pfnProgramGetGlobalVariablePointer_t pfnGetGlobalVariablePointer;
383393
ur_pfnProgramGetInfo_t pfnGetInfo;
384394
ur_pfnProgramGetBuildInfo_t pfnGetBuildInfo;
385395
ur_pfnProgramSetSpecializationConstants_t pfnSetSpecializationConstants;

include/ur_print.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramReleaseParams(const struct ur_
13061306
/// - `buff_size < out_size`
13071307
UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramGetFunctionPointerParams(const struct ur_program_get_function_pointer_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
13081308

1309+
///////////////////////////////////////////////////////////////////////////////
1310+
/// @brief Print ur_program_get_global_variable_pointer_params_t struct
1311+
/// @returns
1312+
/// - ::UR_RESULT_SUCCESS
1313+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1314+
/// - `buff_size < out_size`
1315+
UR_APIEXPORT ur_result_t UR_APICALL urPrintProgramGetGlobalVariablePointerParams(const struct ur_program_get_global_variable_pointer_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
1316+
13091317
///////////////////////////////////////////////////////////////////////////////
13101318
/// @brief Print ur_program_get_info_params_t struct
13111319
/// @returns

include/ur_print.hpp

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -837,9 +837,6 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) {
837837
case UR_FUNCTION_ADAPTER_GET_INFO:
838838
os << "UR_FUNCTION_ADAPTER_GET_INFO";
839839
break;
840-
case UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP:
841-
os << "UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP";
842-
break;
843840
case UR_FUNCTION_PROGRAM_BUILD_EXP:
844841
os << "UR_FUNCTION_PROGRAM_BUILD_EXP";
845842
break;
@@ -897,21 +894,27 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) {
897894
case UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP:
898895
os << "UR_FUNCTION_KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP";
899896
break;
897+
case UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER:
898+
os << "UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER";
899+
break;
900+
case UR_FUNCTION_DEVICE_GET_SELECTED:
901+
os << "UR_FUNCTION_DEVICE_GET_SELECTED";
902+
break;
900903
case UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP:
901904
os << "UR_FUNCTION_COMMAND_BUFFER_RETAIN_COMMAND_EXP";
902905
break;
903906
case UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP:
904907
os << "UR_FUNCTION_COMMAND_BUFFER_RELEASE_COMMAND_EXP";
905908
break;
909+
case UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP:
910+
os << "UR_FUNCTION_COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP";
911+
break;
906912
case UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP:
907913
os << "UR_FUNCTION_COMMAND_BUFFER_GET_INFO_EXP";
908914
break;
909915
case UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP:
910916
os << "UR_FUNCTION_COMMAND_BUFFER_COMMAND_GET_INFO_EXP";
911917
break;
912-
case UR_FUNCTION_DEVICE_GET_SELECTED:
913-
os << "UR_FUNCTION_DEVICE_GET_SELECTED";
914-
break;
915918
default:
916919
os << "unknown enumerator";
917920
break;
@@ -10791,6 +10794,44 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1079110794
return os;
1079210795
}
1079310796

10797+
///////////////////////////////////////////////////////////////////////////////
10798+
/// @brief Print operator for the ur_program_get_global_variable_pointer_params_t type
10799+
/// @returns
10800+
/// std::ostream &
10801+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_program_get_global_variable_pointer_params_t *params) {
10802+
10803+
os << ".hDevice = ";
10804+
10805+
ur::details::printPtr(os,
10806+
*(params->phDevice));
10807+
10808+
os << ", ";
10809+
os << ".hProgram = ";
10810+
10811+
ur::details::printPtr(os,
10812+
*(params->phProgram));
10813+
10814+
os << ", ";
10815+
os << ".pGlobalVariableName = ";
10816+
10817+
ur::details::printPtr(os,
10818+
*(params->ppGlobalVariableName));
10819+
10820+
os << ", ";
10821+
os << ".pGlobalVariableSizeRet = ";
10822+
10823+
ur::details::printPtr(os,
10824+
*(params->ppGlobalVariableSizeRet));
10825+
10826+
os << ", ";
10827+
os << ".ppGlobalVariablePointerRet = ";
10828+
10829+
ur::details::printPtr(os,
10830+
*(params->pppGlobalVariablePointerRet));
10831+
10832+
return os;
10833+
}
10834+
1079410835
///////////////////////////////////////////////////////////////////////////////
1079510836
/// @brief Print operator for the ur_program_get_info_params_t type
1079610837
/// @returns
@@ -16706,6 +16747,9 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_
1670616747
case UR_FUNCTION_PROGRAM_GET_FUNCTION_POINTER: {
1670716748
os << (const struct ur_program_get_function_pointer_params_t *)params;
1670816749
} break;
16750+
case UR_FUNCTION_PROGRAM_GET_GLOBAL_VARIABLE_POINTER: {
16751+
os << (const struct ur_program_get_global_variable_pointer_params_t *)params;
16752+
} break;
1670916753
case UR_FUNCTION_PROGRAM_GET_INFO: {
1671016754
os << (const struct ur_program_get_info_params_t *)params;
1671116755
} break;

scripts/core/EXP-USM-P2P.rst

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ or copying the memory located on a separate "peer" device.
2727

2828
Motivation
2929
--------------------------------------------------------------------------------
30-
Several important projects that the SYCL programming model aims to support use
31-
fine-grained peer to peer memory access controls.
32-
Two such examples that SYCL supports are Pytorch and Gromacs.
33-
This experimental extension to UR aims to provide a portable interface that can
34-
call appropriate driver functions to query and control peer memory access
35-
across the CUDA, HIP and L0 adapters.
30+
Programming models like SYCL or OpenMP aim to support several important
31+
projects that utilise fine-grained peer-to-peer memory access controls.
32+
This experimental extension to the Unified-Runtime API aims to provide a
33+
portable interface that can call appropriate driver functions to query and
34+
control peer memory access within different adapters such as CUDA, HIP and
35+
Level Zero.
3636

3737
API
3838
--------------------------------------------------------------------------------
3939

40+
Macros
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
* ${X}_USM_P2P_EXTENSION_STRING_EXP
43+
4044
Enums
4145
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4246

@@ -48,14 +52,23 @@ Functions
4852
* ${x}UsmP2PDisablePeerAccessExp
4953
* ${x}UsmP2PPeerAccessGetInfoExp
5054

55+
Support
56+
--------------------------------------------------------------------------------
57+
58+
Adapters which support this experimental feature *must* return the valid string
59+
defined in ``${X}_USM_P2P_EXTENSION_STRING_EXP`` as one of the options from
60+
${x}DeviceGetInfo when querying for ${X}_DEVICE_INFO_EXTENSIONS.
61+
5162
Changelog
5263
--------------------------------------------------------------------------------
5364

54-
+-----------+------------------------+
55-
| Revision | Changes |
56-
+===========+========================+
57-
| 1.0 | Initial Draft |
58-
+-----------+------------------------+
65+
+-----------+---------------------------------------------+
66+
| Revision | Changes |
67+
+===========+=============================================+
68+
| 1.0 | Initial Draft |
69+
+-----------+---------------------------------------------+
70+
| 1.1 | Added USM_P2P_EXTENSION_STRING_EXP ID Macro |
71+
+-----------+---------------------------------------------+
5972

6073
Contributors
6174
--------------------------------------------------------------------------------

scripts/core/exp-usm-p2p.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ type: header
1212
desc: "Intel $OneApi Unified Runtime Experimental APIs for USM P2P"
1313
ordinal: "99"
1414
--- #--------------------------------------------------------------------------
15+
type: macro
16+
desc: "The extension string that defines support for USM P2P which is returned when querying device extensions."
17+
name: $X_USM_P2P_EXTENSION_STRING_EXP
18+
value: "\"$x_exp_usm_p2p\""
19+
--- #--------------------------------------------------------------------------
1520
type: enum
1621
desc: "Supported peer info"
1722
class: $xUsmP2P

scripts/core/program.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,43 @@ params:
311311
desc: |
312312
[out] Returns the pointer to the function if it is found in the program.
313313
--- #--------------------------------------------------------------------------
314+
type: function
315+
desc: "Retrieves a pointer to a device global variable."
316+
class: $xProgram
317+
name: GetGlobalVariablePointer
318+
decl: static
319+
ordinal: "7"
320+
analogue:
321+
- "**clGetDeviceGlobalVariablePointerINTEL**"
322+
details:
323+
- "Retrieves a pointer to a device global variable."
324+
- "The application may call this function from simultaneous threads for the same device."
325+
- "The implementation of this function should be thread-safe."
326+
params:
327+
- type: "$x_device_handle_t"
328+
name: hDevice
329+
desc: |
330+
[in] handle of the device to retrieve the pointer for.
331+
- type: "$x_program_handle_t"
332+
name: hProgram
333+
desc: |
334+
[in] handle of the program where the global variable is.
335+
- type: "const char*"
336+
name: pGlobalVariableName
337+
desc: |
338+
[in] mangled name of the global variable to retrieve the pointer for.
339+
- type: "size_t*"
340+
name: pGlobalVariableSizeRet
341+
desc: |
342+
[out][optional] Returns the size of the global variable if it is found in the program.
343+
- type: "void**"
344+
name: ppGlobalVariablePointerRet
345+
desc: |
346+
[out] Returns the pointer to the global variable if it is found in the program.
347+
returns:
348+
- $X_RESULT_ERROR_INVALID_VALUE:
349+
- "`name` is not a valid variable in the program."
350+
--- #--------------------------------------------------------------------------
314351
type: enum
315352
desc: "Get Program object information"
316353
class: $xProgram

scripts/core/registry.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,6 @@ etors:
502502
- name: ADAPTER_GET_INFO
503503
desc: Enumerator for $xAdapterGetInfo
504504
value: '181'
505-
- name: COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP
506-
desc: Enumerator for $xCommandBufferUpdateKernelLaunchExp
507-
value: '182'
508505
- name: PROGRAM_BUILD_EXP
509506
desc: Enumerator for $xProgramBuildExp
510507
value: '197'
@@ -562,21 +559,27 @@ etors:
562559
- name: KERNEL_SUGGEST_MAX_COOPERATIVE_GROUP_COUNT_EXP
563560
desc: Enumerator for $xKernelSuggestMaxCooperativeGroupCountExp
564561
value: '215'
562+
- name: PROGRAM_GET_GLOBAL_VARIABLE_POINTER
563+
desc: Enumerator for $xProgramGetGlobalVariablePointer
564+
value: '216'
565+
- name: DEVICE_GET_SELECTED
566+
desc: Enumerator for $xDeviceGetSelected
567+
value: '217'
565568
- name: COMMAND_BUFFER_RETAIN_COMMAND_EXP
566569
desc: Enumerator for $xCommandBufferRetainCommandExp
567-
value: '216'
570+
value: '218'
568571
- name: COMMAND_BUFFER_RELEASE_COMMAND_EXP
569572
desc: Enumerator for $xCommandBufferReleaseCommandExp
570-
value: '217'
573+
value: '219'
574+
- name: COMMAND_BUFFER_UPDATE_KERNEL_LAUNCH_EXP
575+
desc: Enumerator for $xCommandBufferUpdateKernelLaunchExp
576+
value: '220'
571577
- name: COMMAND_BUFFER_GET_INFO_EXP
572578
desc: Enumerator for $xCommandBufferGetInfoExp
573-
value: '218'
579+
value: '221'
574580
- name: COMMAND_BUFFER_COMMAND_GET_INFO_EXP
575581
desc: Enumerator for $xCommandBufferCommandGetInfoExp
576-
value: '219'
577-
- name: DEVICE_GET_SELECTED
578-
desc: Enumerator for $xDeviceGetSelected
579-
value: '220'
582+
value: '222'
580583
---
581584
type: enum
582585
desc: Defines structure types

0 commit comments

Comments
 (0)