C++ Library Extensions 2022.12.09
To help learn modern C++ programming
tpf::parallel Namespace Reference

Implements set operations. More...

Classes

struct  cache_wrapper
 
class  counting_iterator
 
struct  st_cache_aligned_array
 
struct  st_cache_wrapper
 
struct  st_cache_wrapper< T, true >
 

Typedefs

template<typename T >
using cache_wrapper_t = typename st_cache_wrapper< T, std::is_class_v< T > >::type
 
template<typename Type , template< typename, typename... > class Container>
using cache_aligned_container_t = Container< cache_wrapper_t< Type >, tbb::cache_aligned_allocator< cache_wrapper_t< Type > > >
 
template<typename Type >
using cache_aligned_vector_t = cache_aligned_container_t< Type, std::vector >
 
template<typename Type , size_t Size>
using cache_aligned_array_t = st_cache_aligned_array< Type, Size >
 

Functions

constexpr size_t default_alignment ()
 
template<typename ElementType , typename Operation >
void atomic_operation (std::atomic< ElementType > &atom, Operation &&opr)
 
constexpr unsigned long long least_power_of_2_ge_n (unsigned long long n)
 
constexpr unsigned long long fast_integer_power (unsigned long long x, unsigned long long n)
 
template<typename Type >
bool is_cache_aligned (Type *ptr)
 
template<typename Type1 , typename Type2 >
bool is_cache_aligned (Type1 *ptr1, Type2 *ptr2)
 
template<typename Type1 , typename Type2 >
bool is_cache_aligned (Type1 &value1, Type2 &value2)
 
template<typename Type >
bool is_cache_aligned (Type &value)
 
bool go_parallel (size_t element_count, size_t greater_than)
 
template<typename IteratorType >
bool go_parallel (IteratorType begin, IteratorType end, size_t greater_than)
 
template<typename ContainerType >
bool go_parallel (ContainerType &&container, size_t greater_than)
 
template<typename IndexType , typename CallbackType >
void for_index (IndexType begin_index, IndexType end_index, CallbackType &&callback, size_t greater_than=ConcurrencyLimit)
 
template<typename ContainerType , typename CallbackType >
void for_index (ContainerType &&container, CallbackType &&callback, size_t greater_than=ConcurrencyLimit)
 
template<typename IndexType , typename InitType , typename SumupType , typename HandleParallelType >
auto reduce_index (IndexType begin_index, IndexType end_index, InitType &&init_value, SumupType &&sum_up, HandleParallelType &&handle_parallel, size_t greater_than=ConcurrencyLimit)
 
template<typename ContainerType , typename InitType , typename SumupType , typename HandleParallelType >
auto reduce_index (ContainerType &&container, InitType &&init_value, SumupType &&sum_up, HandleParallelType &&handle_parallel, size_t greater_than=ConcurrencyLimit)
 

Variables

constexpr auto cache_line_size = 64
 
constexpr size_t ConcurrencyLimit = 10
 
constexpr size_t ForceSequential = ConcurrencyLimit - 1
 
constexpr size_t ForceParallel = ConcurrencyLimit + 1
 

Detailed Description

Implements set operations.

Typedef Documentation

◆ cache_aligned_array_t

template<typename Type , size_t Size>
using tpf::parallel::cache_aligned_array_t = typedef st_cache_aligned_array<Type, Size>

Definition at line 332 of file tpf_parallel.hpp.

◆ cache_aligned_container_t

template<typename Type , template< typename, typename... > class Container>
using tpf::parallel::cache_aligned_container_t = typedef Container< cache_wrapper_t<Type>, tbb::cache_aligned_allocator<cache_wrapper_t<Type> >>

Definition at line 321 of file tpf_parallel.hpp.

◆ cache_aligned_vector_t

template<typename Type >
using tpf::parallel::cache_aligned_vector_t = typedef cache_aligned_container_t<Type, std::vector>

Definition at line 325 of file tpf_parallel.hpp.

◆ cache_wrapper_t

template<typename T >
using tpf::parallel::cache_wrapper_t = typedef typename st_cache_wrapper<T, std::is_class_v<T> >::type

Definition at line 318 of file tpf_parallel.hpp.

Function Documentation

◆ atomic_operation()

template<typename ElementType , typename Operation >
void tpf::parallel::atomic_operation ( std::atomic< ElementType > &  atom,
Operation &&  opr 
)
inline

Definition at line 125 of file tpf_parallel.hpp.

◆ default_alignment()

constexpr size_t tpf::parallel::default_alignment ( )
inlineconstexpr

