TDLS 0.4.0
Tiny Device-callable Linear Solvers
Loading...
Searching...
No Matches
options.hpp File Reference

Shared vocabulary and conventions of the solver families. More...

#include <type_traits>
#include <tdls/core/macros.hpp>
#include <tdls/core/target.hpp>
Include dependency graph for options.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum class  tdls::Schedule { RightLooking , LeftLooking }
 Elimination schedule of a factorization. More...
 
enum class  tdls::RowInterchange { Logical , Physical , Auto }
 Row interchanges of a factorization with partial pivoting. More...
 
enum class  tdls::MatrixLayout { RowMajor , ColMajor }
 Memory layout of a dense matrix. More...
 

Functions

template<typename T , bool gpu>
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_fit_on (const int n) noexcept
 Whether a matrix of n unknowns is small enough for the physical row interchanges on the given hardware (RowInterchange::Auto). On GPU, the matrix must fit in the registers of a thread, n^2 values of T within about 200 registers of 32 bits: n <= 14 in float, 10 in double and long double (which GPUs compute as double). On CPU, measured on 6 cores (the blocks of ArrowheadLUpp): n <= 8 in float (the tiled solver vectorizes better beyond), 12 in double and long double.
 
template<typename T >
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_fit (const int n) noexcept
 physical_rows_fit_on for the hardware of this compilation pass (TDLS_TARGET_GPU).
 
template<typename T , bool gpu>
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_on (const RowInterchange r, const int n) noexcept
 Whether a factorization of n unknowns interchanges its rows physically on the given hardware, RowInterchange::Auto resolved.
 
template<typename T >
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows (const RowInterchange r, const int n) noexcept
 physical_rows_on for the hardware of this compilation pass (TDLS_TARGET_GPU).
 
template<typename T >
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_here (const RowInterchange r, const int n) noexcept
 Whether a factorization of n unknowns interchanges its rows physically, decided at run time on the side of the code: as physical_rows, except in a single-pass nvc++ compilation, where host code takes the CPU rule and device code the GPU rule.
 
template<int s>
TDLS_HOST_DEVICE TDLS_FORCE_INLINE_ALL constexpr int tdls::detail::stride_or (const int runtime) noexcept
 The stride an entry point uses: the compile-time stride when it is known, the runtime one otherwise (see dynamic_stride).
 

Variables

constexpr int tdls::dynamic_stride = -1
 The compile-time stride of an operand whose stride is known at run time only: the default of the stride template parameters of the compile-time solvers.
 
template<int... s>
constexpr bool tdls::detail::any_static_stride = ((s != dynamic_stride) || ...)
 Whether one of the strides of an entry point is known at compile time: the entry point then runs its runtime-stride instantiation with the constants.
 

Detailed Description

Shared vocabulary and conventions of the solver families.

Author
Tristan Chenaille

Knob types shared by the configuration of every solver family: the elimination schedule of a factorization, the row interchanges of its partial pivoting and the memory layout of a dense matrix. Each family configuration carries its own members of these types.

The families also share one calling convention. Every operand is a raw pointer pre-offset by the caller plus one runtime element stride, which covers the AoS, SoA and AoSoA batch layouts alike. The entry points of the compile-time solvers also take each stride as a template argument, dynamic_stride by default: a stride known at compile time is given there (see dynamic_stride). The flat element index of an object (N*N for a matrix) must stay below 2^31; element offsets, index times stride, are computed in 64-bit arithmetic (TDLS_STRIDED). Residency template booleans, where a solver offers them, describe what the passed buffers are and carry no default. Factorizing entry points come in counting and diagnostics-free overloads, the latter compiling the diagnostics out entirely.

Enumeration Type Documentation

◆ MatrixLayout

enum class tdls::MatrixLayout
strong

Memory layout of a dense matrix.

Enumerator
RowMajor 

Element (r, c) at flat index r * N + c, the TFEL convention.

ColMajor 

Element (r, c) at flat index c * N + r.

◆ RowInterchange

enum class tdls::RowInterchange
strong

Row interchanges of a factorization with partial pivoting.

Enumerator
Logical 

Rows never move: the position of each row in the pivoted order is tracked.

Physical 

Rows are exchanged, as in LAPACK: the row at each position is stored there.

Auto 

Physical when the matrix is small enough to stay in registers, Logical otherwise, for the target of the code (detail::physical_rows_fit): the default of the blocks of ArrowheadLUpp (ArrowheadLUppConfig::block_row_interchange), factored and used within one solve. TiledLUpp and CooperativeLUpp reject it.

◆ Schedule

enum class tdls::Schedule
strong

