Added timing of reading and writing

This commit is contained in:
elvis
2023-08-25 16:43:58 +02:00
parent 36eb1c7caf
commit 49180c6b8a
2 changed files with 65 additions and 0 deletions

View File

@ -1,2 +1,21 @@
# StencilParallelPattern
To compile with debug symbols:
```
cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build/
cd build/
make
```
To compile with optimizations:
```
cmake -DCMAKE_BUILD_TYPE=Release -S . -B build/
cd build/
make
```

View File

@ -155,6 +155,25 @@ long long int sequential(vector<string> images,
return ret;
}
long long int reading_writing(vector<string> images) {
Reader<char> reader(images);
Writer<char> writer;
ff::ff_Pipe<> pipe(reader, writer);
UTimer timer;
timer.start();
if (pipe.run_and_wait_end() < 0) {
error("running pipeline\n");
return 1;
}
timer.stop();
long long int ret = timer.print("\tElapsed time: ");
return ret;
}
// -----------------------------------------------------------------------------
// stencil used for the examples
char gameOfLife(vector<char> in) {
auto v = std::accumulate(in.begin() + 1, in.end(), 0);
if (in[0] && v < 2) {
@ -170,6 +189,7 @@ char gameOfLife(vector<char> in) {
// -----------------------------------------------------------------------------
int main(int argc, char *argv[]) {
int average_max = 5;
int average_max_rw = 15;
int iter_for_num_workers_images1 = 128;
vector<string> images1 = {
@ -193,6 +213,8 @@ int main(int argc, char *argv[]) {
ofstream csvfile;
csvfile.open("performance.csv");
goto theend;
for (std::string image : images1) {
cout << endl
<< "\033[1;31mProcessing: \t" << image << "\033[0m" << endl;
@ -376,6 +398,30 @@ int main(int argc, char *argv[]) {
csvfile << "\n";
}
}
theend:
cout << "Computing reading and writing speeds" << endl;
for (auto image : images1) {
csvfile << "RWtime:," << image << ",";
vector<long long int> results;
for (int i = 0; i < average_max_rw; ++i) {
results.push_back(reading_writing({image}));
}
csvfile << std::accumulate(results.begin(), results.end(), 0) /
average_max_rw
<< "\n";
}
for (auto image : images2) {
csvfile << "RWtime:," << image << ",";
vector<long long int> results;
for (int i = 0; i < average_max_rw; ++i) {
results.push_back(reading_writing({image}));
}
csvfile << std::accumulate(results.begin(), results.end(), 0) /
average_max_rw
<< "\n";
}
csvfile.close();
return 0;