17#include <utils/Logger.h>
21#include "Simulation.h"
30 virtual double getOwn(
int index1,
int index2)
const = 0;
32 virtual double getFace(
int index1,
int index2)
const = 0;
34 virtual double getEdge(
int index1,
int index2)
const = 0;
36 virtual double getCorner(
int index1,
int index2)
const = 0;
51 TunerLoad(
int count1,
int count2, std::vector<double>&& ownTime, std::vector<double>&& faceTime,
52 std::vector<double>&& edgeTime, std::vector<double>&& cornerTime);
58 _count1 { 0 }, _count2 { 0 } {
65 double getOwn(
int index1,
int index2)
const override {
66 if (index2 < _count2 && index1 < _count1) {
67 return accessVec(_ownTime, index1, index2);
70 return index1 * (index1 - 1) / 2 * _ownConst[0] + index2 * (index2 - 1) / 2 * _ownConst[1]
71 + index2 * index1 * _ownConst[2];
75 double getFace(
int index1,
int index2)
const override {
76 if (index2 < _count2 && index1 < _count1) {
77 return accessVec(_faceTime, index1, index2);
79 return costsNeighbour(index1, index2, _faceConst);
83 double getEdge(
int index1,
int index2)
const override {
84 if (index2 < _count2 && index1 < _count1) {
85 return accessVec(_edgeTime, index1, index2);
87 return costsNeighbour(index1, index2, _edgeConst);
91 double getCorner(
int index1,
int index2)
const override {
92 if (index2 < _count2 && index1 < _count1) {
93 return accessVec(_cornerTime, index1, index2);
95 return costsNeighbour(index1, index2, _cornerConst);
99 int getCount1() const noexcept {
103 int getCount2() const noexcept {
111 stream <<
"Vectorization Tuner File" << std::endl;
112 stream <<
"own" << std::endl;
113 time.writeVec(stream,
time._ownTime);
114 stream <<
"face" << std::endl;
115 time.writeVec(stream,
time._faceTime);
116 stream <<
"edge" << std::endl;
117 time.writeVec(stream,
time._edgeTime);
118 stream <<
"corner" << std::endl;
119 time.writeVec(stream,
time._cornerTime);
132 static std::vector<double> readVec(std::istream& in,
int& count1,
int& count2);
137 static double costsNeighbour(
int index1,
int index2, std::array<double, 3> consts) noexcept {
138 return index1 * index1 * consts[0] + index2 * index2 * consts[1] + index1 * index2 * 2 * consts[2];
146 void writeVec(std::ostream& out,
const std::vector<double>& vec)
const {
147 for (
int index1 = 0; index1 < _count1; ++index1) {
148 for (
int index2 = 0; index2 < _count2 - 1; ++index2) {
149 out << accessVec(vec, index1, index2) <<
";";
152 if (vec.size() != 0) {
153 out << accessVec(vec, index1, _count2 - 1);
165 std::array<double, 3> calcConsts(
const std::vector<double>& timeVec,
bool inner);
167 double accessVec(
const std::vector<double>& vec,
int index1,
int index2)
const {
168 return vec[index2 + _count2 * index1];
182 std::vector<double> _ownTime;
183 std::vector<double> _faceTime;
184 std::vector<double> _edgeTime;
185 std::vector<double> _cornerTime;
194 std::array<double, 3> _ownConst{};
195 std::array<double, 3> _faceConst{};
196 std::array<double, 3> _edgeConst{};
197 std::array<double, 3> _cornerConst{};
205 double getOwn(
int index1,
int index2)
const override {
206 return (index1 + index2) * (index1 + index2);
209 double getFace(
int index1,
int index2)
const override {
210 return 0.5 * (index1 + index2) * (index1 + index2);
213 double getEdge(
int index1,
int index2)
const override {
214 return 0.5 * (index1 + index2) * (index1 + index2);
217 double getCorner(
int index1,
int index2)
const override {
218 return 0.5 * (index1 + index2) * (index1 + index2);
231 MeasureLoad(
bool timeValuesShouldBeIncreasing,
int interpolationStartsAt);
233 double getOwn(
int index1,
int index2)
const override {
234 return getValue(index1 + index2);
237 double getFace(
int index1,
int index2)
const override {
238 return getValue(index1 + index2);
241 double getEdge(
int index1,
int index2)
const override {
242 return getValue(index1 + index2);
245 double getCorner(
int index1,
int index2)
const override {
246 return getValue(index1 + index2);
253 double getValue(
int numParticles)
const;
254 void calcConstants();
257 std::vector<double> _times;
263 std::array<double, 3> _interpolationConstants{};
265 bool _preparedLoad{
false};
266 double _previousTime{0.};
267 int _interpolationStartsAt{1};
268 bool _timeValuesShouldBeIncreasing{
true};
handle boundary region and multiple processes
Definition: DomainDecompBase.h:51
Definition: LoadCalc.h:24
Definition: LoadCalc.h:227
Definition: LoadCalc.h:203
Definition: LoadCalc.h:44
static TunerLoad read(std::istream &stream)
Definition: LoadCalc.cpp:143
TunerLoad()
Definition: LoadCalc.h:57
static void write(std::ostream &stream, const TunerLoad &time)
Definition: LoadCalc.h:110
double getOwn(int index1, int index2) const override
Definition: LoadCalc.h:65
::xsd::cxx::tree::time< char, simple_type > time
C++ type corresponding to the time XML Schema built-in type.
Definition: vtk-punstructured.h:438
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Definition: vtk-punstructured.h:270