ryujin 2.5.0 revision 3a6c8d57210175dea14d8116e1fe878f349f8c1c
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
Utilities
Collaboration diagram for Utilities:

Classes

class  ryujin::ComputingTimer
 
class  ryujin::GeoTIFFReader
 
class  ryujin::Lazy< T >
 
class  ryujin::Library< Base, Args >
 
struct  ryujin::ArrayReducer< ElementReducer >
 
class  ryujin::MPIEnsemble
 
class  ryujin::MPIEnsembleContainer< T >
 

Enumerations

enum class  ryujin::HeightNormalization { ryujin::HeightNormalization::none , ryujin::HeightNormalization::minimum , ryujin::HeightNormalization::average , ryujin::HeightNormalization::maximum }
 

Functions

template<typename ScalarNumber , typename Functor , typename... Args>
void ryujin::cpu_simd_loop (const std::string &region_name, const Functor &body, const unsigned int left, const unsigned int internal, const unsigned int right, Args &&...args)
 
template<typename ScalarNumber , typename Functor , typename... Args>
void ryujin::gpu_loop (const std::string &region_name, const Functor &body, const unsigned int left, const unsigned int internal, const unsigned int right, Args &&...args)
 
template<typename MemorySpace , typename ScalarNumber , typename Functor , typename... Args>
void ryujin::loop (const std::string &region_name, const Functor &body, const unsigned int left, const unsigned int internal, const unsigned int right, Args &&...args)
 
void ryujin::print_revision_and_version (std::ostream &stream)
 

Various convenience wrappers for dealing with dealii::Function,

dealii::Tensor:

template<int dim, typename Number , typename Callable >
ToFunction< dim, Number, Callable > ryujin::to_function (const Callable &callable, const unsigned int k)
 
template<typename FT , int problem_dim = FT::dimension, typename TT = typename FT::value_type, typename T = typename TT::value_type>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > ryujin::contract (const FT &flux_ij, const TT &c_ij)
 
template<typename FT , int problem_dim = FT::dimension>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE FT ryujin::add (const FT &flux_left_ij, const FT &flux_right_ij)
 

Functions

template<typename Number >
DEAL_II_HOST_DEVICE_ALWAYS_INLINE void ryujin::quadratic_newton_step (Number &p_1, Number &p_2, const Number phi_p_1, const Number phi_p_2, const Number dphi_p_1, const Number dphi_p_2, const Number sign=Number(1.0))
 

Macros for accessor definitions with automatic dereferencing

#define ACCESSOR_READ_ONLY(member)
 
#define ACCESSOR(member)
 
#define ACCESSOR_READ_ONLY_NO_DEREFERENCE(member)
 
#define ACCESSOR_CONTAINER_READ_ONLY(container, member)
 

Macros for compiler hints

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

Likwid support

#define LIKWID_MARKER_INIT
 
#define LIKWID_MARKER_THREADINIT
 
#define LIKWID_MARKER_CLOSE
 
#define LIKWID_MARKER_START(opt)
 
#define LIKWID_MARKER_STOP(opt)
 

NVTX support

#define NVTX_MARKER_INIT
 
#define NVTX_MARKER_CLOSE
 
#define NVTX_MARKER_START(opt)
 
#define NVTX_MARKER_STOP(opt)
 

Clang LSAN support

#define LSAN_DISABLE
 
#define LSAN_ENABLE
 

Detailed Description

Helper functions, macros and classes: loop abstractions for the host and device memory spaces, MPI ensembles, timers and instrumentation, a Newton solver, lazy initialization, and parameter conversion (include/ryujin/base).

Macro Definition Documentation

◆ ACCESSOR_READ_ONLY

#define ACCESSOR_READ_ONLY (   member)
Value:
inline const 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 168 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 180 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 193 of file convenience_macros.h.

◆ ACCESSOR_CONTAINER_READ_ONLY

#define ACCESSOR_CONTAINER_READ_ONLY (   container,
  member 
)
Value:
inline const auto &member() const \
{ \
return dereference(dereference(container).member); \
}

Variant of the macro above that takes two arguments, container and member, and creates an accessor function.

const Foo& member() const { return container_.member; }

The function will dereference container and member if they are of pointer type.

Definition at line 211 of file convenience_macros.h.

◆ RYUJIN_PRAGMA

#define RYUJIN_PRAGMA (   x)    _Pragma(#x)

Defined during the device compilation pass of a "single source" offloading compiler (clang CUDA/HIP, SYCL), i.e., when the current translation unit is compiled for the device and not for the host. Macro expanding to a #pragma directive that looks nicer in indented code and can be used in other preprocessor macro definitions.

