8 #ifndef HIPACE_GPUUTIL_H_
9 #define HIPACE_GPUUTIL_H_
20 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
29 start(-rhs.begin.x - rhs.begin.y * rhs.jstride)
30 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
42 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
49 T*
ptr (
int i,
int j)
const noexcept {
50 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
56 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
58 void index_assert (
int i,
int j,
int k,
int n)
const
60 if (i<begin.x || i>=
end.x || j<begin.y || j>=
end.y || k<begin.z || k>=
end.z
61 || n < 0 || n >= ncomp) {
62 #if AMREX_DEVICE_COMPILE
69 ss <<
" (" <<
i <<
"," <<
j <<
"," << k <<
"," << n
70 <<
") is out of bound ("
74 <<
"0:" << ncomp-1 <<
")";
82 template<
class T>
inline
87 template<
class T>
inline
92 template<
class T>
inline
104 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
114 start(-rhs.begin.x - rhs.begin.y * rhs.jstride)
115 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
127 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
134 T*
ptr (
int i,
int j,
int n)
const noexcept {
135 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
142 #if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
144 void index_assert (
int i,
int j,
int k,
int n)
const
146 if (i<begin.x || i>=
end.x || j<begin.y || j>=
end.y || k<begin.z || k>=
end.z
147 || n < 0 || n >= ncomp) {
148 #if AMREX_DEVICE_COMPILE
154 std::stringstream ss;
155 ss <<
" (" <<
i <<
"," <<
j <<
"," << k <<
"," << n
156 <<
") is out of bound ("
160 <<
"0:" << ncomp-1 <<
")";
168 template<
class T>
inline
173 template<
class T>
inline
178 template<
class T>
inline
187 amrex::Real
abssq(amrex::Real r, amrex::Real
i)
193 void AtomicAdd(amrex::Real* ptr, amrex::Real val, [[maybe_unused]]
bool do_omp_atomic=
true) {
196 #elif defined(AMREX_USE_OMP)
#define AMREX_ALWAYS_ASSERT(EX)
#define AMREX_FORCE_INLINE
#define AMREX_DEVICE_PRINTF(...)
#define AMREX_GPU_HOST_DEVICE
Array3< T > to_array3(amrex::Array4< T > &&in)
Definition: GPUUtil.H:169
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real abssq(amrex::Real r, amrex::Real i)
Definition: GPUUtil.H:187
Array2< T > to_array2(amrex::Array4< T > &&in)
Definition: GPUUtil.H:83
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AtomicAdd(amrex::Real *ptr, amrex::Real val, [[maybe_unused]] bool do_omp_atomic=true)
Definition: GPUUtil.H:193
amrex::MFItInfo DfltMfi
Definition: GPUUtil.H:183
amrex::MFItInfo DfltMfiTlng
Definition: GPUUtil.H:184
int i
Definition: MakeOpenBoundary.py:152
j
Definition: MakeOpenBoundary.py:128
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T Add(T *sum, T value) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 end(Box const &box) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 begin(Box const &box) noexcept
void Abort(const std::string &msg)
T *AMREX_RESTRICT p
Definition: GPUUtil.H:16
amrex::Long start
Definition: GPUUtil.H:18
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & operator()(int i, int j) const noexcept
Definition: GPUUtil.H:41
amrex::Long jstride
Definition: GPUUtil.H:17
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * ptr(int i, int j) const noexcept
Definition: GPUUtil.H:49
Array2(const amrex::Array4< T > &rhs) noexcept
Definition: GPUUtil.H:26
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T & operator()(int i, int j, int n) const noexcept
Definition: GPUUtil.H:126
T *AMREX_RESTRICT p
Definition: GPUUtil.H:99
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T * ptr(int i, int j, int n) const noexcept
Definition: GPUUtil.H:134
amrex::Long jstride
Definition: GPUUtil.H:100
amrex::Long start
Definition: GPUUtil.H:102
amrex::Long nstride
Definition: GPUUtil.H:101
Array3(const amrex::Array4< T > &rhs) noexcept
Definition: GPUUtil.H:110