Skip to content

Commit b3506f4

Browse files
authored
Merge pull request #935 from DamianDuy/changeBucketGenerationFor1
[umf] change default MinBucketSize and ensure buckets are generated from the min size 8
2 parents 00143fc + 0502237 commit b3506f4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

source/common/umf_pools/disjoint_pool.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ class DisjointPool::AllocImpl {
293293
// Generate buckets sized such as: 64, 96, 128, 192, ..., CutOff.
294294
// Powers of 2 and the value halfway between the powers of 2.
295295
auto Size1 = params.MinBucketSize;
296+
// Buckets sized smaller than the bucket default size- 8 aren't needed.
297+
Size1 = std::max(Size1, MIN_BUCKET_DEFAULT_SIZE);
296298
auto Size2 = Size1 + Size1 / 2;
297299
for (; Size2 < CutOff; Size1 *= 2, Size2 *= 2) {
298300
Buckets.push_back(std::make_unique<Bucket>(Size1, *this));

source/common/umf_pools/disjoint_pool.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
namespace usm {
1919

20+
inline constexpr size_t MIN_BUCKET_DEFAULT_SIZE = 8;
21+
2022
// Configuration for specific USM allocator instance
2123
class DisjointPoolConfig {
2224
public:
@@ -46,7 +48,7 @@ class DisjointPoolConfig {
4648

4749
// Holds the minimum bucket size valid for allocation of a memory type.
4850
// This value must be a power of 2.
49-
size_t MinBucketSize = 1;
51+
size_t MinBucketSize = MIN_BUCKET_DEFAULT_SIZE;
5052

5153
// Holds size of the pool managed by the allocator.
5254
size_t CurPoolSize = 0;

0 commit comments

Comments
 (0)