@@ -166,9 +166,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_provider) {
166
166
167
167
TEST_P (CoarseWithMemoryStrategyTest, coarseTest_basic_fixed_memory) {
168
168
// preallocate some memory and initialize the vector with zeros
169
- const size_t buff_size = 20 * MB;
169
+ const size_t buff_size = 20 * MB + coarse_params. page_size ;
170
170
std::vector<char > buffer (buff_size, 0 );
171
- void *buf = (void *)buffer.data ();
171
+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
172
+ coarse_params.page_size );
172
173
ASSERT_NE (buf, nullptr );
173
174
174
175
coarse_params.cb .alloc = NULL ;
@@ -206,9 +207,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_fixed_memory) {
206
207
207
208
TEST_P (CoarseWithMemoryStrategyTest, coarseTest_fixed_memory_various) {
208
209
// preallocate some memory and initialize the vector with zeros
209
- const size_t buff_size = 20 * MB;
210
+ const size_t buff_size = 20 * MB + coarse_params. page_size ;
210
211
std::vector<char > buffer (buff_size, 0 );
211
- void *buf = (void *)buffer.data ();
212
+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
213
+ coarse_params.page_size );
212
214
ASSERT_NE (buf, nullptr );
213
215
214
216
coarse_params.cb .alloc = NULL ;
@@ -627,6 +629,15 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic_free_cb_fails) {
627
629
}
628
630
629
631
TEST_P (CoarseWithMemoryStrategyTest, coarseTest_split_cb_fails) {
632
+ if (coarse_params.allocation_strategy ==
633
+ UMF_COARSE_MEMORY_STRATEGY_FASTEST) {
634
+ // This test is designed for the UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE
635
+ // and UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE strategies,
636
+ // because the UMF_COARSE_MEMORY_STRATEGY_FASTEST strategy
637
+ // looks always for a block of size greater by the page size.
638
+ return ;
639
+ }
640
+
630
641
umf_memory_provider_handle_t malloc_memory_provider;
631
642
umf_result = umfMemoryProviderCreate (&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL ,
632
643
&malloc_memory_provider);
@@ -702,9 +713,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_split_cb_fails) {
702
713
703
714
TEST_P (CoarseWithMemoryStrategyTest, coarseTest_merge_cb_fails) {
704
715
// preallocate some memory and initialize the vector with zeros
705
- const size_t buff_size = 10 * MB;
716
+ const size_t buff_size = 10 * MB + coarse_params. page_size ;
706
717
std::vector<char > buffer (buff_size, 0 );
707
- void *buf = (void *)buffer.data ();
718
+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
719
+ coarse_params.page_size );
708
720
ASSERT_NE (buf, nullptr );
709
721
710
722
coarse_params.cb .alloc = NULL ;
@@ -901,6 +913,15 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_provider_alloc_not_set) {
901
913
}
902
914
903
915
TEST_P (CoarseWithMemoryStrategyTest, coarseTest_basic) {
916
+ if (coarse_params.allocation_strategy ==
917
+ UMF_COARSE_MEMORY_STRATEGY_FASTEST) {
918
+ // This test is designed for the UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE
919
+ // and UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE strategies,
920
+ // because the UMF_COARSE_MEMORY_STRATEGY_FASTEST strategy
921
+ // looks always for a block of size greater by the page size.
922
+ return ;
923
+ }
924
+
904
925
umf_memory_provider_handle_t malloc_memory_provider;
905
926
umf_result = umfMemoryProviderCreate (&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL ,
906
927
&malloc_memory_provider);
@@ -1065,6 +1086,15 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_basic) {
1065
1086
}
1066
1087
1067
1088
TEST_P (CoarseWithMemoryStrategyTest, coarseTest_simple1) {
1089
+ if (coarse_params.allocation_strategy ==
1090
+ UMF_COARSE_MEMORY_STRATEGY_FASTEST) {
1091
+ // This test is designed for the UMF_COARSE_MEMORY_STRATEGY_FASTEST_BUT_ONE
1092
+ // and UMF_COARSE_MEMORY_STRATEGY_CHECK_ALL_SIZE strategies,
1093
+ // because the UMF_COARSE_MEMORY_STRATEGY_FASTEST strategy
1094
+ // looks always for a block of size greater by the page size.
1095
+ return ;
1096
+ }
1097
+
1068
1098
umf_memory_provider_handle_t malloc_memory_provider;
1069
1099
umf_result = umfMemoryProviderCreate (&UMF_MALLOC_MEMORY_PROVIDER_OPS, NULL ,
1070
1100
&malloc_memory_provider);
@@ -1106,8 +1136,9 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_simple1) {
1106
1136
ASSERT_NE (t[i], nullptr );
1107
1137
}
1108
1138
1109
- if (max_alloc_size == 0 ) {
1110
- max_alloc_size = coarse_get_stats (ch).alloc_size ;
1139
+ size_t alloc_size = coarse_get_stats (ch).alloc_size ;
1140
+ if (alloc_size > max_alloc_size) {
1141
+ max_alloc_size = alloc_size;
1111
1142
}
1112
1143
1113
1144
for (int i = 0 ; i < nptrs; i++) {
@@ -1253,9 +1284,10 @@ TEST_P(CoarseWithMemoryStrategyTest, coarseTest_alignment_provider) {
1253
1284
1254
1285
TEST_P (CoarseWithMemoryStrategyTest, coarseTest_alignment_fixed_memory) {
1255
1286
// preallocate some memory and initialize the vector with zeros
1256
- const size_t alloc_size = 40 * MB;
1287
+ const size_t alloc_size = 40 * MB + coarse_params. page_size ;
1257
1288
std::vector<char > buffer (alloc_size, 0 );
1258
- void *buf = (void *)buffer.data ();
1289
+ void *buf = (void *)ALIGN_UP_SAFE ((uintptr_t )buffer.data (),
1290
+ coarse_params.page_size );
1259
1291
ASSERT_NE (buf, nullptr );
1260
1292
1261
1293
coarse_params.cb .alloc = NULL ;
0 commit comments