Skip to content

Commit

Permalink
Merge pull request #935 from DamianDuy/changeBucketGenerationFor1
Browse files Browse the repository at this point in the history
[umf] change default MinBucketSize and ensure buckets are generated from the min size 8
  • Loading branch information
pbalcer authored Oct 24, 2023
2 parents 00143fc + 0502237 commit b3506f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions source/common/umf_pools/disjoint_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ class DisjointPool::AllocImpl {
// Generate buckets sized such as: 64, 96, 128, 192, ..., CutOff.
// Powers of 2 and the value halfway between the powers of 2.
auto Size1 = params.MinBucketSize;
// Buckets sized smaller than the bucket default size- 8 aren't needed.
Size1 = std::max(Size1, MIN_BUCKET_DEFAULT_SIZE);
auto Size2 = Size1 + Size1 / 2;
for (; Size2 < CutOff; Size1 *= 2, Size2 *= 2) {
Buckets.push_back(std::make_unique<Bucket>(Size1, *this));
Expand Down
4 changes: 3 additions & 1 deletion source/common/umf_pools/disjoint_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

namespace usm {

inline constexpr size_t MIN_BUCKET_DEFAULT_SIZE = 8;

// Configuration for specific USM allocator instance
class DisjointPoolConfig {
public:
Expand Down Expand Up @@ -46,7 +48,7 @@ class DisjointPoolConfig {

// Holds the minimum bucket size valid for allocation of a memory type.
// This value must be a power of 2.
size_t MinBucketSize = 1;
size_t MinBucketSize = MIN_BUCKET_DEFAULT_SIZE;

// Holds size of the pool managed by the allocator.
size_t CurPoolSize = 0;
Expand Down

0 comments on commit b3506f4

Please sign in to comment.