Skip to content

Commit 933016d

Browse files
committed
wip stuff
1 parent f545439 commit 933016d

10 files changed

Lines changed: 269 additions & 96 deletions

File tree

‎benchmarks/src/BenchmarkBase.h‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ template
6666
>
6767
void RunBenchmark(std::ostream& logfile, TBenchmark b, const TParams& params)
6868
{
69-
std::cout << "Engine: " << typeid(typename TBenchmark::Domain::Policy::Engine).name() << std::endl << std::endl;
70-
logfile << "Engine: " << typeid(typename TBenchmark::Domain::Policy::Engine).name() << std::endl << std::endl;
71-
7269
double sum = 0;
7370
double min = DBL_MAX;
7471
double max = DBL_MIN;
@@ -77,7 +74,7 @@ void RunBenchmark(std::ostream& logfile, TBenchmark b, const TParams& params)
7774
{
7875
double r = b.Run(params);
7976
std::cout << "\tRun " << i << ": " << r << std::endl;
80-
logfile << "\tRun " << i << ": " << r << std::endl;
77+
logfile << "\tRun " << i << ": " << r << std::endl;
8178

8279
sum += r;
8380

@@ -105,7 +102,7 @@ void RunBenchmark(std::ostream& logfile, TBenchmark b, const TParams& params)
105102
template
106103
<
107104
int RUN_COUNT,
108-
template <typename> class TBenchmark,
105+
typename TBenchmark,
109106
typename TParams
110107
>
111108
void RunBenchmarkClass(const char* name, std::ostream& out, const TParams& params)
@@ -118,8 +115,8 @@ void RunBenchmarkClass(const char* name, std::ostream& out, const TParams& param
118115
params.Print(out);
119116
out << ") =====" << std::endl << std::endl;
120117

121-
REACT_EXPAND_PACK(RunBenchmark<RUN_COUNT>(out, TBenchmark<Ds>(), params));
118+
RunBenchmark<RUN_COUNT>(out, TBenchmark(), params);
122119
}
123120

124-
#define RUN_BENCHMARK(out, runCount, benchmarkClass, params, ...) \
125-
RunBenchmarkClass<runCount, benchmarkClass, decltype(params), __VA_ARGS__>(#benchmarkClass, out, params)
121+
#define RUN_BENCHMARK(out, runCount, benchmarkClass, params) \
122+
RunBenchmarkClass<runCount, benchmarkClass, decltype(params)>(#benchmarkClass, out, params)

‎benchmarks/src/BenchmarkFanout.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "BenchmarkBase.h"
1717

1818
#include "react/Signal.h"
19-
19+
/*
2020
using namespace react;
2121
2222
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -42,8 +42,7 @@ struct BenchmarkParams_Fanout
4242
const int Delay;
4343
};
4444
45-
template <typename D>
46-
struct Benchmark_Fanout : public BenchmarkBase<D>
45+
struct Benchmark_Fanout
4746
{
4847
double Run(const BenchmarkParams_Fanout& params)
4948
{
@@ -83,4 +82,6 @@ struct Benchmark_Fanout : public BenchmarkBase<D>
8382
}
8483
};
8584
85+
*/
86+
8687
#endif // CPP_REACT_BENCHMARK_FANOUT_H

‎benchmarks/src/BenchmarkGrid.h‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ class GridGraphGenerator
4040

4141
std::vector<size_t> widths;
4242

43-
void Generate()
43+
void Generate(const ReactiveGroupBase& group)
4444
{
4545
assert(inputSignals.size() >= 1);
4646
assert(widths.size() >= 1);
4747

4848
SignalVectType buf1 = std::move(inputSignals);
4949
SignalVectType buf2;
5050

51-
SignalVectT* curBuf = &buf1;
52-
SignalVectT* nextBuf = &buf2;
51+
SignalVectType* curBuf = &buf1;
52+
SignalVectType* nextBuf = &buf2;
5353

5454
size_t curWidth = inputSignals.size();
5555

@@ -70,36 +70,36 @@ class GridGraphGenerator
7070

7171
if (shouldGrow)
7272
{
73-
auto s = (*l) ->* Function1;
74-
nextBuf->push_back(s);
73+
auto s = SignalType{ group, function1, *l };
74+
nextBuf->push_back(std::move(s));
7575
}
7676

7777
while (r != curBuf->end())
7878
{
79-
auto s = (*l,*r) ->* Function2;
80-
nextBuf->push_back(s);
81-
nodeCount++;
79+
auto s = SignalType{ group, function2, *l, *r };
80+
nextBuf->push_back(std::move(s));
81+
++nodeCount;
8282
++l; ++r;
8383
}
8484

8585
if (shouldGrow)
8686
{
87-
auto s = (*l) ->* Function1;
88-
nextBuf->push_back(s);
89-
nodeCount++;
87+
auto s = SignalType{ group, function1, *l };
88+
nextBuf->push_back(std::move(s));
89+
++nodeCount;
9090
}
9191

9292
curBuf->clear();
9393

9494
// Swap buffer pointers
95-
SignalVectT* t = curBuf;
95+
SignalVectType* t = curBuf;
9696
curBuf = nextBuf;
9797
nextBuf = t;
9898

9999
if (shouldGrow)
100-
curWidth++;
100+
++curWidth;
101101
else
102-
curWidth--;
102+
--curWidth;
103103
}
104104
}
105105

@@ -135,18 +135,19 @@ struct Benchmark_Grid
135135
double Run(const BenchmarkParams_Grid& params, const ReactiveGroupBase& group)
136136
{
137137
VarSignal<int, shared> in{ group, 1 };
138+
Signal<int, shared> in2 = in;
138139

139140
GridGraphGenerator<int> generator;
140141

141-
generator.inputSignals.push_back(in);
142+
generator.inputSignals.push_back(in2);
142143

143144
generator.widths.push_back(params.N);
144145
generator.widths.push_back(1);
145146

146147
generator.function1 = [] (int a) { return a; };
147148
generator.function2 = [] (int a, int b) { return a + b; };
148149

149-
generator.Generate();
150+
generator.Generate(group);
150151

151152
auto t0 = tbb::tick_count::now();
152153
for (int i=0; i<params.K; i++)

‎benchmarks/src/BenchmarkLifeSim.h‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// http://www.boost.org/LICENSE_1_0.txt)
66

77
#pragma once
8-
8+
/*
99
#include <iostream>
1010
#include <fstream>
1111
#include <memory>
@@ -318,8 +318,10 @@ struct Benchmark_LifeSim : public BenchmarkBase<D>
318318
logfile.open("log.txt");
319319
320320
D::Log().Write(logfile);
321-
logfile.close()*/;
321+
logfile.close()*//*;
322322
323-
return d;
323+
//return d;
324324
}
325-
};
325+
};
326+
327+
*/

‎benchmarks/src/BenchmarkRandom.h‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#include "BenchmarkBase.h"
1515
#include "react/common/Types.h"
1616

17-
#include "react/Domain.h"
17+
#include "react/Group.h"
1818
#include "react/Signal.h"
1919

2020
using namespace react;
21-
21+
/*
2222
///////////////////////////////////////////////////////////////////////////////////////////////////
2323
/// DiamondGraphGenerator
2424
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -215,8 +215,7 @@ struct BenchmarkParams_Random
215215
const int SlowSeed;
216216
};
217217
218-
template <typename D>
219-
struct Benchmark_Random : public BenchmarkBase<D>
218+
struct Benchmark_Random
220219
{
221220
double Run(const BenchmarkParams_Random& params)
222221
{
@@ -321,4 +320,4 @@ struct Benchmark_Random : public BenchmarkBase<D>
321320
322321
return d;
323322
}
324-
};
323+
};*/

‎benchmarks/src/BenchmarkSequence.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include "react/Signal.h"
1616

17+
/*
18+
1719
using namespace react;
1820
1921
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -39,8 +41,7 @@ struct BenchmarkParams_Sequence
3941
const int Delay;
4042
};
4143
42-
template <typename D>
43-
struct Benchmark_Sequence : public BenchmarkBase<D>
44+
struct Benchmark_Sequence
4445
{
4546
double Run(const BenchmarkParams_Sequence& params)
4647
{
@@ -76,4 +77,4 @@ struct Benchmark_Sequence : public BenchmarkBase<D>
7677
7778
return d;
7879
}
79-
};
80+
};*/

‎benchmarks/src/Main.cpp‎

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace {
2727

2828
using namespace react;
2929

30-
void runBenchmarkGrid(std::ostream& out)
30+
/*void runBenchmarkGrid(std::ostream& out)
3131
{
3232
RUN_BENCHMARK(out, 5, Benchmark_Grid, BenchmarkParams_Grid(20, 10000),
3333
ToposortSTDomain, ToposortDomain, PulsecountDomain);
@@ -40,9 +40,9 @@ void runBenchmarkGrid(std::ostream& out)
4040
4141
RUN_BENCHMARK(out, 5, Benchmark_Grid, BenchmarkParams_Grid(50, 10000),
4242
ToposortSTDomain, ToposortDomain, PulsecountDomain);
43-
}
43+
}*/
4444

45-
void runBenchmarkRandom(std::ostream& out)
45+
/*void runBenchmarkRandom(std::ostream& out)
4646
{
4747
const auto w = 20;
4848
const auto h = 11;
@@ -67,7 +67,7 @@ void runBenchmarkRandom(std::ostream& out)
6767
seed1 *= 2;
6868
seed2 *= 2;
6969
}
70-
}
70+
}*/
7171

7272
void runBenchmarkFanout(std::ostream& out)
7373
{
@@ -80,14 +80,14 @@ void runBenchmarkFanout(std::ostream& out)
8080
//RUN_BENCHMARK(out, 5, Benchmark_Fanout, BenchmarkParams_Fanout(1000, 10000, 0),
8181
// ToposortSTDomain, ToposortDomain, ELMDomain, PulsecountDomain, SourceSetDomain);
8282

83-
RUN_BENCHMARK(out, 3, Benchmark_Fanout, BenchmarkParams_Fanout(10, 10, 10),
83+
/* RUN_BENCHMARK(out, 3, Benchmark_Fanout, BenchmarkParams_Fanout(10, 10, 10),
8484
ToposortSTDomain, ToposortDomain, PulsecountDomain);
8585
8686
RUN_BENCHMARK(out, 3, Benchmark_Fanout, BenchmarkParams_Fanout(100, 10, 10),
8787
ToposortSTDomain, ToposortDomain, PulsecountDomain);
8888
8989
RUN_BENCHMARK(out, 3, Benchmark_Fanout, BenchmarkParams_Fanout(1000, 10, 10),
90-
ToposortSTDomain, ToposortDomain, PulsecountDomain);
90+
ToposortSTDomain, ToposortDomain, PulsecountDomain);*/
9191
}
9292

9393
void runBenchmarkSequence(std::ostream& out)
@@ -101,14 +101,14 @@ void runBenchmarkSequence(std::ostream& out)
101101
//RUN_BENCHMARK(out, 3, Benchmark_Sequence, BenchmarkParams_Sequence(1000, 10000, 0),
102102
// ToposortSTDomain, ToposortDomain, ELMDomain, PulsecountDomain, SourceSetDomain);
103103

104-
RUN_BENCHMARK(out, 3, Benchmark_Sequence, BenchmarkParams_Sequence(10, 10, 10),
105-
ToposortSTDomain, ToposortDomain, PulsecountDomain);
104+
//RUN_BENCHMARK(out, 3, Benchmark_Sequence, BenchmarkParams_Sequence(10, 10, 10),
105+
// ToposortSTDomain, ToposortDomain, PulsecountDomain);
106106

107-
RUN_BENCHMARK(out, 3, Benchmark_Sequence, BenchmarkParams_Sequence(100, 10, 10),
108-
ToposortSTDomain, ToposortDomain, PulsecountDomain);
107+
//RUN_BENCHMARK(out, 3, Benchmark_Sequence, BenchmarkParams_Sequence(100, 10, 10),
108+
// ToposortSTDomain, ToposortDomain, PulsecountDomain);
109109

110-
RUN_BENCHMARK(out, 3, Benchmark_Sequence, BenchmarkParams_Sequence(1000, 10, 10),
111-
ToposortSTDomain, ToposortDomain, PulsecountDomain);
110+
//RUN_BENCHMARK(out, 3, Benchmark_Sequence, BenchmarkParams_Sequence(1000, 10, 10),
111+
// ToposortSTDomain, ToposortDomain, PulsecountDomain);
112112
}
113113

114114
void runBenchmarkLifeSim(std::ostream& out)
@@ -119,8 +119,8 @@ void runBenchmarkLifeSim(std::ostream& out)
119119
//RUN_BENCHMARK(std::cout, 1, Benchmark_LifeSim, BenchmarkParams_LifeSim(250, 30, 10000),
120120
// SourceSetDomain, PulsecountDomain);
121121

122-
RUN_BENCHMARK(out, 1, Benchmark_LifeSim, BenchmarkParams_LifeSim(100, 15, 10000),
123-
ToposortSTDomainConc, ToposortDomainConc, PulsecountDomainConc);
122+
//RUN_BENCHMARK(out, 1, Benchmark_LifeSim, BenchmarkParams_LifeSim(100, 15, 10000),
123+
// ToposortSTDomainConc, ToposortDomainConc, PulsecountDomainConc);
124124

125125
//RUN_BENCHMARK(out, 3, Benchmark_LifeSim, BenchmarkParams_LifeSim(100, 50, 100),
126126
// PulsecountDomain, PulsecountDomain);
@@ -130,8 +130,8 @@ void runBenchmarks()
130130
{
131131
std::ofstream logfile;
132132

133-
std::string path = "Benchmark Results/" + CurrentDateTime() + ".txt";
134-
logfile.open(path.c_str());
133+
//std::string path = "Benchmark Results/" + CurrentDateTime() + ".txt";
134+
//logfile.open(path.c_str());
135135

136136
// === GRID
137137
//runBenchmarkGrid(logfile);
@@ -148,14 +148,14 @@ void runBenchmarks()
148148
//runBenchmarkSequence(logfile);
149149

150150
// === LIFESIM
151-
runBenchmarkLifeSim(logfile);
151+
//runBenchmarkLifeSim(logfile);
152152

153153
logfile.close();
154154
}
155155

156156
void debugBenchmarks()
157157
{
158-
using TestDomain = PulsecountDomain;
158+
//using TestDomain = PulsecountDomain;
159159

160160
//RUN_BENCHMARK(std::cout, 1, Benchmark_Grid, BenchmarkParams_Grid(30, 1),
161161
// TestDomain);
@@ -172,8 +172,8 @@ void debugBenchmarks()
172172
//RUN_BENCHMARK(std::cout, 1, Benchmark_Random, BenchmarkParams_Random(10, 25, 10, 0, 10, 25, 25, false),
173173
// ToposortDomain);
174174

175-
RUN_BENCHMARK(std::cout, 1, Benchmark_Random, BenchmarkParams_Random(40, 11, 2, 0, 1, 40, 40, false, 41556, 21624),
176-
TestDomain);
175+
//RUN_BENCHMARK(std::cout, 1, Benchmark_Random, BenchmarkParams_Random(40, 11, 2, 0, 1, 40, 40, false, 41556, 21624),
176+
// TestDomain);
177177

178178
//const auto w = 10;
179179
//const auto h = 11;
@@ -194,21 +194,11 @@ void debugBenchmarks()
194194
//RunBenchmark<1>(Benchmark2<BTokenDomain>());
195195
//RunBenchmark<1>(Benchmark2<SourceSetDomain>());
196196
//RunBenchmark<3>(Benchmark2<ToposortDomain>());
197-
198-
#ifdef REACT_ENABLE_LOGGING
199-
std::ofstream logfile;
200-
logfile.open("log.txt");
201-
202-
TestDomain::Log().Write(logfile);
203-
logfile.close();
204-
#endif
205197
}
206198

207199
void profileBenchmark()
208200
{
209-
RUN_BENCHMARK(std::cout, 3, Benchmark_Grid, BenchmarkParams_Grid(100, 10000),
210-
//SubtreeDomain);
211-
ToposortSTDomain, ToposortDomain, PulsecountDomain, SubtreeDomain);
201+
RUN_BENCHMARK(std::cout, 3, Benchmark_Grid, BenchmarkParams_Grid(100, 10000));
212202

213203
//RUN_BENCHMARK(std::cout, 1, Benchmark_Grid, BenchmarkParams_Grid(30, 10000),
214204
//SourceSetDomain);

0 commit comments

Comments
 (0)