cuDDL
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
cuddl::batch_result_tile Struct Reference

Non-owning view of one batch-search tile's results. More...

Collaboration diagram for cuddl::batch_result_tile:
[legend]

Public Member Functions

__host__ __device__ constexpr uint32_t words_per_query () const noexcept
 
__host__ __device__ uint64_t slot_count () const noexcept
 Slots of the tile's layout, filled or not.
 
__host__ __device__ bool passed (uint32_t query_id, uint32_t reference_id) const noexcept
 Whether the pair has a result in this tile, in either order for all-to-all tiles.
 
__host__ __device__ cuda::std::optional< batch_search_result > find (uint32_t query_id, uint32_t reference_id) const noexcept
 The pair's result, or nothing when it did not pass.
 
__host__ __device__ uint32_t match_count (uint32_t query_id, uint32_t reference_id) const noexcept
 The pair's index match count, in either order for all-to-all tiles; the pair must pass and counts must be present.
 
template<typename F >
__host__ __device__ void for_each_passing (F &&f) const
 Calls f with every passing result, query-major and in reference order.
 
template<typename F >
__host__ __device__ void for_each_passing (uint32_t begin, uint32_t end, F &&f) const
 Calls f with the passing results of the tile's query rows [begin, end), in the order of the whole-tile visit.
 
__host__ __device__ uint64_t passing_before (uint32_t query) const noexcept
 Number of passing results in the tile's query rows before row query, which may be query_count.
 
__host__ __device__ uint64_t count () const noexcept
 Number of passing results.
 

Public Attributes

packed_pairwise_counts const * results {}
 
uint32_t const * match_counts {}
 Index match counts parallel to results, when requested; otherwise null.
 
uint32_t const * pass_bits {}
 Passing pairs, when the tile applied a threshold; null when every slot is filled.
 
uint32_t const * word_offsets {}
 For packed results: the number of passing results before each pass-bit word.
 
uint32_t first_query_id {}
 
uint32_t query_count {}
 
uint32_t reference_count {}
 
uint32_t bucket_count {}
 Buckets per sketch, from which both-empty counts are recovered.
 
bool upper_triangle {}
 

Detailed Description

Non-owning view of one batch-search tile's results.

Results are stored as packed_pairwise_counts; a result's position identifies its pair, so the accessors return full batch_search_result values. On the device, results sit at fixed slots: one row of reference_count slots per query, or for all-to-all tiles the packed strict upper triangle of pairs with query_id < reference_id. Exhaustive tiles fill every slot. Threshold (indexed) tiles fill only the passing pairs' slots and mark them in pass_bits, one bit per reference in rows of (reference_count + 31) / 32 words per query. Host copies (download) hold only the passing results, packed in order, and locate them through word_offsets.

All-to-all tiles store each pair once, in the row of its smaller ID. The lookups take the pair in either order: asked for (a, b) with b < a, they answer from the stored (b, a), with lower and higher swapped, as pairwise_counts::mirrored gives. The pair is then in the tile whose queries include b.

Definition at line 147 of file reference_database.cuh.

Member Function Documentation

◆ count()

__host__ __device__ uint64_t cuddl::batch_result_tile::count ( ) const
inlinenoexcept

Number of passing results.

Definition at line 264 of file reference_database.cuh.

264 {
265 if (pass_bits == nullptr) return slot_count();
266 auto const words = static_cast<size_t>(query_count) * words_per_query();
267 if (words == 0U) return 0U;
268 if (word_offsets != nullptr) {
269 return static_cast<uint64_t>(word_offsets[words - 1U]) +
270 static_cast<uint64_t>(cuda::std::popcount(pass_bits[words - 1U]));
271 }
272 uint64_t total = 0U;
273 for (size_t w = 0; w < words; ++w) {
274 total += static_cast<uint64_t>(cuda::std::popcount(pass_bits[w]));
275 }
276 return total;
277 }
auto const total
Definition kernels.cuh:443
auto const words
Definition top_k.cuh:204
__host__ __device__ constexpr uint32_t words_per_query() const noexcept
uint32_t const * word_offsets
For packed results: the number of passing results before each pass-bit word.
uint32_t const * pass_bits
Passing pairs, when the tile applied a threshold; null when every slot is filled.
__host__ __device__ uint64_t slot_count() const noexcept
Slots of the tile's layout, filled or not.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find()

