cuSBF
Loading...
Searching...
No Matches
Namespaces | Classes | Concepts | Enumerations | Functions
cusbf Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  Config
 Compile-time configuration for a cusbf::filter. More...
 
struct  CudaError
 
class  DenseRecordBatchBuilder
 Accumulates parsed FASTX records into a dense RecordBatchView. More...
 
struct  device_span
 A span that is assumed to point to device-accessible memory. More...
 
struct  DnaAlphabet
 An alphabet for encoding DNA sequences, consisting of the symbols A, C, G, and T. More...
 
struct  DnaTripletAlphabet
 An alphabet that encodes non-overlapping DNA triplets as single symbols. More...
 
struct  Error
 Error payload carried in Result on failure. More...
 
struct  FastxDetailedQueryRecord
 Detailed per-record query results returned by Filter FASTX detail APIs. More...
 
struct  FastxDetailedQueryReport
 Aggregate and per-record results returned by Filter FASTX detail APIs. More...
 
struct  FastxInsertReport
 Summary statistics returned by Filter insert operations on FASTX and record-batch input. More...
 
struct  FastxParseError
 
struct  FastxQueryReport
 Summary statistics returned by Filter query operations on FASTX and record-batch input. More...
 
struct  FastxRecordView
 Per-record query payload emitted by FASTX streaming query APIs. More...
 
class  filter
 GPU Super Bloom filter (defined in filter.cuh). More...
 
struct  filter_block
 One 256-bit filter block stored as an array of Config::blockWordCount words. More...
 
class  filter_ref
 Non-owning device reference to sectorized filter storage. More...
 
struct  InvalidArgumentError
 
struct  IoError
 
struct  NormalizedRecord
 Per-record metadata inside a normalized record batch. More...
 
class  NormalizedRecordBatch
 Host-resident Normalized record batch ready for bulk sequence insert/query. More...
 
struct  ProteinAlphabet
 An alphabet for encoding protein sequences, consisting of the 20 standard amino acids plus common ambiguous and rare residue symbols: More...
 
struct  RecordBatchView
 Dense host-resident sequence batch plus explicit record boundaries. More...
 
struct  RecordQueryView
 Per-record query payload emitted by query_record_batch(). More...
 
struct  RecordRange
 Ordered non-overlapping byte range for one record inside a dense sequence batch. More...
 
struct  ResourceError
 
struct  Result
 Fallible API result: cuda::std::expected<T, Error> with cuSBF factories. More...
 
struct  Result< void >
 
struct  SourceLocation
 File, line, and column for a C++ call site or FASTX input position. More...
 

Concepts

concept  Alphabet
 Concept for alphabet-like types used to encode bytes as symbol indices.
 
concept  RecordQueryConsumer
 Callable invoked once per record by Filter::query_record_batch overloads that take a callback.
 
concept  FastxRecordConsumer
 Callable invoked once per record by Filter::query_fastx_records and related FASTX streaming query APIs.
 

Enumerations

enum class  ErrorCategory : uint8_t {
  cuda , io , fastx_parse , invalid_argument ,
  resource
}
 Error category for Result failures. More...
 

Functions

template<typename Config >
constexpr uint64_t dense_packed_word_count (uint64_t num_symbols)
 Returns the number of uint64_t words required for num_symbols encoded symbols.
 
template<typename Config >
constexpr uint64_t dense_packed_kmer_count (uint64_t num_symbols)
 Returns the number of k-mer windows in a dense packed symbol sequence.
 
template<typename Config >
std::vector< uint64_t > pack_dense_sequence (std::string_view sequence)
 Packs an ASCII sequence into dense symbolBits-wide uint64_t words.
 
template<typename Config >
void pack_dense_sequence_device (const char *d_sequence, uint64_t num_symbols, uint64_t *d_words, cudaStream_t stream={})
 Packs a device-resident encoded byte sequence into dense uint64_t words.
 
void require_void (const Result< void > &result)
 Aborts when a Result is unsuccessful (benchmarks and tests).
 
void cuda_abort_on_error (cudaError_t error, std::source_location location=std::source_location::current())
 Terminates the process when error is not cudaSuccess (for RAII teardown only).
 
