Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amukkara committed Sep 10, 2023
1 parent cc7cce6 commit f8837a1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/cuco/detail/trie/trie.inl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ __global__ void trie_lookup_kernel(
auto key_start_pos = keys + offsets[key_id];
auto key_length = offsets[key_id + 1] - offsets[key_id];

outputs[key_id] = ref.lookup_key(key_start_pos, key_length);
outputs[key_id] = ref.lookup(key_start_pos, key_length);
key_id += loop_stride;
}
}
Expand Down
11 changes: 8 additions & 3 deletions include/cuco/detail/trie/trie_ref.inl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ class operator_impl<op::trie_lookup_tag, trie_ref<LabelType, Allocator, Operator

public:
/**
* @brief Lookup a single key in trie
* @brief Lookup a single key
*
* @param key Iterator to first character of search key
* @tparam KeyIt Device-accessible iterator whose `value_type` can be converted to trie's
* `LabelType`
*
* @param key Iterator to first character of key
* @param length Number of characters in key
*
* @return Index of key if it exists in trie, -1 otherwise
*/
template <typename KeyIt>
[[nodiscard]] __device__ size_type lookup_key(KeyIt key, size_type length) const noexcept
[[nodiscard]] __device__ size_type lookup(KeyIt key, size_type length) const noexcept
{
auto const& trie = static_cast<ref_type const&>(*this).trie_;

Expand All @@ -50,6 +53,8 @@ class operator_impl<op::trie_lookup_tag, trie_ref<LabelType, Allocator, Operator
/**
* @brief Find position of last child of a node
*
* @tparam BitsetRef Device-accessible reference to bitset
*
* @param louds louds bitset of current level
* @param node_id node index in current level
*
Expand Down
18 changes: 12 additions & 6 deletions include/cuco/trie.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class trie {
~trie() noexcept(false);

/**
* @brief Insert new key into trie
* @brief Insert a single key into trie
*
* @param key Key to insert
*/
Expand All @@ -53,16 +53,22 @@ class trie {
void build() noexcept(false);

/**
* @brief Bulk lookup vector of keys
* @brief For every pair (`offsets_begin[i]`, `offsets_begin[i + 1]`) in the range
* `[offsets_begin, offsets_end)`, checks if the key defined by characters in the range
* [`keys_begin[offsets_begin[i]]`, `keys_begin[offsets_begin[i + 1]]`) is present in trie.
* Stores the index of key if it exists in trie (-1 otherwise) in `outputs_begin[i]`
*
* @tparam KeyIt Device-accessible iterator to individual characters of keys
* @tparam OffsetIt Device-accessible iterator to positions of key boundaries
* @tparam OutputIt Device-accessible iterator to lookup result
* @tparam KeyIt Device-accessible iterator whose `value_type` can be converted to trie's
* `LabelType`
* @tparam OffsetIt Device-accessible iterator whose `value_type` can be converted to trie's
* `size_type`
* @tparam OutputIt Device-accessible iterator whose `value_type` can be constructed from boolean
* type
*
* @param keys_begin Begin iterator to individual key characters
* @param offsets_begin Begin iterator to offsets of key boundaries
* @param offsets_end End iterator to offsets
* @param outputs_begin Begin iterator to results
* @param outputs_begin Begin iterator to lookup results
* @param stream Stream to execute lookup kernel
*/
template <typename KeyIt, typename OffsetIt, typename OutputIt>
Expand Down

0 comments on commit f8837a1

Please sign in to comment.