Skip to content

ThreadedDistribution

#include <sbio/execution/threaded.hh>
class ThreadedDistribution

Defined in src/lib/sbio/execution/threaded.hh:61

ThreadedExecution manages a single-process/multi-thread IO strategy.

This distribution manager provides the necessary index distribution, and data synchronization when operating brokers in a single process/multi-threaded environment. Its base parallel unit is a thread. Data-buffers (DataRole), and broker group buffers (TableRole) use per-thread buffers, allowing for true thread-level parallelism. Other buffer roles are intentionally shared, and available process wide.

The ThreadedExecution alias below composes this manager with host-memory.

Return Name Description
constexpr std::bitset< static_cast< std::size_t >(ParallelizationMethods::NUM_METHODS) > ParallelSupport static constexpr

static constexpr

constexpr std::bitset< static_cast< std::size_t >(ParallelizationMethods::NUM_METHODS) > ParallelSupport { 0x1 }

Type: constexpr std::bitset< static_cast< std::size_t >(ParallelizationMethods::NUM_METHODS) >

Defined in src/lib/sbio/execution/threaded.hh:82

Return Name Description
constexpr BufferScope scope_for static inline constexpr
void configure_impl static inline
std::size_t unit_ordinal static inline The ordinal (associated number) for the calling parallel unit.
void init_logger static inline Setup a spdlog logger.
IOStatus get_data_impl static inline The ThreadedExecution policy splits BrokerGroup data fetch and resolution.
IOStatus get_data_steps_impl static inline The ThreadedExecution policy multi-contiguous step fetch and get.
StepBatch< typename FTraits::StepIdxType > next_batch_impl static inline The ThreadedExecution policy generates step indices in monotonically.
FTraits::StepIdxType next_impl static inline The ThreadedExecution policy generates step indices in monotonically.
void end_iteration_impl static inline Exit the iteration with state, releasing any held steps.

static inline constexpr

template<typename Descriptor> constexpr static inline constexpr BufferScope scope_for()

Defined in src/lib/sbio/execution/threaded.hh:64


static inline

static inline void configure_impl(const Config & config)

Defined in src/lib/sbio/execution/threaded.hh:84


static inline

static inline std::size_t unit_ordinal()

Defined in src/lib/sbio/execution/threaded.hh:170

The ordinal (associated number) for the calling parallel unit.

The threads are given a number in the order that they ask for one.


static inline

static inline void init_logger()

Defined in src/lib/sbio/execution/threaded.hh:181

Setup a spdlog logger.


static inline

template<class FTraits, class FetchCBType, class GetCBType> static inline IOStatus get_data_impl(typename FTraits::StepIdxType step_idx, FetchCBType && unit_fetcher, std::size_t num_fetches, GetCBType && unit_get_data, std::size_t num_accesses)

Defined in src/lib/sbio/execution/threaded.hh:219

The ThreadedExecution policy splits BrokerGroup data fetch and resolution.

When the BrokerGroup requests data of a specific kind for a specific index, the process will be split into two stages. First, the IO fetch portion, where the data is actually pulled from the stream into memory buffers, is done behind a lock. This lock simplifies life on the Broker-side, as any shared mutable state (counters, or internal tracking variables) does not need to be protected while data is being read. It, of course, has a performance penalty, however, as the fetch is serialized.

After the fetch portion concludes, the data resolution stage can be done in parallel.

The IOStatus from the fetch and get procedure.

Parameter Type Description
step_idx typename FTraits::StepIdxType The step_idx for which data should be fetched and read. @oaram[in] unit_fetcher A per-broker callback from the BrokerGroup to fetch data.
num_fetches std::size_t The number of fetches to perform. (Generally equal to the number of brokers)
unit_get_data GetCBType && A per-broker callback from the BrokerGroup to resolve a piece of requested data inside the bytes just fetched.
num_accesses std::size_t The number of gets to perform. (Generally equal to the number of brokers)

static inline

template<class FTraits, class FetchCBType, class GetCBType> static inline IOStatus get_data_steps_impl(const std::initializer_list< typename FTraits::StepIdxType > steps, FetchCBType && unit_fetcher, std::size_t num_fetches, GetCBType && unit_get_data, std::size_t num_accesses)

Defined in src/lib/sbio/execution/threaded.hh:263

The ThreadedExecution policy multi-contiguous step fetch and get.

The IOStatus from the fetch and get procedure.

Parameter Type Description
steps const std::initializer_list< typename FTraits::StepIdxType > The steps to read { start, stop }. Currently adding a third step for strided access is not yet supported. @oaram[in] unit_fetcher A per-broker callback from the BrokerGroup to fetch data.
num_fetches std::size_t The number of fetches to perform. (Generally equal to the number of brokers)
unit_get_data GetCBType && A per-broker callback from the BrokerGroup to resolve a piece of requested data inside the bytes just fetched.
num_accesses std::size_t The number of gets to perform. (Generally equal to the number of brokers)

static inline

template<class FTraits, class IndexTrigger> static inline StepBatch< typename FTraits::StepIdxType > next_batch_impl(IterationState & state, std::size_t batch_size, typename FTraits::StepIdxType & max_capacity, IndexTrigger && trigger)

Defined in src/lib/sbio/execution/threaded.hh:323

The ThreadedExecution policy generates step indices in monotonically.

As the index generator is shared by all threads in the process, it is generated on an atomic counter. This requires the use of acquire/release semantics, and thus has some ammount of overhead compared to a lock-free policy.

Likewise, a lock is explicitly acquired in the event that the index capacity has been reached, and thus a reindexing trigger must be called.

The next step_idx.

Parameter Type Description
batch_size std::size_t The maximum number of steps in a batch.
max_capacity typename FTraits::StepIdxType & The current max capacity (currently available indices).
trigger IndexTrigger && The reindex callback routine.

static inline

template<class FTraits, class IndexTrigger> static inline FTraits::StepIdxType next_impl(IterationState & state, typename FTraits::StepIdxType & max_capacity, IndexTrigger && trigger)

Defined in src/lib/sbio/execution/threaded.hh:429

The ThreadedExecution policy generates step indices in monotonically.

The next step_idx.

Parameter Type Description
max_capacity typename FTraits::StepIdxType & The current max capacity (currently available indices).
trigger IndexTrigger && The reindex callback routine.

static inline

static inline void end_iteration_impl(IterationState & state)

Defined in src/lib/sbio/execution/threaded.hh:444

Exit the iteration with state, releasing any held steps.

Return Name Description
std::size_t m_num_threads static
std::atomic< std::size_t > m_next_unit_ordinal static For unit_ordinal routine.
std::shared_ptr< spdlog::logger > m_logger static

static

std::size_t m_num_threads { 0 }

Defined in src/lib/sbio/execution/threaded.hh:457


static

std::atomic< std::size_t > m_next_unit_ordinal { 0 }

Defined in src/lib/sbio/execution/threaded.hh:458

For unit_ordinal routine.


static

std::shared_ptr< spdlog::logger > m_logger

Defined in src/lib/sbio/execution/threaded.hh:460

Return Name Description
void release_step static inline

static inline

static inline void release_step(IterationState & state)

Defined in src/lib/sbio/execution/threaded.hh:449