Skip to content

Commit 96e69c4

Browse files
committed
Add resident device change call
1 parent 2d9d4ed commit 96e69c4

25 files changed

+1306
-113
lines changed

include/umf/memory_pool_ops.h

Lines changed: 1 addition & 1 deletion
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

include/umf/providers/provider_level_zero.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#ifndef UMF_LEVEL_ZERO_PROVIDER_H
99
#define UMF_LEVEL_ZERO_PROVIDER_H
1010

11+
#include <stdbool.h>
12+
1113
#include <umf/memory_provider_gpu.h>
1214

1315
#ifdef __cplusplus
@@ -101,6 +103,17 @@ umf_result_t umfLevelZeroMemoryProviderParamsSetDeviceOrdinal(
101103
umf_result_t umfLevelZeroMemoryProviderParamsSetName(
102104
umf_level_zero_memory_provider_params_handle_t hParams, const char *name);
103105

106+
/// @brief Adds or removes devices on which allocations should be made
107+
/// resident.
108+
/// @param provider handle to the memory provider
109+
/// @param device device handle
110+
/// @param is_adding Boolean indicating if peer is to be removed or added
111+
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on
112+
/// failure.
113+
umf_result_t umfLevelZeroMemoryProviderResidentDeviceChange(
114+
umf_memory_provider_handle_t provider, ze_device_handle_t device,
115+
bool is_adding);
116+
104117
const umf_memory_provider_ops_t *umfLevelZeroMemoryProviderOps(void);
105118

106119
#ifdef __cplusplus

src/critnib/critnib.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,8 @@ int critnib_find(struct critnib *c, uintptr_t key, enum find_dir_t dir,
10941094
*
10951095
* If func() returns non-zero, the search is aborted.
10961096
*/
1097-
static int iter(struct critnib_node *__restrict n, word min, word max,
1097+
static int iter(struct critnib_node *__restrict n, const word min,
1098+
const word max,
10981099
int (*func)(word key, void *value, void *privdata),
10991100
void *privdata) {
11001101
if (is_leaf(n)) {
@@ -1129,9 +1130,21 @@ static int iter(struct critnib_node *__restrict n, word min, word max,
11291130
void critnib_iter(critnib *c, uintptr_t min, uintptr_t max,
11301131
int (*func)(uintptr_t key, void *value, void *privdata),
11311132
void *privdata) {
1133+
bool wasIterating = false;
11321134
utils_mutex_lock(&c->mutex);
11331135
if (c->root) {
11341136
iter(c->root, min, max, func, privdata);
1137+
wasIterating = true;
11351138
}
11361139
utils_mutex_unlock(&c->mutex);
1140+
if (!wasIterating) {
1141+
LOG_DEBUG("there was no root, iterating critnib: %p was skipped",
1142+
(void *)c);
1143+
}
1144+
}
1145+
1146+
void critnib_iter_all(critnib *c,
1147+
int (*func)(uintptr_t key, void *value, void *privdata),
1148+
void *privdata) {
1149+
critnib_iter(c, 0, (uintptr_t)-1, func, privdata);
11371150
}

src/critnib/critnib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ int critnib_insert(critnib *c, uintptr_t key, void *value, int update);
3535
void critnib_iter(critnib *c, uintptr_t min, uintptr_t max,
3636
int (*func)(uintptr_t key, void *value, void *privdata),
3737
void *privdata);
38+
void critnib_iter_all(critnib *c,
39+
int (*func)(uintptr_t key, void *value, void *privdata),
40+
void *privdata);
41+
3842
int critnib_remove_release(critnib *c, uintptr_t key);
3943

4044
/*

src/libumf.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ EXPORTS
154154
umfGetMemoryPropertySize
155155
umfJemallocPoolParamsSetName
156156
umfLevelZeroMemoryProviderParamsSetName
157+
umfLevelZeroMemoryProviderResidentDeviceChange
157158
umfOsMemoryProviderParamsSetName
158159
umfPoolTrimMemory
159160
umfScalablePoolParamsSetName

src/libumf.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ UMF_1.1 {
152152
umfGetMemoryPropertySize;
153153
umfJemallocPoolParamsSetName;
154154
umfLevelZeroMemoryProviderParamsSetName;
155+
umfLevelZeroMemoryProviderResidentDeviceChange;
155156
umfOsMemoryProviderParamsSetName;
156157
umfPoolTrimMemory;
157158
umfScalablePoolParamsSetName;

0 commit comments

Comments
 (0)