Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::vutils Namespace Reference

Namespaces

namespace  internal

Classes

class  ExpressionParser
 Compiles and evaluates a scalar math expression at runtime. More...

Functions

void configureVtkThreading ()
 Configure the VTK SMP thread budget.
void checkOpenBlasThreading ()
 Validate the active OpenBLAS thread count.
template<typename T, typename IndexType>
std::vector< T > slice (const std::vector< T > &source, const std::vector< IndexType > &indices)
 Build a new vector by selecting elements of source at the given indices.
template<typename Tuple, typename Func, std::size_t... Is>
void for_each_impl (Tuple &&tuple, Func &&func, std::index_sequence< Is... >)
template<typename Tuple, typename Func>
void for_each (Tuple &&tuple, Func &&func)
 Apply func to every element of tuple, in order.
template<typename Tuple, typename Func, std::size_t... Is>
void for_each_impl_idxed (Tuple &&tuple, Func &&func, std::index_sequence< Is... >)
template<typename Tuple, typename Func>
void for_each_idxed (Tuple &&tuple, Func &&func)
 Apply func to every element of tuple together with its index.

Function Documentation

◆ checkOpenBlasThreading()

void vulpes::vutils::checkOpenBlasThreading ( )

Validate the active OpenBLAS thread count.

The function compares the number of threads reported by OpenBLAS with the requested thread budget:

  • OPENBLAS_NUM_THREADS is used when it contains a valid positive integer;
  • otherwise, if OPENBLAS_NUM_THREADS is absent, a valid OMP_NUM_THREADS value is used as the expected budget;
  • if OPENBLAS_NUM_THREADS is present but invalid, no expected OpenBLAS budget can be inferred.
  • if neither OPENBLAS_NUM_THREADS nor OMP_NUM_THREADS is set, no expected budget can be inferred either; a stronger warning is emitted since OpenBLAS's actual thread count is then unpredictable and may silently oversubscribe the machine under MPI.

OpenBLAS is inspected dynamically through libopenblas.so.0 and openblas_get_num_threads(). Diagnostic warnings are emitted if OpenBLAS cannot be inspected or if its active thread count differs from the expected value.

Note
Call this function after PetscInitialize(), when PETSc's BLAS backend is available in the process.
This function is diagnostic only. It does not modify the OpenBLAS thread count.
If PETSc uses another BLAS implementation, OpenBLAS validation is unavailable and a warning is emitted.

◆ configureVtkThreading()

void vulpes::vutils::configureVtkThreading ( )

Configure the VTK SMP thread budget.

The thread budget is read from the OMP_NUM_THREADS environment variable. The value must be a positive integer representable as an int.

If OMP_NUM_THREADS is absent or invalid, Vulpes configures VTK to use one thread per MPI process and emits a warning.

Note
Call this function after MPI initialization and before any VTK parallel operation.
This function configures VTK only. It does not configure PETSc, OpenMP, or the BLAS implementation.

◆ for_each()

template<typename Tuple, typename Func>
void vulpes::vutils::for_each ( Tuple && tuple,
Func && func )

Apply func to every element of tuple, in order.

Template Parameters
TupleAny std::tuple-like type.
FuncCallable invocable with each element of tuple.
Parameters
tupleThe tuple to iterate over.
funcThe callable applied to each element.

◆ for_each_idxed()

template<typename Tuple, typename Func>
void vulpes::vutils::for_each_idxed ( Tuple && tuple,
Func && func )

Apply func to every element of tuple together with its index.

Template Parameters
TupleAny std::tuple-like type.
FuncCallable invocable with each element of tuple and its std::size_t index.
Parameters
tupleThe tuple to iterate over.
funcThe callable applied to each (element, index) pair.

◆ for_each_impl()

template<typename Tuple, typename Func, std::size_t... Is>
void vulpes::vutils::for_each_impl ( Tuple && tuple,
Func && func,
std::index_sequence< Is... >  )

◆ for_each_impl_idxed()

template<typename Tuple, typename Func, std::size_t... Is>
void vulpes::vutils::for_each_impl_idxed ( Tuple && tuple,
Func && func,
std::index_sequence< Is... >  )

◆ slice()

template<typename T, typename IndexType>
std::vector< T > vulpes::vutils::slice ( const std::vector< T > & source,
const std::vector< IndexType > & indices )

Build a new vector by selecting elements of source at the given indices.

Template Parameters
TElement type.
IndexTypeIntegral index type.
Parameters
sourceThe vector to select elements from.
indicesIndices into source, in the desired output order.
Returns
A new vector containing source[indices[0]], source[indices[1]], ....