Skip to content

Commit dd0ffe3

Browse files
committed
fix ci failures
1 parent b0f868a commit dd0ffe3

File tree

3 files changed

+61
-13
lines changed

3 files changed

+61
-13
lines changed

benchmark/libponyrt/mem/pool.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44

55
#define LARGE_ALLOC ponyint_pool_adjust_size(POOL_MAX + 1)
66

7-
/// When we mmap, pull at least this many bytes.
8-
#ifdef PLATFORM_IS_ILP32
9-
#define POOL_MMAP (16 * 1024 * 1024) // 16 MB
10-
#else
11-
#define POOL_MMAP (128 * 1024 * 1024) // 128 MB
12-
#endif
13-
147
typedef char block_t[32];
158

169
class PoolBench: public ::benchmark::Fixture

src/libponyrt/mem/pool.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ PONY_EXTERN_C_BEGIN
3232
* and 16 bytes for the memalign and message passing pool implementations.
3333
*/
3434

35+
#ifndef POOL_USE_DEFAULT
36+
#define POOL_MIN_BITS 4
37+
#else
3538
#define POOL_MIN_BITS 5
39+
#endif
40+
3641
#define POOL_MAX_BITS 20
3742
#define POOL_ALIGN_BITS 10
3843

@@ -57,6 +62,28 @@ size_t ponyint_pool_used_size(size_t index);
5762

5863
size_t ponyint_pool_adjust_size(size_t size);
5964

65+
#ifndef POOL_USE_DEFAULT
66+
#define POOL_INDEX(SIZE) \
67+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 0)), 0, \
68+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 1)), 1, \
69+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 2)), 2, \
70+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 3)), 3, \
71+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 4)), 4, \
72+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 5)), 5, \
73+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 6)), 6, \
74+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 7)), 7, \
75+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 8)), 8, \
76+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 9)), 9, \
77+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 10)), 10, \
78+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 11)), 11, \
79+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 12)), 12, \
80+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 13)), 13, \
81+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 14)), 14, \
82+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 15)), 15, \
83+
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 16)), 16, \
84+
EXPR_NONE \
85+
)))))))))))))))))
86+
#else
6087
#define POOL_INDEX(SIZE) \
6188
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 0)), 0, \
6289
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 1)), 1, \
@@ -76,6 +103,7 @@ size_t ponyint_pool_adjust_size(size_t size);
76103
__pony_choose_expr(SIZE <= (1 << (POOL_MIN_BITS + 15)), 15, \
77104
EXPR_NONE \
78105
))))))))))))))))
106+
#endif
79107

80108
#define POOL_ALLOC(TYPE) \
81109
(TYPE*) ponyint_pool_alloc(POOL_INDEX(sizeof(TYPE)))

test/libponyrt/mem/pool.cc

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,53 @@ TEST(Pool, LargeAlloc)
7777

7878
TEST(Pool, Index)
7979
{
80+
size_t expected_index = 0;
8081
size_t index = ponyint_pool_index(1);
8182
ASSERT_TRUE(index == 0);
8283

84+
index = ponyint_pool_index(7);
85+
ASSERT_TRUE(index == expected_index);
86+
87+
index = ponyint_pool_index(8);
88+
ASSERT_TRUE(index == expected_index);
89+
90+
index = ponyint_pool_index(9);
91+
ASSERT_TRUE(index == expected_index);
92+
93+
index = ponyint_pool_index(15);
94+
ASSERT_TRUE(index == expected_index);
95+
96+
index = ponyint_pool_index(16);
97+
ASSERT_TRUE(index == expected_index);
98+
99+
#ifndef POOL_USE_DEFAULT
100+
expected_index++;
101+
#endif
102+
103+
index = ponyint_pool_index(17);
104+
ASSERT_TRUE(index == expected_index);
105+
83106
index = ponyint_pool_index(31);
84-
ASSERT_TRUE(index == 0);
107+
ASSERT_TRUE(index == expected_index);
85108

86109
index = ponyint_pool_index(32);
87-
ASSERT_TRUE(index == 0);
110+
ASSERT_TRUE(index == expected_index);
111+
112+
expected_index++;
88113

89114
index = ponyint_pool_index(33);
90-
ASSERT_TRUE(index == 1);
115+
ASSERT_TRUE(index == expected_index);
91116

92117
index = ponyint_pool_index(63);
93-
ASSERT_TRUE(index == 1);
118+
ASSERT_TRUE(index == expected_index);
94119

95120
index = ponyint_pool_index(64);
96-
ASSERT_TRUE(index == 1);
121+
ASSERT_TRUE(index == expected_index);
122+
123+
expected_index++;
97124

98125
index = ponyint_pool_index(65);
99-
ASSERT_TRUE(index == 2);
126+
ASSERT_TRUE(index == expected_index);
100127

101128
index = ponyint_pool_index(POOL_MAX - 1);
102129
ASSERT_TRUE(index == POOL_COUNT - 1);

0 commit comments

Comments
 (0)