__host__ __device__ cuda::std::optional< batch_search_result > cuddl::batch_result_tile::find ( uint32_t  query_id,
uint32_t  reference_id 
) const
inlinenoexcept

The pair's result, or nothing when it did not pass.

All-to-all tiles answer in either order, with the counts seen from query_id.

Definition at line 195 of file reference_database.cuh.

195 {
196 if (!passed(query_id, reference_id)) return cuda::std::nullopt;
197 if (upper_triangle && reference_id < query_id) {
198 auto const stored = results[position(reference_id, query_id)].unpack(bucket_count);
199 return batch_search_result{query_id, reference_id, stored.mirrored()};
200 }
201 return result(query_id, reference_id, results[position(query_id, reference_id)]);
202 }
auto const query_id
Definition top_k.cuh:201
packed_pairwise_counts const * results
__host__ __device__ bool passed(uint32_t query_id, uint32_t reference_id) const noexcept
Whether the pair has a result in this tile, in either order for all-to-all tiles.
uint32_t bucket_count
Buckets per sketch, from which both-empty counts are recovered.
__host__ __device__ constexpr pairwise_counts unpack(uint32_t bucket_count) const noexcept
Here is the call graph for this function:

◆ for_each_passing() [1/2]

template<typename F >
__host__ __device__ void cuddl::batch_result_tile::for_each_passing ( F &&  f) const
inline

Calls f with every passing result, query-major and in reference order.

Definition at line 216 of file reference_database.cuh.

216 {
218 }
__host__ __device__ void for_each_passing(F &&f) const
Calls f with every passing result, query-major and in reference order.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ for_each_passing() [2/2]

template<typename F >
__host__ __device__ void cuddl::batch_result_tile::for_each_passing ( uint32_t  begin,
uint32_t  end,
F &&  f 
) const
inline

Calls f with the passing results of the tile's query rows [begin, end), in the order of the whole-tile visit.

Disjoint row ranges can be visited concurrently; the first result of row begin is passing result passing_before(begin) of the tile.

Definition at line 224 of file reference_database.cuh.

224 {
225 auto next = begin < end ? stored_before(begin) : 0U;
226 for (uint32_t query = begin; query < end; ++query) {
227 auto const query_id = first_query_id + query;
228 if (pass_bits == nullptr) {
229 // Every slot passes, and slots are in this order.
230 for (auto reference = upper_triangle ? query_id + 1U : 0U;
231 reference < reference_count;
232 ++reference) {
233 f(result(query_id, reference, results[next++]));
234 }
235 continue;
236 }
237 auto const words = words_per_query();
238 for (uint32_t w = 0; w < words; ++w) {
239 for (auto bits = pass_bits[static_cast<size_t>(query) * words + w]; bits != 0U;
240 bits &= bits - 1U) {
241 auto const reference =
242 w * 32U + static_cast<uint32_t>(cuda::std::countr_zero(bits));
243 auto const at = word_offsets != nullptr ? next++ : slot(query, reference);
244 f(result(query_id, reference, results[at]));
245 }
246 }
247 }
248 }
auto const * query
Definition kernels.cuh:1030
auto *const bits
Definition kernels.cuh:1184
Here is the call graph for this function:

◆ match_count()

__host__ __device__ uint32_t cuddl::batch_result_tile::match_count ( uint32_t  query_id,
uint32_t  reference_id 
) const
inlinenoexcept

The pair's index match count, in either order for all-to-all tiles; the pair must pass and counts must be present.

Definition at line 207 of file reference_database.cuh.

207 {
208 if (upper_triangle && reference_id < query_id) {
209 cuda::std::swap(query_id, reference_id);
210 }
211 return match_counts[position(query_id, reference_id)];
212 }
uint32_t const * match_counts
Index match counts parallel to results, when requested; otherwise null.

◆ passed()

