Skip to content

Commit 8fc0a2b

Browse files
committed
change ctl api to support wildcards in name parameter
1 parent aeb1f61 commit 8fc0a2b

23 files changed

+828
-455
lines changed

benchmark/benchmark_umf.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ struct provider_interface {
4545
if (state.thread_index() != 0) {
4646
return;
4747
}
48-
umfCtlExec("umf.provider.by_handle.stats.peak_memory.reset", provider,
49-
NULL, 0);
48+
umfCtlExec("umf.provider.by_handle.{}.stats.peak_memory.reset", NULL, 0,
49+
provider);
5050
}
5151

5252
void postBench([[maybe_unused]] ::benchmark::State &state) {
@@ -55,8 +55,8 @@ struct provider_interface {
5555
}
5656
size_t arg;
5757
umf_result_t ret =
58-
umfCtlGet("umf.provider.by_handle.stats.allocated_memory", provider,
59-
&arg, sizeof(arg));
58+
umfCtlGet("umf.provider.by_handle.{}.stats.allocated_memory", &arg,
59+
sizeof(arg), provider);
6060
if (ret == UMF_RESULT_SUCCESS) {
6161
state.counters["provider_memory_allocated"] =
6262
static_cast<double>(arg);

include/umf/base.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ typedef enum umf_ctl_query_type {
5656
CTL_QUERY_READ,
5757
CTL_QUERY_WRITE,
5858
CTL_QUERY_RUNNABLE,
59-
CTL_QUERY_SUBTREE,
60-
61-
MAX_CTL_QUERY_TYPE
6259
} umf_ctl_query_type_t;
6360

6461
#ifdef __cplusplus

include/umf/experimental/ctl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ extern "C" {
1919
///
2020
/// @brief Get value of a specified attribute at the given name.
2121
/// @param name name of an attribute to be retrieved
22-
/// @param ctx pointer to the pool or the provider
2322
/// @param arg [out] pointer to the variable where the value will be stored
2423
/// @param size size of the value, depends on the context
24+
/// @param ... additional arguments that can be passed to the callback
2525
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
2626
///
27-
umf_result_t umfCtlGet(const char *name, void *ctx, void *arg, size_t size);
27+
umf_result_t umfCtlGet(const char *name, void *arg, size_t size, ...);
2828

2929
///
3030
/// @brief Set value of a specified attribute at the given name.
3131
/// @param name name of an attribute to be set
32-
/// @param ctx pointer to the pool or the provider, NULL for the 'default' path
3332
/// @param arg [in] pointer to the value that will be set
3433
/// @param size [in] size of the value, depends on the context
34+
/// @param ... additional arguments that can be passed to the callback
3535
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
3636
///
37-
umf_result_t umfCtlSet(const char *name, void *ctx, void *arg, size_t size);
37+
umf_result_t umfCtlSet(const char *name, void *arg, size_t size, ...);
3838

3939
///
4040
/// @brief Execute callback related with the specified attribute.
4141
/// @param name name of an attribute to be executed
42-
/// @param ctx pointer to the pool or the provider
4342
/// @param arg [in/out] pointer to the value, can be used as an input or output
4443
/// @param size [in] size of the value, depends on the context
44+
/// @param ... additional arguments that can be passed to the callback
4545
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
4646
///
47-
umf_result_t umfCtlExec(const char *name, void *ctx, void *arg, size_t size);
47+
umf_result_t umfCtlExec(const char *name, void *arg, size_t size, ...);
4848

4949
#ifdef __cplusplus
5050
}

include/umf/memory_pool_ops.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#ifndef UMF_MEMORY_POOL_OPS_H
1111
#define UMF_MEMORY_POOL_OPS_H 1
1212

13+
#include <stdarg.h>
14+
1315
#include <umf/base.h>
1416
#include <umf/memory_provider.h>
1517

@@ -158,12 +160,13 @@ typedef struct umf_memory_pool_ops_t {
158160
/// @param arg argument for the operation.
159161
/// @param size size of the argument [optional - check name requirements]
160162
/// @param queryType type of the query to be performed.
163+
/// @param args variable arguments for the operation.
161164
///
162165
/// @return umf_result_t result of the control operation.
163166
///
164167
umf_result_t (*ext_ctl)(void *hPool, int operationType, const char *name,
165168
void *arg, size_t size,
166-
umf_ctl_query_type_t queryType);
169+
umf_ctl_query_type_t queryType, va_list args);
167170

168171
} umf_memory_pool_ops_t;
169172

include/umf/memory_provider_ops.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#ifndef UMF_MEMORY_PROVIDER_OPS_H
1111
#define UMF_MEMORY_PROVIDER_OPS_H 1
1212

13+
#include <stdarg.h>
14+
1315
#include <umf/base.h>
1416

1517
#ifdef __cplusplus
@@ -268,12 +270,13 @@ typedef struct umf_memory_provider_ops_t {
268270
/// @param arg argument for the operation.
269271
/// @param size size of the argument [optional - check name requirements]
270272
/// @param queryType type of the query to be performed.
273+
/// @param args variable arguments for the operation.
271274
///
272275
/// @return umf_result_t result of the control operation.
273276
///
274277
umf_result_t (*ext_ctl)(void *provider, int operationType, const char *name,
275278
void *arg, size_t size,
276-
umf_ctl_query_type_t queryType);
279+
umf_ctl_query_type_t queryType, va_list args);
277280

278281
} umf_memory_provider_ops_t;
279282

0 commit comments

Comments
 (0)