26#if defined(P3M) || defined(DP3M)
70 std::size_t m_n_trials;
74 std::unique_ptr<TuningLogger>
m_logger =
nullptr;
91 static auto constexpr time_sentinel = std::numeric_limits<double>::max();
95 :
m_system{system}, m_timings{timings}, m_n_trials{0ul},
106 double time = std::numeric_limits<double>::max();
142 virtual std::tuple<double, double, double, double>
144 double r_cut_iL)
const = 0;
147 virtual std::optional<std::string>
158 auto const tuned_params =
get_time();
164 throw std::runtime_error(
m_logger->get_name() +
165 ": failed to reach requested accuracy");
169 commit(tuned_params.mesh, tuned_params.cao, tuned_params.r_cut_iL,
170 tuned_params.alpha_L);
172 m_logger->tuning_results(tuned_params.mesh, tuned_params.cao,
173 tuned_params.r_cut_iL, tuned_params.alpha_L,
174 tuned_params.accuracy, tuned_params.time);
182 double &tuned_r_cut_iL,
double &tuned_alpha_L,
183 double &tuned_accuracy);
185 double &tuned_r_cut_iL,
double &tuned_alpha_L,
186 double &tuned_accuracy);
Vector implementation and trait types for boost qvm interoperability.
Tuning algorithm for P3M.
double get_m_time(Utils::Vector3i const &mesh, int &tuned_cao, double &tuned_r_cut_iL, double &tuned_alpha_L, double &tuned_accuracy)
Get the optimal alpha and the corresponding computation time for a fixed mesh.
static auto constexpr time_sentinel
Value for invalid time measurements.
virtual void determine_mesh_limits()=0
Determine a sensible range for the mesh.
virtual void setup_logger(bool verbose)=0
Configure the logger.
virtual TuningAlgorithm::Parameters get_time()=0
Tuning loop entry point.
static auto constexpr max_n_consecutive_trials
Maximal number of consecutive trials that don't improve runtime.
System::System & m_system
virtual ~TuningAlgorithm()=default
virtual void on_solver_change() const =0
Re-initialize the currently active solver.
double get_mc_time(Utils::Vector3i const &mesh, int cao, double &tuned_r_cut_iL, double &tuned_alpha_L, double &tuned_accuracy)
Get the optimal alpha and the corresponding computation time for a fixed mesh and cao.
virtual std::tuple< double, double, double, double > calculate_accuracy(Utils::Vector3i const &mesh, int cao, double r_cut_iL) const =0
Get the minimal error for this combination of parameters.
void increment_n_trials()
virtual std::optional< std::string > layer_correction_veto_r_cut(double r_cut) const =0
Veto real-space cutoffs larger than the layer correction gap.
void commit(Utils::Vector3i const &mesh, int cao, double r_cut_iL, double alpha_L)
Write tuned parameters to the P3M parameter struct.
void determine_cao_limits(int initial_cao)
Determine a sensible range for the charge assignment order.
TuningAlgorithm(System::System &system, double prefactor, int timings)
void determine_r_cut_limits()
Determine a sensible range for the real-space cutoff.
virtual P3MParameters & get_params()=0
Get the P3M parameters.
std::unique_ptr< TuningLogger > m_logger
static auto constexpr time_granularity
Granularity of the time measurement (milliseconds).
This file contains the defaults for ESPResSo.
Common functions for dipolar and charge P3M.
Structure to hold P3M parameters and some dependent variables.
double accuracy
accuracy of the actual parameter set.
bool tuning
tuning or production?