Implements basic tasks for OpenMP parallelism and suitable scalar alternatives.
More...
#include <openmp_utils.h>
Implements basic tasks for OpenMP parallelism and suitable scalar alternatives.
This class defines utility functions that implement some basic OpenMP capabilities and an equivalent scalar alternative to use in compilations where OpenMP is not enabled. The idea is to allow Kratos developers to design their code in parallel, knowing that it will work in scalar runs as well.
◆ PartitionVector
◆ DivideInPartitions()
static void Kratos::OpenMPUtils::DivideInPartitions |
( |
const int |
NumTerms, |
|
|
const int |
NumThreads, |
|
|
PartitionVector & |
Partitions |
|
) |
| |
|
inlinestatic |
Divide an array of length NumTerms between NumThreads threads.
Creates a std::vector containing NumThreads + 1 terms, where term k is the first and position of the array that corresponds to thread k. The k+1 term is the end of the array, so that the vector can be used to iterate the array between 'k' and 'k+1' in each thread.
- Parameters
-
NumTerms | Number of objects to be divided between the threads. |
NumThreads | The number of parallel threads that will be used. |
Partitions | This object will contain the begin and end positions for each thread. |
◆ GetCurrentNumberOfThreads()
static int Kratos::OpenMPUtils::GetCurrentNumberOfThreads |
( |
| ) |
|
|
inlinestatic |
Wrapper for omp_get_num_threads().
- Returns
- Number of OpenMP threads in the current team.
◆ IsDynamic()
static int Kratos::OpenMPUtils::IsDynamic |
( |
| ) |
|
|
inlinestatic |
Wrapper for omp_get_dynamic().
- Returns
- Dynamic teams are enabled.
◆ IsInParallel()
static int Kratos::OpenMPUtils::IsInParallel |
( |
| ) |
|
|
inlinestatic |
Wrapper for omp_in_parallel().
- Returns
- Maximum number of OpenMP threads that will be used in parallel regions.
◆ KRATOS_DEPRECATED_MESSAGE() [1/3]
Kratos::OpenMPUtils::KRATOS_DEPRECATED_MESSAGE |
( |
"This is legacy |
version, |
|
|
please use the \"ParallelUtilities\" instead" |
|
|
) |
| |
|
inline |
Wrapper for omp_get_max_threads().
- Returns
- Maximum number of OpenMP threads that will be used in parallel regions.
◆ KRATOS_DEPRECATED_MESSAGE() [2/3]
Kratos::OpenMPUtils::KRATOS_DEPRECATED_MESSAGE |
( |
"This is legacy |
version, |
|
|
please use the \"ParallelUtilities\" instead" |
|
|
) |
| |
|
inline |
Wrapper for omp_get_num_procs().
- Returns
- Number of processors available to the device.
◆ KRATOS_DEPRECATED_MESSAGE() [3/3]
Kratos::OpenMPUtils::KRATOS_DEPRECATED_MESSAGE |
( |
"This is legacy |
version, |
|
|
please use the \"utilities/builtin_timer.h\" instead" |
|
|
) |
| |
|
inline |
Timing routine.
Determine the current time by calling an appropiate (scalar or parallel) timer class.
- Returns
- Current time
◆ PartitionedIterators()
template<class TVector >
static void Kratos::OpenMPUtils::PartitionedIterators |
( |
TVector & |
rVector, |
|
|
typename TVector::iterator & |
rBegin, |
|
|
typename TVector::iterator & |
rEnd |
|
) |
| |
|
inlinestatic |
Generate a partition for an std::vector-like array, providing iterators to the begin and end positions for each thread.
This function assumes that the vector class will have an iterator type and implement begin(), end() and size() methods.
- Parameters
-
rVector | An arary containing the elements to be distributed between the threads. |
rBegin | Iterator pointing to the first element in rVector to be used in the current thread. |
rEnd | Iterator pointing to the end position for the current thread in rVector. |
◆ ThisThread()
static int Kratos::OpenMPUtils::ThisThread |
( |
| ) |
|
|
inlinestatic |
Wrapper for omp_get_thread_num().
- Returns
- The thread number for this thread, 0 if scalar run.
The documentation for this class was generated from the following file:
- /home/runner/work/Documentation/Documentation/master/kratos/utilities/openmp_utils.h