Skip to content

Commit

Permalink
explicitly cast shmem_map_size
Browse files Browse the repository at this point in the history
  • Loading branch information
srinivasyadav18 committed Jul 31, 2024
1 parent a948a98 commit 2cd20f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
13 changes: 8 additions & 5 deletions include/cuco/detail/static_map/static_map.inl
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,18 @@ void static_map<Key, T, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Stora
auto const num = cuco::detail::distance(first, last);
if (num == 0) { return; }

using shmem_size_type = int32_t;

int32_t constexpr shmem_block_size = 1024;
int32_t const default_grid_size = cuco::detail::grid_size(num, cg_size);

int32_t constexpr cardinality_threshold = shmem_block_size;
int32_t constexpr shared_map_num_elements = cardinality_threshold + shmem_block_size;
float constexpr load_factor = 0.7;
int32_t constexpr shared_map_size = (1.0 / load_factor) * shared_map_num_elements;
shmem_size_type constexpr cardinality_threshold = shmem_block_size;
shmem_size_type constexpr shared_map_num_elements = cardinality_threshold + shmem_block_size;
float constexpr load_factor = 0.7;
shmem_size_type constexpr shared_map_size =
static_cast<shmem_size_type>((1.0 / load_factor) * shared_map_num_elements);

using extent_type = cuco::extent<int32_t, shared_map_size>;
using extent_type = cuco::extent<shmem_size_type, shared_map_size>;
using shared_map_type = cuco::static_map<Key,
T,
extent_type,
Expand Down
17 changes: 9 additions & 8 deletions tests/static_map/insert_or_apply_test.cu
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ void test_insert_or_apply_shmem(Map& map, size_type num_keys, size_type num_uniq

int32_t constexpr shmem_block_size = 1024;

// Workaround to avoid compiler error:
// using a pre-constructed compile time constant for shared_map_size (2925) from
// evaluating expression (1/LF * shmem_block_size + cardinality_threshold).
// Here LF = load factor = 0.7, and cardinality_threshold = 1024
// Therefore shared_map_size = (1/0.7) * (1024 + 1024) = 2925
int32_t constexpr shared_map_size = 2925;

using extent_type = cuco::extent<int32_t, static_cast<int32_t>(shared_map_size)>;
using shmem_size_type = int32_t;

shmem_size_type constexpr cardinality_threshold = shmem_block_size;
shmem_size_type constexpr shared_map_num_elements = cardinality_threshold + shmem_block_size;
float constexpr load_factor = 0.7;
shmem_size_type constexpr shared_map_size =
static_cast<shmem_size_type>((1.0 / load_factor) * shared_map_num_elements);

using extent_type = cuco::extent<shmem_size_type, shared_map_size>;
using shared_map_type = cuco::static_map<Key,
Value,
extent_type,
Expand Down

0 comments on commit 2cd20f9

Please sign in to comment.