2
2
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
4
5
+ #include " memspace_fixtures.hpp"
5
6
#include " memspace_helpers.hpp"
6
7
7
8
#include < umf/base.h>
@@ -13,17 +14,53 @@ using umf_test::test;
13
14
TEST_F (test, memTargetNuma) {
14
15
auto memspace = umfMemspaceHostAllGet ();
15
16
ASSERT_NE (memspace, nullptr );
16
-
17
+ umf_memtarget_type_t type;
17
18
for (size_t i = 0 ; i < umfMemspaceMemtargetNum (memspace); i++) {
18
19
auto hTarget = umfMemspaceMemtargetGet (memspace, i);
19
20
ASSERT_NE (hTarget, nullptr );
20
- umf_memtarget_type_t type;
21
21
auto ret = umfMemtargetGetType (hTarget, &type);
22
22
EXPECT_EQ (ret, UMF_RESULT_SUCCESS);
23
23
EXPECT_EQ (type, UMF_MEMTARGET_TYPE_NUMA);
24
24
}
25
25
}
26
26
27
+ TEST_F (numaNodesTest, getCapacity) {
28
+ auto memspace = umfMemspaceHostAllGet ();
29
+ ASSERT_NE (memspace, nullptr );
30
+ std::vector<size_t > capacities;
31
+ for (auto nodeId : nodeIds) {
32
+ capacities.push_back (numa_node_size64 (nodeId, nullptr ));
33
+ }
34
+
35
+ for (size_t i = 0 ; i < umfMemspaceMemtargetNum (memspace); i++) {
36
+ auto hTarget = umfMemspaceMemtargetGet (memspace, i);
37
+ ASSERT_NE (hTarget, nullptr );
38
+ size_t capacity;
39
+ auto ret = umfMemtargetGetCapacity (hTarget, &capacity);
40
+ EXPECT_EQ (ret, UMF_RESULT_SUCCESS);
41
+ auto it = std::find (capacities.begin (), capacities.end (), capacity);
42
+ EXPECT_NE (it, capacities.end ());
43
+ if (it != capacities.end ()) {
44
+ capacities.erase (it);
45
+ }
46
+ }
47
+ ASSERT_EQ (capacities.size (), 0 );
48
+ }
49
+
50
+ TEST_F (numaNodesTest, getCapacityInvalid) {
51
+ auto memspace = umfMemspaceHostAllGet ();
52
+ ASSERT_NE (memspace, nullptr );
53
+ size_t capacity;
54
+ auto ret = umfMemtargetGetCapacity (NULL , &capacity);
55
+ EXPECT_EQ (ret, UMF_RESULT_ERROR_INVALID_ARGUMENT);
56
+ ret = umfMemtargetGetCapacity (NULL , NULL );
57
+ EXPECT_EQ (ret, UMF_RESULT_ERROR_INVALID_ARGUMENT);
58
+ auto hTarget = umfMemspaceMemtargetGet (memspace, 0 );
59
+ ASSERT_NE (hTarget, nullptr );
60
+ ret = umfMemtargetGetCapacity (hTarget, NULL );
61
+ EXPECT_EQ (ret, UMF_RESULT_ERROR_INVALID_ARGUMENT);
62
+ }
63
+
27
64
TEST_F (test, memTargetInvalid) {
28
65
auto memspace = umfMemspaceHostAllGet ();
29
66
ASSERT_NE (memspace, nullptr );
0 commit comments