Skip to content

Commit 831b46d

Browse files
committed
Move spec changes to adapter.yml, removed 'loader_only' so the new entry point gets added to the ddi tables.
1 parent 7e86cd4 commit 831b46d

File tree

22 files changed

+322
-154
lines changed

22 files changed

+322
-154
lines changed

include/ur_api.h

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ typedef enum ur_function_t {
226226
UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_MEMORY_EXP = 226, ///< Enumerator for ::urBindlessImagesImportExternalMemoryExp
227227
UR_FUNCTION_BINDLESS_IMAGES_IMPORT_EXTERNAL_SEMAPHORE_EXP = 227, ///< Enumerator for ::urBindlessImagesImportExternalSemaphoreExp
228228
UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP = 228, ///< Enumerator for ::urEnqueueNativeCommandExp
229-
UR_FUNCTION_LOADER_CONFIG_SET_LOGGER_CALLBACK = 229, ///< Enumerator for ::urLoaderConfigSetLoggerCallback
229+
UR_FUNCTION_SET_LOGGER_CALLBACK = 230, ///< Enumerator for ::urSetLoggerCallback
230230
/// @cond
231231
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
232232
/// @endcond
@@ -787,30 +787,6 @@ UR_APIEXPORT ur_result_t UR_APICALL
787787
urLoaderTearDown(
788788
void);
789789

790-
///////////////////////////////////////////////////////////////////////////////
791-
/// @brief Callback function to retrieve output from the logger.
792-
typedef void (*ur_logger_output_callback_t)(
793-
const char *pLoggerMsg, ///< [in][out] pointer to data to be passed to callback
794-
void *pUserData ///< [in][out] pointer to data to be passed to callback
795-
);
796-
797-
///////////////////////////////////////////////////////////////////////////////
798-
/// @brief Set a callback function for use by the logger to retrieve logging
799-
/// output.
800-
///
801-
/// @returns
802-
/// - ::UR_RESULT_SUCCESS
803-
/// - ::UR_RESULT_ERROR_UNINITIALIZED
804-
/// - ::UR_RESULT_ERROR_DEVICE_LOST
805-
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
806-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
807-
/// + `NULL == pfnLoggerCallback`
808-
UR_APIEXPORT ur_result_t UR_APICALL
809-
urLoaderConfigSetLoggerCallback(
810-
ur_logger_output_callback_t pfnLoggerCallback, ///< [in] Function pointer to callback from the logger.
811-
void *pUserData ///< [in][out][optional] pointer to data to be passed to callback
812-
);
813-
814790
#if !defined(__GNUC__)
815791
#pragma endregion
816792
#endif
@@ -1011,6 +987,33 @@ typedef enum ur_adapter_backend_t {
1011987

1012988
} ur_adapter_backend_t;
1013989

990+
///////////////////////////////////////////////////////////////////////////////
991+
/// @brief Callback function to retrieve output from the logger.
992+
typedef void (*ur_logger_output_callback_t)(
993+
const char *pLoggerMsg, ///< [in][out] pointer to data to be passed to callback
994+
void *pUserData ///< [in][out] pointer to data to be passed to callback
995+
);
996+
997+
///////////////////////////////////////////////////////////////////////////////
998+
/// @brief Set a callback function for use by the logger to retrieve logging
999+
/// output.
1000+
///
1001+
/// @returns
1002+
/// - ::UR_RESULT_SUCCESS
1003+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
1004+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
1005+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
1006+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
1007+
/// + `NULL == hAdapter`
1008+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
1009+
/// + `NULL == pfnLoggerCallback`
1010+
UR_APIEXPORT ur_result_t UR_APICALL
1011+
urSetLoggerCallback(
1012+
ur_adapter_handle_t hAdapter, ///< [in] handle of the adapter
1013+
ur_logger_output_callback_t pfnLoggerCallback, ///< [in] Function pointer to callback from the logger.
1014+
void *pUserData ///< [in][out][optional] pointer to data to be passed to callback
1015+
);
1016+
10141017
#if !defined(__GNUC__)
10151018
#pragma endregion
10161019
#endif
@@ -9667,15 +9670,6 @@ typedef struct ur_loader_config_set_code_location_callback_params_t {
96679670
void **ppUserData;
96689671
} ur_loader_config_set_code_location_callback_params_t;
96699672

9670-
///////////////////////////////////////////////////////////////////////////////
9671-
/// @brief Function parameters for urLoaderConfigSetLoggerCallback
9672-
/// @details Each entry is a pointer to the parameter passed to the function;
9673-
/// allowing the callback the ability to modify the parameter's value
9674-
typedef struct ur_loader_config_set_logger_callback_params_t {
9675-
ur_logger_output_callback_t *ppfnLoggerCallback;
9676-
void **ppUserData;
9677-
} ur_loader_config_set_logger_callback_params_t;
9678-
96799673
///////////////////////////////////////////////////////////////////////////////
96809674
/// @brief Function parameters for urPlatformGet
96819675
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -10585,6 +10579,16 @@ typedef struct ur_adapter_get_info_params_t {
1058510579
size_t **ppPropSizeRet;
1058610580
} ur_adapter_get_info_params_t;
1058710581

10582+
///////////////////////////////////////////////////////////////////////////////
10583+
/// @brief Function parameters for urSetLoggerCallback
10584+
/// @details Each entry is a pointer to the parameter passed to the function;
10585+
/// allowing the callback the ability to modify the parameter's value
10586+
typedef struct ur_set_logger_callback_params_t {
10587+
ur_adapter_handle_t *phAdapter;
10588+
ur_logger_output_callback_t *ppfnLoggerCallback;
10589+
void **ppUserData;
10590+
} ur_set_logger_callback_params_t;
10591+
1058810592
///////////////////////////////////////////////////////////////////////////////
1058910593
/// @brief Function parameters for urEnqueueKernelLaunch
1059010594
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_ddi.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,13 @@ typedef ur_result_t(UR_APICALL *ur_pfnAdapterGetInfo_t)(
10371037
void *,
10381038
size_t *);
10391039

1040+
///////////////////////////////////////////////////////////////////////////////
1041+
/// @brief Function-pointer for urSetLoggerCallback
1042+
typedef ur_result_t(UR_APICALL *ur_pfnSetLoggerCallback_t)(
1043+
ur_adapter_handle_t,
1044+
ur_logger_output_callback_t,
1045+
void *);
1046+
10401047
///////////////////////////////////////////////////////////////////////////////
10411048
/// @brief Table of Global functions pointers
10421049
typedef struct ur_global_dditable_t {
@@ -1045,6 +1052,7 @@ typedef struct ur_global_dditable_t {
10451052
ur_pfnAdapterRetain_t pfnAdapterRetain;
10461053
ur_pfnAdapterGetLastError_t pfnAdapterGetLastError;
10471054
ur_pfnAdapterGetInfo_t pfnAdapterGetInfo;
1055+
ur_pfnSetLoggerCallback_t pfnSetLoggerCallback;
10481056
} ur_global_dditable_t;
10491057

10501058
///////////////////////////////////////////////////////////////////////////////

include/ur_print.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,14 +1106,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintLoaderConfigEnableLayerParams(const s
11061106
/// - `buff_size < out_size`
11071107
UR_APIEXPORT ur_result_t UR_APICALL urPrintLoaderConfigSetCodeLocationCallbackParams(const struct ur_loader_config_set_code_location_callback_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
11081108

1109-
///////////////////////////////////////////////////////////////////////////////
1110-
/// @brief Print ur_loader_config_set_logger_callback_params_t struct
1111-
/// @returns
1112-
/// - ::UR_RESULT_SUCCESS
1113-
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1114-
/// - `buff_size < out_size`
1115-
UR_APIEXPORT ur_result_t UR_APICALL urPrintLoaderConfigSetLoggerCallbackParams(const struct ur_loader_config_set_logger_callback_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
1116-
11171109
///////////////////////////////////////////////////////////////////////////////
11181110
/// @brief Print ur_platform_get_params_t struct
11191111
/// @returns
@@ -1810,6 +1802,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintAdapterGetLastErrorParams(const struc
18101802
/// - `buff_size < out_size`
18111803
UR_APIEXPORT ur_result_t UR_APICALL urPrintAdapterGetInfoParams(const struct ur_adapter_get_info_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
18121804

1805+
///////////////////////////////////////////////////////////////////////////////
1806+
/// @brief Print ur_set_logger_callback_params_t struct
1807+
/// @returns
1808+
/// - ::UR_RESULT_SUCCESS
1809+
/// - ::UR_RESULT_ERROR_INVALID_SIZE
1810+
/// - `buff_size < out_size`
1811+
UR_APIEXPORT ur_result_t UR_APICALL urPrintSetLoggerCallbackParams(const struct ur_set_logger_callback_params_t *params, char *buffer, const size_t buff_size, size_t *out_size);
1812+
18131813
///////////////////////////////////////////////////////////////////////////////
18141814
/// @brief Print ur_enqueue_kernel_launch_params_t struct
18151815
/// @returns

include/ur_print.hpp

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_function_t value) {
942942
case UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP:
943943
os << "UR_FUNCTION_ENQUEUE_NATIVE_COMMAND_EXP";
944944
break;
945-
case UR_FUNCTION_LOADER_CONFIG_SET_LOGGER_CALLBACK:
946-
os << "UR_FUNCTION_LOADER_CONFIG_SET_LOGGER_CALLBACK";
945+
case UR_FUNCTION_SET_LOGGER_CALLBACK:
946+
os << "UR_FUNCTION_SET_LOGGER_CALLBACK";
947947
break;
948948
default:
949949
os << "unknown enumerator";
@@ -10269,26 +10269,6 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1026910269
return os;
1027010270
}
1027110271

10272-
///////////////////////////////////////////////////////////////////////////////
10273-
/// @brief Print operator for the ur_loader_config_set_logger_callback_params_t type
10274-
/// @returns
10275-
/// std::ostream &
10276-
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_loader_config_set_logger_callback_params_t *params) {
10277-
10278-
os << ".pfnLoggerCallback = ";
10279-
10280-
os << reinterpret_cast<void *>(
10281-
*(params->ppfnLoggerCallback));
10282-
10283-
os << ", ";
10284-
os << ".pUserData = ";
10285-
10286-
ur::details::printPtr(os,
10287-
*(params->ppUserData));
10288-
10289-
return os;
10290-
}
10291-
1029210272
///////////////////////////////////////////////////////////////////////////////
1029310273
/// @brief Print operator for the ur_platform_get_params_t type
1029410274
/// @returns
@@ -12767,6 +12747,32 @@ inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct
1276712747
return os;
1276812748
}
1276912749

12750+
///////////////////////////////////////////////////////////////////////////////
12751+
/// @brief Print operator for the ur_set_logger_callback_params_t type
12752+
/// @returns
12753+
/// std::ostream &
12754+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_set_logger_callback_params_t *params) {
12755+
12756+
os << ".hAdapter = ";
12757+
12758+
ur::details::printPtr(os,
12759+
*(params->phAdapter));
12760+
12761+
os << ", ";
12762+
os << ".pfnLoggerCallback = ";
12763+
12764+
os << reinterpret_cast<void *>(
12765+
*(params->ppfnLoggerCallback));
12766+
12767+
os << ", ";
12768+
os << ".pUserData = ";
12769+
12770+
ur::details::printPtr(os,
12771+
*(params->ppUserData));
12772+
12773+
return os;
12774+
}
12775+
1277012776
///////////////////////////////////////////////////////////////////////////////
1277112777
/// @brief Print operator for the ur_enqueue_kernel_launch_params_t type
1277212778
/// @returns
@@ -17338,9 +17344,6 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_
1733817344
case UR_FUNCTION_LOADER_CONFIG_SET_CODE_LOCATION_CALLBACK: {
1733917345
os << (const struct ur_loader_config_set_code_location_callback_params_t *)params;
1734017346
} break;
17341-
case UR_FUNCTION_LOADER_CONFIG_SET_LOGGER_CALLBACK: {
17342-
os << (const struct ur_loader_config_set_logger_callback_params_t *)params;
17343-
} break;
1734417347
case UR_FUNCTION_PLATFORM_GET: {
1734517348
os << (const struct ur_platform_get_params_t *)params;
1734617349
} break;
@@ -17602,6 +17605,9 @@ inline ur_result_t UR_APICALL printFunctionParams(std::ostream &os, ur_function_
1760217605
case UR_FUNCTION_ADAPTER_GET_INFO: {
1760317606
os << (const struct ur_adapter_get_info_params_t *)params;
1760417607
} break;
17608+
case UR_FUNCTION_SET_LOGGER_CALLBACK: {
17609+
os << (const struct ur_set_logger_callback_params_t *)params;
17610+
} break;
1760517611
case UR_FUNCTION_ENQUEUE_KERNEL_LAUNCH: {
1760617612
os << (const struct ur_enqueue_kernel_launch_params_t *)params;
1760717613
} break;

scripts/core/adapter.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,31 @@ etors:
200200
- name: NATIVE_CPU
201201
value: "5"
202202
desc: "The backend is Native CPU"
203+
--- #--------------------------------------------------------------------------
204+
type: fptr_typedef
205+
desc: "Callback function to retrieve output from the logger."
206+
name: $x_logger_output_callback_t
207+
return: "void"
208+
params:
209+
- type: const char*
210+
name: pLoggerMsg
211+
desc: "[in][out] pointer to data to be passed to callback"
212+
- type: void*
213+
name: pUserData
214+
desc: "[in][out] pointer to data to be passed to callback"
215+
--- #--------------------------------------------------------------------------
216+
type: function
217+
desc: "Set a callback function for use by the logger to retrieve logging output."
218+
class: $x
219+
name: SetLoggerCallback
220+
decl: static
221+
params:
222+
- type: $x_adapter_handle_t
223+
name: hAdapter
224+
desc: "[in] handle of the adapter"
225+
- type: $x_logger_output_callback_t
226+
name: pfnLoggerCallback
227+
desc: "[in] Function pointer to callback from the logger."
228+
- type: void*
229+
name: pUserData
230+
desc: "[in][out][optional] pointer to data to be passed to callback"

scripts/core/loader.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -225,29 +225,3 @@ ordinal: "1"
225225
params: []
226226
returns:
227227
- $X_RESULT_ERROR_OUT_OF_HOST_MEMORY
228-
--- #--------------------------------------------------------------------------
229-
type: fptr_typedef
230-
desc: "Callback function to retrieve output from the logger."
231-
name: $x_logger_output_callback_t
232-
return: "void"
233-
params:
234-
- type: const char*
235-
name: pLoggerMsg
236-
desc: "[in][out] pointer to data to be passed to callback"
237-
- type: void*
238-
name: pUserData
239-
desc: "[in][out] pointer to data to be passed to callback"
240-
--- #--------------------------------------------------------------------------
241-
type: function
242-
desc: "Set a callback function for use by the logger to retrieve logging output."
243-
class: $xLoaderConfig
244-
loader_only: True
245-
name: SetLoggerCallback
246-
decl: static
247-
params:
248-
- type: $x_logger_output_callback_t
249-
name: pfnLoggerCallback
250-
desc: "[in] Function pointer to callback from the logger."
251-
- type: void*
252-
name: pUserData
253-
desc: "[in][out][optional] pointer to data to be passed to callback"

scripts/core/registry.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,9 @@ etors:
592592
- name: ENQUEUE_NATIVE_COMMAND_EXP
593593
desc: Enumerator for $xEnqueueNativeCommandExp
594594
value: '228'
595-
- name: LOADER_CONFIG_SET_LOGGER_CALLBACK
596-
desc: Enumerator for $xLoaderConfigSetLoggerCallback
597-
value: '229'
595+
- name: SET_LOGGER_CALLBACK
596+
desc: Enumerator for $xSetLoggerCallback
597+
value: '230'
598598
---
599599
type: enum
600600
desc: Defines structure types

source/adapters/cuda/ur_interface_loader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable(
209209
pDdiTable->pfnAdapterRetain = urAdapterRetain;
210210
pDdiTable->pfnAdapterGetLastError = urAdapterGetLastError;
211211
pDdiTable->pfnAdapterGetInfo = urAdapterGetInfo;
212+
pDdiTable->pfnSetLoggerCallback = urSetLoggerCallback;
212213

213214
return UR_RESULT_SUCCESS;
214215
}

source/adapters/hip/ur_interface_loader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable(
209209
pDdiTable->pfnAdapterGetLastError = urAdapterGetLastError;
210210
pDdiTable->pfnAdapterRelease = urAdapterRelease;
211211
pDdiTable->pfnAdapterRetain = urAdapterRetain;
212+
pDdiTable->pfnSetLoggerCallback = urSetLoggerCallback;
212213

213214
return UR_RESULT_SUCCESS;
214215
}

source/adapters/level_zero/ur_interface_loader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetGlobalProcAddrTable(
4444
pDdiTable->pfnAdapterRetain = urAdapterRetain;
4545
pDdiTable->pfnAdapterGetLastError = urAdapterGetLastError;
4646
pDdiTable->pfnAdapterGetInfo = urAdapterGetInfo;
47+
pDdiTable->pfnSetLoggerCallback = urSetLoggerCallback;
4748

4849
return retVal;
4950
}

0 commit comments

Comments
 (0)