-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperformanceEvaluator.cpp
More file actions
169 lines (118 loc) · 4.71 KB
/
Copy pathperformanceEvaluator.cpp
File metadata and controls
169 lines (118 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//#define MAP_TESTER // First implementation
//#define MAP_OF_SEQ_TESTER // Second implementaton
#define ACTIVITIES_NUMBER 5
#ifdef MAP_TESTER
#include <bsp_both_impl.hpp>
#include <uTimer.hpp>
#include <iostream>
#include <algorithm>
#include <random>
using namespace std::chrono;
using IntActivityFunction = Superstep<int>::ActivityFunction;
using IntCommunicationProtocol = Superstep<int>::CommunicationProtocols;
using IntCommunicationProtocolFun = std::function<Superstep<int>::CommunicationProtocols (int, std::vector<int> &)>;
using ms = milliseconds;
int main (int argn, char **argv) {
if (argn != 5) {
std::cerr << "Usage:\t ./perfEval <input len> <number of procressors> <computation delay> <communication delay>\n";
return EXIT_FAILURE;
}
std::cout << "Hello user! Running MAP_TESTER\n";
BSP<int> bspPattern;
int inputLen = std::atoi (argv[1]);
int p = std::atoi (argv[2]);
int compPhaseDelay = std::atoi (argv[3]);
int commPhaseDelay = std::atoi (argv[4]);
for (int j=0; j<ACTIVITIES_NUMBER; j++) {
BSP<int>::SuperstepPointer sj = BSP<int>::SuperstepPointer (new Superstep<int> ());
for (int i=0; i<p; i++) {
IntActivityFunction aFun = IntActivityFunction ([compPhaseDelay, inputLen, p] (int actIdx, std::vector<int> &inputs) {
for (auto i=0; i<inputLen/p; i++) {
auto start = high_resolution_clock::now();
do {} while (duration_cast<ms>(high_resolution_clock::now() - start).count () < compPhaseDelay);
}
return ;
});
auto aComFun = IntCommunicationProtocolFun ([commPhaseDelay, inputLen, p] (int actIdx, std::vector<int> els) {
IntCommunicationProtocol cp (ACTIVITIES_NUMBER);
for (auto i=0; i<inputLen/p; i++) {
auto start = high_resolution_clock::now();
do {} while (duration_cast<ms>(high_resolution_clock::now() - start).count () < commPhaseDelay);
}
return cp;
});
sj->addActivity (aFun, aComFun);
}
std::cout << "Superstep id: " << bspPattern.addSuperstep (std::move(sj)) << std::endl;
}
std::vector<std::vector<int>> inputVectors (p), outputVectors (p);
for (size_t i=0; i<inputVectors.size(); i++) {
inputVectors[i] = std::vector<int> (inputLen/p);
}
{
UTimer timer ("Running whole BSP pattern");
bspPattern.runAndWait (inputVectors, outputVectors, false);
}
return 0;
}
#endif // MAP_TESTER
#ifdef MAP_OF_SEQ_TESTER
#define MAP_OF_SEQ_MODEL
#include <bsp_both_impl.hpp>
#include <uTimer.hpp>
#include <iostream>
#include <algorithm>
#include <random>
#include <cstdint>
using namespace std::chrono;
using IntActivityFunction = Superstep<int>::ActivityFunction;
using IntCommunicationProtocol = Superstep<int>::CommunicationProtocols;
using IntCommunicationProtocolFun = std::function<Superstep<int>::CommunicationProtocols (int, int, int, int, std::vector<int> &)>;
using ms = milliseconds;
int main (int argn, char **argv) {
if (argn != 6) {
std::cerr << "Usage: ./PerfEval_MS <input len> <processors> <sub_processors> <computation delay> <communication delay>\n";
return EXIT_FAILURE;
}
std::cout << "Hello user! Running MAP_OF_SEQ_zTESTER\n";
BSP<int> bspPattern;
int inputLen = std::atoi (argv[1]);
int p = std::atoi (argv[2]);
int q = std::atoi (argv[3]);
int compPhaseDelay = std::atoi (argv[4]);
int commPhaseDelay = std::atoi (argv[5]);
for (int j=0; j<ACTIVITIES_NUMBER; j++) {
BSP<int>::SuperstepPointer sj = BSP<int>::SuperstepPointer (new Superstep<int> ());
for (int i=0; i<p; i++) {
auto aFun = IntActivityFunction ([compPhaseDelay, inputLen, p, q] (int actIdx, int subWIdx, int start, int end,
std::vector<int> &inputs) {
for (auto i=0; i<inputLen/(p*q); i++) {
auto start = high_resolution_clock::now();
do {} while (duration_cast<ms>(high_resolution_clock::now() - start).count () < compPhaseDelay);
}
return ;
});
auto aComFun = IntCommunicationProtocolFun ([p, q, commPhaseDelay, inputLen] (int actIdx, int subWIdx, int start,
int end, std::vector<int> els) {
IntCommunicationProtocol cp (ACTIVITIES_NUMBER);
for (auto i=0; i<inputLen/(p*q); i++) {
auto start = high_resolution_clock::now();
do {} while (duration_cast<ms>(high_resolution_clock::now() - start).count () < commPhaseDelay);
}
return cp;
});
sj->addActivity (aFun, aComFun);
}
std::cout << "Superstep id: " << bspPattern.addSuperstep (std::move(sj)) << std::endl;
}
std::vector<std::vector<int>> inputVectors (p), outputVectors (p);
for (size_t i=0; i<inputVectors.size(); i++) {
inputVectors[i] = std::vector<int> (inputLen / p);
}
{
UTimer timer ("Running whole BSP pattern");
bspPattern.runAndWait (q, inputVectors, outputVectors, false);
}
return 0;
}
#endif // MAP_OF_SEQ_TESTER