4#include <cuda/std/cstdint>
35template <u
int32_t K,
size_t BucketCount,
typename Layout = default_register_layout>
47 : scores_(std::move(other.scores_)),
48 query_count_(std::exchange(other.query_count_, 0U)),
49 compatibility_(other.compatibility_) {}
54 scores_ = std::move(other.scores_);
55 query_count_ = std::exchange(other.query_count_, 0U);
56 compatibility_ = other.compatibility_;
69 std::span<std::filesystem::path const> paths,
70 cuda::stream_ref stream,
75 CUDDL_TRY(batch.set_blacklist(options.blacklist, stream));
76 CUDDL_TRY((detail::stage_paths<K, BucketCount, Layout>(
79 options.staging_bytes,
80 options.parser_workers,
82 options.decompression,
85 batch.reduce_rows(stream),
86 options.blacklist ? options.blacklist->get().view() :
cuda::std::nullopt
90 }
catch (cuda::cuda_error
const& error) {
92 }
catch (std::system_error
const& error) {
94 }
catch (std::bad_alloc
const& error) {
104 std::span<sequence_genome const> genomes,
105 cuda::stream_ref stream,
110 CUDDL_TRY(batch.set_blacklist(options.blacklist, stream));
111 CUDDL_TRY((detail::stage_sequences<K, BucketCount, Layout>(
114 options.staging_bytes,
116 batch.reduce_rows(stream),
117 options.blacklist ? options.blacklist->get().view() :
cuda::std::nullopt
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) {
125 }
catch (std::bad_alloc
const& error) {
131 return {scores_.data(),
static_cast<size_t>(query_count_) * BucketCount};
141 return compatibility_;
150 static_cast<size_t>(queries) * BucketCount,
154 query_count_(queries) {}
158 [[nodiscard]]
auto reduce_rows(cuda::stream_ref stream) {
159 return [
this, stream](
160 device_span<uint32_t const> group,
size_t base,
size_t count
162 return extract_scores_batch_async<BucketCount>(
164 device_span<score_type>{scores_.data() + base * BucketCount, count * BucketCount},
170 cuda::device_buffer<score_type> scores_;
171 uint32_t query_count_ = 0;
172 score_compatibility compatibility_ = score_compatibility::current<K, BucketCount, Layout>();
174 Result<void> set_blacklist(
175 std::optional<std::reference_wrapper<device_blacklist const>> filter,
176 cuda::stream_ref stream
178 if (!filter)
return Ok();
179 CUDDL_TRY(filter->get().validate(K, BucketCount, stream));
180 compatibility_.blacklist_identity = filter->get().source().identity();
181 compatibility_.blacklist_version = filter->get().source().version();
Query sketches held on the device, in the shape a search consumes them.
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.
device_span< score_type const > scores() const noexcept
Query rows in query-ID order, BucketCount scores each.
query_sketch_batch & operator=(query_sketch_batch &&other) noexcept
Move-assigns the batch, leaving the source empty.
score_compatibility compatibility() const noexcept
Compatibility a search must be given alongside scores.
query_sketch_batch & operator=(query_sketch_batch const &)=delete
uint32_t query_count() const noexcept
Query count, in the order the paths or genomes were supplied.
__host__ ~query_sketch_batch()
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.
query_sketch_batch(query_sketch_batch &&other) noexcept
query_sketch_batch(query_sketch_batch const &)=delete
#define CUDDL_TRY(expr)
Propagates a cuddl::Result failure from the enclosing function (GNU statement expression).
Batch operations over contiguous device rows.
Result< void > Ok() noexcept
Success return for Result<void>; same as return {}.
cuda::std::unexpected< Error > Err(Error error)
Failure return; converts to any Result<T> via cuda::std::unexpected.
static Error cuda(cudaError_t code, std::source_location location=std::source_location::current())
static Error resource(std::string message)
Fallible API result: cuda::std::expected<T, Error> with cuDDL factories.
A span that is assumed to point to device-accessible memory.
Knobs for a build the caller feeds with FASTA/FASTQ paths.
Construction parameters of compatible score rows.
Knobs for a build the caller feeds with bases it already holds.