Skip to content

Commit 418b255

Browse files
committed
To append
1 parent 475229e commit 418b255

File tree

8 files changed

+75
-39
lines changed

8 files changed

+75
-39
lines changed

include/umf/base.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ enum ctl_query_type {
5858
MAX_CTL_QUERY_TYPE
5959
};
6060

61+
// struct ctl;
62+
63+
// enum ctl_query_source;
64+
65+
// int ctl_query(struct ctl *ctl, void *ctx, enum ctl_query_source source,
66+
// const char *name, enum ctl_query_type type, void *arg);
67+
68+
int umfCtlGet(const char *name, void *ctx, void *arg);
69+
70+
// void umfCtlSet(const char *name, ...) { (void)name; }
71+
72+
// void umfCtlExec(const char *name, ...) { (void)name; }
73+
74+
6175
#ifdef __cplusplus
6276
}
6377
#endif

src/ctl/ctl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ char *Strdup(const char *s) {
7979
return p;
8080
}
8181

82+
int umfCtlGet(const char *name, void *ctx, void *arg) {
83+
return ctl_query(NULL, ctx, CTL_QUERY_PROGRAMMATIC,
84+
name, CTL_QUERY_READ,
85+
arg);
86+
}
87+
8288
/*
8389
* ctl_find_node -- (internal) searches for a matching entry point in the
8490
* provided nodes
@@ -629,9 +635,3 @@ int ctl_arg_string(const void *arg, void *dest, size_t dest_size) {
629635

630636
return 0;
631637
}
632-
633-
void umfCtlGet(const char *name, ...) { (void)name; }
634-
635-
void umfCtlSet(const char *name, ...) { (void)name; }
636-
637-
void umfCtlExec(const char *name, ...) { (void)name; }

src/ctl/ctl.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ enum ctl_query_source {
4545
MAX_CTL_QUERY_SOURCE
4646
};
4747

48-
// enum ctl_query_type {
49-
// CTL_QUERY_READ,
50-
// CTL_QUERY_WRITE,
51-
// CTL_QUERY_RUNNABLE,
52-
// CTL_QUERY_SUBTREE,
53-
54-
// MAX_CTL_QUERY_TYPE
55-
// };
56-
5748
typedef int (*node_callback)(void *ctx, enum ctl_query_source type, void *arg,
5849
struct ctl_index_utlist *indexes, char *extra_name,
5950
enum ctl_query_type query_type);

src/libumf.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ EXPORTS
1414
umfTearDown
1515
umfGetCurrentVersion
1616
umfCloseIPCHandle
17+
umfCtlExec
18+
umfCtlGet
19+
umfCtlSet
1720
umfCUDAMemoryProviderOps
1821
umfCUDAMemoryProviderParamsCreate
1922
umfCUDAMemoryProviderParamsDestroy

src/libumf.map

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ UMF_0.10 {
88
umfTearDown;
99
umfGetCurrentVersion;
1010
umfCloseIPCHandle;
11+
umfCtlExec;
12+
umfCtlGet;
13+
umfCtlSet;
1114
umfCUDAMemoryProviderOps;
1215
umfCUDAMemoryProviderParamsCreate;
1316
umfCUDAMemoryProviderParamsDestroy;

test/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,14 @@ add_umf_test(
197197
LIBS ${UMF_LOGGER_LIBS})
198198

199199
add_umf_test(
200-
NAME ctl
201-
SRCS ctl/test.cpp ctl/ctl_debug.c ../src/ctl/ctl.c ${BA_SOURCES_FOR_TEST}
200+
NAME ctl_unittest
201+
SRCS ctl/ctl_unittest.cpp ctl/ctl_debug.c ../src/ctl/ctl.c
202+
${BA_SOURCES_FOR_TEST}
203+
LIBS ${UMF_UTILS_FOR_TEST})
204+
205+
add_umf_test(
206+
NAME ctl_api
207+
SRCS ctl/ctl_api.cpp ${BA_SOURCES_FOR_TEST}
202208
LIBS ${UMF_UTILS_FOR_TEST})
203209

204210
add_umf_test(

test/ctl/ctl_api.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
*
3+
* Copyright (C) 2025 Intel Corporation
4+
*
5+
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
6+
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
*
8+
*/
9+
10+
#include <umf.h>
11+
#include <umf/memory_provider.h>
12+
#include <umf/providers/provider_os_memory.h>
13+
14+
#include "../common/base.hpp"
15+
#include "gtest/gtest.h"
16+
17+
using namespace umf_test;
18+
19+
TEST_F(test, ctl_by_handle_os_provider) {
20+
umf_memory_provider_handle_t hProvider = NULL;
21+
umf_memory_provider_ops_t *os_provider_ops = umfOsMemoryProviderOps();
22+
umf_os_memory_provider_params_handle_t os_memory_provider_params = NULL;
23+
24+
umfOsMemoryProviderParamsCreate(&os_memory_provider_params);
25+
int ret = umfMemoryProviderCreate(os_provider_ops,
26+
os_memory_provider_params, &hProvider);
27+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
28+
29+
int ipc_enabled = 0xBAD;
30+
// WRAPPER HERE
31+
// ret = ctl_query(NULL, hProvider, CTL_QUERY_PROGRAMMATIC,
32+
// "umf.provider.by_handle.ipc_enabled", CTL_QUERY_READ,
33+
// &ipc_enabled);
34+
ret = umfCtlGet("umf.provider.by_handle.ipc_enabled", hProvider, &ipc_enabled);
35+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
36+
ASSERT_EQ(ipc_enabled, 0);
37+
38+
umfOsMemoryProviderParamsDestroy(os_memory_provider_params);
39+
umfMemoryProviderDestroy(hProvider);
40+
}

test/ctl/test.cpp renamed to test/ctl/ctl_unittest.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "ctl/ctl.h"
1212
#include "ctl/ctl_debug.h"
1313
#include "umf/base.h"
14-
#include "umf/memory_provider.h"
14+
#include "gtest/gtest.h"
1515
#include <umf.h>
1616
#include <umf/providers/provider_os_memory.h>
1717

@@ -95,24 +95,3 @@ TEST_F(test, ctl_debug_read_from_file) {
9595
deinitialize_debug_ctl();
9696
#endif
9797
}
98-
99-
TEST_F(test, by_handle_provider_ctl) {
100-
umf_memory_provider_handle_t hProvider = NULL;
101-
umf_memory_provider_ops_t *os_provider_ops = umfOsMemoryProviderOps();
102-
umf_os_memory_provider_params_handle_t os_memory_provider_params = NULL;
103-
104-
umfOsMemoryProviderParamsCreate(&os_memory_provider_params);
105-
int ret = umfMemoryProviderCreate(os_provider_ops,
106-
os_memory_provider_params, &hProvider);
107-
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
108-
109-
int ipc_enabled = 0xBAD;
110-
ret = ctl_query(NULL, hProvider, CTL_QUERY_PROGRAMMATIC,
111-
"umf.provider.by_handle.ipc_enabled", CTL_QUERY_READ,
112-
&ipc_enabled);
113-
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
114-
ASSERT_EQ(ipc_enabled, 0);
115-
116-
umfOsMemoryProviderParamsDestroy(os_memory_provider_params);
117-
umfMemoryProviderDestroy(hProvider);
118-
}

0 commit comments

Comments
 (0)