cuDDL
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
cuddl::query_sketch_batch< K, BucketCount, Layout > Class Template Reference

Query sketches held on the device, in the shape a search consumes them. More...

Public Types

using score_type = uint16_t
 

Public Member Functions

 query_sketch_batch (query_sketch_batch const &)=delete
 
query_sketch_batch & operator= (query_sketch_batch const &)=delete
 
__host__ ~query_sketch_batch ()
 
 query_sketch_batch (query_sketch_batch &&other) noexcept
 
query_sketch_batch & operator= (query_sketch_batch &&other) noexcept
 Move-assigns the batch, leaving the source empty.
 
device_span< score_type const > scores () const noexcept
 Query rows in query-ID order, BucketCount scores each.
 
uint32_t query_count () const noexcept
 Query count, in the order the paths or genomes were supplied.
 
score_compatibility compatibility () const noexcept
 Compatibility a search must be given alongside scores.
 

Static Public Member Functions

static Result< query_sketch_batch > sketch (std::span< std::filesystem::path const > paths, cuda::stream_ref stream, path_build_options options={})
 Sketches one query per plain or gzip/BGZF FASTA/FASTQ file on the GPU.
 
static Result< query_sketch_batch > sketch_from_sequences (std::span< sequence_genome const > genomes, cuda::stream_ref stream, sequence_build_options options={})
 Sketches one query per genome of bases the caller already holds.
 

Detailed Description

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
class cuddl::query_sketch_batch< K, BucketCount, Layout >

Query sketches held on the device, in the shape a search consumes them.

A query is the winner score of every register, one uint16_t row per query genome, which is what reference_database::search_async and search_batch_async take. Sketching queries through reference_database_file would retain host score rows and labels that queries do not need. This keeps the sketches on the device in the shape a search wants, and nothing else.

The batch is move-only and owns its device allocation. Query IDs follow the order of the paths, or of the genomes handed to sketch_from_sequences. The allocating stream must outlive the batch, and @ref scores stays valid until the device work on that stream completes.

Definition at line 36 of file query_sketch.cuh.

Member Typedef Documentation

◆ score_type

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
using cuddl::query_sketch_batch< K, BucketCount, Layout >::score_type = uint16_t

Definition at line 38 of file query_sketch.cuh.

Constructor & Destructor Documentation

◆ query_sketch_batch() [1/2]

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
cuddl::query_sketch_batch< K, BucketCount, Layout >::query_sketch_batch ( query_sketch_batch< K, BucketCount, Layout > const &  )
delete

◆ ~query_sketch_batch()

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
__host__ cuddl::query_sketch_batch< K, BucketCount, Layout >::~query_sketch_batch ( )
inline

Definition at line 44 of file query_sketch.cuh.

44{} // NOLINT(modernize-use-equals-default)

◆ query_sketch_batch() [2/2]

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
cuddl::query_sketch_batch< K, BucketCount, Layout >::query_sketch_batch ( query_sketch_batch< K, BucketCount, Layout > &&  other)
inlinenoexcept

Definition at line 46 of file query_sketch.cuh.

47 : scores_(std::move(other.scores_)),
48 query_count_(std::exchange(other.query_count_, 0U)),
49 compatibility_(other.compatibility_) {}

Member Function Documentation

◆ compatibility()

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
score_compatibility cuddl::query_sketch_batch< K, BucketCount, Layout >::compatibility ( ) const
inlinenoexcept

Compatibility a search must be given alongside scores.

Definition at line 140 of file query_sketch.cuh.

140 {
141 return compatibility_;
142 }

◆ operator=() [1/2]

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
query_sketch_batch & cuddl::query_sketch_batch< K, BucketCount, Layout >::operator= ( query_sketch_batch< K, BucketCount, Layout > &&  other)
inlinenoexcept

Move-assigns the batch, leaving the source empty.

Definition at line 52 of file query_sketch.cuh.

52 {
53 if (this != &other) {
54 scores_ = std::move(other.scores_);
55 query_count_ = std::exchange(other.query_count_, 0U);
56 compatibility_ = other.compatibility_;
57 }
58 return *this;
59 }

◆ operator=() [2/2]

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
query_sketch_batch & cuddl::query_sketch_batch< K, BucketCount, Layout >::operator= ( query_sketch_batch< K, BucketCount, Layout > const &  )
delete

