Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions Src/Base/AMReX_GpuContainers.H
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ namespace amrex::Gpu {

auto size = std::distance(begin, end);
if (size == 0) { return; }
#ifdef AMREX_USE_GPU
htod_memcpy(&(*result), &(*begin), size*sizeof(value_type));
#else
std::memcpy(&(*result), &(*begin), size*sizeof(value_type));
#endif
}

/**
Expand Down Expand Up @@ -166,11 +162,7 @@ namespace amrex::Gpu {

auto size = std::distance(begin, end);
if (size == 0) { return; }
#ifdef AMREX_USE_GPU
dtoh_memcpy(&(*result), &(*begin), size*sizeof(value_type));
#else
std::memcpy(&(*result), &(*begin), size*sizeof(value_type));
#endif
}

/**
Expand Down Expand Up @@ -203,11 +195,7 @@ namespace amrex::Gpu {

auto size = std::distance(begin, end);
if (size == 0) { return; }
#ifdef AMREX_USE_GPU
dtod_memcpy(&(*result), &(*begin), size*sizeof(value_type));
#else
std::memcpy(&(*result), &(*begin), size*sizeof(value_type));
#endif
}

/**
Expand Down Expand Up @@ -241,11 +229,7 @@ namespace amrex::Gpu {

auto size = std::distance(begin, end);
if (size == 0) { return; }
#ifdef AMREX_USE_GPU
htod_memcpy_async(&(*result), &(*begin), size*sizeof(value_type));
#else
std::memcpy(&(*result), &(*begin), size*sizeof(value_type));
#endif
}

/**
Expand Down Expand Up @@ -279,11 +263,7 @@ namespace amrex::Gpu {

auto size = std::distance(begin, end);
if (size == 0) { return; }
#ifdef AMREX_USE_GPU
dtoh_memcpy_async(&(*result), &(*begin), size*sizeof(value_type));
#else
std::memcpy(&(*result), &(*begin), size*sizeof(value_type));
#endif
}

/**
Expand Down Expand Up @@ -317,11 +297,7 @@ namespace amrex::Gpu {

auto size = std::distance(begin, end);
if (size == 0) { return; }
#ifdef AMREX_USE_GPU
dtod_memcpy_async(&(*result), &(*begin), size*sizeof(value_type));
#else
std::memcpy(&(*result), &(*begin), size*sizeof(value_type));
#endif
}

/**
Expand Down
27 changes: 25 additions & 2 deletions Src/Base/AMReX_GpuDevice.H
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,31 @@ dtod_memcpy_async (void* p_d_dst, const void* p_d_src, const std::size_t sz) noe
#endif
}

#else // AMREX_USE_GPU

inline void
htod_memcpy_async (void* p_d, const void* p_h, const std::size_t sz) noexcept
{
if (sz == 0) { return; }
std::memcpy(p_d, p_h, sz);
}

inline void
dtoh_memcpy_async (void* p_h, const void* p_d, const std::size_t sz) noexcept
{
if (sz == 0) { return; }
std::memcpy(p_h, p_d, sz);
}

inline void
dtod_memcpy_async (void* p_d_dst, const void* p_d_src, const std::size_t sz) noexcept
{
if (sz == 0) { return; }
std::memcpy(p_d_dst, p_d_src, sz);
}

#endif // AMREX_USE_GPU

inline void
htod_memcpy (void* p_d, const void* p_h, const std::size_t sz) noexcept
{
Expand All @@ -313,8 +338,6 @@ dtod_memcpy (void* p_d_dst, const void* p_d_src, const std::size_t sz) noexcept
Gpu::streamSynchronize();
}

#endif

#ifdef AMREX_USE_HYPRE
void hypreSynchronize ();
#endif
Expand Down
7 changes: 1 addition & 6 deletions Src/FFT/AMReX_FFT_OpenBCSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,7 @@ void OpenBCSolver<T>::setGreensFunction (F const& greens_function)
if (srcfab) {
auto* dstfab = detail::get_fab(m_G_fft);
if (dstfab) {
#if defined(AMREX_USE_GPU)
Gpu::dtod_memcpy_async
#else
std::memcpy
#endif
(dstfab->dataPtr(), srcfab->dataPtr(), dstfab->nBytes());
Gpu::dtod_memcpy_async(dstfab->dataPtr(), srcfab->dataPtr(), dstfab->nBytes());
} else {
amrex::Abort("FFT::OpenBCSolver: how did this happen");
}
Expand Down
16 changes: 0 additions & 16 deletions Src/FFT/AMReX_FFT_R2C.H
Original file line number Diff line number Diff line change
Expand Up @@ -976,23 +976,15 @@ void R2C<T,D,C>::forward (RT const* in, CT* out)
auto [cdata, csz] = install_raw_ptr(m_raw_cmf, out);

if (rsz > 0) {
#ifdef AMREX_USE_GPU
Gpu::dtod_memcpy_async(rdata.get(),in,rsz);
Gpu::streamSynchronize();
#else
std::memcpy(rdata.get(),in,rsz);
#endif
}

forward(m_raw_mf, m_raw_cmf);

if (csz) {
#ifdef AMREX_USE_GPU
Gpu::dtod_memcpy_async(out,cdata.get(),csz);
Gpu::streamSynchronize();
#else
std::memcpy(out,cdata.get(),csz);
#endif
}
}

Expand Down Expand Up @@ -1075,23 +1067,15 @@ void R2C<T,D,C>::backward (CT const* in, RT* out)
auto [cdata, csz] = install_raw_ptr(m_raw_cmf, in);

if (csz) {
#ifdef AMREX_USE_GPU
Gpu::dtod_memcpy_async(cdata.get(),in,csz);
Gpu::streamSynchronize();
#else
std::memcpy(cdata.get(),in,csz);
#endif
}

backward(m_raw_cmf, m_raw_mf);

if (rsz > 0) {
#ifdef AMREX_USE_GPU
Gpu::dtod_memcpy_async(out,rdata.get(),rsz);
Gpu::streamSynchronize();
#else
std::memcpy(out,rdata.get(),rsz);
#endif
}
}

Expand Down
4 changes: 0 additions & 4 deletions Src/LinearSolvers/AMReX_AlgVector.H
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ void AlgVector<T,Allocator>::copyAsync (AlgVector<T> const& rhs)
AMREX_ASSERT(m_data.size() == rhs.m_data.size());
T* dst = m_data.data();
T const* src = rhs.data();
#ifdef AMREX_USE_GPU
Gpu::dtod_memcpy_async(dst, src, n*sizeof(T));
#else
std::memcpy(dst, src, n*sizeof(T));
#endif
}

template <typename T, typename Allocator>
Expand Down
8 changes: 0 additions & 8 deletions Src/Particle/AMReX_NeighborList.H
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,7 @@ public:

// Get tot bin count on host
int tot_bins;
#ifdef AMREX_USE_GPU
Gpu::dtoh_memcpy( &tot_bins, off_bins_p + num_bin_types, sizeof(int) );
#else
std::memcpy( &tot_bins, off_bins_p + num_bin_types, sizeof(int) );
#endif

m_bins.build(np_total, pstruct_ptr, tot_bins, bm);

Expand Down Expand Up @@ -397,11 +393,7 @@ public:

// Now we can allocate and build our neighbor list
unsigned int total_nbors;
#ifdef AMREX_USE_GPU
Gpu::dtoh_memcpy(&total_nbors,m_nbor_offsets.dataPtr()+np_size,sizeof(unsigned int));
#else
std::memcpy(&total_nbors,m_nbor_offsets.dataPtr()+np_size,sizeof(unsigned int));
#endif

m_nbor_list.resize(total_nbors);
auto* pm_nbor_list = m_nbor_list.dataPtr();
Expand Down
8 changes: 0 additions & 8 deletions Src/Particle/AMReX_NeighborParticlesI.H
Original file line number Diff line number Diff line change
Expand Up @@ -936,19 +936,11 @@ buildNeighborList (CheckPair const& check_pair, int type_ind, int* ref_ratio,
auto dxInv = lgeom.InvCellSizeArray();
auto ploa = lgeom.ProbLoArray();

#ifdef AMREX_USE_GPU
Gpu::htod_memcpy_async( dxi_v.data() + type, dxInv.data(), sizeof(dxInv) );
Gpu::htod_memcpy_async( plo_v.data() + type, ploa.data() , sizeof(ploa) );
Gpu::htod_memcpy_async( lo_v.data() + type, &lo , sizeof(lo) );
Gpu::htod_memcpy_async( hi_v.data() + type, &hi , sizeof(hi) );
Gpu::htod_memcpy_async( nbins_v.data() + type, &nbins , sizeof(nbins) );
#else
std::memcpy( dxi_v.data() + type, dxInv.data(), sizeof(dxInv) );
std::memcpy( plo_v.data() + type, ploa.data() , sizeof(ploa) );
std::memcpy( lo_v.data() + type, &lo , sizeof(lo) );
std::memcpy( hi_v.data() + type, &hi , sizeof(hi) );
std::memcpy( nbins_v.data() + type, &nbins , sizeof(nbins) );
#endif
}

Gpu::exclusive_scan(nbins_v.begin(), nbins_v.end(), off_bins_v.begin());
Expand Down
4 changes: 0 additions & 4 deletions Tests/EB_CNS/Exec/Combustor/cns_prob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ extern "C" {
pp.query("interior_T" , CNS::h_prob_parm->interior_T);
pp.query("interior_P" , CNS::h_prob_parm->interior_p);

#ifdef AMREX_USE_GPU
// Cannot use Gpu::copy because ProbParm is not trivailly copyable.
Gpu::htod_memcpy_async(CNS::d_prob_parm, CNS::h_prob_parm, sizeof(ProbParm));
#else
std::memcpy(CNS::d_prob_parm, CNS::h_prob_parm, sizeof(ProbParm));
#endif

Gpu::HostVector<Real> inflow_state(CNS::numState());

Expand Down
Loading