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;
150 template <
typename T>
158 template <
typename T,
typename BinaryOperation>
160 T
reduce (T
const& v, BinaryOperation
const&) {
return v; }
166 template <
typename T>
168 T
hmin (T
const& v) {
return v; }
174 template <
typename T>
176 T
hmax (T
const& v) {
return v; }
182 template <
typename T>
184 T
min (T
const& a, T
const& b) {
return (b < a) ? b : a; }
190 template <
typename T>
192 T
max (T
const& a, T
const& b) {
return (a < b) ? b : a; }
206 template<
int SIMD_WIDTH = native_simd_size_real>
207 using SIMDReal = stdx::fixed_size_simd<amrex::Real, SIMD_WIDTH>;
209 template<
int SIMD_WIDTH = native_simd_size_particlereal>
210 using SIMDParticleReal = stdx::fixed_size_simd<amrex::ParticleReal, SIMD_WIDTH>;
213 template<
typename T_ParticleReal = SIMDParticleReal<>>
214 using SIMDInt = stdx::rebind_simd_t<int, T_ParticleReal>;
217 template<
typename T_ParticleReal = SIMDParticleReal<>>
218 using SIMDIdCpu = stdx::rebind_simd_t<std::uint64_t, T_ParticleReal>;
223 template<
int SIMD_WIDTH = native_simd_size_real>
226 template<
int SIMD_WIDTH = native_simd_size_particlereal>
230 template<
typename T_ParticleReal = SIMDParticleReal<>>
234 template<
typename T_ParticleReal = SIMDParticleReal<>>
240 struct InternalVectorized {};
270 template<
int SIMD_WIDTH = native_simd_size_real>
275 static constexpr int simd_width = SIMD_WIDTH;
283 constexpr bool is_vectorized = std::is_base_of_v<detail::InternalVectorized, T>;
305 template<
typename R,
typename... Args>
308 constexpr bool val_arr[
sizeof...(Args)] {!std::is_const_v<std::remove_reference_t<Args>>...};
312 template<
typename C,
typename R,
typename... Args>
315 constexpr bool val_arr[
sizeof...(Args)] {!std::is_const_v<std::remove_reference_t<Args>>...};
318 template<
typename C,
typename R,
typename... Args>
321 constexpr bool val_arr[
sizeof...(Args)] {!std::is_const_v<std::remove_reference_t<Args>>...};
338 template <
typename T,
typename IndexType>
342 if constexpr (std::is_integral_v<IndexType>) {
344 }
else if constexpr (IndexType::width == 1) {
348 using DataType = stdx::fixed_size_simd<std::decay_t<T>, IndexType::width>;
355 val.copy_from(&ptr[i.index], stdx::element_aligned);
359 static_assert(IndexType::width == 1,
"SIMD width must be 1 for non-SIMD builds");
394 template <
auto P_Method,
int N,
bool ForceWriteback =
false,
395 typename T,
typename IndexType,
typename ValType>
404 if constexpr (!std::is_same_v<ValType, T>) {
411 val.copy_to(&ptr[i.index], amrex::simd::stdx::element_aligned);
413 amrex::Abort(
"store_1d: ValType val must alias T ptr data (to make this a no-OP).");
Runtime initialization/finalization helpers and global diagnostics.
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_RESTRICT
Definition AMReX_Extension.H:37
#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__ T max(T const &a, T const &b)
Definition AMReX_SIMD.H:192
__host__ __device__ T hmin(T const &v)
Definition AMReX_SIMD.H:168
__host__ __device__ T min(T const &a, T const &b)
Definition AMReX_SIMD.H:184
__host__ __device__ bool any_of(bool const v)
Definition AMReX_SIMD.H:84
__host__ __device__ T hmax(T const &v)
Definition AMReX_SIMD.H:176
__host__ __device__ detail::where_expression< T > where(bool const mask, T &value)
Definition AMReX_SIMD.H:120
__host__ __device__ T reduce(T const &v)
Definition AMReX_SIMD.H:152
__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:397
std::uint64_t SIMDIdCpu
Definition AMReX_SIMD.H:235
constexpr auto native_simd_size_real
Definition AMReX_SIMD.H:220
int SIMDInt
Definition AMReX_SIMD.H:231
constexpr bool is_vectorized
Definition AMReX_SIMD.H:283
constexpr bool is_nth_arg_non_const(R(*)(Args...), int n)
Definition AMReX_SIMD.H:306
amrex::ParticleReal SIMDParticleReal
Definition AMReX_SIMD.H:227
__host__ __device__ decltype(auto) load_1d(T *ptr, IndexType const i)
Definition AMReX_SIMD.H:340
constexpr auto native_simd_size_particlereal
Definition AMReX_SIMD.H:221
amrex::Real SIMDReal
Definition AMReX_SIMD.H:224
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:259
IndexTypeND< 3 > IndexType
IndexType is an alias for amrex::IndexTypeND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:41
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:241
const int[]
Definition AMReX_BLProfiler.cpp:1664
Definition AMReX_SIMD.H:273