Skip to content

Commit b64363c

Browse files
committed
Add IPC tests
1 parent ae2f950 commit b64363c

File tree

7 files changed

+503
-3
lines changed

7 files changed

+503
-3
lines changed

src/cpp_helpers.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2023 Intel Corporation
3+
* Copyright (C) 2023-2024 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -93,6 +93,11 @@ template <typename T> umf_memory_provider_ops_t providerOpsBase() {
9393
UMF_ASSIGN_OP(ops.ext, T, purge_force, UMF_RESULT_ERROR_UNKNOWN);
9494
UMF_ASSIGN_OP(ops.ext, T, allocation_merge, UMF_RESULT_ERROR_UNKNOWN);
9595
UMF_ASSIGN_OP(ops.ext, T, allocation_split, UMF_RESULT_ERROR_UNKNOWN);
96+
UMF_ASSIGN_OP(ops.ipc, T, get_ipc_handle_size, UMF_RESULT_ERROR_UNKNOWN);
97+
UMF_ASSIGN_OP(ops.ipc, T, get_ipc_handle, UMF_RESULT_ERROR_UNKNOWN);
98+
UMF_ASSIGN_OP(ops.ipc, T, put_ipc_handle, UMF_RESULT_ERROR_UNKNOWN);
99+
UMF_ASSIGN_OP(ops.ipc, T, open_ipc_handle, UMF_RESULT_ERROR_UNKNOWN);
100+
UMF_ASSIGN_OP(ops.ipc, T, close_ipc_handle, UMF_RESULT_ERROR_UNKNOWN);
96101
return ops;
97102
}
98103
} // namespace detail

test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,7 @@ if(UMF_PROXY_LIB_ENABLED AND UMF_BUILD_SHARED_LIBRARY)
241241
LIBS umf_proxy
242242
CFGS ${CONFIGS})
243243
endif()
244+
245+
if(UMF_ENABLE_POOL_TRACKING)
246+
add_umf_test(NAME ipc SRCS ipcAPI.cpp)
247+
endif()

test/common/provider.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ typedef struct provider_base_t {
7373
[[maybe_unused]] size_t firstSize) {
7474
return UMF_RESULT_ERROR_UNKNOWN;
7575
}
76+
umf_result_t get_ipc_handle_size([[maybe_unused]] size_t *size) noexcept {
77+
return UMF_RESULT_ERROR_UNKNOWN;
78+
}
79+
umf_result_t
80+
get_ipc_handle([[maybe_unused]] const void *ptr,
81+
[[maybe_unused]] size_t size,
82+
[[maybe_unused]] void *providerIpcData) noexcept {
83+
return UMF_RESULT_ERROR_UNKNOWN;
84+
}
85+
umf_result_t
86+
put_ipc_handle([[maybe_unused]] void *providerIpcData) noexcept {
87+
return UMF_RESULT_ERROR_UNKNOWN;
88+
}
89+
umf_result_t open_ipc_handle([[maybe_unused]] void *providerIpcData,
90+
[[maybe_unused]] void **ptr) noexcept {
91+
return UMF_RESULT_ERROR_UNKNOWN;
92+
}
93+
umf_result_t close_ipc_handle([[maybe_unused]] void *ptr) noexcept {
94+
return UMF_RESULT_ERROR_UNKNOWN;
95+
}
7696
} provider_base_t;
7797

7898
umf_memory_provider_ops_t BASE_PROVIDER_OPS =

test/common/provider_null.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2023 Intel Corporation
1+
// Copyright (C) 2023-2024 Intel Corporation
22
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

@@ -93,6 +93,41 @@ static umf_result_t nullAllocationSplit(void *provider, void *ptr,
9393
return UMF_RESULT_SUCCESS;
9494
}
9595