Definition at line 121 of file tpf_parallel.hpp.

◆ fast_integer_power()

constexpr unsigned long long tpf::parallel::fast_integer_power ( unsigned long long  x,
unsigned long long  n 
)
inlineconstexpr

Definition at line 217 of file tpf_parallel.hpp.

◆ for_index() [1/2]

template<typename ContainerType , typename CallbackType >
void tpf::parallel::for_index ( ContainerType &&  container,
CallbackType &&  callback,
size_t  greater_than = ConcurrencyLimit 
)

Definition at line 416 of file tpf_parallel.hpp.

Here is the call graph for this function:

◆ for_index() [2/2]

template<typename IndexType , typename CallbackType >
void tpf::parallel::for_index ( IndexType  begin_index,
IndexType  end_index,
CallbackType &&  callback,
size_t  greater_than = ConcurrencyLimit 
)

Definition at line 399 of file tpf_parallel.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ go_parallel() [1/3]

template<typename ContainerType >
bool tpf::parallel::go_parallel ( ContainerType &&  container,
size_t  greater_than 
)
inline

Definition at line 390 of file tpf_parallel.hpp.

Here is the call graph for this function:

◆ go_parallel() [2/3]

template<typename IteratorType >
bool tpf::parallel::go_parallel ( IteratorType  begin,
IteratorType  end,
size_t  greater_than 
)
inline

Definition at line 378 of file tpf_parallel.hpp.

Here is the call graph for this function:

◆ go_parallel() [3/3]

bool tpf::parallel::go_parallel ( size_t  element_count,
size_t  greater_than 
)
inline

Definition at line 372 of file tpf_parallel.hpp.

Here is the caller graph for this function:

◆ is_cache_aligned() [1/4]

template<typename Type >
bool tpf::parallel::is_cache_aligned ( Type &  value)

Definition at line 361 of file tpf_parallel.hpp.

Here is the call graph for this function:

◆ is_cache_aligned() [2/4]

template<typename Type >
bool tpf::parallel::is_cache_aligned ( Type *  ptr)

Definition at line 335 of file tpf_parallel.hpp.

Here is the caller graph for this function:

◆ is_cache_aligned() [3/4]

template<typename Type1 , typename Type2 >
bool tpf::parallel::is_cache_aligned ( Type1 &  value1,
Type2 &  value2 
)

Definition at line 355 of file tpf_parallel.hpp.

Here is the call graph for this function:

◆ is_cache_aligned() [4/4]

template<typename Type1 , typename Type2 >
bool tpf::parallel::is_cache_aligned ( Type1 *  ptr1,
Type2 *  ptr2 
)

Definition at line 349 of file tpf_parallel.hpp.

◆ least_power_of_2_ge_n()

constexpr unsigned long long tpf::parallel::least_power_of_2_ge_n ( unsigned long long  n)
inlineconstexpr

Definition at line 203 of file tpf_parallel.hpp.

◆ reduce_index() [1/2]

template<typename ContainerType , typename InitType , typename SumupType , typename HandleParallelType >
auto tpf::parallel::reduce_index ( ContainerType &&  container,
InitType &&  init_value,
SumupType &&  sum_up,
HandleParallelType &&  handle_parallel,
size_t  greater_than = ConcurrencyLimit 
)

Definition at line 449 of file tpf_parallel.hpp.

Here is the call graph for this function:

◆ reduce_index() [2/2]

template<typename IndexType , typename InitType , typename SumupType , typename HandleParallelType >
auto tpf::parallel::reduce_index ( IndexType  begin_index,
IndexType  end_index,
InitType &&  init_value,
SumupType &&  sum_up,
HandleParallelType &&  handle_parallel,
size_t  greater_than = ConcurrencyLimit 
)

Definition at line 425 of file tpf_parallel.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cache_line_size

constexpr auto tpf::parallel::cache_line_size = 64
inlineconstexpr

Definition at line 118 of file tpf_parallel.hpp.

◆ ConcurrencyLimit

constexpr size_t tpf::parallel::ConcurrencyLimit = 10
constexpr

Definition at line 366 of file tpf_parallel.hpp.

◆ ForceParallel

constexpr size_t tpf::parallel::ForceParallel = ConcurrencyLimit + 1
constexpr

Definition at line 370 of file tpf_parallel.hpp.

◆ ForceSequential

constexpr size_t tpf::parallel::ForceSequential = ConcurrencyLimit - 1
constexpr

Definition at line 369 of file tpf_parallel.hpp.