ryujin 2.1.1 revision c38afcfdec63b34961924f05408760247496a1f0
Classes | Functions
Miscellaneous

Classes

class  ryujin::MPIEnsemble
 
class  ryujin::SynchronizationDispatch
 
class  ryujin::Scope
 

Functions

template<int dim, typename Number , typename Callable >
ToFunction< dim, Number, Callable > ryujin::to_function (const Callable &callable, const unsigned int k)
 

Various convenience functions and macros

#define AssertThrowSIMD(variable, condition, exception)
 
#define ACCESSOR_READ_ONLY(member)
 
#define ACCESSOR(member)
 
#define ACCESSOR_READ_ONLY_NO_DEREFERENCE(member)
 
#define ASM_LABEL(label)   asm("#" label);
 

OpenMP parallel for macros

Intended use:

// serial work
// per thread work and thread-local storage declarations
for (unsigned int i = 0; i < size_internal; i += simd_length) {
// parallel for loop that is statically distributed on all available
// worker threads by slicing the interval [0,size_internal)
}
#define RYUJIN_PARALLEL_REGION_BEGIN
Definition: openmp.h:54
#define RYUJIN_OMP_FOR
Definition: openmp.h:70
#define RYUJIN_PARALLEL_REGION_END
Definition: openmp.h:63
#define RYUJIN_PRAGMA(x)   _Pragma(#x)
 
#define RYUJIN_PARALLEL_REGION_BEGIN
 
#define RYUJIN_PARALLEL_REGION_END   }
 
#define RYUJIN_OMP_FOR   RYUJIN_PRAGMA(omp for)
 
#define RYUJIN_OMP_FOR_NOWAIT   RYUJIN_PRAGMA(omp for nowait)
 
#define RYUJIN_OMP_BARRIER   RYUJIN_PRAGMA(omp barrier)
 
#define RYUJIN_OMP_CRITICAL   RYUJIN_PRAGMA(omp critical)
 
#define RYUJIN_OMP_SINGLE   RYUJIN_PRAGMA(omp single)
 
#define RYUJIN_LIKELY(x)   (__builtin_expect(!!(x), 1))
 
#define RYUJIN_UNLIKELY(x)   (__builtin_expect(!!(x), 0))
 

Detailed Description

Miscellaneous helper functions, macros and classes.

Macro Definition Documentation

◆ AssertThrowSIMD

#define AssertThrowSIMD (   variable,
  condition,
  exception 
)
Value:
if constexpr (std::is_same< \
typename std::remove_const<decltype(variable)>::type, \
double>::value || \
std::is_same< \
typename std::remove_const<decltype(variable)>::type, \
float>::value) { \
AssertThrow(condition(variable), exception); \
} else { \
for (unsigned int k = 0; k < decltype(variable)::size(); ++k) { \
AssertThrow(condition((variable)[k]), exception); \
} \
}

