Skip to content

Commit

Permalink
Add rehash for multiset and multimap
Browse files Browse the repository at this point in the history
  • Loading branch information
PointKernel committed Nov 5, 2024
1 parent 93d6172 commit 505697e
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 0 deletions.
58 changes: 58 additions & 0 deletions include/cuco/detail/static_multimap/static_multimap.inl
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,64 @@ static_multimap<Key, T, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Stora
return impl_->count(first, last, ref(op::count), stream);
}

template <class Key,
class T,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multimap<Key, T, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::rehash(
cuda::stream_ref stream)
{
this->impl_->rehash(*this, stream);
}

template <class Key,
class T,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multimap<Key, T, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::rehash(
size_type capacity, cuda::stream_ref stream)
{
auto const extent = make_bucket_extent<static_multimap>(capacity);
this->impl_->rehash(extent, *this, stream);
}

template <class Key,
class T,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multimap<Key, T, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::
rehash_async(cuda::stream_ref stream)
{
this->impl_->rehash_async(*this, stream);
}

template <class Key,
class T,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multimap<Key, T, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::
rehash_async(size_type capacity, cuda::stream_ref stream)
{
auto const extent = make_bucket_extent<static_multimap>(capacity);
this->impl_->rehash_async(extent, *this, stream);
}

template <class Key,
class T,
class Extent,
Expand Down
54 changes: 54 additions & 0 deletions include/cuco/detail/static_multiset/static_multiset.inl
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,60 @@ static_multiset<Key, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>
return impl_->retrieve_outer(first, last, output_probe, output_match, probe_ref, stream);
}

template <class Key,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multiset<Key, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::rehash(
cuda::stream_ref stream)
{
this->impl_->rehash(*this, stream);
}

template <class Key,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multiset<Key, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::rehash(
size_type capacity, cuda::stream_ref stream)
{
auto const extent = make_bucket_extent<static_multiset>(capacity);
this->impl_->rehash(extent, *this, stream);
}

template <class Key,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multiset<Key, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::rehash_async(
cuda::stream_ref stream)
{
this->impl_->rehash_async(*this, stream);
}

template <class Key,
class Extent,
cuda::thread_scope Scope,
class KeyEqual,
class ProbingScheme,
class Allocator,
class Storage>
void static_multiset<Key, Extent, Scope, KeyEqual, ProbingScheme, Allocator, Storage>::rehash_async(
size_type capacity, cuda::stream_ref stream)
{
auto const extent = make_bucket_extent<static_multiset>(capacity);
this->impl_->rehash_async(extent, *this, stream);
}

template <class Key,
class Extent,
cuda::thread_scope Scope,
Expand Down
55 changes: 55 additions & 0 deletions include/cuco/static_multimap.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,61 @@ class static_multimap {
template <typename InputIt>
size_type count(InputIt first, InputIt last, cuda::stream_ref stream = {}) const;

/**
* @brief Regenerates the container.
*
* @note This function synchronizes the given stream. For asynchronous execution use
* `rehash_async`.
*
* @param stream CUDA stream used for this operation
*/
void rehash(cuda::stream_ref stream = {});

/**
* @brief Reserves at least the specified number of slots and regenerates the container
*
* @note Changes the number of slots to a value that is not less than `capacity`, then
* rehashes the container, i.e. puts the elements into appropriate slots considering
* that the total number of slots has changed.
*
* @note This function synchronizes the given stream. For asynchronous execution use
* `rehash_async`.
*
* @note Behavior is undefined if the desired `capacity` is insufficient to store all of the
* contained elements.
*
* @note This function is not available if the conatiner's `extent_type` is static.
*
* @param capacity New capacity of the container
* @param stream CUDA stream used for this operation
*/
void rehash(size_type capacity, cuda::stream_ref stream = {});

/**
* @brief Asynchronously regenerates the container.
*
* @param stream CUDA stream used for this operation
*/
void rehash_async(cuda::stream_ref stream = {});

/**
* @brief Asynchronously reserves at least the specified number of slots and regenerates the
* container
*
* @note Changes the number of slots to a value that is not less than `capacity`, then
* rehashes the container, i.e. puts the elements into appropriate slots considering
* that the total number of slots has changed.
*
* @note Behavior is undefined if the desired `capacity` is insufficient to store all of the
* contained elements.
*
* @note This function is not available if the conatiner's `extent_type` is static.
*
* @param capacity New capacity of the container
* @param stream CUDA stream used for this operation
*/
void rehash_async(size_type capacity, cuda::stream_ref stream = {});

/**
* @brief Gets the maximum number of elements the hash map can hold.
*
Expand Down
55 changes: 55 additions & 0 deletions include/cuco/static_multiset.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,61 @@ class static_multiset {
OutputMatchIt output_match,
cuda::stream_ref stream = {}) const;

/**
* @brief Regenerates the container.
*
* @note This function synchronizes the given stream. For asynchronous execution use
* `rehash_async`.
*
* @param stream CUDA stream used for this operation
*/
void rehash(cuda::stream_ref stream = {});

/**
* @brief Reserves at least the specified number of slots and regenerates the container
*
* @note Changes the number of slots to a value that is not less than `capacity`, then
* rehashes the container, i.e. puts the elements into appropriate slots considering
* that the total number of slots has changed.
*
* @note This function synchronizes the given stream. For asynchronous execution use
* `rehash_async`.
*
* @note Behavior is undefined if the desired `capacity` is insufficient to store all of the
* contained elements.
*
* @note This function is not available if the conatiner's `extent_type` is static.
*
* @param capacity New capacity of the container
* @param stream CUDA stream used for this operation
*/
void rehash(size_type capacity, cuda::stream_ref stream = {});

/**
* @brief Asynchronously regenerates the container.
*
* @param stream CUDA stream used for this operation
*/
void rehash_async(cuda::stream_ref stream = {});

/**
* @brief Asynchronously reserves at least the specified number of slots and regenerates the
* container
*
* @note Changes the number of slots to a value that is not less than `capacity`, then
* rehashes the container, i.e. puts the elements into appropriate slots considering
* that the total number of slots has changed.
*
* @note Behavior is undefined if the desired `capacity` is insufficient to store all of the
* contained elements.
*
* @note This function is not available if the conatiner's `extent_type` is static.
*
* @param capacity New capacity of the container
* @param stream CUDA stream used for this operation
*/
void rehash_async(size_type capacity, cuda::stream_ref stream = {});

/**
* @brief Gets the number of elements in the container.
*
Expand Down

0 comments on commit 505697e

Please sign in to comment.