cuSBF
Loading...
Searching...
No Matches
dense_packed.cuh
Go to the documentation of this file.
1#pragma once
2
3#include <cuda/__cmath/ceil_div.h>
4
5#include <cstdint>
6
7#include <cusbf/config.cuh>
9
10namespace cusbf::detail {
11
13template <typename Config>
17
19template <typename Config>
21 return cuda::ceil_div(num_symbols, dense_packed_symbols_per_word<Config>());
22}
23
25template <typename Config>
27 return num_symbols < Config::k ? 0 : (num_symbols - Config::k + 1);
28}
29
43template <typename Config>
55
57template <typename Config>
66
68template <typename Config>
80
89template <typename Config>
119
126template <typename Config>
127__global__ void
128pack_dense_sequence_kernel(const char* sequence, uint64_t num_symbols, uint64_t* words) {
130 const uint64_t word_index = static_cast<uint64_t>(blockIdx.x) * blockDim.x + threadIdx.x;
132 if (word_index >= num_words) {
133 return;
134 }
135
140 if (symbol_index >= num_symbols) {
141 break;
142 }
143 const uint8_t symbol =
144 Config::Alphabet::encode(sequence + symbol_index * Config::symbolWidth);
145 packed_word |=
147 }
148 words[word_index] = packed_word;
149}
150
151} // namespace cusbf::detail
__device__ __forceinline__ uint8_t dense_packed_symbol_at(const uint64_t *words, uint64_t symbol_index)
Decodes one packed symbol at global index symbol_index.
__device__ __forceinline__ bool prepare_dense_packed_tiles(const uint64_t *words, uint64_t block_start_kmer, uint64_t block_kmers, uint64_t *word_tile, uint8_t *sequence_tile)
Fills sequence_tile with encoded symbols for k-mers starting at block_start_kmer.
constexpr uint64_t dense_packed_symbols_per_word()
Encoded symbols stored in each uint64_t word for 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.
__device__ __forceinline__ uint8_t dense_packed_symbol_at_local(const uint64_t *word_tile, uint64_t first_word_index, uint64_t symbol_index)
Decodes one packed symbol from a block-local word tile.
constexpr uint64_t dense_packed_word_count(uint64_t num_symbols)
Returns the number of uint64_t words required for num_symbols encoded symbols.
__global__ void pack_dense_sequence_kernel(const char *sequence, uint64_t num_symbols, uint64_t *words)
Packs an encoded byte sequence into dense symbolBits-wide uint64_t words.
consteval bool separatorPositionAlwaysEncodesInvalid(char *input, uint64_t separatorPosition, uint64_t index)
Recursively tests whether placing the separator byte at any position in an input of valid bytes alway...
Definition Alphabet.cuh:37
static constexpr uint64_t symbolWidth
Input bytes per symbol.
Definition config.cuh:49
static constexpr uint64_t symbolMask
Low symbolBits mask for one encoded symbol.
Definition config.cuh:53
static constexpr uint64_t cudaBlockSize
CUDA threads per kernel block.
Definition config.cuh:57
static constexpr uint16_t k
K-mer length in symbols.
Definition config.cuh:39
static constexpr uint64_t symbolBits
Bits per packed symbol in a uint64_t k-mer.
Definition config.cuh:51
Device-side view of a dense packed symbol sequence.
device_span< const uint64_t > words
Dense packed words (device memory).
uint64_t num_symbols
Number of valid encoded symbols represented in words.
constexpr __host__ __device__ uint64_t kmerCount() const
Number of k-mer windows in this sequence.
A span that is assumed to point to device-accessible memory.