96+
static umf_result_t nullGetIpcHandleSize(void *provider, size_t *size) {
97+
(void)provider;
98+
(void)size;
99+
return UMF_RESULT_SUCCESS;
100+
}
101+
102+
static umf_result_t nullGetIpcHandle(void *provider, const void *ptr,
103+
size_t size, void *ipcHandle) {
104+
(void)provider;
105+
(void)ptr;
106+
(void)size;
107+
(void)ipcHandle;
108+
return UMF_RESULT_SUCCESS;
109+
}
110+
111+
static umf_result_t nullPutIpcHandle(void *provider, void *ipcHandle) {
112+
(void)provider;
113+
(void)ipcHandle;
114+
return UMF_RESULT_SUCCESS;
115+
}
116+
117+
static umf_result_t nullOpenIpcHandle(void *provider, void *ipcHandle,
118+
void **ptr) {
119+
(void)provider;
120+
(void)ipcHandle;
121+
(void)ptr;
122+
return UMF_RESULT_SUCCESS;
123+
}
124+
125+
static umf_result_t nullCloseIpcHandle(void *provider, void *ptr) {
126+
(void)provider;
127+
(void)ptr;
128+
return UMF_RESULT_SUCCESS;
129+
}
130+
96131
umf_memory_provider_ops_t UMF_NULL_PROVIDER_OPS = {
97132
.version = UMF_VERSION_CURRENT,
98133
.initialize = nullInitialize,
@@ -107,4 +142,9 @@ umf_memory_provider_ops_t UMF_NULL_PROVIDER_OPS = {
107142
.ext.purge_force = nullPurgeForce,
108143
.ext.allocation_merge = nullAllocationMerge,
109144
.ext.allocation_split = nullAllocationSplit,
145+
.ipc.get_ipc_handle_size = nullGetIpcHandleSize,
146+
.ipc.get_ipc_handle = nullGetIpcHandle,
147+
.ipc.put_ipc_handle = nullPutIpcHandle,
148+
.ipc.open_ipc_handle = nullOpenIpcHandle,
149+
.ipc.close_ipc_handle = nullCloseIpcHandle,
110150
};

test/common/provider_trace.c

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2023 Intel Corporation
1+
// Copyright (C) 2023-2024 Intel Corporation
22
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

@@ -127,6 +127,53 @@ static umf_result_t traceAllocationSplit(void *provider, void *ptr,
127127
ptr, totalSize, firstSize);
128128
}
129129

130+
static umf_result_t traceGetIpcHandleSize(void *provider, size_t *pSize) {
131+
umf_provider_trace_params_priv_t *traceProvider =
132+
(umf_provider_trace_params_priv_t *)provider;
133+
134+
traceProvider->trace("get_ipc_handle_size");
135+
return umfMemoryProviderGetIPCHandleSize(traceProvider->hUpstreamProvider,
136+
pSize);
137+
}
138+
139+
static umf_result_t traceGetIpcHandle(void *provider, const void *ptr,
140+
size_t size, void *ipcHandle) {
141+
umf_provider_trace_params_priv_t *traceProvider =
142+
(umf_provider_trace_params_priv_t *)provider;
143+
144+
traceProvider->trace("get_ipc_handle");
145+
return umfMemoryProviderGetIPCHandle(traceProvider->hUpstreamProvider, ptr,
146+
size, ipcHandle);
147+
}
148+
149+
static umf_result_t tracePutIpcHandle(void *provider, void *ipcHandle) {
150+
umf_provider_trace_params_priv_t *traceProvider =
151+
(umf_provider_trace_params_priv_t *)provider;
152+
153+
traceProvider->trace("put_ipc_handle");
154+
return umfMemoryProviderPutIPCHandle(traceProvider->hUpstreamProvider,
155+
ipcHandle);
156+
}
157+
158+
static umf_result_t traceOpenIpcHandle(void *provider, void *ipcHandle,
159+
void **ptr) {
160+
umf_provider_trace_params_priv_t *traceProvider =
161+
(umf_provider_trace_params_priv_t *)provider;
162+
163+
traceProvider->trace("open_ipc_handle");
164+
return umfMemoryProviderOpenIPCHandle(traceProvider->hUpstreamProvider,
165+
ipcHandle, ptr);
166+
}
167+
168+
static umf_result_t traceCloseIpcHandle(void *provider, void *ptr) {
169+
umf_provider_trace_params_priv_t *traceProvider =
170+
(umf_provider_trace_params_priv_t *)provider;
171+
172+
traceProvider->trace("close_ipc_handle");
173+
return umfMemoryProviderCloseIPCHandle(traceProvider->hUpstreamProvider,
174+
ptr);
175+
}
176+
130177
umf_memory_provider_ops_t UMF_TRACE_PROVIDER_OPS = {
131178
.version = UMF_VERSION_CURRENT,
132179
.initialize = traceInitialize,
@@ -141,4 +188,9 @@ umf_memory_provider_ops_t UMF_TRACE_PROVIDER_OPS = {
141188
.ext.purge_force = tracePurgeForce,
142189
.ext.allocation_merge = traceAllocationMerge,
143190
.ext.allocation_split = traceAllocationSplit,
191+
.ipc.get_ipc_handle_size = traceGetIpcHandleSize,
192+
.ipc.get_ipc_handle = traceGetIpcHandle,
193+
.ipc.put_ipc_handle = tracePutIpcHandle,
194+
.ipc.open_ipc_handle = traceOpenIpcHandle,
195+
.ipc.close_ipc_handle = traceCloseIpcHandle,
144196
};

0 commit comments

Comments
 (0)