Skip to content

Commit

Permalink
Change GPU sync to GPU stream sync (Exawind#1507)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored Feb 27, 2025
1 parent 23b314b commit d012d58
Show file tree
Hide file tree
Showing 78 changed files with 149 additions and 149 deletions.
4 changes: 2 additions & 2 deletions amr-wind/core/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void Field::to_uniform_space() noexcept
detJ[nbx](i, j, k) / fac[nbx](i, j, k, n);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
m_mesh_mapped = true;
}

Expand Down Expand Up @@ -445,7 +445,7 @@ void Field::to_stretched_space() noexcept
fac[nbx](i, j, k, n) / detJ[nbx](i, j, k);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
m_mesh_mapped = false;
}

Expand Down
4 changes: 2 additions & 2 deletions amr-wind/core/field_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ lower_bound(FType& field, const amrex::Real min_value, const int icomp = 0)
amrex::max(min_value, farrs[nbx](i, j, k, icomp));
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

/** Computes the global maximum of a field from all levels
Expand Down Expand Up @@ -465,7 +465,7 @@ inline void normalize(FType& field)
}
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

} // namespace amr_wind::field_ops
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/diffusion/incflo_diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void viscosity_to_uniform_space(
std::pow(fac_arrs[nbx](i, j, k, 2), 2);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

} // namespace diffusion
4 changes: 2 additions & 2 deletions amr-wind/equation_systems/CompRHSOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct ComputeRHSOp
});
}
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

/** Compute right-hand side for corrector steps
Expand Down Expand Up @@ -259,7 +259,7 @@ struct ComputeRHSOp
});
}
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

// data members
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/DiffusionOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void DiffSolverIface<LinOp>::linsys_solve_impl()
rho_arrs[nbx](i, j, k) * fld_arrs[nbx](i, j, k, n);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

amrex::MLMG mlmg(*this->m_solver);
this->setup_solver(mlmg);
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/PDEOps.H
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct SrcTermOpBase
vf_arrs[nbx](i, j, k, n) *= rho_arrs[nbx](i, j, k);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

//! Update source terms during time-integration procedure
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/equation_systems/density/density_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct ComputeRHSOp<Density, Scheme>
// k));
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

void corrector_rhs(
Expand Down Expand Up @@ -73,7 +73,7 @@ struct ComputeRHSOp<Density, Scheme>
// 0.5 * (rho(i, j, k) + rho_o(i, j, k));
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

// data members
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/icns/icns_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void MacProjOp::mac_proj_to_uniform_space(
rho_arrs[nbx](i, j, k);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

} // namespace amr_wind::pde
8 changes: 4 additions & 4 deletions amr-wind/equation_systems/icns/icns_diffusion.H
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public:
divtau_arrs[nbx](i, j, k, 2) *= rhoinv;
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}
}

Expand Down Expand Up @@ -244,7 +244,7 @@ public:
rho_arrs[nbx](i, j, k) * fld_arrs[nbx](i, j, k, n);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

amrex::MLMG mlmg(*m_solver_scalar);
m_options(mlmg);
Expand Down Expand Up @@ -401,7 +401,7 @@ public:
divtau_arrs[nbx](i, j, k, 2) *= rhoinv;
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}
}

Expand Down Expand Up @@ -478,7 +478,7 @@ public:
rho_arrs[nbx](i, j, k) * fld_arrs[nbx](i, j, k, n);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

for (int i = 0; i < AMREX_SPACEDIM; ++i) {
auto vel_comp = m_pdefields.field.subview(i);
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/equation_systems/levelset/levelset_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct ComputeRHSOp<Levelset, Scheme>
// k));
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

void corrector_rhs(
Expand Down Expand Up @@ -112,7 +112,7 @@ struct ComputeRHSOp<Levelset, Scheme>
// 0.5 * (phi(i, j, k) + phi_o(i, j, k));
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

// data members
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/tke/tke_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct PostSolveOp<TKE>
: field_arrs[nbx](i, j, k);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
m_fields.field.fillpatch(time);
}

Expand Down
2 changes: 1 addition & 1 deletion amr-wind/equation_systems/vof/vof_hybridsolver_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static void replace_masked_vof(
: vfmasked_arrs[nbx](i, j, k);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

} // namespace amr_wind::multiphase
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/immersed_boundary/bluff_body/bluff_body_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void apply_mms_vel(CFDSim& sim)
}
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

void apply_dirichlet_vel(CFDSim& sim, const amrex::Vector<amrex::Real>& vel_bc)
Expand Down Expand Up @@ -129,7 +129,7 @@ void apply_dirichlet_vel(CFDSim& sim, const amrex::Vector<amrex::Real>& vel_bc)
}
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

void prepare_netcdf_file(
Expand Down
2 changes: 1 addition & 1 deletion amr-wind/mesh_mapping_models/ChannelFlowMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void ChannelFlowMap::create_face_map(int lev, const amrex::Geometry& geom)
scale_fac_zf_arrs[nbx](i, j, k, 1) *
scale_fac_zf_arrs[nbx](i, j, k, 2);
});
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
// TODO: Call fill patch operators ?
}

Expand Down
2 changes: 1 addition & 1 deletion amr-wind/mesh_mapping_models/ConstantMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void ConstantMap::create_face_map(int lev)
scale_fac_zf_arrs[nbx](i, j, k, 2);
});

amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

/** Construct the non-uniform mesh field
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/ocean_waves/relaxation_zones/linear_waves_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct InitDataOp<LinearWaves>
phi_arrs[nbx](i, j, k) = phi;
}
});
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}
};

Expand Down Expand Up @@ -214,7 +214,7 @@ struct UpdateTargetFieldsOp<LinearWaves>
}
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void update_target_vof(CFDSim& sim)
multiphase::levelset_to_vof(i, j, k, eps, target_phi[nbx]);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

void apply_relaxation_zones(CFDSim& sim, const RelaxZonesBaseData& wdata)
Expand Down Expand Up @@ -265,7 +265,7 @@ void apply_relaxation_zones(CFDSim& sim, const RelaxZonesBaseData& wdata)
rho1 * volfrac(i, j, k) + rho2 * (1. - volfrac(i, j, k));
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

vof.fillpatch(time);
velocity.fillpatch(time);
Expand Down
4 changes: 2 additions & 2 deletions amr-wind/ocean_waves/relaxation_zones/stokes_waves_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct InitDataOp<StokesWaves>
phi_arrs[nbx](i, j, k) = phi;
}
});
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}
};

Expand Down Expand Up @@ -227,7 +227,7 @@ struct UpdateTargetFieldsOp<StokesWaves>
}
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}
};

Expand Down
6 changes: 3 additions & 3 deletions amr-wind/ocean_waves/relaxation_zones/waves2amr_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void postprocess_velocity_mfab_liquid(
vel[nbx](i, j, k, 2) = 0.0;
}
});
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

void postprocess_velocity_field_liquid(
Expand Down Expand Up @@ -509,7 +509,7 @@ struct InitDataOp<W2AWaves>
w2a_vel[nbx](i, j, k, 1) = quiescent[0];
w2a_vel[nbx](i, j, k, 2) = quiescent[0];
});
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
#else
amrex::ignore_unused(data, level, geom, multiphase_mode);
#endif
Expand Down Expand Up @@ -718,7 +718,7 @@ struct UpdateTargetFieldsOp<W2AWaves>
(time - t_last) / (W2A_t - t_last + 1e-16);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
#else
amrex::ignore_unused(data, time);
#endif
Expand Down
18 changes: 9 additions & 9 deletions amr-wind/overset/OversetOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void OversetOps::update_gradp()
gp_lev_arrs[nbx](i, j, k, n) = gp_proj_arrs[nbx](i, j, k, n);
});
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

// Averaging down here would be unnecessary; it is built into calcGradPhi
}
Expand Down Expand Up @@ -249,7 +249,7 @@ void OversetOps::sharpen_nalu_data()
iblank_cell(lev), dx, max_pvscale);
pvscale = std::min(pvscale, pvscale_lev);
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
amrex::ParallelDescriptor::ReduceRealMin(pvscale);

// Convert levelset to vof to get target_vof
Expand All @@ -260,14 +260,14 @@ void OversetOps::sharpen_nalu_data()
// A tolerance of 0 should do nothing
overset_ops::process_vof((*target_vof)(lev), m_target_cutoff);
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

// Replace vof with original values in amr domain
for (int lev = 0; lev < nlevels; ++lev) {
overset_ops::harmonize_vof(
(*target_vof)(lev), vof(lev), iblank_cell(lev));
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

// Put fluxes in vector for averaging down during iterations
amrex::Vector<amrex::Array<amrex::MultiFab*, AMREX_SPACEDIM>> fluxes(
Expand Down Expand Up @@ -319,7 +319,7 @@ void OversetOps::sharpen_nalu_data()
err = amrex::max(err, err_lev);
}
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

// Average down fluxes across levels for consistency
for (int lev = nlevels - 1; lev > 0; --lev) {
Expand All @@ -338,7 +338,7 @@ void OversetOps::sharpen_nalu_data()
m_convg_tol);
ptfac = amrex::min(ptfac, ptfac_lev);
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
amrex::ParallelDescriptor::ReduceRealMin(ptfac);

// Conform pseudo dt (dtau) to pseudo CFL
Expand All @@ -357,7 +357,7 @@ void OversetOps::sharpen_nalu_data()
velocity(lev).FillBoundary(geom[lev].periodicity());
gp(lev).FillBoundary(geom[lev].periodicity());
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();

// Update density (fillpatch built in)
m_mphase->set_density_via_vof();
Expand All @@ -382,7 +382,7 @@ void OversetOps::sharpen_nalu_data()
for (int lev = 0; lev < nlevels; ++lev) {
overset_ops::equate_field(levelset(lev), velocity(lev));
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

void OversetOps::form_perturb_pressure()
Expand Down Expand Up @@ -421,7 +421,7 @@ void OversetOps::replace_masked_gradp()
// Reapply pressure gradient term
overset_ops::apply_pressure_gradient(vel(lev), rho(lev), gp(lev), dt);
}
amrex::Gpu::synchronize();
amrex::Gpu::streamSynchronize();
}

} // namespace amr_wind
Loading

0 comments on commit d012d58

Please sign in to comment.