KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
Public Member Functions | List of all members
Kratos::IndexPartition< TIndexType, TMaxThreads > Class Template Reference

This class is useful for index iteration over containers. More...

#include <parallel_utilities.h>

Collaboration diagram for Kratos::IndexPartition< TIndexType, TMaxThreads >:

Public Member Functions

 IndexPartition (TIndexType Size, int Nchunks=ParallelUtilities::GetNumThreads())
 constructor using the size of the partition to be used More...
 
template<class TUnaryFunction >
void for_pure_c11 (TUnaryFunction &&f)
 
template<class TUnaryFunction >
void for_each (TUnaryFunction &&f)
 
template<class TReducer , class TUnaryFunction >
TReducer::return_type for_each (TUnaryFunction &&f)
 
template<class TThreadLocalStorage , class TFunction >
void for_each (const TThreadLocalStorage &rThreadLocalStoragePrototype, TFunction &&f)
 loop with thread local storage (TLS). f called on every entry in rData More...
 
template<class TReducer , class TThreadLocalStorage , class TFunction >
TReducer::return_type for_each (const TThreadLocalStorage &rThreadLocalStoragePrototype, TFunction &&f)
 

Detailed Description

template<class TIndexType = std::size_t, int TMaxThreads = Globals::MaxAllowedThreads>
class Kratos::IndexPartition< TIndexType, TMaxThreads >

This class is useful for index iteration over containers.

Parameters
TIndexTypetype of index to be used in the loop
TMaxThreads- maximum number of threads allowed in the partitioning. must be known at compile time to avoid heap allocations in the partitioning

Constructor & Destructor Documentation

◆ IndexPartition()

template<class TIndexType = std::size_t, int TMaxThreads = Globals::MaxAllowedThreads>
Kratos::IndexPartition< TIndexType, TMaxThreads >::IndexPartition ( TIndexType  Size,
int  Nchunks = ParallelUtilities::GetNumThreads() 
)
inline

constructor using the size of the partition to be used

Parameters
Size- the size of the partition
Nchunks- number of threads to be used in the loop (must be lower than TMaxThreads)

Member Function Documentation

◆ for_each() [1/4]

template<class TIndexType = std::size_t, int TMaxThreads = Globals::MaxAllowedThreads>
template<class TThreadLocalStorage , class TFunction >
void Kratos::IndexPartition< TIndexType, TMaxThreads >::for_each ( const TThreadLocalStorage &  rThreadLocalStoragePrototype,
TFunction &&  f 
)
inline

loop with thread local storage (TLS). f called on every entry in rData

Parameters
TThreadLocalStoragetemplate parameter specifying the thread local storage
f- must be a function accepting as input IndexType and the thread local storage

◆ for_each() [2/4]

template<class TIndexType = std::size_t, int TMaxThreads = Globals::MaxAllowedThreads>
template<class TReducer , class TThreadLocalStorage , class TFunction >
TReducer::return_type Kratos::IndexPartition< TIndexType, TMaxThreads >::for_each ( const TThreadLocalStorage &  rThreadLocalStoragePrototype,
TFunction &&  f 
)
inline

version with reduction and thread local storage (TLS) to be called for each index in the partition function f is expected to return the values to be reduced

Parameters
TReducer- template parameter specifying the type of reducer to be applied
TThreadLocalStoragetemplate parameter specifying the thread local storage
f- must be a function accepting as input IndexType and the thread local storage

◆ for_each() [3/4]

template<class TIndexType = std::size_t, int TMaxThreads = Globals::MaxAllowedThreads>
template<class TUnaryFunction >
void Kratos::IndexPartition< TIndexType, TMaxThreads >::for_each ( TUnaryFunction &&  f)
inline

simple version of for_each (no reduction) to be called for each index in the partition

Parameters
f- must be a unary function accepting as input IndexType

◆ for_each() [4/4]

template<class TIndexType = std::size_t, int TMaxThreads = Globals::MaxAllowedThreads>
template<class TReducer , class TUnaryFunction >
TReducer::return_type Kratos::IndexPartition< TIndexType, TMaxThreads >::for_each ( TUnaryFunction &&  f)
inline

version with reduction to be called for each index in the partition function f is expected to return the values to be reduced

Parameters
TReducer- template parameter specifying the type of reducer to be applied
f- must be a unary function accepting as input IndexType

◆ for_pure_c11()

template<class TIndexType = std::size_t, int TMaxThreads = Globals::MaxAllowedThreads>
template<class TUnaryFunction >
void Kratos::IndexPartition< TIndexType, TMaxThreads >::for_pure_c11 ( TUnaryFunction &&  f)
inline

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