3#include <cuda/algorithm>
4#include <cuda/std/cstdint>
24template <u
int32_t K,
size_t BucketCount,
typename Layout = default_register_layout>
26 static_assert(K >= 1 && K <= 31);
27 static_assert(BucketCount >= (
size_t{1} << 11) && BucketCount <= (
size_t{1} << 13));
28 static_assert((BucketCount & (BucketCount - 1)) == 0);
37 cuda::std::optional<blacklist_view>
blacklist = cuda::std::nullopt
52 [[nodiscard]]
static constexpr uint32_t
kmer_length() noexcept {
59 cuda::fill_bytes(stream, cuda::std::span{registers_.data(), registers_.size()}, 0);
68 return detail::launch_construction<BucketCount, Layout>(
69 input, registers_, stream, blacklist_
83 return detail::launch_sequence_add<BucketCount, Layout>(
84 sequence, K, registers_, stream, blacklist_
91 template <
bool IncludeCardinality = false>
95 cuda::stream_ref stream
97 detail::summary_kernel<BucketCount, IncludeCardinality, Layout>
99 registers_.data(), other.registers_.data(), output
101 return cuda_try(cudaGetLastError());
109 double* estimate_out,
110 cuda::stream_ref stream
112 detail::cardinality_kernel<BucketCount, Layout><<<1,
detail::block_size, 0, stream.get()>>>(
113 registers_.data(), empty_out, estimate_out
115 return cuda_try(cudaGetLastError());
121 cuda::stream_ref stream
123 detail::hybrid_cardinality_kernel<BucketCount, Layout>
125 return cuda_try(cudaGetLastError());
130 cuda::std::optional<blacklist_view> blacklist_;
Non-owning implementation view of a DDL sketch.
static constexpr size_t bucket_count() noexcept
Number of registers in the sketch.
Result< void > add_sequence_async(device_span< char const > sequence, cuda::stream_ref stream) const noexcept
Accumulates device-resident raw ASCII bases without clearing.
Result< void > add_async(device_span< uint64_t const > input, cuda::stream_ref stream) const noexcept
Accumulates packed device k-mers into the existing sketch without clearing it.
__host__ __device__ constexpr device_span< register_type > data() const noexcept
Device registers.
__host__ __device__ constexpr sketch_view(device_span< register_type > registers, cuda::std::optional< blacklist_view > blacklist=cuda::std::nullopt) noexcept
Constructs a reference over registers.
Result< void > clear_async(cuda::stream_ref stream) const noexcept
Resets every register to zero.
Result< void > summary_async(sketch_view other, pairwise_summary &output, cuda::stream_ref stream) const noexcept
Computes the raw pairwise summary into caller-owned device storage.
Result< void > hybrid_cardinality_async(hybrid_cardinality_estimates *output, cuda::stream_ref stream) const noexcept
Computes BBTools and paper-style HybridDDL estimates in one GPU register scan.
static constexpr uint32_t kmer_length() noexcept
Compile-time k-mer length.
Result< void > cardinality_async(uint64_t *empty_out, double *estimate_out, cuda::stream_ref stream) const noexcept
Computes this sketch's cardinality reduction on the GPU.
__global__ size_t uint32_t bool blacklist_view bool Layout
__global__ size_t uint32_t bool blacklist_view blacklist
constexpr uint32_t block_size
Threads per CTA for the single-pair and cardinality reduction kernels.
__global__ size_t uint32_t * registers
Result< void > cuda_try(cudaError_t error, std::source_location location=std::source_location::current())
Checks a CUDA runtime call and returns an error on failure.
Fallible API result: cuda::std::expected<T, Error> with cuDDL factories.
A span that is assumed to point to device-accessible memory.
Experimental DDL cardinality estimates computed from one register scan.
Pairwise counts with an optional compile-time cardinality field.