Definition at line 243 of file convenience_macros.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)
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 260 of file convenience_macros.h.

◆ LIKWID_MARKER_INIT

#define LIKWID_MARKER_INIT

Macro initializing likwid instrumentation. Used in main().

Definition at line 24 of file instrumentation.h.

◆ LIKWID_MARKER_THREADINIT

#define LIKWID_MARKER_THREADINIT

Macro initializing likwid instrumentation on a worker thread. Used in main().

Definition at line 32 of file instrumentation.h.

◆ LIKWID_MARKER_CLOSE

#define LIKWID_MARKER_CLOSE

Macro finalizing likwid instrumentation. Used in main().

Definition at line 39 of file instrumentation.h.

◆ LIKWID_MARKER_START

#define LIKWID_MARKER_START (   opt)

A set of macros that start and stop likwid instrumentation (if support for likwid is enabled). We currently annotate all named host compute loops, i.e., cpu_simd_loop() and cpu_reduction_loop() in loop.h. Usage:

LIKWID_MARKER_START("string identifier")
// critical compute kernel section
LIKWID_MARKER_STOP("string identifier")
#define LIKWID_MARKER_START(opt)
#define LIKWID_MARKER_STOP(opt)

Definition at line 54 of file instrumentation.h.

◆ LIKWID_MARKER_STOP

#define LIKWID_MARKER_STOP (   opt)

A set of macros that start and stop likwid instrumentation (if support for likwid is enabled). We currently annotate all named host compute loops, i.e., cpu_simd_loop() and cpu_reduction_loop() in loop.h. Usage:

LIKWID_MARKER_START("string identifier")
// critical compute kernel section
LIKWID_MARKER_STOP("string identifier")

Definition at line 61 of file instrumentation.h.

◆ NVTX_MARKER_INIT

#define NVTX_MARKER_INIT

Macro starting the CUDA profiler. Used in main().

Definition at line 87 of file instrumentation.h.

◆ NVTX_MARKER_CLOSE

#define NVTX_MARKER_CLOSE

Macro stopping the CUDA profiler. Used in main().

Definition at line 94 of file instrumentation.h.

◆ NVTX_MARKER_START

#define NVTX_MARKER_START (   opt)

A set of macros that push and pop a named NVTX range (if support for NVTX is enabled). Such a range shows up as a labeled interval in the timeline of the CUDA profiler and allows to attribute individual kernel launches to the compute loop they originate from. We currently annotate all named device compute loops, i.e., gpu_loop() and gpu_reduction_loop() in loop.h. Usage:

NVTX_MARKER_START("string identifier")
// critical compute kernel section
NVTX_MARKER_STOP("string identifier")
#define NVTX_MARKER_START(opt)
#define NVTX_MARKER_STOP(opt)

Definition at line 112 of file instrumentation.h.

◆ NVTX_MARKER_STOP

#define NVTX_MARKER_STOP (   opt)

A set of macros that push and pop a named NVTX range (if support for NVTX is enabled). Such a range shows up as a labeled interval in the timeline of the CUDA profiler and allows to attribute individual kernel launches to the compute loop they originate from. We currently annotate all named device compute loops, i.e., gpu_loop() and gpu_reduction_loop() in loop.h. Usage:

NVTX_MARKER_START("string identifier")
// critical compute kernel section
NVTX_MARKER_STOP("string identifier")

Definition at line 119 of file instrumentation.h.

◆ LSAN_DISABLE

#define LSAN_DISABLE

Explicitly disable/enable the LLVM/Clang LeakSanitiver

// Calling some external code path that is leaky and that we cannot
// control...
#define LSAN_ENABLE
#define LSAN_DISABLE

Definition at line 141 of file instrumentation.h.

◆ LSAN_ENABLE

#define LSAN_ENABLE

Explicitly disable/enable the LLVM/Clang LeakSanitiver

// Calling some external code path that is leaky and that we cannot
// control...

Definition at line 148 of file instrumentation.h.

Enumeration Type Documentation

◆ HeightNormalization

enum class ryujin::HeightNormalization
strong

Controls how the height information read in from a GeoTIFF image is normalized.

Enumerator
none 

do not normalize the height:

minimum 

set minimum to zero:

average 

set average to zero:

maximum 

set maximum to zero:

Definition at line 31 of file geotiff_reader.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 72 of file convenience_macros.h.

◆ cpu_simd_loop()

template<typename ScalarNumber , typename Functor , typename... Args>
void ryujin::cpu_simd_loop ( const std::string &  region_name,
const Functor &  body,
const unsigned int  left,
const unsigned int  internal,
const unsigned int  right,
Args &&...  args 
)
inline

