-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (27 loc) · 839 Bytes
/
Copy pathmain.cpp
File metadata and controls
38 lines (27 loc) · 839 Bytes
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
#include <thread>
#include <iostream>
#include <barrier>
#include <vector>
#include "library/library.h"
using namespace std;
int main(int argc, char *argv[]){
cout << "Number of arguments pass: " << argc << endl << endl;
if (argc!=4){ return 0; }
const int NX = atoi(argv[1]);
const int NT = atoi(argv[2]);
const int nthreads = atoi(argv[3]);
BurgersEquation Beq = BurgersEquation(0.03, NX, NT);
barrier sync_point(nthreads);
auto glambda = [&](auto lb, auto rb){Beq.getSolution(lb, rb, sync_point);};
vector<thread> threads;
int lb, rb;
for(int i=0; i<nthreads; i++){
lb = NX / nthreads * i + 1;
rb = NX / nthreads * (i + 1) + 1;
threads.emplace_back(glambda, lb, rb);
}
for(auto& t : threads){
t.join();
}
Beq.saveResults();
}