cuDDL
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
cuddl::detail::sequence_buffer_pool Class Reference

Public Member Functions

 sequence_buffer_pool (cuda::stream_ref stream, size_t buffers, size_t limit, bool page_locked, bool in_place)
 limit bounds one buffer; larger genomes stay on the loader's own growing buffer.
 
void set_capacity (size_t buffers, size_t reserve_each=0)
 Number of buffers the pool may grow to.
 
size_t buffers () const noexcept
 Buffers allocated so far. Read once the loaders have stopped.
 
decompression_target acquire (size_t bytes)
 Returns reusable bytes, or a null target when the pool cannot serve.
 

Detailed Description

Definition at line 867 of file database_staging.cuh.

Constructor & Destructor Documentation

◆ sequence_buffer_pool()

cuddl::detail::sequence_buffer_pool::sequence_buffer_pool ( cuda::stream_ref  stream,
size_t  buffers,
size_t  limit,
bool  page_locked,
bool  in_place 
)
inline

limit bounds one buffer; larger genomes stay on the loader's own growing buffer.

in_place says kernels read leased buffers themselves. Otherwise only copies read them, and every consumer drops a lease once its copies have completed, so a slot is reusable as soon as it is released.

Definition at line 875 of file database_staging.cuh.

882 : stream_(stream),
883 limit_(limit),
884 pinned_pool_(
885 page_locked
886 ? std::optional{device_pinned_pool(stream.device(), pinned_placement::host)}
887 : std::nullopt
888 ),
889 in_place_(in_place) {
890 slots_.reserve(buffers);
891 }
size_t buffers() const noexcept
Buffers allocated so far. Read once the loaders have stopped.
@ in_place
Decompress into a heap buffer and let the kernels read it there.
@ host
Any node: for buffers host threads fill.
cuda::pinned_memory_pool_ref device_pinned_pool(cuda::device_ref device, pinned_placement placement)
A page-locked memory pool accessible from device only.
Here is the call graph for this function:

Member Function Documentation

◆ acquire()

decompression_target cuddl::detail::sequence_buffer_pool::acquire ( size_t  bytes)
inline

Returns reusable bytes, or a null target when the pool cannot serve.

Definition at line 915 of file database_staging.cuh.

915 {
916 if (bytes == 0 || bytes > limit_) return {};
917 slot* owner = nullptr;
918 {
919 std::lock_guard lock(mutex_);
920 owner = claim();
921 if (owner == nullptr) return {};
922 }
923 // Wait on the loader thread rather than the build loop: the slot is already reserved,
924 // so this blocks only the genome that needs it. A failing wait throws out of the loader,
925 // which reports it through the pool's error slot like any other load failure.
926 if (in_place_) owner->consumed.sync();
927 if (owner->size < bytes) {
928 auto grown = size_t{1} << 16;
929 while (grown < bytes) {
930 grown *= 2;
931 }
932 owner->resize(stream_, grown, pinned_pool_);
933 }
934 return lease(owner);
935 }

◆ buffers()

size_t cuddl::detail::sequence_buffer_pool::buffers ( ) const
inlinenoexcept

Buffers allocated so far. Read once the loaders have stopped.

Definition at line 910 of file database_staging.cuh.

910 {
911 return slots_.size();
912 }

◆ set_capacity()

void cuddl::detail::sequence_buffer_pool::set_capacity ( size_t  buffers,
size_t  reserve_each = 0 
)
inline

Number of buffers the pool may grow to.

With reserve_each, page-locks that many bytes per buffer at once and returns them to the pool, which keeps them, so loaders take their buffers from pinned memory. Each loader page-locking its own first buffer serialised them in the driver: with 64 loaders on a Xeon w9-3595X, 20,000 genomes spent 9% of their host time there and took 3.3 s, against 3.0 s with the reservation.

Definition at line 900 of file database_staging.cuh.

900 {
901 capacity_ = std::max<size_t>(1, buffers);
902 if (pinned_pool_ && reserve_each != 0 && !ablated("pinned-reservation")) {
903 cuda::buffer<char, cuda::mr::host_accessible, cuda::mr::device_accessible> reserved(
904 stream_, *pinned_pool_, capacity_ * reserve_each, cuda::no_init
905 );
906 }
907 }
constexpr bool ablated(std::string_view) noexcept
Always false: this build compiles the ablation switches out.
Definition ablation.hpp:82
Here is the call graph for this function:

The documentation for this class was generated from the following file: