-
Notifications
You must be signed in to change notification settings - Fork 113
Add static_multimap::pair_contains
#175
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
Changes from 5 commits
1366cfc
e815261
ec0f19d
8e88d14
a0c178c
9e07fc9
1657014
e6a71ae
32d0b17
4618205
bfa1461
107ee9b
0462bea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -280,15 +280,41 @@ class static_multimap { | |
| * @param first Beginning of the sequence of keys | ||
| * @param last End of the sequence of keys | ||
| * @param output_begin Beginning of the output sequence indicating whether each key is present | ||
| * @param stream CUDA stream used for contains | ||
| * @param key_equal The binary function to compare two keys for equality | ||
| * @param stream CUDA stream used for contains | ||
| */ | ||
| template <typename InputIt, typename OutputIt, typename KeyEqual = thrust::equal_to<key_type>> | ||
| void contains(InputIt first, | ||
| InputIt last, | ||
| OutputIt output_begin, | ||
| cudaStream_t stream = 0, | ||
| KeyEqual key_equal = KeyEqual{}) const; | ||
| KeyEqual key_equal = KeyEqual{}, | ||
| cudaStream_t stream = 0) const; | ||
|
|
||
| /** | ||
| * @brief Indicates whether the pairs in the range `[first, last)` are contained in the map. | ||
| * | ||
| * Stores `true` or `false` to `(output + i)` indicating if the pair `*(first + i)` exists in | ||
| * the map. | ||
| * | ||
| * @tparam InputIt Device accessible random access input iterator where | ||
| * `std::is_convertible<std::iterator_traits<InputIt>::value_type, | ||
| * static_multimap<K, V>::value_type>` is `true` | ||
|
PointKernel marked this conversation as resolved.
Outdated
|
||
| * @tparam OutputIt Device accessible output iterator whose `value_type` is convertible from | ||
| * `bool` | ||
|
PointKernel marked this conversation as resolved.
Outdated
|
||
| * @tparam PairEqual Binary callable type used to compare input pair and slot content for equality | ||
| * | ||
| * @param first Beginning of the sequence of pairs | ||
| * @param last End of the sequence of pairs | ||
| * @param output_begin Beginning of the output sequence indicating whether each pair is present | ||
| * @param pair_equal The binary function to compare input pair and slot content for equality | ||
| * @param stream CUDA stream used for contains | ||
| */ | ||
| template <typename InputIt, typename OutputIt, typename PairEqual = thrust::equal_to<value_type>> | ||
|
PointKernel marked this conversation as resolved.
Outdated
|
||
| void pair_contains(InputIt first, | ||
| InputIt last, | ||
| OutputIt output_begin, | ||
| PairEqual pair_equal = PairEqual{}, | ||
| cudaStream_t stream = 0) const; | ||
|
|
||
| /** | ||
| * @brief Counts the occurrences of keys in `[first, last)` contained in the multimap. | ||
|
|
@@ -834,6 +860,28 @@ class static_multimap { | |
| Key const& k, | ||
| KeyEqual key_equal = KeyEqual{}) noexcept; | ||
|
|
||
| /** | ||
| * @brief Indicates whether the pair `p` exists in the map. | ||
| * | ||
| * If the pair `p` was inserted into the map, `contains` returns | ||
| * true. Otherwise, it returns false. Uses the CUDA Cooperative Groups API to | ||
| * to leverage multiple threads to perform a single `contains` operation. This provides a | ||
| * significant boost in throughput compared to the non Cooperative Group | ||
| * `contains` at moderate to high load factors. | ||
| * | ||
| * @tparam PairEqual Binary callable type | ||
| * @param g The Cooperative Group used to perform the contains operation | ||
| * @param k The pair to search for | ||
| * @param pair_equal The binary callable used to compare input pair and slot content | ||
| * for equality | ||
| * @return A boolean indicating whether the input pair was inserted in the map | ||
| */ | ||
| template <typename PairEqual = thrust::equal_to<value_type>> | ||
|
PointKernel marked this conversation as resolved.
Outdated
|
||
| __device__ __forceinline__ bool pair_contains( | ||
| cooperative_groups::thread_block_tile<ProbeSequence::cg_size> const& g, | ||
| value_type const& p, | ||
|
PointKernel marked this conversation as resolved.
Outdated
|
||
| PairEqual pair_equal = PairEqual{}) noexcept; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition, we also need to add the version of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is exposed to the users, right? So the users don't have that parameter.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unlike single map, multimap needs to handle duplicates. That's the reason that we provide CG APIs only in multimap. Non-CG APIs are provided in single map but are also rarely used. Can you provide more details on your use case i.e. why would non-CG implementation is preferred over the CG ones?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
users can create a CG e.g. https://godbolt.org/z/o6jYYv7Ys
PointKernel marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * @brief Counts the occurrence of a given key contained in multimap. | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.