Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::simd Namespace Reference

Namespaces

namespace  stdx
 

Classes

struct  Vectorized
 

Typedefs

template<int SIMD_WIDTH = native_simd_size_real>
using SIMDReal = amrex::Real
 
template<int SIMD_WIDTH = native_simd_size_particlereal>
using SIMDParticleReal = amrex::ParticleReal
 
template<typename T_ParticleReal = SIMDParticleReal<>>
using SIMDInt = int
 
template<typename T_ParticleReal = SIMDParticleReal<>>
using SIMDIdCpu = std::uint64_t
 

Functions

template<typename R , typename... Args>
constexpr bool is_nth_arg_non_const (R(*)(Args...), int n)
 
template<typename C , typename R , typename... Args>
constexpr bool is_nth_arg_non_const (R(C::*)(Args...), int n)
 
template<typename T , typename IndexType >
__host__ __device__ decltype(auto) load_1d (T *ptr, IndexType const i)
 
template<auto P_Method, int N, typename T , typename IndexType , typename ValType >
__host__ __device__ void store_1d (ValType const &__restrict__ val, T *const __restrict__ ptr, IndexType const i)
 

Variables

constexpr auto native_simd_size_real = 1
 
constexpr auto native_simd_size_particlereal = 1
 
template<typename T >
constexpr bool is_vectorized = std::is_base_of_v<detail::InternalVectorized, T>
 

Typedef Documentation

◆ SIMDIdCpu

template<typename T_ParticleReal = SIMDParticleReal<>>
using amrex::simd::SIMDIdCpu = typedef std::uint64_t

◆ SIMDInt

template<typename T_ParticleReal = SIMDParticleReal<>>
using amrex::simd::SIMDInt = typedef int

◆ SIMDParticleReal

template<int SIMD_WIDTH = native_simd_size_particlereal>
using amrex::simd::SIMDParticleReal = typedef amrex::ParticleReal

◆ SIMDReal

template<int SIMD_WIDTH = native_simd_size_real>
using amrex::simd::SIMDReal = typedef amrex::Real

Function Documentation

◆ is_nth_arg_non_const() [1/2]

template<typename R , typename... Args>
constexpr bool amrex::simd::is_nth_arg_non_const ( R(*)(Args...)  ,
int  n 
)
constexpr

Check if a function argument is declared as non-const

Use in conjunction with conditional write-back logic from vector registers, e.g.,

template<typename T_Real>
void compute (T_Real & AMREX_RESTRICT x,
T_Real const & AMREX_RESTRICT y) { ... }
part_x.copy_from(&m_part_x[i], stdx::element_aligned);
part_y.copy_from(&m_part_y[i], stdx::element_aligned);
compute(part_x, part_y);
if constexpr (is_nth_arg_non_const(compute<double>, 0))
part_x.copy_to(&m_part_x[i], stdx::element_aligned);
if constexpr (is_nth_arg_non_const(compute<double>, 1))
part_y.copy_to(&m_part_y[i], stdx::element_aligned);
#define AMREX_RESTRICT
Definition AMReX_Extension.H:32
constexpr bool is_nth_arg_non_const(R(*)(Args...), int n)
Definition AMReX_SIMD.H:149

◆ is_nth_arg_non_const() [2/2]

template<typename C , typename R , typename... Args>
constexpr bool amrex::simd::is_nth_arg_non_const ( R(C::*)(Args...)  ,
int  n 
)
constexpr

◆ load_1d()

template<typename T , typename IndexType >
__host__ __device__ decltype(auto) amrex::simd::load_1d ( T *  ptr,
IndexType const  i 
)
inline

Load 1D contiguous data from array pointers

On GPU and CPU w/o SIMD, this dereferences a 1D array element at the index position i. On CPU with SIMD, this loads a SIMD register at the IndexType::width SIMD-wide index position i.

Template Parameters
Tdata type (amrex::ParticleReal or int or uint64_t)
IndexTypeint or amrex::SIMDindex<SIMD_WIDTH, int>
Parameters
ptrpointer to the array data
iindex or SIMD index
Returns
a reference to the (scalar) data OR a new SIMD variable (register) loaded with data

◆ store_1d()

template<auto P_Method, int N, typename T , typename IndexType , typename ValType >
__host__ __device__ void amrex::simd::store_1d ( ValType const &__restrict__  val,
T *const __restrict__  ptr,
IndexType const  i 
)
inline

Store SIMD register data back to a 1D contiguous array in RAM

On GPU and CPU without SIMD, this does nothing because we already modified the (global) RAM directly via pointer.

On CPU with SIMD, this performs a conditional writeback of a SIMD register to RAM (index in pointer array), but only if the argument was not passed as const and thus was likely changed.

Good optimizing compilers can eliminate writebacks of unchanged values themselves, but we better help a little for robustness. Background: https://github.com/AMReX-Codes/amrex/pull/4520#issuecomment-3064064215

Template Parameters
P_Methodpointer to the method that used the data (for is_nth_arg_non_const)
Nthe argument index (for is_nth_arg_non_const)
Tdata type
IndexTypeint or SIMD index
ValTypethe type of the value to store
Parameters
valthe value to store
ptrpointer to contiguous 1D array data
iindex or SIMD index

Variable Documentation

◆ is_vectorized

template<typename T >
constexpr bool amrex::simd::is_vectorized = std::is_base_of_v<detail::InternalVectorized, T>
constexpr

Check if a Functor Class works with amrex::ParallelForSIMD

See also
amrex::simd::Vectorized

◆ native_simd_size_particlereal

constexpr auto amrex::simd::native_simd_size_particlereal = 1
constexpr

◆ native_simd_size_real

constexpr auto amrex::simd::native_simd_size_real = 1
constexpr