cuda::std::unexpected< ErrorErr (Error error)
 Failure return; converts to any Result<T> via cuda::std::unexpected.
 
Result< void > Ok () noexcept
 Success return for Result<void>; same as return {}.
 
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.
 
template<typename Config >
Result< void > normalize_record_batch_into (RecordBatchView batch, std::string &sequence_out, std::vector< NormalizedRecord > &records_out)
 Builds a normalized record batch into reusable host buffers.
 
template<typename Config >
Result< NormalizedRecordBatchnormalize_record_batch (RecordBatchView batch)
 Builds a normalized record batch from a dense RecordBatchView.
 

Enumeration Type Documentation

◆ ErrorCategory

enum class cusbf::ErrorCategory : uint8_t
strong

Error category for Result failures.

Enumerator
cuda 
io 
fastx_parse 
invalid_argument 
resource 

Definition at line 67 of file error.hpp.

Function Documentation

◆ cuda_abort_on_error()

void cusbf::cuda_abort_on_error ( cudaError_t  error,
std::source_location  location = std::source_location::current() 
)
inline

Terminates the process when error is not cudaSuccess (for RAII teardown only).

Definition at line 187 of file error.hpp.

190 {
191 if (error == cudaSuccess) {
192 return;
193 }
194 const Error err = Error::cuda(error, location);
195 std::fputs(err.message().c_str(), stderr);
196 std::fputc('\n', stderr);
197 std::abort();
198}
Here is the call graph for this function:

◆ cuda_try()

Result< void > cusbf::cuda_try ( cudaError_t  error,
std::source_location  location = std::source_location::current() 
)
inline

Checks a CUDA runtime call and returns an error on failure.

Definition at line 230 of file error.hpp.

230 {
231 if (error == cudaSuccess) {
232 return Ok();
233 }
234 return Err(Error::cuda(error, location));
235}
Result< void > Ok() noexcept
Success return for Result<void>; same as return {}.
Definition error.hpp:224
Here is the call graph for this function:

◆ dense_packed_kmer_count()

template<typename Config >
constexpr uint64_t cusbf::dense_packed_kmer_count ( uint64_t  num_symbols)
constexpr

Returns the number of k-mer windows in a dense packed symbol sequence.

Definition at line 24 of file dense_packed.hpp.

24 {
25 return detail::dense_packed_kmer_count<Config>(num_symbols);
26}
Here is the call graph for this function:

◆ dense_packed_word_count()

template<typename Config >
constexpr uint64_t cusbf::dense_packed_word_count ( uint64_t  num_symbols)
constexpr

Returns the number of uint64_t words required for num_symbols encoded symbols.

Definition at line 18 of file dense_packed.hpp.

18 {
19 return detail::dense_packed_word_count<Config>(num_symbols);
20}
Here is the call graph for this function:

◆ Err()

cuda::std::unexpected< Error > cusbf::Err ( Error  error)
inline

Failure return; converts to any Result<T> via cuda::std::unexpected.

Definition at line 219 of file error.hpp.

219 {
220 return cuda::std::unexpected<Error>(std::move(error));
221}
Here is the caller graph for this function:

◆ normalize_record_batch()

template<typename Config >
Result< NormalizedRecordBatch > cusbf::normalize_record_batch ( RecordBatchView  batch)

Builds a normalized record batch from a dense RecordBatchView.

Template Parameters
ConfigFilter configuration (alphabet and k-mer sizing).
Parameters
batchDense input batch without embedded separators.
Returns
Owning normalized batch ready for filter::insert_record_batch or query APIs.

Definition at line 314 of file normalized_record_batch.hpp.

314 {
315 return NormalizedRecordBatch::from_batch<Config>(batch);
316}

◆ normalize_record_batch_into()

template<typename Config >
Result< void > cusbf::normalize_record_batch_into ( RecordBatchView  batch,
std::string &  sequence_out,
std::vector< NormalizedRecord > &  records_out 
)

Builds a normalized record batch into reusable host buffers.

Template Parameters
ConfigFilter configuration (alphabet and k-mer sizing).
Parameters
batchDense input batch without embedded separators.
sequence_outOutput normalized sequence buffer (resized in place).
records_outOutput per-record metadata (cleared then filled).

