4#include <AMReX_Config.H>
12# if __cplusplus >= 202002L
13# include <vir/simd_cvt.h>
27 using namespace vir::stdx;
28# if __cplusplus >= 202002L
58 template <
typename T,
typename Abi>
60 vir::stdx::simd<T, Abi>
select (
61 typename vir::stdx::simd<T, Abi>::mask_type
const&
mask,
62 vir::stdx::simd<T, Abi>
const& true_val,
63 vir::stdx::simd<T, Abi>
const& false_val)
65 vir::stdx::simd<T, Abi> result = false_val;
84 bool any_of (
bool const v) {
return v; }
89 struct where_expression {
94 where_expression& operator= (T
const& new_val)
96 if (
mask) { *value = new_val; }
118 template <
typename T>
120 detail::where_expression<T>
where (
bool const mask, T& value)
122 return {
mask, &value};
130 template <
typename T>
132 T
select (
bool const mask, T
const& true_val, T
const& false_val)
134 return mask ? true_val : false_val;
149 template<
int SIMD_WIDTH = native_simd_size_real>
150 using SIMDReal = stdx::fixed_size_simd<amrex::Real, SIMD_WIDTH>;
152 template<
int SIMD_WIDTH = native_simd_size_particlereal>
153 using SIMDParticleReal = stdx::fixed_size_simd<amrex::ParticleReal, SIMD_WIDTH>;
156 template<
typename T_ParticleReal = SIMDParticleReal<>>
157 using SIMDInt = stdx::rebind_simd_t<int, T_ParticleReal>;
160 template<
typename T_ParticleReal = SIMDParticleReal<>>
161 using SIMDIdCpu = stdx::rebind_simd_t<std::uint64_t, T_ParticleReal>;
166 template<
int SIMD_WIDTH = native_simd_size_real>
169 template<
int SIMD_WIDTH = native_simd_size_particlereal>
173 template<
typename T_ParticleReal = SIMDParticleReal<>>
177 template<
typename T_ParticleReal = SIMDParticleReal<>>
183 struct InternalVectorized {};
213 template<
int SIMD_WIDTH = native_simd_size_real>
218 static constexpr int simd_width = SIMD_WIDTH;
226 constexpr bool is_vectorized = std::is_base_of_v<detail::InternalVectorized, T>;
248 template<
typename R,
typename... Args>
251 constexpr bool val_arr[
sizeof...(Args)] {!std::is_const_v<std::remove_reference_t<Args>>...};
255 template<
typename C,
typename R,
typename... Args>
258 constexpr bool val_arr[
sizeof...(Args)] {!std::is_const_v<std::remove_reference_t<Args>>...};
261 template<
typename C,
typename R,
typename... Args>
264 constexpr bool val_arr[
sizeof...(Args)] {!std::is_const_v<std::remove_reference_t<Args>>...};
281 template <
typename T,
typename IndexType>
285 if constexpr (std::is_integral_v<IndexType>) {
287 }
else if constexpr (IndexType::width == 1) {
291 using DataType = stdx::fixed_size_simd<std::decay_t<T>, IndexType::width>;
298 val.copy_from(&ptr[i.index], stdx::element_aligned);
302 static_assert(IndexType::width == 1,
"SIMD width must be 1 for non-SIMD builds");
337 template <
auto P_Method,
int N,
bool ForceWriteback =
false,
338 typename T,
typename IndexType,
typename ValType>
347 if constexpr (!std::is_same_v<ValType, T>) {
354 val.copy_to(&ptr[i.index], amrex::simd::stdx::element_aligned);
356 amrex::Abort(
"store_1d: ValType val must alias T ptr data (to make this a no-OP).");
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_RESTRICT
Definition AMReX_Extension.H:32
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Array4< int const > mask
Definition AMReX_InterpFaceRegister.cpp:93
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
amrex_particle_real ParticleReal
Floating Point Type for Particles.
Definition AMReX_REAL.H:90
__host__ __device__ bool any_of(bool const v)
Definition AMReX_SIMD.H:84
__host__ __device__ detail::where_expression< T > where(bool const mask, T &value)
Definition AMReX_SIMD.H:120
__host__ __device__ T select(bool const mask, T const &true_val, T const &false_val)
Definition AMReX_SIMD.H:132
Definition AMReX_SIMD.H:22
__host__ __device__ void store_1d(ValType const &__restrict__ val, T *const __restrict__ ptr, IndexType const i)
Definition AMReX_SIMD.H:340
std::uint64_t SIMDIdCpu
Definition AMReX_SIMD.H:178
constexpr auto native_simd_size_real
Definition AMReX_SIMD.H:163
int SIMDInt
Definition AMReX_SIMD.H:174
constexpr bool is_vectorized
Definition AMReX_SIMD.H:226
constexpr bool is_nth_arg_non_const(R(*)(Args...), int n)
Definition AMReX_SIMD.H:249
amrex::ParticleReal SIMDParticleReal
Definition AMReX_SIMD.H:170
__host__ __device__ decltype(auto) load_1d(T *ptr, IndexType const i)
Definition AMReX_SIMD.H:283
constexpr auto native_simd_size_particlereal
Definition AMReX_SIMD.H:164
amrex::Real SIMDReal
Definition AMReX_SIMD.H:167
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139
IndexTypeND< 3 > IndexType
IndexType is an alias for amrex::IndexTypeND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:36
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:241
const int[]
Definition AMReX_BLProfiler.cpp:1664
Definition AMReX_SIMD.H:216