3
3
// See LICENSE.TXT
4
4
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
5
6
+ #include " umf_pools/disjoint_pool_config_parser.hpp"
6
7
#include " ur_pool_manager.hpp"
7
8
8
9
#include < uur/fixtures.h>
@@ -18,6 +19,27 @@ auto createMockPoolHandle() {
18
19
[](umf_memory_pool_t *) {});
19
20
}
20
21
22
+ bool compareConfig (const usm::umf_disjoint_pool_config_t &left,
23
+ usm::umf_disjoint_pool_config_t &right) {
24
+ return left.MaxPoolableSize == right.MaxPoolableSize &&
25
+ left.Capacity == right.Capacity &&
26
+ left.SlabMinSize == right.SlabMinSize ;
27
+ }
28
+
29
+ bool compareConfigs (const usm::DisjointPoolAllConfigs &left,
30
+ usm::DisjointPoolAllConfigs &right) {
31
+ return left.EnableBuffers == right.EnableBuffers &&
32
+ compareConfig (left.Configs [usm::DisjointPoolMemType::Host],
33
+ right.Configs [usm::DisjointPoolMemType::Host]) &&
34
+ compareConfig (left.Configs [usm::DisjointPoolMemType::Device],
35
+ right.Configs [usm::DisjointPoolMemType::Device]) &&
36
+ compareConfig (left.Configs [usm::DisjointPoolMemType::Shared],
37
+ right.Configs [usm::DisjointPoolMemType::Shared]) &&
38
+ compareConfig (
39
+ left.Configs [usm::DisjointPoolMemType::SharedReadOnly],
40
+ right.Configs [usm::DisjointPoolMemType::SharedReadOnly]);
41
+ }
42
+
21
43
TEST_P (urUsmPoolDescriptorTest, poolIsPerContextTypeAndDevice) {
22
44
auto &devices = uur::DevicesEnvironment::instance->devices ;
23
45
@@ -111,4 +133,29 @@ TEST_P(urUsmPoolManagerTest, poolManagerGetNonexistant) {
111
133
}
112
134
}
113
135
136
+ TEST_P (urUsmPoolManagerTest, config) {
137
+ // Check default config
138
+ usm::DisjointPoolAllConfigs def;
139
+ usm::DisjointPoolAllConfigs parsed1 =
140
+ usm::parseDisjointPoolConfig (" 1;host:2M,4,64K;device:4M,4,64K;"
141
+ " shared:0,0,2M;read_only_shared:4M,4,2M" ,
142
+ 0 );
143
+ ASSERT_EQ (compareConfigs (def, parsed1), true );
144
+
145
+ // Check partially set config
146
+ usm::DisjointPoolAllConfigs parsed2 =
147
+ usm::parseDisjointPoolConfig (" 1;device:4M;shared:0,0,2M" , 0 );
148
+ ASSERT_EQ (compareConfigs (def, parsed2), true );
149
+
150
+ // Check non-default config
151
+ usm::DisjointPoolAllConfigs test (def);
152
+ test.Configs [usm::DisjointPoolMemType::Shared].MaxPoolableSize = 128 * 1024 ;
153
+ test.Configs [usm::DisjointPoolMemType::Shared].Capacity = 4 ;
154
+ test.Configs [usm::DisjointPoolMemType::Shared].SlabMinSize = 64 * 1024 ;
155
+
156
+ usm::DisjointPoolAllConfigs parsed3 =
157
+ usm::parseDisjointPoolConfig (" 1;shared:128K,4,64K" , 0 );
158
+ ASSERT_EQ (compareConfigs (test, parsed3), true );
159
+ }
160
+
114
161
UUR_INSTANTIATE_DEVICE_TEST_SUITE_P (urUsmPoolManagerTest);
0 commit comments