Definition at line 289 of file normalized_record_batch.hpp.

293 {
294 CUSBF_TRY(detail::validateRecordBatch<Config>(batch));
295
296 const uint64_t estimated_bytes = detail::estimate_normalized_batch_bytes<Config>(batch);
297 sequence_out.resize(static_cast<size_t>(estimated_bytes));
298 size_t sequence_out_bytes = 0;
299 detail::normalize_record_batch_into_buffer<Config>(
300 batch, sequence_out.data(), sequence_out_bytes, records_out
301 );
302 sequence_out.resize(sequence_out_bytes);
303 return {};
304}
#define CUSBF_TRY(expr)
Propagates a cusbf::Result failure from the enclosing function (GNU statement expression).
Definition error.hpp:246
Here is the call graph for this function:

◆ Ok()

Result< void > cusbf::Ok ( )
inlinenoexcept

Success return for Result<void>; same as return {}.

Definition at line 224 of file error.hpp.

224 {
225 return Result<void>::ok();
226}
Fallible API result: cuda::std::expected<T, Error> with cuSBF factories.
Definition error.hpp:152
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_dense_sequence()

template<typename Config >
std::vector< uint64_t > cusbf::pack_dense_sequence ( std::string_view  sequence)

Packs an ASCII sequence into dense symbolBits-wide uint64_t words.

Reads one symbol every Config::symbolWidth input bytes via Config::Alphabet. Trailing input shorter than one symbol is ignored. Invalid bytes are stored as their low Config::symbolBits (same as masking Config::Alphabet::invalidSymbol).

Definition at line 36 of file dense_packed.hpp.

36 {
37 const uint64_t num_symbols = sequence.size() / Config::symbolWidth;
38 std::vector<uint64_t> words(dense_packed_word_count<Config>(num_symbols), 0);
39 constexpr uint64_t symbols_per_word = detail::dense_packed_symbols_per_word<Config>();
40 for (uint64_t symbol_index = 0; symbol_index < num_symbols; ++symbol_index) {
41 const uint8_t symbol =
42 Config::Alphabet::encode(sequence.data() + symbol_index * Config::symbolWidth);
43 const uint64_t word_index = symbol_index / symbols_per_word;
44 const auto bit_offset =
45 static_cast<unsigned>((symbol_index % symbols_per_word) * Config::symbolBits);
46 words[word_index] |= (static_cast<uint64_t>(symbol & Config::symbolMask) << bit_offset);
47 }
48 return words;
49}
Here is the call graph for this function:

◆ pack_dense_sequence_device()

template<typename Config >
void cusbf::pack_dense_sequence_device ( const char *  d_sequence,
uint64_t  num_symbols,
uint64_t *  d_words,
cudaStream_t  stream = {} 
)
inline

Packs a device-resident encoded byte sequence into dense uint64_t words.

d_sequence holds num_symbols symbols at Config::symbolWidth bytes each. d_words must hold at least dense_packed_word_count(num_symbols) words.

Definition at line 58 of file dense_packed.hpp.

62 {}
63) {
64 if (num_symbols == 0) {
65 return;
66 }
67 constexpr uint64_t block_size = 256;
68 const uint64_t num_words = dense_packed_word_count<Config>(num_symbols);
69 const uint64_t grid_size = cuda::ceil_div(num_words, block_size);
70 detail::pack_dense_sequence_kernel<Config>
71 <<<grid_size, block_size, 0, stream>>>(d_sequence, num_symbols, d_words);
72 CUSBF_CUDA_CALL(cudaGetLastError());
73}
#define CUSBF_CUDA_CALL(err)
Checks a CUDA runtime call and throws std::runtime_error on failure.

◆ require_void()

void cusbf::require_void ( const Result< void > &  result)
inline

Aborts when a Result is unsuccessful (benchmarks and tests).

Definition at line 178 of file error.hpp.

178 {
179 if (!result) {
180 std::fputs(result.error().message().c_str(), stderr);
181 std::fputc('\n', stderr);
182 std::abort();
183 }
184}