Skip to content

Commit

Permalink
Simplify tiling in plasma deposition (#1093)
Browse files Browse the repository at this point in the history
* Simplify tiling in plasma deposition

* remove m_tmp_densities

* update doc

* fix merge
  • Loading branch information
AlexanderSinn authored Apr 12, 2024
1 parent 9040d62 commit 2e2e592
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 242 deletions.
6 changes: 2 additions & 4 deletions docs/source/run/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,8 @@ When both are specified, the per-species value is used.
Whether to add a neutralizing background of immobile particles of opposite charge.

* ``plasmas.sort_bin_size`` (`int`) optional (default `32`)
Tile size for plasma current deposition, when running on CPU.
When tiling is activated (``hipace.do_tiling = 1``), the current deposition is done in temporary
arrays of size ``sort_bin_size`` (+ guard cells) that are atomic-added to the main current
arrays.
Tile size for plasma current deposition, when running on CPU
and tiling is activated (``hipace.do_tiling = 1``).

* ``<plasma name>.temperature_in_ev`` (`float`) optional (default `0`)
| Initializes the plasma particles with a given temperature :math:`k_B T` in eV. Using a temperature, the plasma particle momentum is normally distributed with a variance of :math:`k_B T /(M c^2)` in each dimension, with :math:`M` the particle mass, :math:`k_B` the Boltzmann constant, and :math:`T` the isotropic temperature in Kelvin.
Expand Down
3 changes: 1 addition & 2 deletions src/Hipace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ Hipace::InitData ()
#endif

for (int lev=0; lev<m_N_level; ++lev) {
m_fields.AllocData(lev, m_3D_geom[lev], m_slice_ba[lev], m_slice_dm[lev],
m_multi_plasma.m_sort_bin_size);
m_fields.AllocData(lev, m_3D_geom[lev], m_slice_ba[lev], m_slice_dm[lev]);
if (lev==0) {
// laser inits only on level 0
m_multi_laser.InitData(m_slice_ba[0], m_slice_dm[0], m_3D_geom[0]);
Expand Down
7 changes: 1 addition & 6 deletions src/fields/Fields.H
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ public:
* \param[in] geom Geometry
* \param[in] slice_ba BoxArray for the slice
* \param[in] slice_dm DistributionMapping for the slice
* \param[in] bin_size size of plasma tiles, for tmp arrays
*/
void AllocData (
int lev, amrex::Geometry const& geom, const amrex::BoxArray& slice_ba,
const amrex::DistributionMapping& slice_dm, int bin_size);
const amrex::DistributionMapping& slice_dm);

/** get function for the 2D slices */
amrex::Vector<amrex::MultiFab>& getSlices () {return m_slices; }
Expand All @@ -123,8 +122,6 @@ public:
amrex::MultiFab getStagingArea (const int lev) {
return amrex::MultiFab(m_poisson_solver[lev]->StagingArea(), amrex::make_alias, 0, 1);
}
/** Return reference to density tile arrays */
amrex::Vector<amrex::FArrayBox>& getTmpDensities() { return m_tmp_densities; }
/** check whether the fields are initialized correctly */
void checkInit() {
for (auto& slices_lev : m_slices) {
Expand Down Expand Up @@ -513,8 +510,6 @@ private:
std::string m_poisson_solver_str = "FFTDirichlet";
/** Class to handle transverse FFT Poisson solver on 1 slice */
amrex::Vector<std::unique_ptr<FFTPoissonSolver>> m_poisson_solver;
/** Temporary density arrays. one per OpenMP thread, used when tiling is on. */
amrex::Vector<amrex::FArrayBox> m_tmp_densities;
/** Stores temporary values for z interpolation in Fields::Copy */
amrex::Gpu::DeviceVector<amrex::Real> m_rel_z_vec;
/** Stores temporary values for z interpolation in Fields::Copy on the CPU */
Expand Down
16 changes: 1 addition & 15 deletions src/fields/Fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Fields::Fields (const int nlev)
void
Fields::AllocData (
int lev, amrex::Geometry const& geom, const amrex::BoxArray& slice_ba,
const amrex::DistributionMapping& slice_dm, int bin_size)
const amrex::DistributionMapping& slice_dm)
{
HIPACE_PROFILE("Fields::AllocData()");
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(slice_ba.size() == 1,
Expand Down Expand Up @@ -197,20 +197,6 @@ Fields::AllocData (
amrex::Abort("Unknown poisson solver '" + m_poisson_solver_str +
"', must be 'FFTDirichlet', 'FFTPeriodic' or 'MGDirichlet'");
}
int num_threads = 1;
#ifdef AMREX_USE_OMP
num_threads = omp_get_max_threads();
#endif
if (Hipace::m_do_tiling) {

m_tmp_densities.resize(num_threads);
for (int i=0; i<num_threads; i++){
amrex::Box bx = {{0, 0, 0}, {bin_size-1, bin_size-1, 0}};
bx.grow(m_slices_nguards);
// jx jy jz rho chi rhomjz
m_tmp_densities[i].resize(bx, 6);
}
}

if (lev == 0 && m_insitu_period > 0) {
#ifdef HIPACE_USE_OPENPMD
Expand Down
Loading

0 comments on commit 2e2e592

Please sign in to comment.