Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gpu version of computing cloud cover #1671

Merged
merged 1 commit into from
Jul 9, 2024
Merged
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
3 changes: 2 additions & 1 deletion Source/ERF.H
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public:
void sample_points (int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab& mf);
void sample_lines (int lev, amrex::Real time, amrex::IntVect cell, amrex::MultiFab& mf);

void derive_diag_profiles (amrex::Gpu::HostVector<amrex::Real>& h_avg_u , amrex::Gpu::HostVector<amrex::Real>& h_avg_v ,
void derive_diag_profiles (amrex::Real time,
amrex::Gpu::HostVector<amrex::Real>& h_avg_u , amrex::Gpu::HostVector<amrex::Real>& h_avg_v ,
amrex::Gpu::HostVector<amrex::Real>& h_avg_w , amrex::Gpu::HostVector<amrex::Real>& h_avg_rho,
amrex::Gpu::HostVector<amrex::Real>& h_avg_th , amrex::Gpu::HostVector<amrex::Real>& h_avg_ksgs,
amrex::Gpu::HostVector<amrex::Real>& h_avg_kturb,
Expand Down
30 changes: 17 additions & 13 deletions Source/IO/ERF_Write1DProfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ ERF::write_1D_profiles (Real time)
Gpu::HostVector<Real> h_avg_sgshfx, h_avg_sgsdiss; // only output tau_{theta,w} and epsilon for now

if (NumDataLogs() > 1) {
derive_diag_profiles(h_avg_u, h_avg_v, h_avg_w,
derive_diag_profiles(time,
h_avg_u, h_avg_v, h_avg_w,
h_avg_rho, h_avg_th, h_avg_ksgs, h_avg_kturb,
h_avg_qv, h_avg_qc, h_avg_qr, h_avg_wqv, h_avg_wqc, h_avg_wqr, h_avg_qi, h_avg_qs, h_avg_qg,
h_avg_uu, h_avg_uv, h_avg_uw, h_avg_vv, h_avg_vw, h_avg_ww,
Expand Down Expand Up @@ -179,18 +180,21 @@ ERF::write_1D_profiles (Real time)
* @param h_avg_pw Profile for pressure perturbation * z-velocity on Host
*/

void ERF::derive_diag_profiles(Gpu::HostVector<Real>& h_avg_u , Gpu::HostVector<Real>& h_avg_v , Gpu::HostVector<Real>& h_avg_w,
Gpu::HostVector<Real>& h_avg_rho , Gpu::HostVector<Real>& h_avg_th , Gpu::HostVector<Real>& h_avg_ksgs,
Gpu::HostVector<Real>& h_avg_kturb, Gpu::HostVector<Real>& h_avg_qv , Gpu::HostVector<Real>& h_avg_qc , Gpu::HostVector<Real>& h_avg_qr,
Gpu::HostVector<Real>& h_avg_wqv , Gpu::HostVector<Real>& h_avg_wqc, Gpu::HostVector<Real>& h_avg_wqr,
Gpu::HostVector<Real>& h_avg_qi , Gpu::HostVector<Real>& h_avg_qs , Gpu::HostVector<Real>& h_avg_qg,
Gpu::HostVector<Real>& h_avg_uu , Gpu::HostVector<Real>& h_avg_uv , Gpu::HostVector<Real>& h_avg_uw,
Gpu::HostVector<Real>& h_avg_vv , Gpu::HostVector<Real>& h_avg_vw , Gpu::HostVector<Real>& h_avg_ww,
Gpu::HostVector<Real>& h_avg_uth , Gpu::HostVector<Real>& h_avg_vth, Gpu::HostVector<Real>& h_avg_wth,
Gpu::HostVector<Real>& h_avg_thth,
Gpu::HostVector<Real>& h_avg_uiuiu , Gpu::HostVector<Real>& h_avg_uiuiv , Gpu::HostVector<Real>& h_avg_uiuiw,
Gpu::HostVector<Real>& h_avg_p,
Gpu::HostVector<Real>& h_avg_pu , Gpu::HostVector<Real>& h_avg_pv , Gpu::HostVector<Real>& h_avg_pw)
void ERF::derive_diag_profiles(Real time,
Gpu::HostVector<Real>& h_avg_u , Gpu::HostVector<Real>& h_avg_v , Gpu::HostVector<Real>& h_avg_w,
Gpu::HostVector<Real>& h_avg_rho , Gpu::HostVector<Real>& h_avg_th , Gpu::HostVector<Real>& h_avg_ksgs,
Gpu::HostVector<Real>& h_avg_kturb, Gpu::HostVector<Real>& h_avg_qv,
Gpu::HostVector<Real>& h_avg_qc , Gpu::HostVector<Real>& h_avg_qr,
Gpu::HostVector<Real>& h_avg_wqv , Gpu::HostVector<Real>& h_avg_wqc, Gpu::HostVector<Real>& h_avg_wqr,
Gpu::HostVector<Real>& h_avg_qi , Gpu::HostVector<Real>& h_avg_qs , Gpu::HostVector<Real>& h_avg_qg,
Gpu::HostVector<Real>& h_avg_uu , Gpu::HostVector<Real>& h_avg_uv , Gpu::HostVector<Real>& h_avg_uw,
Gpu::HostVector<Real>& h_avg_vv , Gpu::HostVector<Real>& h_avg_vw , Gpu::HostVector<Real>& h_avg_ww,
Gpu::HostVector<Real>& h_avg_uth , Gpu::HostVector<Real>& h_avg_vth, Gpu::HostVector<Real>& h_avg_wth,
Gpu::HostVector<Real>& h_avg_thth,
Gpu::HostVector<Real>& h_avg_uiuiu , Gpu::HostVector<Real>& h_avg_uiuiv,
Gpu::HostVector<Real>& h_avg_uiuiw,
Gpu::HostVector<Real>& h_avg_p,
Gpu::HostVector<Real>& h_avg_pu , Gpu::HostVector<Real>& h_avg_pv , Gpu::HostVector<Real>& h_avg_pw)

{
// We assume that this is always called at level 0
Expand Down
10 changes: 9 additions & 1 deletion Source/IO/ERF_WriteScalarProfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,15 @@ ERF::cloud_fraction (Real time)
AMREX_ASSERT(numpts < Long(std::numeric_limits<int>::max));

#if 1
ParallelDescriptor::ReduceIntMax(p,static_cast<int>(numpts));
if (amrex::UseGpuAwareMpi()) {
ParallelDescriptor::ReduceIntMax(p,static_cast<int>(numpts));
} else {
Gpu::PinnedVector<int> hv(numpts);
Gpu::copyAsync(Gpu::deviceToHost, p, p+numpts, hv.data());
Gpu::streamSynchronize();
ParallelDescriptor::ReduceIntMax(hv.data(),static_cast<int>(numpts));
Gpu::copyAsync(Gpu::hostToDevice, hv,data(), hv.data()+numpts, p);
}

// Sum over component 0
Long num_cloudy = qc_2d.template sum<RunOn::Device>(0);
Expand Down
Loading