Mixed serial/SIMD variant of the dealii AssertThrow macro. If variable is just a plain double or float, then this macro defaults to a simple call to dealii::AssertThrow(condition(variable), exception). Otherwise (if decltype(variable) has a subscript operator operator[], the dealii::AssertThrow macro is expanded for all components of the variable.

Definition at line 120 of file convenience_macros.h.

◆ ACCESSOR_READ_ONLY

#define ACCESSOR_READ_ONLY (   member)
Value:
inline auto &member() const \
{ \
return dereference(member##_); \
}

A convenience macro that automatically writes out an accessor (or getter) function:

const Foo& bar() const { return bar_; }

or

const Foo& bar() const { return *bar_; }

depending on whether bar_ can be dereferenced, or not.

Definition at line 186 of file convenience_macros.h.

◆ ACCESSOR

#define ACCESSOR (   member)
Value:
inline auto &member() \
{ \
return dereference(member##_); \
}

Variant of the macro above that returns a mutable reference.

Definition at line 198 of file convenience_macros.h.

◆ ACCESSOR_READ_ONLY_NO_DEREFERENCE

#define ACCESSOR_READ_ONLY_NO_DEREFERENCE (   member)
Value:
inline const auto &member() const \
{ \
return member##_; \
}

Variant of the macro above that does not attempt to dereference the underlying object.

Definition at line 211 of file convenience_macros.h.

◆ ASM_LABEL

#define ASM_LABEL (   label)    asm("#" label);

Injects a label into the generated assembly.

Definition at line 223 of file convenience_macros.h.

◆ RYUJIN_PRAGMA

#define RYUJIN_PRAGMA (   x)    _Pragma(#x)

Macro expanding to a #pragma directive that can be used in other preprocessor macro definitions.

Definition at line 47 of file openmp.h.

◆ RYUJIN_PARALLEL_REGION_BEGIN

#define RYUJIN_PARALLEL_REGION_BEGIN
Value:
RYUJIN_PRAGMA(omp parallel default(shared)) \
{
#define RYUJIN_PRAGMA(x)
Definition: openmp.h:47

Begin an openmp parallel region.

Definition at line 54 of file openmp.h.

◆ RYUJIN_PARALLEL_REGION_END

#define RYUJIN_PARALLEL_REGION_END   }

End an openmp parallel region.

Definition at line 63 of file openmp.h.

◆ RYUJIN_OMP_FOR

#define RYUJIN_OMP_FOR   RYUJIN_PRAGMA(omp for)

Enter a parallel for loop.

Definition at line 70 of file openmp.h.

◆ RYUJIN_OMP_FOR_NOWAIT

#define RYUJIN_OMP_FOR_NOWAIT   RYUJIN_PRAGMA(omp for nowait)

Enter a parallel for loop with "nowait" declaration, i.e., the end of the for loop does not include an implicit thread synchronization barrier.

Definition at line 79 of file openmp.h.

◆ RYUJIN_OMP_BARRIER

#define RYUJIN_OMP_BARRIER   RYUJIN_PRAGMA(omp barrier)

Declare an explicit Thread synchronization barrier.

Definition at line 86 of file openmp.h.

◆ RYUJIN_OMP_CRITICAL

#define RYUJIN_OMP_CRITICAL   RYUJIN_PRAGMA(omp critical)

Annotate a critical section that has to be accessed sequentially.

Definition at line 93 of file openmp.h.

◆ RYUJIN_OMP_SINGLE

#define RYUJIN_OMP_SINGLE   RYUJIN_PRAGMA(omp single)

Annotate a section that has to be executed on one thread only.

Definition at line 100 of file openmp.h.

◆ RYUJIN_LIKELY

#define RYUJIN_LIKELY (   x)    (__builtin_expect(!!(x), 1))

Compiler hint annotating a boolean to be likely true.

Intended use:

if (RYUJIN_LIKELY(thread_ready == true)) {
// likely branch
}
#define RYUJIN_LIKELY(x)
Definition: openmp.h:116
Note
The performance penalty of incorrectly marking a condition as likely is severe. Use only if the condition is almost always true.

Definition at line 116 of file openmp.h.

◆ RYUJIN_UNLIKELY

#define RYUJIN_UNLIKELY (   x)    (__builtin_expect(!!(x), 0))

Compiler hint annotating a boolean expression to be likely false.

Intended use:

if (RYUJIN_UNLIKELY(thread_ready == false)) {
// unlikely branch
}
#define RYUJIN_UNLIKELY(x)
Definition: openmp.h:132
Note
The performance penalty of incorrectly marking a condition as unlikely is severe. Use only if the condition is almost always false.

Definition at line 132 of file openmp.h.

Function Documentation

◆ to_function()

template<int dim, typename Number , typename Callable >
ToFunction< dim, Number, Callable > ryujin::to_function ( const Callable &  callable,
const unsigned int  k 
)

Convenience wrapper that creates a (scalar) dealii::Function object out of a (fairly general) callable object returning array-like values. An example usage is given by the interpolation of initial values performed in InitialValues::interpolate_hyperbolic_vector() and InitialValues::interpolate_initial_precomputed_vector()

for(unsigned int i = 0; i < problem_dimension; ++i)
dealii::VectorTools::interpolate(
dof_handler,
to_function<dim, Number>(callable, i),
U[i]);
Parameters
callableA callable object that provides an operator(const Point<dim> &) and returns an array or rank-1 tensor. More precisely, the return type must have a subscript operator operator[].
kIndex describing the component that is returned by the function object.

Definition at line 69 of file convenience_macros.h.