Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add device subsets example #346

Merged
merged 34 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f6f37fa
Add device subsets example
PointKernel Jul 3, 2023
d35db89
Merge remote-tracking branch 'upstream/dev' into subset-example
PointKernel Aug 5, 2023
482a14e
Cleanups: fix typo, remove printf etc
PointKernel Aug 5, 2023
8e559e0
Remove unrelated code
PointKernel Aug 5, 2023
40b9b15
Merge remote-tracking branch 'upstream/dev' into subset-example
PointKernel Aug 8, 2023
fda8f88
Add default extent template parameter
PointKernel Aug 8, 2023
2c92f84
Add missing headers
PointKernel Aug 9, 2023
233c668
Add missing header + temporarily disable asserts
PointKernel Aug 9, 2023
4eb25c9
Update subset example
PointKernel Aug 9, 2023
b68761d
Merge remote-tracking branch 'upstream/dev' into subset-example
PointKernel Aug 10, 2023
56b5dc3
Update example
PointKernel Aug 10, 2023
eff6faa
Resolve merging conflict
PointKernel Aug 10, 2023
871424a
Add default parameters to aow_storage for convenience
PointKernel Aug 10, 2023
635988b
Add storage initialized_async
PointKernel Aug 15, 2023
393ee3b
Update subset example
PointKernel Aug 15, 2023
70c3df7
Renaming
PointKernel Aug 15, 2023
085d1bb
Minor cleanups
PointKernel Aug 16, 2023
755db26
Add docs and comments
PointKernel Aug 17, 2023
8c746d7
Merge remote-tracking branch 'upstream/dev' into subset-example
PointKernel Sep 1, 2023
cce72b4
Merge remote-tracking branch 'upstream/dev' into subset-example
PointKernel Sep 6, 2023
b8028f4
Remove CGSize from window_extent
PointKernel Sep 6, 2023
d913720
Add more headers
PointKernel Sep 6, 2023
02eabf6
Temporarily disable window extent checks in open addressing ref base …
PointKernel Sep 11, 2023
3d016f6
Remove window_size tparam from window_extent
sleeepyjack Sep 12, 2023
5d88ea7
Add operator-agnostic static_set_ref move ctor and with() helper func…
sleeepyjack Sep 13, 2023
2433c09
Update device subset example
sleeepyjack Sep 13, 2023
c46d6fe
Partially re-enable checks
sleeepyjack Sep 13, 2023
adc6a54
Merge remote-tracking branch 'upstream/dev' into subset-example
PointKernel Sep 22, 2023
770a2ad
Merge remote-tracking branch 'origin/subset-example' into subset-example
PointKernel Sep 25, 2023
c632a9f
Remove window_extent static check and use size_t in the example
PointKernel Sep 26, 2023
2fa3810
With function to static_map_ref
PointKernel Sep 26, 2023
9e29ea7
Add TODO reminder
PointKernel Sep 26, 2023
8c8c3c1
Clean up example code
PointKernel Sep 26, 2023
2e7658c
Move the sentinel
PointKernel Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions include/cuco/detail/static_map/static_map_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ __host__ __device__ constexpr static_map_ref<
{
}

template <typename Key,
typename T,
cuda::thread_scope Scope,
typename KeyEqual,
typename ProbingScheme,
typename StorageRef,
typename... Operators>
template <typename... OtherOperators>
__host__ __device__ constexpr static_map_ref<Key,
T,
Scope,
KeyEqual,
ProbingScheme,
StorageRef,
Operators...>::
static_map_ref(
static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, OtherOperators...>&&
other) noexcept
: impl_{std::move(other.impl_)},
predicate_{std::move(other.predicate_)},
empty_value_sentinel_{other.empty_value_sentinel_}
PointKernel marked this conversation as resolved.
Show resolved Hide resolved
{
}

template <typename Key,
typename T,
cuda::thread_scope Scope,
Expand Down Expand Up @@ -92,6 +116,21 @@ static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>
return empty_value_sentinel_;
}

template <typename Key,
typename T,
cuda::thread_scope Scope,
typename KeyEqual,
typename ProbingScheme,
typename StorageRef,
typename... Operators>
template <typename... NewOperators>
auto static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, Operators...>::with(
NewOperators...) && noexcept
{
return static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, NewOperators...>(
std::move(*this));
}

template <typename Key,
typename T,
cuda::thread_scope Scope,
Expand Down
39 changes: 39 additions & 0 deletions include/cuco/static_map_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ class static_map_ref
probing_scheme_type const& probing_scheme,
storage_ref_type storage_ref) noexcept;

/**
* @brief Operator-agnostic move constructor.
*
* @tparam OtherOperators Operator set of the `other` object
*
* @param other Object to construct `*this` from
*/
template <typename... OtherOperators>
__host__ __device__ explicit constexpr static_map_ref(
static_map_ref<Key, T, Scope, KeyEqual, ProbingScheme, StorageRef, OtherOperators...>&&
other) noexcept;

/**
* @brief Gets the maximum number of elements the container can hold.
*
Expand All @@ -130,6 +142,23 @@ class static_map_ref
*/
[[nodiscard]] __host__ __device__ constexpr mapped_type empty_value_sentinel() const noexcept;

/**
* @brief Creates a reference with new operators from the current object.
*
* Note that this function uses move semantics and thus invalidates the current object.
*
* @warning Using two or more reference objects to the same container but with
* a different operator set at the same time results in undefined behavior.
*
* @tparam NewOperators List of `cuco::op::*_tag` types
*
* @param ops List of operators, e.g., `cuco::insert`
*
* @return `*this` with `NewOperators...`
*/
template <typename... NewOperators>
[[nodiscard]] __host__ __device__ auto with(NewOperators... ops) && noexcept;

private:
struct predicate_wrapper;

Expand All @@ -140,6 +169,16 @@ class static_map_ref
// Mixins need to be friends with this class in order to access private members
template <typename Op, typename Ref>
friend class detail::operator_impl;

// Refs with other operator sets need to be friends too
template <typename Key_,
typename T_,
cuda::thread_scope Scope_,
typename KeyEqual_,
typename ProbingScheme_,
typename StorageRef_,
typename... Operators_>
friend class static_map_ref;
};

} // namespace experimental
Expand Down