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.
Classes | Namespaces | Macros | Functions
parallel_utilities.h File Reference
#include <iostream>
#include <array>
#include <iterator>
#include <vector>
#include <tuple>
#include <cmath>
#include <limits>
#include <future>
#include <thread>
#include <mutex>
#include "includes/define.h"
#include "includes/global_variables.h"
#include "includes/lock_object.h"
Include dependency graph for parallel_utilities.h:

Go to the source code of this file.

Classes

class  Kratos::ParallelUtilities
 Shared memory parallelism related helper class. More...
 
class  Kratos::BlockPartition< TIterator, MaxThreads >
 
class  Kratos::IndexPartition< TIndexType, TMaxThreads >
 This class is useful for index iteration over containers. More...
 

Namespaces

 Kratos
 REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
 

Macros

#define KRATOS_CRITICAL_SECTION   const std::lock_guard scope_lock(ParallelUtilities::GetGlobalLock());
 
#define KRATOS_PREPARE_CATCH_THREAD_EXCEPTION   std::stringstream err_stream;
 
#define KRATOS_CATCH_THREAD_EXCEPTION
 
#define KRATOS_CHECK_AND_THROW_THREAD_EXCEPTION
 

Functions

template<class TIterator , class TFunction , std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, typename std::iterator_traits< TIterator >::iterator_category >, bool > = true>
void Kratos::block_for_each (TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
 Execute a functor on all items of a range in parallel. More...
 
template<class TReduction , class TIterator , class TFunction , std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, typename std::iterator_traits< TIterator >::iterator_category >, bool > = true>
TReduction::return_type Kratos::block_for_each (TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
 Execute a functor on all items of a range in parallel, and perform a reduction. More...
 
template<class TIterator , class TTLS , class TFunction , std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, typename std::iterator_traits< TIterator >::iterator_category >, bool > = true>
void Kratos::block_for_each (TIterator itBegin, TIterator itEnd, const TTLS &rTLS, TFunction &&rFunction)
 Execute a functor with thread local storage on all items of a range in parallel. More...
 
template<class TReduction , class TIterator , class TTLS , class TFunction , std::enable_if_t< std::is_base_of_v< std::input_iterator_tag, typename std::iterator_traits< TIterator >::iterator_category >, bool > = true>
TReduction::return_type Kratos::block_for_each (TIterator itBegin, TIterator itEnd, const TTLS &tls, TFunction &&rFunction)
 Execute a functor with thread local storage on all items of a range in parallel, and perform a reduction. More...
 
template<class TContainerType , class TFunctionType , std::enable_if_t<!std::is_same_v< std::iterator_traits< typename decltype(std::declval< std::remove_cv_t< TContainerType >>().begin())::value_type >, void >, bool > = true>
void Kratos::block_for_each (TContainerType &&v, TFunctionType &&func)
 simplified version of the basic loop (without reduction) to enable template type deduction More...
 
template<class TReducer , class TContainerType , class TFunctionType , std::enable_if_t<!std::is_same_v< std::iterator_traits< typename decltype(std::declval< std::remove_cv_t< TContainerType >>().begin())::value_type >, void >, bool > = true>
TReducer::return_type Kratos::block_for_each (TContainerType &&v, TFunctionType &&func)
 simplified version of the basic loop with reduction to enable template type deduction More...
 
template<class TContainerType , class TThreadLocalStorage , class TFunctionType , std::enable_if_t<!std::is_same_v< std::iterator_traits< typename decltype(std::declval< std::remove_cv_t< TContainerType >>().begin())::value_type >, void >, bool > = true>
void Kratos::block_for_each (TContainerType &&v, const TThreadLocalStorage &tls, TFunctionType &&func)
 simplified version of the basic loop with thread local storage (TLS) to enable template type deduction More...
 
template<class TReducer , class TContainerType , class TThreadLocalStorage , class TFunctionType , std::enable_if_t<!std::is_same_v< std::iterator_traits< typename decltype(std::declval< std::remove_cv_t< TContainerType >>().begin())::value_type >, void >, bool > = true>
TReducer::return_type Kratos::block_for_each (TContainerType &&v, const TThreadLocalStorage &tls, TFunctionType &&func)
 simplified version of the basic loop with reduction and thread local storage (TLS) to enable template type deduction More...
 

Macro Definition Documentation

◆ KRATOS_CATCH_THREAD_EXCEPTION

#define KRATOS_CATCH_THREAD_EXCEPTION
Value:
} catch(Exception& e) { \
KRATOS_CRITICAL_SECTION \
err_stream << "Thread #" << i << " caught exception: " << e.what(); \
} catch(std::exception& e) { \
KRATOS_CRITICAL_SECTION \
err_stream << "Thread #" << i << " caught exception: " << e.what(); \
} catch(...) { \
KRATOS_CRITICAL_SECTION \
err_stream << "Thread #" << i << " caught unknown exception:"; \
}
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31

◆ KRATOS_CHECK_AND_THROW_THREAD_EXCEPTION

#define KRATOS_CHECK_AND_THROW_THREAD_EXCEPTION
Value:
const std::string& err_msg = err_stream.str(); \
KRATOS_ERROR_IF_NOT(err_msg.empty()) << "The following errors occured in a parallel region!\n" << err_msg << std::endl;
string err_msg
Definition: fluid_chimera_analysis.py:21

◆ KRATOS_CRITICAL_SECTION

#define KRATOS_CRITICAL_SECTION   const std::lock_guard scope_lock(ParallelUtilities::GetGlobalLock());

◆ KRATOS_PREPARE_CATCH_THREAD_EXCEPTION

#define KRATOS_PREPARE_CATCH_THREAD_EXCEPTION   std::stringstream err_stream;