dispenso
A library for task parallelism
 
Loading...
Searching...
No Matches
dispenso::DefaultConcurrentVectorTraits Struct Reference

#include <concurrent_vector.h>

Static Public Attributes

static constexpr bool kPreferBuffersInline = true
 Prefer to place the pointers to the buffers inline in the class.
 
static constexpr ConcurrentVectorReallocStrategy kReallocStrategy
 How far/whether to allocate before memory is required.
 
static constexpr bool kIteratorPreferSpeed = true
 Should we prefer faster, but larger iterators, or slower, but smaller iterators.
 

Detailed Description

The default ConcurrentVector traits type. All members are required should one wish to supply a custom set of traits.

Definition at line 113 of file concurrent_vector.h.

Member Data Documentation

◆ kIteratorPreferSpeed

constexpr bool dispenso::DefaultConcurrentVectorTraits::kIteratorPreferSpeed = true
staticconstexpr

Should we prefer faster, but larger iterators, or slower, but smaller iterators.

If an algorithm needs to store iterators for later use, size overhead could become a concern. By using kIteratorPreferSpeed == true, the size of an iterator will be roughly double the iterator when kIteratorPreferSpeed == false. Conversely, iterate + dereference is also about twice as fast.

Definition at line 145 of file concurrent_vector.h.

◆ kPreferBuffersInline

constexpr bool dispenso::DefaultConcurrentVectorTraits::kPreferBuffersInline = true
staticconstexpr

Prefer to place the pointers to the buffers inline in the class.

This can consume a lot of space, e.g. on the stack. This can be a couple of kilobytes. But performance is improved by 5% to 15%. When set to false, this results in those pointers residing in a separate heap allocation.

Definition at line 121 of file concurrent_vector.h.

◆ kReallocStrategy

constexpr ConcurrentVectorReallocStrategy dispenso::DefaultConcurrentVectorTraits::kReallocStrategy
staticconstexpr
Initial value:
=
ConcurrentVectorReallocStrategy::kAsNeeded

How far/whether to allocate before memory is required.

We can allocate ahead, which may reduce the chances of another thread blocking while waiting for memory to be allocated. This implies a pretty stiff memory overhead, which people may not want to pay (up to 3x overhead after the first bucket for kFullBufferAhead). This can be set to kAsNeeded instead of kFullBufferAhead, which makes overheads similar to typical std::vector implementation (up to 2x overhead). Performance differences are modest, so unless you need to squeeze the most out of your use, kAsNeeded is okay.

Definition at line 133 of file concurrent_vector.h.


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