diff --git a/Src/Base/AMReX_GpuContainers.H b/Src/Base/AMReX_GpuContainers.H index 3825bbd4de3..fc04651a165 100644 --- a/Src/Base/AMReX_GpuContainers.H +++ b/Src/Base/AMReX_GpuContainers.H @@ -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 } /** @@ -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 } /** @@ -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 } /** @@ -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 } /** @@ -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 } /** @@ -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 } /** diff --git a/Src/Base/AMReX_GpuDevice.H b/Src/Base/AMReX_GpuDevice.H index eb2b95943e7..847e5923c35 100644 --- a/Src/Base/AMReX_GpuDevice.H +++ b/Src/Base/AMReX_GpuDevice.H @@ -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 { @@ -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 diff --git a/Src/FFT/AMReX_FFT_OpenBCSolver.H b/Src/FFT/AMReX_FFT_OpenBCSolver.H index e54aedb0a8e..0cd881ac2bf 100644 --- a/Src/FFT/AMReX_FFT_OpenBCSolver.H +++ b/Src/FFT/AMReX_FFT_OpenBCSolver.H @@ -143,12 +143,7 @@ void OpenBCSolver::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"); } diff --git a/Src/FFT/AMReX_FFT_R2C.H b/Src/FFT/AMReX_FFT_R2C.H index 72560bfc2c7..d4eb5ff7b39 100644 --- a/Src/FFT/AMReX_FFT_R2C.H +++ b/Src/FFT/AMReX_FFT_R2C.H @@ -976,23 +976,15 @@ void R2C::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 } } @@ -1075,23 +1067,15 @@ void R2C::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 } } diff --git a/Src/LinearSolvers/AMReX_AlgVector.H b/Src/LinearSolvers/AMReX_AlgVector.H index f2cb7b45b17..348e3b7d585 100644 --- a/Src/LinearSolvers/AMReX_AlgVector.H +++ b/Src/LinearSolvers/AMReX_AlgVector.H @@ -171,11 +171,7 @@ void AlgVector::copyAsync (AlgVector 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 diff --git a/Src/Particle/AMReX_NeighborList.H b/Src/Particle/AMReX_NeighborList.H index 6233a41002a..a656281e3ce 100644 --- a/Src/Particle/AMReX_NeighborList.H +++ b/Src/Particle/AMReX_NeighborList.H @@ -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); @@ -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(); diff --git a/Src/Particle/AMReX_NeighborParticlesI.H b/Src/Particle/AMReX_NeighborParticlesI.H index aaf3bb54381..a85a9faf7a7 100644 --- a/Src/Particle/AMReX_NeighborParticlesI.H +++ b/Src/Particle/AMReX_NeighborParticlesI.H @@ -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()); diff --git a/Tests/EB_CNS/Exec/Combustor/cns_prob.cpp b/Tests/EB_CNS/Exec/Combustor/cns_prob.cpp index c48fc4fc72c..d0f72ee517f 100644 --- a/Tests/EB_CNS/Exec/Combustor/cns_prob.cpp +++ b/Tests/EB_CNS/Exec/Combustor/cns_prob.cpp @@ -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 inflow_state(CNS::numState());