-
Notifications
You must be signed in to change notification settings - Fork 20
/
cpymat.cpp
50 lines (41 loc) · 1.27 KB
/
cpymat.cpp
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
#include "concore.hpp"
//instead of below, this file will be C++ equivalent of cpymat.py
#include <vector>
#include <string>
#include <chrono>
#include <iomanip> //setprecision
using namespace std;
int main()
{
Concore concore;
concore.delay = 0.01;
int Nsim = 100;
string init_simtime_u = "[0.0,0.0,0.0]";
string init_simtime_ym = "[0.0,0.0,0.0]";
int minElapsed = 10000000;
int maxElapsed = 0;
int sumElapsed = 0;
vector<double> u = concore.initval(init_simtime_u);
auto wallclock1 = chrono::high_resolution_clock::now();
vector<double> ym;
while(concore.simtime<Nsim){
while (concore.unchanged()){
ym = concore.read(1,"ym",init_simtime_ym);
}
u[0] = ym[0]+1;
cout<<"ym="<<ym[0]<<" u="<<u[0]<<endl;
concore.write(1,"u",u);
auto wallclock2 = chrono::high_resolution_clock::now();
auto duration = chrono::duration_cast<chrono::seconds>(wallclock2 - wallclock1);
int elapsed = duration.count();
sumElapsed += elapsed;
wallclock1 = wallclock2;
minElapsed = min(minElapsed, elapsed);
maxElapsed = max(maxElapsed, elapsed);
}
concore.write(1,"u",init_simtime_u);
cout<<"retry="<<concore.retrycount<<endl;
cout<<"min="<<minElapsed<<endl;
cout<<"avg="<<(sumElapsed/Nsim)<<endl;
cout<<"max="<<maxElapsed<<endl;
}