|
17 | 17 | #include <umf/memory_provider.h>
|
18 | 18 |
|
19 | 19 | #include "base_alloc_global.h"
|
20 |
| -#include "pool_disjoint_ctl.h" |
| 20 | +#include <ctl/ctl.h> |
21 | 21 | #include "pool_disjoint_internal.h"
|
22 | 22 | #include "provider/provider_tracking.h"
|
23 | 23 | #include "uthash/utlist.h"
|
|
26 | 26 | #include "utils_log.h"
|
27 | 27 | #include "utils_math.h"
|
28 | 28 |
|
| 29 | +/* Disjoint pool CTL implementation */ |
| 30 | +struct ctl disjoint_ctl_root; |
| 31 | +static UTIL_ONCE_FLAG ctl_initialized = UTIL_ONCE_FLAG_INIT; |
| 32 | + |
| 33 | +static int CTL_READ_HANDLER(name)(void *ctx, umf_ctl_query_source_t source, |
| 34 | + void *arg, size_t size, |
| 35 | + umf_ctl_index_utlist_t *indexes, |
| 36 | + const char *extra_name, |
| 37 | + umf_ctl_query_type_t queryType) { |
| 38 | + (void)source, (void)indexes, (void)queryType, (void)size, (void)extra_name; |
| 39 | + disjoint_pool_t *pool = (disjoint_pool_t *)ctx; |
| 40 | + |
| 41 | + if (arg == NULL) { |
| 42 | + return -1; |
| 43 | + } |
| 44 | + |
| 45 | + strncpy(pool->params.name, (char *)arg, sizeof(pool->params.name) - 1); |
| 46 | + return 0; |
| 47 | +} |
| 48 | + |
| 49 | +static const umf_ctl_node_t CTL_NODE(disjoint)[] = {CTL_LEAF_RO(name), |
| 50 | + CTL_NODE_END}; |
| 51 | + |
| 52 | +static void initialize_disjoint_ctl(void) { |
| 53 | + CTL_REGISTER_MODULE(&disjoint_ctl_root, disjoint); |
| 54 | +} |
| 55 | + |
| 56 | +umf_result_t disjoint_pool_ctl(void *hPool, int operationType, const char *name, |
| 57 | + void *arg, size_t size, |
| 58 | + umf_ctl_query_type_t queryType) { |
| 59 | + (void)operationType, (void)queryType; |
| 60 | + utils_init_once(&ctl_initialized, initialize_disjoint_ctl); |
| 61 | + |
| 62 | + const char *prefix = "disjoint."; |
| 63 | + const char *name_wo_prefix = strstr(name, "disjoint."); |
| 64 | + |
| 65 | + // Check if the name has the prefix |
| 66 | + if ((name_wo_prefix = strstr(name, prefix)) == NULL) { |
| 67 | + return UMF_RESULT_ERROR_INVALID_ARGUMENT; |
| 68 | + } |
| 69 | + return ctl_query(&disjoint_ctl_root, hPool, CTL_QUERY_PROGRAMMATIC, |
| 70 | + name_wo_prefix, CTL_QUERY_READ, arg, size); |
| 71 | +} |
| 72 | + |
29 | 73 | // Temporary solution for disabling memory poisoning. This is needed because
|
30 | 74 | // AddressSanitizer does not support memory poisoning for GPU allocations.
|
31 | 75 | // More info: https://github.com/oneapi-src/unified-memory-framework/issues/634
|
|
0 commit comments