Skip to content

Commit

Permalink
feat: Add clear function
Browse files Browse the repository at this point in the history
  • Loading branch information
esoha-nvidia committed Jul 29, 2023
1 parent f158748 commit 966da5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/cuco/detail/static_map.inl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ static_map<Key, Value, Scope, Allocator>::static_map(
slots_, empty_key_sentinel_, empty_value_sentinel_, capacity_);
}

template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
void static_map<Key, Value, Scope, Allocator>::clear(cudaStream_t stream) {
auto constexpr block_size = 256;
auto constexpr stride = 4;
auto const grid_size = (capacity_ + stride * block_size - 1) / (stride * block_size);
detail::initialize<block_size, atomic_key_type, atomic_mapped_type>
<<<grid_size, block_size, 0, stream>>>(
slots_, empty_key_sentinel_, empty_value_sentinel_, capacity_);
}

template <typename Key, typename Value, cuda::thread_scope Scope, typename Allocator>
static_map<Key, Value, Scope, Allocator>::~static_map()
{
Expand Down
2 changes: 2 additions & 0 deletions include/cuco/static_map.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ class static_map {
Allocator const& alloc = Allocator{},
cudaStream_t stream = 0);

void clear(cudaStream_t stream = 0);

/**
* @brief Destroys the map and frees its contents.
*
Expand Down

0 comments on commit 966da5c

Please sign in to comment.