Scheduler-test: implement memory-accessing load
...use an array of volatiles, and repeatedly add neighbouring cells ...bake the base allocation size configurable, and tie the alloc to the scale-step
This commit is contained in:
parent
df4ee5e9c1
commit
9ef8e78459
4 changed files with 81 additions and 29 deletions
|
|
@ -137,7 +137,7 @@ namespace lib {
|
|||
{
|
||||
using _Arr = T[];
|
||||
|
||||
T* buff_{nullptr};
|
||||
void* buff_{nullptr};
|
||||
size_t size_{0};
|
||||
|
||||
public:
|
||||
|
|
@ -146,9 +146,9 @@ namespace lib {
|
|||
{
|
||||
if (buff_) discard();
|
||||
size_ = cnt;
|
||||
buff_ = cnt? static_cast<T*> (std::aligned_alloc (std::alignment_of<T>(), cnt * sizeof(T)))
|
||||
buff_ = cnt? std::aligned_alloc (std::alignment_of<T>(), cnt * sizeof(T))
|
||||
: nullptr;
|
||||
return buff_;
|
||||
return front();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -216,6 +216,13 @@ namespace lib {
|
|||
}
|
||||
|
||||
|
||||
T * front() { return &array()[0]; }
|
||||
T const* front() const { return &array()[0]; }
|
||||
T * after() { return &array()[size_];}
|
||||
T const* after() const { return &array()[size_];}
|
||||
T * back () { return after() - 1; }
|
||||
T const* back () const { return after() - 1; }
|
||||
|
||||
T & operator[] (size_t idx) { return array()[idx]; }
|
||||
T const& operator[] (size_t idx) const { return array()[idx]; }
|
||||
|
||||
|
|
|
|||
|
|
@ -872,6 +872,7 @@ SHOW_EXPR(testLoad.getHash())
|
|||
{
|
||||
ComputationalLoad cpuLoad;
|
||||
CHECK (cpuLoad.timeBase == 100us);
|
||||
cpuLoad.useAllocation = true;
|
||||
|
||||
double micros = cpuLoad.invoke();
|
||||
SHOW_EXPR(micros)
|
||||
|
|
@ -882,13 +883,13 @@ SHOW_EXPR(micros)
|
|||
|
||||
micros = cpuLoad.invoke();
|
||||
SHOW_EXPR(micros)
|
||||
CHECK (micros < 123);
|
||||
CHECK (micros < 133);
|
||||
CHECK (micros > 80);
|
||||
|
||||
micros = cpuLoad.benchmark();
|
||||
SHOW_EXPR(micros)
|
||||
CHECK (micros < 105);
|
||||
CHECK (micros > 95);
|
||||
CHECK (micros < 110);
|
||||
CHECK (micros > 90);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ namespace test {
|
|||
using lib::meta::_FunRet;
|
||||
using lib::test::Transiently;
|
||||
|
||||
using std::make_pair;
|
||||
using std::forward;
|
||||
using std::string;
|
||||
using std::swap;
|
||||
|
|
@ -1079,23 +1080,29 @@ namespace test {
|
|||
*/
|
||||
class ComputationalLoad
|
||||
{
|
||||
lib::UninitialisedDynBlock<size_t> memBlock_{};
|
||||
using Sink = volatile size_t;
|
||||
|
||||
lib::UninitialisedDynBlock<Sink> memBlock_{};
|
||||
|
||||
static double&
|
||||
computationSpeed() ///< in iterations/µs
|
||||
computationSpeed (bool mem) ///< in iterations/µs
|
||||
{
|
||||
static double speed{LOAD_SPEED_BASELINE};
|
||||
return speed;
|
||||
static double cpuSpeed{LOAD_SPEED_BASELINE};
|
||||
static double memSpeed{LOAD_SPEED_BASELINE};
|
||||
return mem? memSpeed : cpuSpeed;
|
||||
}
|
||||
|
||||
public:
|
||||
microseconds timeBase = 100us;
|
||||
size_t sizeBase = 1000;
|
||||
bool useAllocation = false;
|
||||
|
||||
double
|
||||
invoke (uint scaleStep =1)
|
||||
{
|
||||
return benchmarkTime ([this,scaleStep]{ causeComputationLoad(scaleStep); });
|
||||
if (scaleStep == 0) return 0;
|
||||
return useAllocation? benchmarkTime ([this,scaleStep]{ causeMemProcessLoad (scaleStep); })
|
||||
: benchmarkTime ([this,scaleStep]{ causeComputationLoad(scaleStep); });
|
||||
}
|
||||
|
||||
double
|
||||
|
|
@ -1109,13 +1116,13 @@ namespace test {
|
|||
void
|
||||
calibrate()
|
||||
{
|
||||
cout<<">CAL: speed="<<computationSpeed()<<" rounds:"<<roundsNeeded(1)<<endl;
|
||||
cout<<">CAL: speed="<<computationSpeed(useAllocation)<<" rounds:"<<roundsNeeded(1)<<endl;
|
||||
auto speed = determineSpeed();
|
||||
cout<<".CAL: speed="<<speed<<endl;
|
||||
speed = determineSpeed();
|
||||
cout<<".CAL: speed="<<speed<<endl;
|
||||
computationSpeed() = determineSpeed();
|
||||
cout<<"<CAL: speed="<<computationSpeed()<<" rounds:"<<roundsNeeded(1)<<endl;
|
||||
computationSpeed(useAllocation) = determineSpeed();
|
||||
cout<<"<CAL: speed="<<computationSpeed(useAllocation)<<" rounds:"<<roundsNeeded(1)<<endl;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1131,26 +1138,42 @@ cout<<"<CAL: speed="<<computationSpeed()<<" rounds:"<<roundsNeeded(1)<<endl;
|
|||
roundsNeeded (uint scaleStep)
|
||||
{
|
||||
auto desiredMicros = scaleStep*timeBase.count();
|
||||
return uint64_t(desiredMicros*computationSpeed());
|
||||
return uint64_t(desiredMicros*computationSpeed(useAllocation));
|
||||
}
|
||||
|
||||
auto
|
||||
allocNeeded (uint scaleStep)
|
||||
{
|
||||
auto cnt = roundsNeeded(scaleStep);
|
||||
auto siz = scaleStep * sizeBase;
|
||||
// increase size to fit
|
||||
siz = cnt /(cnt/siz);
|
||||
cnt /= siz;
|
||||
return make_pair (siz,cnt);
|
||||
}
|
||||
|
||||
void
|
||||
causeComputationLoad (uint scaleStep)
|
||||
{
|
||||
auto round = roundsNeeded(scaleStep);
|
||||
volatile size_t sink;
|
||||
auto round = roundsNeeded (scaleStep);
|
||||
Sink sink;
|
||||
size_t scree;
|
||||
for ( ; 0 < round; --round)
|
||||
scree = compute (scree);
|
||||
boost::hash_combine (scree,scree);
|
||||
sink = scree;
|
||||
sink++;
|
||||
}
|
||||
|
||||
size_t
|
||||
compute (size_t input)
|
||||
void
|
||||
causeMemProcessLoad (uint scaleStep)
|
||||
{
|
||||
boost::hash_combine (input,input);
|
||||
return input;
|
||||
auto [siz,round] = allocNeeded (scaleStep);
|
||||
memBlock_.allocate(siz);
|
||||
++*memBlock_.front();
|
||||
for ( ; 0 < round; --round)
|
||||
for (size_t i=0; i<memBlock_.size()-1; ++i)
|
||||
memBlock_[i+1] += memBlock_[i];
|
||||
++*memBlock_.back();
|
||||
}
|
||||
|
||||
double
|
||||
|
|
@ -1158,8 +1181,8 @@ cout<<"<CAL: speed="<<computationSpeed()<<" rounds:"<<roundsNeeded(1)<<endl;
|
|||
{
|
||||
uint step4gauge = 1;
|
||||
double micros = benchmark (step4gauge);
|
||||
auto roundsDone = roundsNeeded (step4gauge);
|
||||
return roundsDone / micros;
|
||||
auto stepsDone = roundsNeeded (step4gauge);
|
||||
return stepsDone / micros;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -99550,15 +99550,16 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node COLOR="#6b3e25" CREATED="1702180522766" ID="ID_316625699" MODIFIED="1702245071598" TEXT="ComputationLoad">
|
||||
<font NAME="Monospaced" SIZE="13"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1702238322430" ID="ID_891650660" MODIFIED="1702238331269" TEXT="verwendete Techologie?">
|
||||
<node COLOR="#435e98" CREATED="1702238322430" ID="ID_891650660" MODIFIED="1702260278758" TEXT="verwendete Techologie?">
|
||||
<icon BUILTIN="help"/>
|
||||
<node COLOR="#338800" CREATED="1702238333843" ID="ID_1192309298" MODIFIED="1702245044607" TEXT="reine computation-Loop">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1702238371167" ID="ID_767333201" MODIFIED="1702238496567" TEXT="oder eine etwas realistischere Last">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1702238371167" ID="ID_767333201" MODIFIED="1702260275694" TEXT="oder eine etwas realistischere Last">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1702238388101" ID="ID_1772254921" MODIFIED="1702238391640" TEXT="Heap-Allokation"/>
|
||||
<node CREATED="1702238392652" ID="ID_1394905064" MODIFIED="1702238396495" TEXT="Speicher-Zugriffe"/>
|
||||
<node CREATED="1702260259872" ID="ID_1938750699" MODIFIED="1702260272219" TEXT="realisiere hier scaleStep durch größere Allokation"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#ccb59b" COLOR="#6e2a38" CREATED="1702238410562" ID="ID_1357630846" MODIFIED="1702238431601" TEXT="kann ich nicht rein-theoretisch enscheiden">
|
||||
<font ITALIC="true" NAME="SansSerif" SIZE="14"/>
|
||||
|
|
@ -99579,6 +99580,23 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="forward"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1702252767113" ID="ID_688715635" MODIFIED="1702252791529">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
legt die Eichungs-Konstanten <i><font color="#152eb7">statisch </font></i>ab
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<node CREATED="1702252795573" ID="ID_1426973621" MODIFIED="1702252808439" TEXT="wichtig für effizienten Einsatz in Lasttest-Szenarien"/>
|
||||
<node CREATED="1702252814273" ID="ID_184752238" MODIFIED="1702252838764" TEXT="muß dafür eine gewisse Kohärenz der Eichung gewährleisten">
|
||||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1702176870348" ID="ID_1843992678" MODIFIED="1702176878242" TEXT="soll statisch kalibrierbar sein">
|
||||
<node CREATED="1702176883018" ID="ID_1063649357" MODIFIED="1702177162816" TEXT="auf 1 LoadUnit ≙ 500ms"/>
|
||||
|
|
@ -99600,6 +99618,9 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node CREATED="1702232438440" ID="ID_1878954665" MODIFIED="1702232455960" TEXT="man muß für die jeweiligen Einstellungen (re)kalibrieren"/>
|
||||
<node CREATED="1702232412226" HGAP="34" ID="ID_43541079" MODIFIED="1702232463171" TEXT="damit werden nicht-Linearitäten ausgeschaltet" VSHIFT="-7"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1702260328321" ID="ID_1651629984" MODIFIED="1702260339078" TEXT="beide Varianten inkrementell kalibrieren">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1702180295927" ID="ID_773261601" MODIFIED="1702180308206" TEXT="Komponente testen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
@ -99610,7 +99631,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1702180446234" ID="ID_257805938" MODIFIED="1702245405826" TEXT="Last und Eichung">
|
||||
<arrowlink COLOR="#c26a36" DESTINATION="ID_168687387" ENDARROW="Default" ENDINCLINATION="-214;715;" ID="Arrow_ID_917319622" STARTARROW="None" STARTINCLINATION="-169;-474;"/>
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1702245098652" ID="ID_1449908056" MODIFIED="1702245403037" TEXT="Fehler im Test?">
|
||||
<node BACKGROUND_COLOR="#f0d5c5" COLOR="#990033" CREATED="1702245098652" ID="ID_1449908056" MODIFIED="1702260306418" TEXT="Fehler im Test?">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
|
|
@ -99626,7 +99647,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
|
||||
</p>
|
||||
<p>
|
||||
Stelle schon mal fest: der Einzel-Lauf streut ganz deutlich. Und Cache-Effekte könnten auch noch ein gewisses Problem darstellen (wenngleich auch der vorangegangene Test grundsätzlich den Code schon <i>vorgewärmt</i>  hat. Also setze mal  ±20% für den Einzeltest an, aber nur ±5% für den Benchmark
|
||||
Stelle schon mal fest: der Einzel-Lauf streut ganz deutlich. Und Cache-Effekte könnten auch noch ein gewisses Problem darstellen (wenngleich auch der vorangegangene Test grundsätzlich den Code schon <i>vorgewärmt</i>  hat. Also setze mal  ±30% für den Einzeltest an, aber nur ±10% für den Benchmark
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in a new issue