forked from CGCL-codes/DGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrundemo.cpp
More file actions
57 lines (48 loc) · 1.22 KB
/
rundemo.cpp
File metadata and controls
57 lines (48 loc) · 1.22 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
#include "api.h"
#include "debug.h"
#include <iostream>
#include <string>
using namespace std;
class Demo : public SccDagApp<long long>
{
public:
Demo(string dir, string value_dir): SccDagApp(dir, string("demo_value.bin"), value_dir){};
void init(ID id, value_t &value)
{
value = (long long)id;
}
bool update(ID virtual_id, typename SccDagApp::bor_t inbor, typename SccDagApp::bor_t outbor,
bor_cnt_t in_cnt, bor_cnt_t out_cnt, const values_t rvalue, values_t wvalue)
{
long long x = 0;
for(ID i = 0; i < in_cnt; i++)
x += rvalue[inbor[i]];
x = out_cnt == 0 ? 0 : (x + out_cnt) % out_cnt;
wvalue[virtual_id] = x;
return (x == rvalue[virtual_id]);
}
};
int main(int argc, char *argv[])
{
if (argc != 3)
{
cout << "Usage ./rundemo <data dir> <generate value to dir>" << endl;
return 0;
}
string dir(argv[1]), to_dir(argv[2]);
///*
cout << "serial run"; get_time(false);
Demo demo1(dir, to_dir);
demo1.reset();
demo1.normal_para_run();
get_time(); cout << endl;
demo1.print_top(10);
//*/
cout << "para run"; get_time(false);
Demo demo2(dir, to_dir);
demo2.reset();
demo2.para_run();
get_time(); cout << endl;
demo2.print_top(10);
return 0;
}