cuSBF
Loading...
Searching...
No Matches
chunk_stream_pair.cuh
Go to the documentation of this file.
1#pragma once
2
3#include <cuda_runtime.h>
4#include <cuda/stream>
5
6#include <array>
7#include <utility>
8
9#include <cusbf/error.hpp>
10#include <cusbf/helpers.cuh>
11
12namespace cusbf::detail {
13
16 public:
22
25
27 for (cudaStream_t& stream : other.streams_) {
28 stream = nullptr;
29 }
30 }
31
33 if (this != &other) {
34 destroy();
35 streams_ = other.streams_;
36 for (cudaStream_t& stream : other.streams_) {
37 stream = nullptr;
38 }
39 }
40 return *this;
41 }
42
44 destroy();
45 }
46
48 [[nodiscard]] cuda::stream_ref operator[](size_t index) const noexcept {
49 return {streams_.at(index)};
50 }
51
54 for (cudaStream_t stream : streams_) {
55 if (stream != nullptr) {
57 }
58 }
59 return {};
60 }
61
62 private:
63 std::array<cudaStream_t, 2> streams_{nullptr, nullptr};
64
65 void destroy() {
66 for (cudaStream_t& stream : streams_) {
67 if (stream != nullptr) {
69 stream = nullptr;
70 }
71 }
72 }
73};
74
75} // namespace cusbf::detail
Two non-blocking CUDA streams for overlapping chunk H2D and kernel work.
ChunkStreamPair(ChunkStreamPair &&other) noexcept
ChunkStreamPair(const ChunkStreamPair &)=delete
Result< void > sync_all() const
Blocks until both streams complete.
ChunkStreamPair & operator=(const ChunkStreamPair &)=delete
cuda::stream_ref operator[](size_t index) const noexcept
Non-blocking stream at index (0 or 1).
ChunkStreamPair & operator=(ChunkStreamPair &&other) noexcept
#define CUSBF_CUDA_ABORT(expr)
Checks a CUDA call and aborts on failure (destructors and RAII only).
Definition error.hpp:266
#define CUSBF_CUDA_TRY(expr)
Propagates a CUDA error wrapped in cusbf::Result<void>.
Definition error.hpp:269
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
Fallible API result: cuda::std::expected<T, Error> with cuSBF factories.
Definition error.hpp:152