__host__ __device__ bool cuddl::batch_result_tile::passed ( uint32_t  query_id,
uint32_t  reference_id 
) const
inlinenoexcept

Whether the pair has a result in this tile, in either order for all-to-all tiles.

Definition at line 180 of file reference_database.cuh.

180 {
181 if (upper_triangle && reference_id < query_id) {
182 cuda::std::swap(query_id, reference_id);
183 }
184 if (query_id < first_query_id || query_id - first_query_id >= query_count ||
185 reference_id >= reference_count || (upper_triangle && reference_id <= query_id)) {
186 return false;
187 }
188 if (pass_bits == nullptr) return true;
189 return ((pass_bits[word(query_id, reference_id)] >> (reference_id % 32U)) & 1U) != 0U;
190 }
Here is the caller graph for this function:

◆ passing_before()

__host__ __device__ uint64_t cuddl::batch_result_tile::passing_before ( uint32_t  query) const
inlinenoexcept

Number of passing results in the tile's query rows before row query, which may be query_count.

Definition at line 252 of file reference_database.cuh.

252 {
253 if (query >= query_count) return count();
254 if (pass_bits == nullptr || word_offsets != nullptr) return stored_before(query);
255 auto const words = static_cast<size_t>(query) * words_per_query();
256 uint64_t total = 0U;
257 for (size_t w = 0; w < words; ++w) {
258 total += static_cast<uint64_t>(cuda::std::popcount(pass_bits[w]));
259 }
260 return total;
261 }
__host__ __device__ uint64_t count() const noexcept
Number of passing results.
Here is the call graph for this function:

◆ slot_count()

__host__ __device__ uint64_t cuddl::batch_result_tile::slot_count ( ) const
inlinenoexcept

Slots of the tile's layout, filled or not.

Definition at line 167 of file reference_database.cuh.

167 {
168 if (query_count == 0U) return 0U;
169 auto const last = query_count - 1U;
170 if (upper_triangle) {
171 return first_query_id + last + 1U >= reference_count
172 ? slot(last, reference_count)
173 : slot(last, reference_count - 1U) + 1U;
174 }
175 return static_cast<uint64_t>(query_count) * reference_count;
176 }
Here is the caller graph for this function:

◆ words_per_query()

__host__ __device__ constexpr uint32_t cuddl::batch_result_tile::words_per_query ( ) const
inlineconstexprnoexcept

Definition at line 162 of file reference_database.cuh.

162 {
163 return (reference_count + 31U) / 32U;
164 }
Here is the caller graph for this function:

Member Data Documentation

◆ bucket_count

uint32_t cuddl::batch_result_tile::bucket_count {}

Buckets per sketch, from which both-empty counts are recovered.

Definition at line 159 of file reference_database.cuh.

159{};

◆ first_query_id

uint32_t cuddl::batch_result_tile::first_query_id {}

Definition at line 155 of file reference_database.cuh.

155{};

◆ match_counts

uint32_t const* cuddl::batch_result_tile::match_counts {}

Index match counts parallel to results, when requested; otherwise null.

Definition at line 150 of file reference_database.cuh.

150{};

◆ pass_bits

uint32_t const* cuddl::batch_result_tile::pass_bits {}

Passing pairs, when the tile applied a threshold; null when every slot is filled.

Definition at line 152 of file reference_database.cuh.

152{};

◆ query_count

uint32_t cuddl::batch_result_tile::query_count {}

Definition at line 156 of file reference_database.cuh.

156{};

◆ reference_count

uint32_t cuddl::batch_result_tile::reference_count {}

Definition at line 157 of file reference_database.cuh.

157{};

◆ results

packed_pairwise_counts const* cuddl::batch_result_tile::results {}

Definition at line 148 of file reference_database.cuh.

148{};

◆ upper_triangle

bool cuddl::batch_result_tile::upper_triangle {}

Definition at line 160 of file reference_database.cuh.

160{};

◆ word_offsets

uint32_t const* cuddl::batch_result_tile::word_offsets {}

For packed results: the number of passing results before each pass-bit word.

Definition at line 154 of file reference_database.cuh.

154{};

The documentation for this struct was generated from the following file: