Skip to content

Commit 53ec753

Browse files
committed
add unittests and refactor to be backward compatible
1 parent c27407a commit 53ec753

23 files changed

+929
-241
lines changed

include/umf/memory_pool_ops.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ typedef struct umf_memory_pool_ops_t {
167167
///
168168
/// @return umf_result_t result of the control operation.
169169
///
170-
umf_result_t (*ext_ctl)(void *hPool, umf_ctl_query_source_t source,
170+
umf_result_t (*ext_ctl)(void *pool, umf_ctl_query_source_t source,
171171
const char *name, void *arg, size_t size,
172172
umf_ctl_query_type_t queryType, va_list args);
173173

@@ -196,12 +196,12 @@ typedef struct umf_memory_pool_ops_t {
196196
/// @brief Adds or removes devices on which allocations should be made
197197
/// resident.
198198
/// @param pool pointer to the memory pool
199-
/// @param deviceIndex identifier of device
199+
/// @param device device handle
200200
/// @param isAdding Boolean indicating if peer is to be removed or added
201201
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on
202202
/// failure.
203203
///
204-
umf_result_t (*ext_resident_device_change)(void *pool, uint32_t deviceIndex,
204+
umf_result_t (*ext_resident_device_change)(void *pool, void *device,
205205
bool isAdding);
206206
} umf_memory_pool_ops_t;
207207

include/umf/memory_provider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ umfMemoryProviderAllocationMerge(umf_memory_provider_handle_t hProvider,
268268
/// @brief Adds or removes devices on which allocations should be made
269269
/// resident.
270270
/// @param hProvider handle to the memory provider
271-
/// @param deviceIndex identifier of device
271+
/// @param device device handle
272272
/// @param isAdding Boolean indicating if peer is to be removed or added
273273
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on
274274
/// failure.
275275
umf_result_t
276276
umfMemoryProviderResidentDeviceChange(umf_memory_provider_handle_t hProvider,
277-
uint32_t deviceIndex, bool isAdding);
277+
void *device, bool isAdding);
278278

279279
#ifdef __cplusplus
280280
}

include/umf/memory_provider_ops.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,11 @@ typedef struct umf_memory_provider_ops_t {
326326
/// @brief Adds or removes devices on which allocations should be made
327327
/// resident.
328328
/// @param provider handle to the memory provider
329-
/// @param device_index identifier of device
329+
/// @param device device handle
330330
/// @param is_adding Boolean indicating if peer is to be removed or added
331331
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on
332332
/// failure.
333-
umf_result_t (*ext_resident_device_change)(void *provider,
334-
uint32_t device_index,
333+
umf_result_t (*ext_resident_device_change)(void *provider, void *device,
335334
bool is_adding);
336335

337336
} umf_memory_provider_ops_t;

include/umf/providers/provider_level_zero.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,12 @@ umf_result_t umfLevelZeroMemoryProviderParamsSetMemoryType(
6161

6262
/// @brief Set the resident devices in the parameters struct.
6363
/// @param hParams handle to the parameters of the Level Zero Memory Provider.
64-
/// @param hDevices array of all devices for which the memory can be made resident.
65-
/// @param deviceCount number of devices for which the memory can be made resident.
66-
/// @param residentDevicesIndices array of indices in all devices array to devices for which the memory should be made resident.
67-
/// @param residentDevicesCount number of items in indices array.
64+
/// @param hDevices array of devices for which the memory should be made resident.
65+
/// @param deviceCount number of devices for which the memory should be made resident.
6866
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure.
6967
umf_result_t umfLevelZeroMemoryProviderParamsSetResidentDevices(
7068
umf_level_zero_memory_provider_params_handle_t hParams,
71-
ze_device_handle_t *hDevices, uint32_t deviceCount,
72-
uint32_t *residentDevicesIndices, uint32_t residentDevicesCount);
69+
ze_device_handle_t *hDevices, uint32_t deviceCount);
7370

7471
typedef enum umf_level_zero_memory_provider_free_policy_t {
7572
UMF_LEVEL_ZERO_MEMORY_PROVIDER_FREE_POLICY_DEFAULT =

src/libumf.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ EXPORTS
1919
umfCUDAMemoryProviderParamsSetContext
2020
umfCUDAMemoryProviderParamsSetDevice
2121
umfCUDAMemoryProviderParamsSetMemoryType
22+
umfLevelZeroMemoryProviderParamsSetResidentDevices
2223
umfDevDaxMemoryProviderOps
2324
umfDevDaxMemoryProviderParamsCreate
2425
umfDevDaxMemoryProviderParamsDestroy
@@ -143,7 +144,6 @@ EXPORTS
143144
umfJemallocPoolParamsCreate
144145
umfJemallocPoolParamsDestroy
145146
umfJemallocPoolParamsSetNumArenas
146-
umfLevelZeroMemoryProviderParamsSetResidentDevices
147147
umfPoolGetName
148148
; Added in UMF_1.1
149149
umfCUDAMemoryProviderParamsSetName

src/memory_provider.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,10 @@ static umf_result_t umfDefaultGetAllocationPropertiesSize(
154154
return UMF_RESULT_ERROR_NOT_SUPPORTED;
155155
}
156156

157-
static umf_result_t umfDefaultResidentDeviceChange(void *provider,
158-
uint32_t device_index,
157+
static umf_result_t umfDefaultResidentDeviceChange(void *provider, void *device,
159158
bool is_adding) {
160159
(void)provider;
161-
(void)device_index;
160+
(void)device;
162161
(void)is_adding;
163162
return UMF_RESULT_ERROR_NOT_SUPPORTED;
164163
}
@@ -622,12 +621,12 @@ umf_result_t umfMemoryProviderGetAllocationPropertiesSize(
622621

623622
umf_result_t
624623
umfMemoryProviderResidentDeviceChange(umf_memory_provider_handle_t hProvider,
625-
uint32_t deviceIndex, bool isAdding) {
624+
void *device, bool isAdding) {
626625

627626
UMF_CHECK((hProvider != NULL), UMF_RESULT_ERROR_INVALID_ARGUMENT);
628627

629628
umf_result_t res = hProvider->ops.ext_resident_device_change(
630-
hProvider->provider_priv, deviceIndex, isAdding);
629+
hProvider->provider_priv, device, isAdding);
631630

632631
checkErrorAndSetLastProvider(res, hProvider);
633632
return res;

0 commit comments

Comments
 (0)