3#include <cuda_runtime.h>
14#include <thrust/device_vector.h>
41 return d_dense_packed_words_;
44 [[
nodiscard]]
const thrust::device_vector<uint64_t>&
46 return d_dense_packed_words_;
50 return d_resultBuffer_;
54 return d_resultBuffer_;
58 return d_query_layout_records_;
61 [[
nodiscard]]
const thrust::device_vector<QueryLayoutRecord>&
63 return d_query_layout_records_;
67 return d_record_positive_kmers_;
70 [[
nodiscard]]
const thrust::device_vector<uint64_t>&
72 return d_record_positive_kmers_;
76 return normalized_sequence_pings_[
ping & 1U];
82 return normalized_sequence_pings_[
ping & 1U];
86 return normalized_records_pings_[
ping & 1U];
92 return normalized_records_pings_[
ping & 1U];
96 return normalized_sequence_scratch_;
100 return normalized_sequence_scratch_;
104 return normalized_records_scratch_;
108 return normalized_records_scratch_;
112 return record_positive_kmers_scratch_;
116 return record_positive_kmers_scratch_;
120 return result_hits_scratch_;
124 return result_hits_scratch_;
128 if (
bases > d_sequence_.size()) {
129 d_sequence_.resize(
bases);
134 if (words > d_dense_packed_words_.size()) {
135 d_dense_packed_words_.resize(words);
140 if (
kmers > d_resultBuffer_.size()) {
141 d_resultBuffer_.resize(
kmers);
149 thrust::raw_pointer_cast(d_sequence_.data()),
151 sequence.size_bytes(),
162 thrust::raw_pointer_cast(d_sequence_.data()), sequence.size()
170 thrust::raw_pointer_cast(d_dense_packed_words_.data()),
183 thrust::raw_pointer_cast(d_dense_packed_words_.data()), words.size()
189 auto& buffer = d_sequence_pings_[
ping & 1U];
190 if (sequence.size() > buffer.size()) {
191 buffer.resize(sequence.size());
194 thrust::raw_pointer_cast(buffer.data()),
207 for (std::vector<NormalizedRecord>& records : normalized_records_pings_) {
208 std::vector<NormalizedRecord>{}.swap(records);
213 std::string{}.swap(normalized_sequence_scratch_);
214 std::vector<NormalizedRecord>{}.swap(normalized_records_scratch_);
215 std::vector<uint64_t>{}.swap(record_positive_kmers_scratch_);
216 std::vector<uint8_t>{}.swap(result_hits_scratch_);
220 thrust::device_vector<char>{}.swap(d_sequence_);
221 thrust::device_vector<uint64_t>{}.swap(d_dense_packed_words_);
222 for (thrust::device_vector<char>& buffer : d_sequence_pings_) {
223 thrust::device_vector<char>{}.swap(buffer);
225 thrust::device_vector<uint8_t>{}.swap(d_resultBuffer_);
226 thrust::device_vector<QueryLayoutRecord>{}.swap(d_query_layout_records_);
227 thrust::device_vector<uint64_t>{}.swap(d_record_positive_kmers_);
249 thrust::device_vector<char> d_sequence_;
250 thrust::device_vector<uint64_t> d_dense_packed_words_;
251 std::array<thrust::device_vector<char>, 2> d_sequence_pings_;
252 thrust::device_vector<uint8_t> d_resultBuffer_;
253 thrust::device_vector<QueryLayoutRecord> d_query_layout_records_;
254 thrust::device_vector<uint64_t> d_record_positive_kmers_;
255 std::array<FastxPinnedSequenceBuffer, 2> normalized_sequence_pings_;
256 std::array<std::vector<NormalizedRecord>, 2> normalized_records_pings_;
257 std::string normalized_sequence_scratch_;
258 std::vector<NormalizedRecord> normalized_records_scratch_;
259 std::vector<uint64_t> record_positive_kmers_scratch_;
260 std::vector<uint8_t> result_hits_scratch_;
Page-locked host buffer for fused FASTX normalize + H2D staging.
std::vector< NormalizedRecord > & normalized_records_ping(size_t ping) noexcept
std::vector< uint64_t > & record_positive_kmers_scratch() noexcept
std::vector< uint8_t > & result_hits_scratch() noexcept
void shrink_host_scratch()
void shrink_device_staging()
Result< device_span< const uint64_t > > staged_dense_packed_view(std::span< const uint64_t > words, cuda::stream_ref stream)
FastxPipelineState & operator=(const FastxPipelineState &)=delete
thrust::device_vector< QueryLayoutRecord > & query_layout_records_device() noexcept
FastxPipelineState()=default
const FastxPinnedSequenceBuffer & normalized_sequence_ping(size_t ping) const noexcept
void release_host_pings()
Result< device_span< const char > > staged_sequence_view(std::span< const char > sequence, cuda::stream_ref stream)
const std::vector< uint8_t > & result_hits_scratch() const noexcept
const std::vector< NormalizedRecord > & normalized_records_scratch() const noexcept
const thrust::device_vector< uint64_t > & dense_packed_words_device() const noexcept
thrust::device_vector< char > & sequence_device() noexcept
const std::vector< NormalizedRecord > & normalized_records_ping(size_t ping) const noexcept
const thrust::device_vector< uint64_t > & record_positive_kmers_device() const noexcept
void ensure_dense_packed_capacity(uint64_t words)
FastxPipelineState(const FastxPipelineState &)=delete
Result< void > stage_sequence(std::span< const char > sequence, cuda::stream_ref stream)
const std::string & normalized_sequence_scratch() const noexcept
thrust::device_vector< uint64_t > & dense_packed_words_device() noexcept
const thrust::device_vector< char > & sequence_device() const noexcept
const thrust::device_vector< QueryLayoutRecord > & query_layout_records_device() const noexcept
const std::vector< uint64_t > & record_positive_kmers_scratch() const noexcept
FastxPinnedSequenceBuffer & normalized_sequence_ping(size_t ping) noexcept
std::vector< NormalizedRecord > & normalized_records_scratch() noexcept
FastxPipelineState(FastxPipelineState &&) noexcept=default
thrust::device_vector< uint8_t > & result_buffer_device() noexcept
void release_device_staging()
void ensure_sequence_capacity(uint64_t bases)
void ensure_result_capacity(uint64_t kmers)
std::string & normalized_sequence_scratch() noexcept
void release_host_scratch()
Result< void > stage_dense_packed(std::span< const uint64_t > words, cuda::stream_ref stream)
thrust::device_vector< uint64_t > & record_positive_kmers_device() noexcept
const thrust::device_vector< uint8_t > & result_buffer_device() const noexcept
Result< device_span< const char > > stage_sequence_ping(size_t ping, std::string_view sequence, cuda::stream_ref stream)
#define CUSBF_TRY(expr)
Propagates a cusbf::Result failure from the enclosing function (GNU statement expression).
#define CUSBF_CUDA_TRY(expr)
Propagates a CUDA error wrapped in cusbf::Result<void>.
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...
Fallible API result: cuda::std::expected<T, Error> with cuSBF factories.
A span that is assumed to point to device-accessible memory.