◆ query_count()

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
uint32_t cuddl::query_sketch_batch< K, BucketCount, Layout >::query_count ( ) const
inlinenoexcept

Query count, in the order the paths or genomes were supplied.

Definition at line 135 of file query_sketch.cuh.

135 {
136 return query_count_;
137 }

◆ scores()

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
device_span< score_type const > cuddl::query_sketch_batch< K, BucketCount, Layout >::scores ( ) const
inlinenoexcept

Query rows in query-ID order, BucketCount scores each.

Definition at line 130 of file query_sketch.cuh.

130 {
131 return {scores_.data(), static_cast<size_t>(query_count_) * BucketCount};
132 }

◆ sketch()

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
static Result< query_sketch_batch > cuddl::query_sketch_batch< K, BucketCount, Layout >::sketch ( std::span< std::filesystem::path const >  paths,
cuda::stream_ref  stream,
path_build_options  options = {} 
)
inlinestatic

Sketches one query per plain or gzip/BGZF FASTA/FASTQ file on the GPU.

K-mers never cross record boundaries or ambiguous bases, exactly as a reference build treats them, and FASTQ qualities are validated and ignored. A file with no usable record keeps its query ID and scores zero everywhere.

Definition at line 68 of file query_sketch.cuh.

71 {}
72 ) try {
73 return [&]() -> Result<query_sketch_batch> {
74 query_sketch_batch batch(stream, static_cast<uint32_t>(paths.size()));
75 CUDDL_TRY(batch.set_blacklist(options.blacklist, stream));
76 CUDDL_TRY((detail::stage_paths<K, BucketCount, Layout>(
77 paths,
78 stream,
79 options.staging_bytes,
80 options.parser_workers,
81 options.transfer,
82 options.decompression,
83 options.direct_reads,
84 options.statistics,
85 batch.reduce_rows(stream),
86 options.blacklist ? options.blacklist->get().view() : cuda::std::nullopt
87 )));
88 return batch;
89 }();
90 } catch (cuda::cuda_error const& error) {
91 return Err(Error::cuda(static_cast<cudaError_t>(error.status())));
92 } catch (std::system_error const& error) {
93 return Err(Error::resource(error.what()));
94 } catch (std::bad_alloc const& error) {
95 return Err(Error::resource(error.what()));
96 }
query_sketch_batch(query_sketch_batch const &)=delete
#define CUDDL_TRY(expr)
Propagates a cuddl::Result failure from the enclosing function (GNU statement expression).
Definition error.hpp:225
cuda::std::unexpected< Error > Err(Error error)
Failure return; converts to any Result<T> via cuda::std::unexpected.
Definition error.hpp:176
static Error cuda(cudaError_t code, std::source_location location=std::source_location::current())
Definition error.hpp:90
static Error resource(std::string message)
Definition error.hpp:103

◆ sketch_from_sequences()

template<uint32_t K, size_t BucketCount, typename Layout = default_register_layout>
static Result< query_sketch_batch > cuddl::query_sketch_batch< K, BucketCount, Layout >::sketch_from_sequences ( std::span< sequence_genome const >  genomes,
cuda::stream_ref  stream,
sequence_build_options  options = {} 
)
inlinestatic

Sketches one query per genome of bases the caller already holds.

Each genome supplies its records as spans of consecutive bases with the line breaks already removed, the shape a parsed FASTX record has, and the caller keeps every byte alive until this returns.

Definition at line 103 of file query_sketch.cuh.

106 {}
107 ) try {
108 return [&]() -> Result<query_sketch_batch> {
109 query_sketch_batch batch(stream, static_cast<uint32_t>(genomes.size()));
110 CUDDL_TRY(batch.set_blacklist(options.blacklist, stream));
111 CUDDL_TRY((detail::stage_sequences<K, BucketCount, Layout>(
112 genomes,
113 stream,
114 options.staging_bytes,
115 options.statistics,
116 batch.reduce_rows(stream),
117 options.blacklist ? options.blacklist->get().view() : cuda::std::nullopt
118 )));
119 return batch;
120 }();
121 } catch (cuda::cuda_error const& error) {
122 return Err(Error::cuda(static_cast<cudaError_t>(error.status())));
123 } catch (std::system_error const& error) {
124 return Err(Error::resource(error.what()));
125 } catch (std::bad_alloc const& error) {
126 return Err(Error::resource(error.what()));
127 }

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