Elimination schedule of a factorization.

Enumerator
RightLooking 

Factor the diagonal block, push updates into the trailing matrix.

LeftLooking 

Pull updates from prior blocks when a block is visited.

Function Documentation

◆ physical_rows()

template<typename T >
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows ( const RowInterchange r,
const int n )
nodiscardconstexprnoexcept

physical_rows_on for the hardware of this compilation pass (TDLS_TARGET_GPU).

Template Parameters
Tscalar type
Parameters
[in]rthe row interchanges of the configuration
[in]nunknowns
Returns
true for physical row interchanges

◆ physical_rows_fit()

template<typename T >
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_fit ( const int n)
nodiscardconstexprnoexcept

physical_rows_fit_on for the hardware of this compilation pass (TDLS_TARGET_GPU).

Template Parameters
Tscalar type
Parameters
[in]nunknowns
Returns
true when Auto takes the physical row interchanges

◆ physical_rows_fit_on()

template<typename T , bool gpu>
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_fit_on ( const int n)
nodiscardconstexprnoexcept

Whether a matrix of n unknowns is small enough for the physical row interchanges on the given hardware (RowInterchange::Auto). On GPU, the matrix must fit in the registers of a thread, n^2 values of T within about 200 registers of 32 bits: n <= 14 in float, 10 in double and long double (which GPUs compute as double). On CPU, measured on 6 cores (the blocks of ArrowheadLUpp): n <= 8 in float (the tiled solver vectorizes better beyond), 12 in double and long double.

Template Parameters
Tscalar type
gputhe hardware: GPU (true) or CPU (false)
Parameters
[in]nunknowns
Returns
true when Auto takes the physical row interchanges

◆ physical_rows_here()

template<typename T >
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_here ( const RowInterchange r,
const int n )
nodiscardconstexprnoexcept

Whether a factorization of n unknowns interchanges its rows physically, decided at run time on the side of the code: as physical_rows, except in a single-pass nvc++ compilation, where host code takes the CPU rule and device code the GPU rule.

Template Parameters
Tscalar type
Parameters
[in]rthe row interchanges of the configuration
[in]nunknowns
Returns
true for physical row interchanges

◆ physical_rows_on()

template<typename T , bool gpu>
TDLS_HOST_DEVICE constexpr bool tdls::detail::physical_rows_on ( const RowInterchange r,
const int n )
nodiscardconstexprnoexcept

Whether a factorization of n unknowns interchanges its rows physically on the given hardware, RowInterchange::Auto resolved.

Template Parameters
Tscalar type
gputhe hardware: GPU (true) or CPU (false)
Parameters
[in]rthe row interchanges of the configuration
[in]nunknowns
Returns
true for physical row interchanges

◆ stride_or()

template<int s>
TDLS_HOST_DEVICE TDLS_FORCE_INLINE_ALL constexpr int tdls::detail::stride_or ( const int runtime)
nodiscardconstexprnoexcept

The stride an entry point uses: the compile-time stride when it is known, the runtime one otherwise (see dynamic_stride).

Template Parameters
scompile-time stride: dynamic_stride or positive
Parameters
[in]runtimethe stride given as a function argument
Returns
s, or runtime when s is dynamic_stride

Variable Documentation

◆ any_static_stride

template<int... s>
bool tdls::detail::any_static_stride = ((s != dynamic_stride) || ...)
inlineconstexpr

Whether one of the strides of an entry point is known at compile time: the entry point then runs its runtime-stride instantiation with the constants.

Template Parameters
sthe compile-time strides

◆ dynamic_stride

int tdls::dynamic_stride = -1
inlineconstexpr

The compile-time stride of an operand whose stride is known at run time only: the default of the stride template parameters of the compile-time solvers.

Every entry point of TiledLUppSolverStatic, CooperativeLUppSolverStatic and ArrowheadLUppSolverStatic takes the element stride of each strided operand twice: an int function argument, X_stride, and an int template parameter, X_static_stride, dynamic_stride by default. These template parameters come after the others, but for the deduced types of the callables, in the order of the function arguments. With dynamic_stride, the solver reads the function argument. With a positive value, 1 in AoS or 32 in AoSoA by blocks of 32 interleaved systems for instance, the solver uses that value and ignores the function argument: it runs as if the caller had passed the constant, which the compilers fold wherever they inline the solver, everywhere on GPU, and the out-of-line parts of ArrowheadLUpp (the second pass, streamed_out_of_line) receive it as a template argument. A stride known only at run time, the number of systems in SoA, stays a function argument. Under internal residency the stride of the operand is ignored either way.