1 #ifndef AMREX_GPU_ASYNC_ARRAY_H_
2 #define AMREX_GPU_ASYNC_ARRAY_H_
3 #include <AMReX_Config.H>
14 #if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP)
16 #if defined(AMREX_USE_HIP)
18 #elif defined(AMREX_USE_CUDA)
27 template <
typename T, std::enable_if_t<std::is_trivially_copyable_v<T>,
int> = 0>
34 if (n == 0) {
return; }
46 template <
typename U = T, std::enable_if_t<std::is_standard_layout_v<U> && std::is_trivial_v<U>,
int> = 0>
49 if (n == 0) {
return; }
77 #if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP)
78 T** p =
static_cast<T**
>(
std::malloc(2*
sizeof(T*)));
81 #if defined(AMREX_USE_HIP)
84 #elif defined(AMREX_USE_CUDA)
88 #elif defined(AMREX_USE_SYCL)
93 q.submit([&] (sycl::handler& h) {
99 }
catch (sycl::exception
const& ex) {
100 amrex::Abort(std::string(
"host_task: ")+ex.what()+
"!!!!!");
116 if (n == 0) {
return; }
void CUDART_CB amrex_asyncarray_delete(void *p)
Definition: AMReX_GpuAsyncArray.cpp:10
#define AMREX_CUDA_SAFE_CALL(call)
Definition: AMReX_GpuError.H:73
virtual void free(void *pt)=0
A pure virtual function for deleting the arena pointed to by pt.
virtual void * alloc(std::size_t sz)=0
Definition: AMReX_GpuAsyncArray.H:29
AsyncArray(T const *h_p, const std::size_t n)
Definition: AMReX_GpuAsyncArray.H:32
T * h_data
Definition: AMReX_GpuAsyncArray.H:132
void clear()
Definition: AMReX_GpuAsyncArray.H:71
AsyncArray(AsyncArray &&)=delete
T const * data() const noexcept
Definition: AMReX_GpuAsyncArray.H:69
void copyToHost(T *h_p, std::size_t n) const
Definition: AMReX_GpuAsyncArray.H:114
T * d_data
Definition: AMReX_GpuAsyncArray.H:131
void operator=(AsyncArray const &)=delete
~AsyncArray()
Definition: AMReX_GpuAsyncArray.H:62
AsyncArray(AsyncArray const &)=delete
T * data() noexcept
Definition: AMReX_GpuAsyncArray.H:70
AsyncArray(const std::size_t n)
Definition: AMReX_GpuAsyncArray.H:47
bool inLaunchRegion() noexcept
Definition: AMReX_GpuControl.H:86
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void * memcpy(void *dest, const void *src, std::size_t count)
Definition: AMReX_GpuUtility.H:214
void dtoh_memcpy(void *p_h, const void *p_d, const std::size_t sz) noexcept
Definition: AMReX_GpuDevice.H:301
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition: AMReX_GpuDevice.H:251
gpuStream_t gpuStream() noexcept
Definition: AMReX_GpuDevice.H:218
Definition: AMReX_Amr.cpp:49
Arena * The_Pinned_Arena()
Definition: AMReX_Arena.cpp:649
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:225
Arena * The_Arena()
Definition: AMReX_Arena.cpp:609