1#ifndef AMREX_GPU_RANGE_H_
2#define AMREX_GPU_RANGE_H_
3#include <AMReX_Config.H>
13template <
typename T, std::enable_if_t<std::is_
integral_v<T>,
int> = 0>
14bool isEmpty (T n)
noexcept {
return n <= 0; }
22namespace range_detail {
25template <
typename T, std::enable_if_t<std::is_
integral_v<T>,
int> = 0>
27Long size (T
const& b)
noexcept {
return static_cast<Long
>(b); }
29template <
typename T, std::enable_if_t<std::is_
integral_v<T>,
int> = 0>
40 amrex::ignore_unused(b);
50 auto iv = b.atOffset(
offset);
51 return BoxND<dim>(iv,iv,b.ixType());
63 explicit range_impl (T
const& b) noexcept : m_b(b), m_n(range_detail::size(b)) {}
66 range_impl (T
const& b, Long gid, Long grange) noexcept
67 : m_b(b), m_n(range_detail::size(b)), m_gid(gid), m_grange(grange) {}
73 iterator (T
const& b, Long i, Long s) noexcept : mi_b(&b), mi_i(i), mi_s(s) {}
76 void operator++ () noexcept { mi_i += mi_s; }
79 bool operator!= (iterator
const& rhs)
const noexcept {
return mi_i < rhs.mi_i; }
82 T operator* () const noexcept {
return range_detail::at(*mi_b,mi_i); }
91 iterator
begin () const noexcept {
92#if defined (__SYCL_DEVICE_ONLY__)
93 return iterator(m_b, m_gid, m_grange);
96 return iterator(m_b, blockDim.x*blockIdx.x+threadIdx.x, blockDim.x*gridDim.x);
99 return iterator(m_b,0,1);
105 iterator
end () const noexcept {
return iterator(m_b,m_n,0); }
120range_detail::range_impl<T>
Range (T
const& b, Long gid, Long grange)
noexcept {
121 return range_detail::range_impl<T>(b,gid,grange);
127range_detail::range_impl<T>
Range (T
const& b)
noexcept {
return range_detail::range_impl<T>(b); }
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_IF_ON_DEVICE(CODE)
Definition AMReX_GpuQualifiers.H:56
#define AMREX_IF_ON_HOST(CODE)
Definition AMReX_GpuQualifiers.H:58
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1089
A Rectangular Domain on an Integer Lattice.
Definition AMReX_Box.H:49
amrex_long Long
Definition AMReX_INT.H:30
__host__ __device__ range_detail::range_impl< T > Range(T const &b) noexcept
Definition AMReX_GpuRange.H:127
Definition AMReX_Amr.cpp:49
__host__ __device__ Dim3 begin(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:2006
bool isEmpty(T n) noexcept
Definition AMReX_GpuRange.H:14
__host__ __device__ Dim3 end(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:2015