Skip to content

Commit

Permalink
Revert "better parallelisation of apply_delta_f in sys_ee"
Browse files Browse the repository at this point in the history
This reverts commit 38a047d.
  • Loading branch information
Phoelionix committed Jan 15, 2025
1 parent 38a047d commit 0dcb9c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 45 deletions.
11 changes: 0 additions & 11 deletions include/FreeDistribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,6 @@ class Distribution
static double num_basis_funcs(){return basis.num_funcs;}
static void initialise_dynamic_regions(DynamicGridPreset& preset){basis.initialise_regions(preset);}

Eigen::VectorXd get_basis_Sinv(const Eigen::VectorXd& deltaf) const {
// Solves the linear system S fdot = deltaf (returning f dot -S.P.)
return basis.Sinv(deltaf);
}
// Eigen::MatrixXd get_basis_Sinv(const Eigen::MatrixXd& J) {
// // Solves the linear system S fdot = deltaf
// return basis.Sinv(J);
// }


/**
* @brief Returns an order-preserved copy of knots with points that overlap with the basis's boundary removed.
Expand Down Expand Up @@ -344,8 +335,6 @@ class Distribution

static bool dynamic_grid_needs_to_be_reset_with_dynamically_chosen_knots; // TODO duct tape implementation... (eh it's ok).



private:
std::vector<std::vector<double>> f_array; // Spline expansion factors, placed in vector so have option to track a continuum for each element's cascades.
static SplineIntegral basis;
Expand Down
53 changes: 19 additions & 34 deletions src/ElectronRateSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,49 +646,34 @@ void ElectronRateSolver::sys_ee(const state_type& s, state_type& sdot) {
#ifdef NO_EE
#warning No electron-electron interactions
#else

const int threads = input_params.Plasma_Threads();
auto t5 = std::chrono::high_resolution_clock::now();
std::vector<Eigen::VectorXd> vector_of_u;
vector_of_u.resize(Distribution::num_continuums);

#ifdef TRACK_SINGLE_CONTINUUM
size_t _c = 0;
#else
size_t _c = 1; // Iterates through the continuum corresponding to each element's initiated cascades and adds separately. // TODO check if having the full continuum contribute to the actual calcs is better.
#endif
for (;_c < Distribution::num_continuums; _c++){
Eigen::VectorXd vec_dqdt = Eigen::VectorXd::Zero(Distribution::size);
const int threads = input_params.Plasma_Threads();
// compute the dfdt vector
// Electron-electon repulsions
auto t5 = std::chrono::high_resolution_clock::now();
s.F.get_Q_ee(_c, vec_dqdt, threads);
vector_of_u[_c] = (s.F.get_basis_Sinv(vec_dqdt));
auto t6 = std::chrono::high_resolution_clock::now();
ee_time += t6 - t5;
//
// Add change to distribution
auto t7 = std::chrono::high_resolution_clock::now();
/*
#ifdef TRACK_SINGLE_CONTINUUM
sdot.F.applyDeltaF(-99,vec_dqdt,threads); // -99 is a dummy value
#else
sdot.F.applyDeltaF_element_scaled(_c, vec_dqdt,threads);
#endif
*/
sdot.F.applyDeltaF(_c-1,vec_dqdt,threads);
auto t8 = std::chrono::high_resolution_clock::now();
apply_delta_time += t8 - t7;
}
auto t6 = std::chrono::high_resolution_clock::now();
ee_time += t6 - t5;

auto t7 = std::chrono::high_resolution_clock::now();

Eigen::VectorXd u(Distribution::size);

//////applyDeltaF() collapsed loop//////
//
#pragma omp parallel for num_threads(threads) collapse(2)
for (size_t i=0; i<Distribution::size; i++) {
#ifdef TRACK_SINGLE_CONTINUUM
for (size_t _c = 0;
#else
for (size_t _c = 1; // Iterates through the continuum corresponding to each element's initiated cascades and adds separately. // TODO check if having the full continuum contribute to the actual calcs is better.
#endif
_c < Distribution::num_continuums; _c++){
s.F[0][i] += vector_of_u[_c][i];
#ifndef TRACK_SINGLE_CONTINUUM
s.F[_c][i] += vector_of_u[_c][i];
#endif
}
}
/////////////////////////////////////////
auto t8 = std::chrono::high_resolution_clock::now();
apply_delta_time += t8-t7;

#endif // NO_EE
}

Expand Down

0 comments on commit 0dcb9c5

Please sign in to comment.