A thread-parallelized and vectorized loop running on the CPU. The loop traverses the index range [left, internal) SIMD vectorized stepping forward with a stride size equal to the number of packed doubles/singles that the loop body operates on at the same time. For the remainder of the index range, i.e., [internal, right) a serial loop is invoked.

Note
the index internal is rounded down to the next integer multiple of the SIMD stride size.
Here, body is a functor that must accept a "sentinel" type as first argument and the current index i as last argument. Additional args may be specified in the cpu_simd_loop() invocation that will be forwarded to the loop body: body(Number(), std::forward<Args>(args)..., i);

Definition at line 50 of file loop.h.

References LIKWID_MARKER_START, LIKWID_MARKER_STOP, and RYUJIN_PRAGMA.

◆ gpu_loop()

template<typename ScalarNumber , typename Functor , typename... Args>
void ryujin::gpu_loop ( const std::string &  region_name,
const Functor &  body,
const unsigned int  left,
const unsigned int  internal,
const unsigned int  right,
Args &&...  args 
)
inline

A loop running on the device (i.e., in the default memory space). The loop traverses the index range [left, right) with a suitable Kokkos parallel_for using a range policy.

Note
The index range [left, internal) that is used for SIMD vectorization in cpu_simd_loop() is currently ignored: On the device every "lane" operates on a scalar value and the loop body is thus always called with a scalar sentinel type.
Here, body is a functor that must accept a "sentinel" type as first argument and the current index i as last argument. Additional args may be specified in the gpu_loop() invocation that will be forwarded to the loop body: body(ScalarNumber(), std::forward<Args>(args)..., i);
The loop body (and everything it references) has to be callable on the device. In particular, body and all args are copied into the kernel, meaning that the functor must capture by value and must be trivially copyable.
The function fences the execution space before returning. It thus has the same (synchronous) semantics as cpu_simd_loop().

Definition at line 162 of file loop.h.

References NVTX_MARKER_START, and NVTX_MARKER_STOP.

◆ loop()

template<typename MemorySpace , typename ScalarNumber , typename Functor , typename... Args>
void ryujin::loop ( const std::string &  region_name,
const Functor &  body,
const unsigned int  left,
const unsigned int  internal,
const unsigned int  right,
Args &&...  args 
)
inline

A loop running either on the CPU, or on the device depending on the selected memory space: For dealii::MemorySpace::Host the loop is dispatched to cpu_simd_loop(), and for dealii::MemorySpace::Default to gpu_loop().

Note
Here, body is a functor that must accept a "sentinel" type as first argument and the current index i as last argument. Additional args may be specified in the loop() invocation that will be forwarded to the loop body.

Definition at line 218 of file loop.h.

◆ quadratic_newton_step()

template<typename Number >
DEAL_II_HOST_DEVICE_ALWAYS_INLINE void ryujin::quadratic_newton_step ( Number &  p_1,
Number &  p_2,
const Number  phi_p_1,
const Number  phi_p_2,
const Number  dphi_p_1,
const Number  dphi_p_2,
const Number  sign = Number(1.0) 
)

Perform one step of a quadratic Newton iteration, see [17], Algorithm 3.

Note
For this, it has to hold true that \(p_1\le p^\ast\le p_2\), and \(\phi(p_1)\le 0\le \phi(p_2)\), or \(\phi(p_1)\ge 0\ge \phi(p_2)\) and that \(\phi\) itself is a 3-convex/concave function, i.e., \(\phi'''<0\), or \(\phi'''>0\).

Modifies p_1 and P_2 ensures that p_1 <= p_2, and that p_1 (p_2) is monotonically increasing (decreasing).

Todo:
Write out the quadratic Newton step in more detail.

Definition at line 38 of file newton.h.

Referenced by ryujin::Euler::LimiterView< dim, Number, MemorySpace >::limit(), ryujin::EulerAEOS::LimiterView< dim, Number, MemorySpace >::limit(), ryujin::ShallowWater::LimiterView< dim, Number, MemorySpace >::limit(), and ryujin::EulerAEOS::NASGRiemannSolverView< Number, options, MemorySpace >::newton_step().

◆ print_revision_and_version()

void ryujin::print_revision_and_version ( std::ostream &  stream)

Print git revision and version info.

◆ contract()

template<typename FT , int problem_dim = FT::dimension, typename TT = typename FT::value_type, typename T = typename TT::value_type>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > ryujin::contract ( const FT &  flux_ij,
const TT &  c_ij 
)

◆ add()

template<typename FT , int problem_dim = FT::dimension>
DEAL_II_HOST_DEVICE_ALWAYS_INLINE FT ryujin::add ( const FT &  flux_left_ij,
const FT &  flux_right_ij 
)