Skip to content

Commit 919c5de

Browse files
committed
Add tests and new urUSMPoolCreateExp protoype
Also some small fixes here and there in the CUDA adapter.
1 parent 4d1388d commit 919c5de

25 files changed

+1486
-920
lines changed

include/ur_api.h

Lines changed: 178 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ typedef enum ur_function_t {
238238
UR_FUNCTION_ENQUEUE_USM_SHARED_ALLOC_EXP = 251, ///< Enumerator for ::urEnqueueUSMSharedAllocExp
239239
UR_FUNCTION_ENQUEUE_USM_HOST_ALLOC_EXP = 252, ///< Enumerator for ::urEnqueueUSMHostAllocExp
240240
UR_FUNCTION_ENQUEUE_USM_FREE_EXP = 253, ///< Enumerator for ::urEnqueueUSMFreeExp
241+
UR_FUNCTION_USM_POOL_CREATE_EXP = 254, ///< Enumerator for ::urUSMPoolCreateExp
241242
/// @cond
242243
UR_FUNCTION_FORCE_UINT32 = 0x7fffffff
243244
/// @endcond
@@ -7667,6 +7668,39 @@ urEnqueueUSMFreeExp(
76677668
ur_event_handle_t *phEvent ///< [out][optional] return an event object that identifies the async alloc
76687669
);
76697670

7671+
///////////////////////////////////////////////////////////////////////////////
7672+
/// @brief Create USM memory pool with desired properties.
7673+
///
7674+
/// @details
7675+
/// - Create a memory pool associated with a single device.
7676+
/// - See also ::urUSMPoolCrearte and ::ur_usm_pool_limits_desc_t.
7677+
///
7678+
/// @returns
7679+
/// - ::UR_RESULT_SUCCESS
7680+
/// - ::UR_RESULT_ERROR_UNINITIALIZED
7681+
/// - ::UR_RESULT_ERROR_DEVICE_LOST
7682+
/// - ::UR_RESULT_ERROR_ADAPTER_SPECIFIC
7683+
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
7684+
/// + `NULL == hContext`
7685+
/// + `NULL == hDevice`
7686+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
7687+
/// + `NULL == pPoolDesc`
7688+
/// + `NULL == ppPool`
7689+
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
7690+
/// + `::UR_USM_POOL_FLAGS_MASK & pPoolDesc->flags`
7691+
/// - ::UR_RESULT_ERROR_INVALID_VALUE
7692+
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
7693+
/// - ::UR_RESULT_ERROR_UNSUPPORTED_FEATURE
7694+
/// + If any device associated with `hContext` reports `false` for ::UR_DEVICE_INFO_USM_POOL_SUPPORT
7695+
UR_APIEXPORT ur_result_t UR_APICALL
7696+
urUSMPoolCreateExp(
7697+
ur_context_handle_t hContext, ///< [in] handle of the context object
7698+
ur_device_handle_t hDevice, ///< [in] handle of the device object
7699+
ur_usm_pool_desc_t *pPoolDesc, ///< [in] pointer to USM pool descriptor. Can be chained with
7700+
///< ::ur_usm_pool_limits_desc_t
7701+
ur_usm_pool_handle_t *ppPool ///< [out] pointer to USM memory pool
7702+
);
7703+
76707704
#if !defined(__GNUC__)
76717705
#pragma endregion
76727706
#endif
@@ -12119,6 +12153,150 @@ typedef struct ur_enqueue_native_command_exp_params_t {
1211912153
ur_event_handle_t **pphEvent;
1212012154
} ur_enqueue_native_command_exp_params_t;
1212112155

12156+
///////////////////////////////////////////////////////////////////////////////
12157+
/// @brief Function parameters for urUSMHostAlloc
12158+
/// @details Each entry is a pointer to the parameter passed to the function;
12159+
/// allowing the callback the ability to modify the parameter's value
12160+
typedef struct ur_usm_host_alloc_params_t {
12161+
ur_context_handle_t *phContext;
12162+
const ur_usm_desc_t **ppUSMDesc;
12163+
ur_usm_pool_handle_t *ppool;
12164+
size_t *psize;
12165+
void ***pppMem;
12166+
} ur_usm_host_alloc_params_t;
12167+
12168+
///////////////////////////////////////////////////////////////////////////////
12169+
/// @brief Function parameters for urUSMDeviceAlloc
12170+
/// @details Each entry is a pointer to the parameter passed to the function;
12171+
/// allowing the callback the ability to modify the parameter's value
12172+
typedef struct ur_usm_device_alloc_params_t {
12173+
ur_context_handle_t *phContext;
12174+
ur_device_handle_t *phDevice;
12175+
const ur_usm_desc_t **ppUSMDesc;
12176+
ur_usm_pool_handle_t *ppool;
12177+
size_t *psize;
12178+
void ***pppMem;
12179+
} ur_usm_device_alloc_params_t;
12180+
12181+
///////////////////////////////////////////////////////////////////////////////
12182+
/// @brief Function parameters for urUSMSharedAlloc
12183+
/// @details Each entry is a pointer to the parameter passed to the function;
12184+
/// allowing the callback the ability to modify the parameter's value
12185+
typedef struct ur_usm_shared_alloc_params_t {
12186+
ur_context_handle_t *phContext;
12187+
ur_device_handle_t *phDevice;
12188+
const ur_usm_desc_t **ppUSMDesc;
12189+
ur_usm_pool_handle_t *ppool;
12190+
size_t *psize;
12191+
void ***pppMem;
12192+
} ur_usm_shared_alloc_params_t;
12193+
12194+
///////////////////////////////////////////////////////////////////////////////
12195+
/// @brief Function parameters for urUSMFree
12196+
/// @details Each entry is a pointer to the parameter passed to the function;
12197+
/// allowing the callback the ability to modify the parameter's value
12198+
typedef struct ur_usm_free_params_t {
12199+
ur_context_handle_t *phContext;
12200+
void **ppMem;
12201+
} ur_usm_free_params_t;
12202+
12203+
///////////////////////////////////////////////////////////////////////////////
12204+
/// @brief Function parameters for urUSMGetMemAllocInfo
12205+
/// @details Each entry is a pointer to the parameter passed to the function;
12206+
/// allowing the callback the ability to modify the parameter's value
12207+
typedef struct ur_usm_get_mem_alloc_info_params_t {
12208+
ur_context_handle_t *phContext;
12209+
const void **ppMem;
12210+
ur_usm_alloc_info_t *ppropName;
12211+
size_t *ppropSize;
12212+
void **ppPropValue;
12213+
size_t **ppPropSizeRet;
12214+
} ur_usm_get_mem_alloc_info_params_t;
12215+
12216+
///////////////////////////////////////////////////////////////////////////////
12217+
/// @brief Function parameters for urUSMPoolCreate
12218+
/// @details Each entry is a pointer to the parameter passed to the function;
12219+
/// allowing the callback the ability to modify the parameter's value
12220+
typedef struct ur_usm_pool_create_params_t {
12221+
ur_context_handle_t *phContext;
12222+
ur_usm_pool_desc_t **ppPoolDesc;
12223+
ur_usm_pool_handle_t **pppPool;
12224+
} ur_usm_pool_create_params_t;
12225+
12226+
///////////////////////////////////////////////////////////////////////////////
12227+
/// @brief Function parameters for urUSMPoolRetain
12228+
/// @details Each entry is a pointer to the parameter passed to the function;
12229+
/// allowing the callback the ability to modify the parameter's value
12230+
typedef struct ur_usm_pool_retain_params_t {
12231+
ur_usm_pool_handle_t *ppPool;
12232+
} ur_usm_pool_retain_params_t;
12233+
12234+
///////////////////////////////////////////////////////////////////////////////
12235+
/// @brief Function parameters for urUSMPoolRelease
12236+
/// @details Each entry is a pointer to the parameter passed to the function;
12237+
/// allowing the callback the ability to modify the parameter's value
12238+
typedef struct ur_usm_pool_release_params_t {
12239+
ur_usm_pool_handle_t *ppPool;
12240+
} ur_usm_pool_release_params_t;
12241+
12242+
///////////////////////////////////////////////////////////////////////////////
12243+
/// @brief Function parameters for urUSMPoolGetInfo
12244+
/// @details Each entry is a pointer to the parameter passed to the function;
12245+
/// allowing the callback the ability to modify the parameter's value
12246+
typedef struct ur_usm_pool_get_info_params_t {
12247+
ur_usm_pool_handle_t *phPool;
12248+
ur_usm_pool_info_t *ppropName;
12249+
size_t *ppropSize;
12250+
void **ppPropValue;
12251+
size_t **ppPropSizeRet;
12252+
} ur_usm_pool_get_info_params_t;
12253+
12254+
///////////////////////////////////////////////////////////////////////////////
12255+
/// @brief Function parameters for urUSMPoolCreateExp
12256+
/// @details Each entry is a pointer to the parameter passed to the function;
12257+
/// allowing the callback the ability to modify the parameter's value
12258+
typedef struct ur_usm_pool_create_exp_params_t {
12259+
ur_context_handle_t *phContext;
12260+
ur_device_handle_t *phDevice;
12261+
ur_usm_pool_desc_t **ppPoolDesc;
12262+
ur_usm_pool_handle_t **pppPool;
12263+
} ur_usm_pool_create_exp_params_t;
12264+
12265+
///////////////////////////////////////////////////////////////////////////////
12266+
/// @brief Function parameters for urUSMPitchedAllocExp
12267+
/// @details Each entry is a pointer to the parameter passed to the function;
12268+
/// allowing the callback the ability to modify the parameter's value
12269+
typedef struct ur_usm_pitched_alloc_exp_params_t {
12270+
ur_context_handle_t *phContext;
12271+
ur_device_handle_t *phDevice;
12272+
const ur_usm_desc_t **ppUSMDesc;
12273+
ur_usm_pool_handle_t *ppool;
12274+
size_t *pwidthInBytes;
12275+
size_t *pheight;
12276+
size_t *pelementSizeBytes;
12277+
void ***pppMem;
12278+
size_t **ppResultPitch;
12279+
} ur_usm_pitched_alloc_exp_params_t;
12280+
12281+
///////////////////////////////////////////////////////////////////////////////
12282+
/// @brief Function parameters for urUSMImportExp
12283+
/// @details Each entry is a pointer to the parameter passed to the function;
12284+
/// allowing the callback the ability to modify the parameter's value
12285+
typedef struct ur_usm_import_exp_params_t {
12286+
ur_context_handle_t *phContext;
12287+
void **ppMem;
12288+
size_t *psize;
12289+
} ur_usm_import_exp_params_t;
12290+
12291+
///////////////////////////////////////////////////////////////////////////////
12292+
/// @brief Function parameters for urUSMReleaseExp
12293+
/// @details Each entry is a pointer to the parameter passed to the function;
12294+
/// allowing the callback the ability to modify the parameter's value
12295+
typedef struct ur_usm_release_exp_params_t {
12296+
ur_context_handle_t *phContext;
12297+
void **ppMem;
12298+
} ur_usm_release_exp_params_t;
12299+
1212212300
///////////////////////////////////////////////////////////////////////////////
1212312301
/// @brief Function parameters for urBindlessImagesUnsampledImageHandleDestroyExp
1212412302
/// @details Each entry is a pointer to the parameter passed to the function;
@@ -12340,139 +12518,6 @@ typedef struct ur_bindless_images_signal_external_semaphore_exp_params_t {
1234012518
ur_event_handle_t **pphEvent;
1234112519
} ur_bindless_images_signal_external_semaphore_exp_params_t;
1234212520

12343-
///////////////////////////////////////////////////////////////////////////////
12344-
/// @brief Function parameters for urUSMHostAlloc
12345-
/// @details Each entry is a pointer to the parameter passed to the function;
12346-
/// allowing the callback the ability to modify the parameter's value
12347-
typedef struct ur_usm_host_alloc_params_t {
12348-
ur_context_handle_t *phContext;
12349-
const ur_usm_desc_t **ppUSMDesc;
12350-
ur_usm_pool_handle_t *ppool;
12351-
size_t *psize;
12352-
void ***pppMem;
12353-
} ur_usm_host_alloc_params_t;
12354-
12355-
///////////////////////////////////////////////////////////////////////////////
12356-
/// @brief Function parameters for urUSMDeviceAlloc
12357-
/// @details Each entry is a pointer to the parameter passed to the function;
12358-
/// allowing the callback the ability to modify the parameter's value
12359-
typedef struct ur_usm_device_alloc_params_t {
12360-
ur_context_handle_t *phContext;
12361-
ur_device_handle_t *phDevice;
12362-
const ur_usm_desc_t **ppUSMDesc;
12363-
ur_usm_pool_handle_t *ppool;
12364-
size_t *psize;
12365-
void ***pppMem;
12366-
} ur_usm_device_alloc_params_t;
12367-
12368-
///////////////////////////////////////////////////////////////////////////////
12369-
/// @brief Function parameters for urUSMSharedAlloc
12370-
/// @details Each entry is a pointer to the parameter passed to the function;
12371-
/// allowing the callback the ability to modify the parameter's value
12372-
typedef struct ur_usm_shared_alloc_params_t {
12373-
ur_context_handle_t *phContext;
12374-
ur_device_handle_t *phDevice;
12375-
const ur_usm_desc_t **ppUSMDesc;
12376-
ur_usm_pool_handle_t *ppool;
12377-
size_t *psize;
12378-
void ***pppMem;
12379-
} ur_usm_shared_alloc_params_t;
12380-
12381-
///////////////////////////////////////////////////////////////////////////////
12382-
/// @brief Function parameters for urUSMFree
12383-
/// @details Each entry is a pointer to the parameter passed to the function;
12384-
/// allowing the callback the ability to modify the parameter's value
12385-
typedef struct ur_usm_free_params_t {
12386-
ur_context_handle_t *phContext;
12387-
void **ppMem;
12388-
} ur_usm_free_params_t;
12389-
12390-
///////////////////////////////////////////////////////////////////////////////
12391-
/// @brief Function parameters for urUSMGetMemAllocInfo
12392-
/// @details Each entry is a pointer to the parameter passed to the function;
12393-
/// allowing the callback the ability to modify the parameter's value
12394-
typedef struct ur_usm_get_mem_alloc_info_params_t {
12395-
ur_context_handle_t *phContext;
12396-
const void **ppMem;
12397-
ur_usm_alloc_info_t *ppropName;
12398-
size_t *ppropSize;
12399-
void **ppPropValue;
12400-
size_t **ppPropSizeRet;
12401-
} ur_usm_get_mem_alloc_info_params_t;
12402-
12403-
///////////////////////////////////////////////////////////////////////////////
12404-
/// @brief Function parameters for urUSMPoolCreate
12405-
/// @details Each entry is a pointer to the parameter passed to the function;
12406-
/// allowing the callback the ability to modify the parameter's value
12407-
typedef struct ur_usm_pool_create_params_t {
12408-
ur_context_handle_t *phContext;
12409-
ur_usm_pool_desc_t **ppPoolDesc;
12410-
ur_usm_pool_handle_t **pppPool;
12411-
} ur_usm_pool_create_params_t;
12412-
12413-
///////////////////////////////////////////////////////////////////////////////
12414-
/// @brief Function parameters for urUSMPoolRetain
12415-
/// @details Each entry is a pointer to the parameter passed to the function;
12416-
/// allowing the callback the ability to modify the parameter's value
12417-
typedef struct ur_usm_pool_retain_params_t {
12418-
ur_usm_pool_handle_t *ppPool;
12419-
} ur_usm_pool_retain_params_t;
12420-
12421-
///////////////////////////////////////////////////////////////////////////////
12422-
/// @brief Function parameters for urUSMPoolRelease
12423-
/// @details Each entry is a pointer to the parameter passed to the function;
12424-
/// allowing the callback the ability to modify the parameter's value
12425-
typedef struct ur_usm_pool_release_params_t {
12426-
ur_usm_pool_handle_t *ppPool;
12427-
} ur_usm_pool_release_params_t;
12428-
12429-
///////////////////////////////////////////////////////////////////////////////
12430-
/// @brief Function parameters for urUSMPoolGetInfo
12431-
/// @details Each entry is a pointer to the parameter passed to the function;
12432-
/// allowing the callback the ability to modify the parameter's value
12433-
typedef struct ur_usm_pool_get_info_params_t {
12434-
ur_usm_pool_handle_t *phPool;
12435-
ur_usm_pool_info_t *ppropName;
12436-
size_t *ppropSize;
12437-
void **ppPropValue;
12438-
size_t **ppPropSizeRet;
12439-
} ur_usm_pool_get_info_params_t;
12440-
12441-
///////////////////////////////////////////////////////////////////////////////
12442-
/// @brief Function parameters for urUSMPitchedAllocExp
12443-
/// @details Each entry is a pointer to the parameter passed to the function;
12444-
/// allowing the callback the ability to modify the parameter's value
12445-
typedef struct ur_usm_pitched_alloc_exp_params_t {
12446-
ur_context_handle_t *phContext;
12447-
ur_device_handle_t *phDevice;
12448-
const ur_usm_desc_t **ppUSMDesc;
12449-
ur_usm_pool_handle_t *ppool;
12450-
size_t *pwidthInBytes;
12451-
size_t *pheight;
12452-
size_t *pelementSizeBytes;
12453-
void ***pppMem;
12454-
size_t **ppResultPitch;
12455-
} ur_usm_pitched_alloc_exp_params_t;
12456-
12457-
///////////////////////////////////////////////////////////////////////////////
12458-
/// @brief Function parameters for urUSMImportExp
12459-
/// @details Each entry is a pointer to the parameter passed to the function;
12460-
/// allowing the callback the ability to modify the parameter's value
12461-
typedef struct ur_usm_import_exp_params_t {
12462-
ur_context_handle_t *phContext;
12463-
void **ppMem;
12464-
size_t *psize;
12465-
} ur_usm_import_exp_params_t;
12466-
12467-
///////////////////////////////////////////////////////////////////////////////
12468-
/// @brief Function parameters for urUSMReleaseExp
12469-
/// @details Each entry is a pointer to the parameter passed to the function;
12470-
/// allowing the callback the ability to modify the parameter's value
12471-
typedef struct ur_usm_release_exp_params_t {
12472-
ur_context_handle_t *phContext;
12473-
void **ppMem;
12474-
} ur_usm_release_exp_params_t;
12475-
1247612521
///////////////////////////////////////////////////////////////////////////////
1247712522
/// @brief Function parameters for urCommandBufferCreateExp
1247812523
/// @details Each entry is a pointer to the parameter passed to the function;

include/ur_api_funcs.def

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ _UR_API(urEnqueueUSMFreeExp)
136136
_UR_API(urEnqueueCooperativeKernelLaunchExp)
137137
_UR_API(urEnqueueTimestampRecordingExp)
138138
_UR_API(urEnqueueNativeCommandExp)
139+
_UR_API(urUSMHostAlloc)
140+
_UR_API(urUSMDeviceAlloc)
141+
_UR_API(urUSMSharedAlloc)
142+
_UR_API(urUSMFree)
143+
_UR_API(urUSMGetMemAllocInfo)
144+
_UR_API(urUSMPoolCreate)
145+
_UR_API(urUSMPoolRetain)
146+
_UR_API(urUSMPoolRelease)
147+
_UR_API(urUSMPoolGetInfo)
148+
_UR_API(urUSMPoolCreateExp)
149+
_UR_API(urUSMPitchedAllocExp)
150+
_UR_API(urUSMImportExp)
151+
_UR_API(urUSMReleaseExp)
139152
_UR_API(urBindlessImagesUnsampledImageHandleDestroyExp)
140153
_UR_API(urBindlessImagesSampledImageHandleDestroyExp)
141154
_UR_API(urBindlessImagesImageAllocateExp)
@@ -154,18 +167,6 @@ _UR_API(urBindlessImagesImportExternalSemaphoreExp)
154167
_UR_API(urBindlessImagesReleaseExternalSemaphoreExp)
155168
_UR_API(urBindlessImagesWaitExternalSemaphoreExp)
156169
_UR_API(urBindlessImagesSignalExternalSemaphoreExp)
157-
_UR_API(urUSMHostAlloc)
158-
_UR_API(urUSMDeviceAlloc)
159-
_UR_API(urUSMSharedAlloc)
160-
_UR_API(urUSMFree)
161-
_UR_API(urUSMGetMemAllocInfo)
162-
_UR_API(urUSMPoolCreate)
163-
_UR_API(urUSMPoolRetain)
164-
_UR_API(urUSMPoolRelease)
165-
_UR_API(urUSMPoolGetInfo)
166-
_UR_API(urUSMPitchedAllocExp)
167-
_UR_API(urUSMImportExp)
168-
_UR_API(urUSMReleaseExp)
169170
_UR_API(urCommandBufferCreateExp)
170171
_UR_API(urCommandBufferRetainExp)
171172
_UR_API(urCommandBufferReleaseExp)

0 commit comments

Comments
 (0)