Skip to content

Commit e816efc

Browse files
authored
SpectralFieldData: remove timer-based costs tracker from constructor (#6225)
To my understanding, the `SpectralFieldData` constructor is called only at the beginning of the simulation (and most likely after regrid operations) to prepare the FFT plans. Therefore, if I am not mistaken, we should not track the time spent in the constructor for load balancing, since this routine won't be called again before redistributing the boxes. Note that after removing cost tracking from the `SpectralFieldData` constructor, `lev` becomes an unused parameter.
1 parent 66162ee commit e816efc

File tree

6 files changed

+7
-29
lines changed

6 files changed

+7
-29
lines changed

Source/BoundaryConditions/PML.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ PML::PML (const int lev, const BoxArray& grid_ba,
792792
amrex::Vector<amrex::Real> const v_galilean = WarpX::GetInstance().m_v_galilean;
793793
amrex::Vector<amrex::Real> const v_comoving_zero = {0., 0., 0.};
794794
realspace_ba.enclosedCells().grow(nge); // cell-centered + guard cells
795-
spectral_solver_fp = std::make_unique<SpectralSolver>(lev, realspace_ba, dm,
795+
spectral_solver_fp = std::make_unique<SpectralSolver>(realspace_ba, dm,
796796
nox_fft, noy_fft, noz_fft, grid_type, v_galilean,
797797
v_comoving_zero, dx, dt, in_pml, periodic_single_box, update_with_rho,
798798
fft_do_time_averaging, psatd_solution_type, time_dependency_J, time_dependency_rho, m_dive_cleaning, m_divb_cleaning);
@@ -904,7 +904,7 @@ PML::PML (const int lev, const BoxArray& grid_ba,
904904
amrex::Vector<amrex::Real> const v_galilean = WarpX::GetInstance().m_v_galilean;
905905
amrex::Vector<amrex::Real> const v_comoving_zero = {0., 0., 0.};
906906
realspace_cba.enclosedCells().grow(nge); // cell-centered + guard cells
907-
spectral_solver_cp = std::make_unique<SpectralSolver>(lev, realspace_cba, cdm,
907+
spectral_solver_cp = std::make_unique<SpectralSolver>(realspace_cba, cdm,
908908
nox_fft, noy_fft, noz_fft, grid_type, v_galilean,
909909
v_comoving_zero, cdx, dt, in_pml, periodic_single_box, update_with_rho,
910910
fft_do_time_averaging, psatd_solution_type, time_dependency_J, time_dependency_rho, m_dive_cleaning, m_divb_cleaning);

Source/FieldSolver/SpectralSolver/SpectralFieldData.H

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ class SpectralFieldData
144144
{
145145

146146
public:
147-
SpectralFieldData( int lev,
148-
const amrex::BoxArray& realspace_ba,
147+
SpectralFieldData( const amrex::BoxArray& realspace_ba,
149148
const SpectralKSpace& k_space,
150149
const amrex::DistributionMapping& dm,
151150
int n_field_required,

Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,13 @@ SpectralFieldIndex::SpectralFieldIndex (const bool update_with_rho,
129129
}
130130

131131
/* \brief Initialize fields in spectral space, and FFT plans */
132-
SpectralFieldData::SpectralFieldData( const int lev,
133-
const amrex::BoxArray& realspace_ba,
132+
SpectralFieldData::SpectralFieldData( const amrex::BoxArray& realspace_ba,
134133
const SpectralKSpace& k_space,
135134
const amrex::DistributionMapping& dm,
136135
const int n_field_required,
137136
const bool periodic_single_box):
138137
m_periodic_single_box{periodic_single_box}
139138
{
140-
amrex::LayoutData<amrex::Real>* cost = WarpX::getCosts(lev);
141-
const bool do_costs = WarpXUtilLoadBalance::doCosts(cost, realspace_ba, dm);
142-
143139
const BoxArray& spectralspace_ba = k_space.spectralspace_ba;
144140

145141
// Allocate the arrays that contain the fields in spectral space
@@ -177,12 +173,6 @@ SpectralFieldData::SpectralFieldData( const int lev,
177173
// Loop over boxes and allocate the corresponding plan
178174
// for each box owned by the local MPI proc
179175
for ( MFIter mfi(spectralspace_ba, dm); mfi.isValid(); ++mfi ){
180-
if (do_costs)
181-
{
182-
amrex::Gpu::synchronize();
183-
}
184-
auto wt = static_cast<amrex::Real>(amrex::second());
185-
186176
// Note: the size of the real-space box and spectral-space box
187177
// differ when using real-to-complex FFT. When initializing
188178
// the FFT plan, the valid dimensions are those of the real-space box.
@@ -197,13 +187,6 @@ SpectralFieldData::SpectralFieldData( const int lev,
197187
fft_size, tmpRealField[mfi].dataPtr(),
198188
reinterpret_cast<ablastr::math::anyfft::Complex*>( tmpSpectralField[mfi].dataPtr()),
199189
ablastr::math::anyfft::direction::C2R, AMREX_SPACEDIM);
200-
201-
if (do_costs)
202-
{
203-
amrex::Gpu::synchronize();
204-
wt = static_cast<amrex::Real>(amrex::second()) - wt;
205-
amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt);
206-
}
207190
}
208191
}
209192

Source/FieldSolver/SpectralSolver/SpectralSolver.H

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class SpectralSolver
4444
* for the discrete field update equations, and prepare the structures that store
4545
* the fields in spectral space.
4646
*
47-
* \param[in] lev mesh refinement level
4847
* \param[in] realspace_ba BoxArray in real space
4948
* \param[in] dm DistributionMapping for the given BoxArray
5049
* \param[in] norder_x spectral order along x
@@ -73,8 +72,7 @@ class SpectralSolver
7372
* \param[in] divb_cleaning whether to use div(B) cleaning to account for errors in
7473
* div(B) = 0 law (new field G in the update equations)
7574
*/
76-
SpectralSolver (int lev,
77-
const amrex::BoxArray& realspace_ba,
75+
SpectralSolver (const amrex::BoxArray& realspace_ba,
7876
const amrex::DistributionMapping& dm,
7977
int norder_x,
8078
int norder_y,

Source/FieldSolver/SpectralSolver/SpectralSolver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#if WARPX_USE_FFT
2525

2626
SpectralSolver::SpectralSolver (
27-
const int lev,
2827
const amrex::BoxArray& realspace_ba,
2928
const amrex::DistributionMapping& dm,
3029
const int norder_x,
@@ -110,7 +109,7 @@ SpectralSolver::SpectralSolver (
110109
}
111110

112111
// - Initialize arrays for fields in spectral space + FFT plans
113-
field_data = SpectralFieldData(lev, realspace_ba, k_space, dm,
112+
field_data = SpectralFieldData(realspace_ba, k_space, dm,
114113
m_spectral_index.n_fields, periodic_single_box);
115114
}
116115

Source/WarpX.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,8 +3061,7 @@ void WarpX::AllocLevelSpectralSolver (amrex::Vector<std::unique_ptr<SpectralSolv
30613061
solver_dt /= 2.;
30623062
}
30633063

3064-
auto pss = std::make_unique<SpectralSolver>(lev,
3065-
realspace_ba,
3064+
auto pss = std::make_unique<SpectralSolver>(realspace_ba,
30663065
dm,
30673066
nox_fft,
30683067
noy_fft,

0 commit comments

Comments
 (0)