AutoPas  3.0.0
Loading...
Searching...
No Matches
ActiveHarmony.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <chrono>
10#include <cstdio>
11#include <cstdlib>
12#include <string>
13#include <thread>
14#include <vector>
15
24
25#ifdef AUTOPAS_ENABLE_HARMONY
26#include "hclient.h"
27#endif
28
29namespace autopas {
30
38 public:
51 ActiveHarmony(const InteractionTypeOption &interactionType, const std::set<ContainerOption> &allowedContainerOptions,
52 const NumberSet<double> &allowedCellSizeFactors,
53 const std::set<TraversalOption> &allowedTraversalOptions,
54 const std::set<LoadEstimatorOption> &allowedLoadEstimatorOptions,
55 const std::set<DataLayoutOption> &allowedDataLayoutOptions,
56 const std::set<Newton3Option> &allowedNewton3Options, bool mpiDivideAndConquer, AutoPas_MPI_Comm comm);
57
58 ~ActiveHarmony() override;
59
60 TuningStrategyOption getOptionType() const override;
61
62 void addEvidence(const Configuration &configuration, const Evidence &evidence) override;
63
64 bool optimizeSuggestions(std::vector<Configuration> &configQueue,
65 const EvidenceCollection &evidenceCollection) override;
66
71 bool searchSpaceIsTrivial() const;
72
77 bool searchSpaceIsEmpty() const;
78
79 bool needsSmoothedHomogeneityAndMaxDensity() const override;
80
81 bool reset(size_t iteration, size_t tuningPhase, std::vector<Configuration> &configQueue,
82 const autopas::EvidenceCollection &evidenceCollection) override;
83
84 private:
85#ifdef AUTOPAS_ENABLE_HARMONY
89 hdesc_t *hdesc = nullptr;
93 htask_t *htask = nullptr;
94#else
95 using hdef_t = void *;
96#endif
97
98 const InteractionTypeOption _interactionType;
99
100 std::set<ContainerOption> _allowedContainerOptions;
101 std::unique_ptr<NumberSet<double>> _allowedCellSizeFactors;
102 std::set<TraversalOption> _allowedTraversalOptions;
103 std::set<LoadEstimatorOption> _allowedLoadEstimatorOptions;
104 std::set<DataLayoutOption> _allowedDataLayoutOptions;
105 std::set<Newton3Option> _allowedNewton3Options;
106
107 size_t _tuningPhase{0};
108 bool _mpiDivideAndConquer;
109 AutoPas_MPI_Comm _comm;
110 bool _nonLocalServer;
111
115 void resetHarmony();
116
120 Configuration fetchConfiguration();
121
125 void invalidateConfiguration();
126
134 template <class OptionClass>
135 void configureTuningParameter(hdef_t *hdef, const char *name, const std::set<OptionClass> &options);
136
144 template <class OptionClass>
145 OptionClass fetchTuningParameter(const char *name, const std::set<OptionClass> &options);
146
147 void rejectConfiguration(const autopas::Configuration &configuration, bool indefinitely) override;
148
149 void setupTuningParameters(int commSize, hdef_t *hdef);
150
151 static constexpr int cellSizeSamples = 100;
152
153 static constexpr const char *traversalOptionName = "traversalOption";
154 static constexpr const char *loadEstimatorOptionName = "loadEstimatorOption";
155 static constexpr const char *dataLayoutOptionName = "dataLayoutOption";
156 static constexpr const char *cellSizeFactorsName = "cellSizeFactor";
157 static constexpr const char *newton3OptionName = "newton3Option";
158};
159
160} // namespace autopas
Interface to the Active Harmony (AH) tuning framework.
Definition: ActiveHarmony.h:37
bool searchSpaceIsTrivial() const
Indicate if the search space contains only one configuration.
Definition: ActiveHarmony.cpp:270
bool searchSpaceIsEmpty() const
Indicate if the search space contains any configurations.
Definition: ActiveHarmony.cpp:281
TuningStrategyOption getOptionType() const override
Get this object's associated TuningStrategyOption type.
Definition: ActiveHarmony.cpp:340
bool needsSmoothedHomogeneityAndMaxDensity() const override
Indicate whether the strategy needs smoothed values of homogeneity and max density.
Definition: ActiveHarmony.cpp:338
bool reset(size_t iteration, size_t tuningPhase, std::vector< Configuration > &configQueue, const autopas::EvidenceCollection &evidenceCollection) override
Reset all internal parameters to the beginning of a new tuning phase.
Definition: ActiveHarmony.cpp:193
bool optimizeSuggestions(std::vector< Configuration > &configQueue, const EvidenceCollection &evidenceCollection) override
Optimizes the queue of configurations to process.
Definition: ActiveHarmony.cpp:128
void addEvidence(const Configuration &configuration, const Evidence &evidence) override
Notifies the strategy about empirically collected information for the given configuration.
Definition: ActiveHarmony.cpp:58
Class containing multiple options that form an algorithm configuration for the pairwise iteration.
Definition: Configuration.h:24
Class to manage all evidence.
Definition: EvidenceCollection.h:21
Helper class that associates a measurement with the iteration when it was taken.
Definition: Evidence.h:15
Virtual class describing a finite or infinite set of numbers.
Definition: NumberSet.h:22
Interface for tuning strategies for the auto tuner.
Definition: TuningStrategyInterface.h:23
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
AutoPas_MPI_Comm
Dummy for MPI_Comm.
Definition: WrapMPI.h:113