-
Notifications
You must be signed in to change notification settings - Fork 31
/
main.cpp
162 lines (152 loc) · 4.94 KB
/
main.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
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
#include <omp.h>
#include <iostream>
#include <getopt.h>
#include <stdlib.h>
#include "graph.h"
#define no_argument 0
#define required_argument 1
#define optional_argument 2
void plain_test(vid_t v_count, const string& idir, const string& odir, int job);
void dist_test(vid_t v_count, const string& idir, const string& odir, int job);
void multigraph_test(vid_t v_count, const string& idir, const string& odir, int job);
void lubm_test(const string& typefile, const string& idir, const string& odir, int job);
void ldbc_test(const string& conf_file, const string& idir, const string& odir, int job);
void darshan_test0(const string& conf_file, const string& idir, const string& odir);
index_t residue = 0;
int THD_COUNT = 0;
vid_t _global_vcount = 0;
index_t _edge_count = 0;
int _dir = 0;//undirected
int _persist = 0;//no
int _source = 0;//text
void print_usage()
{
string help = "./exe options.\n";
help += " --help -h: This message.\n";
help += " --vcount -v: Vertex count\n";
help += " --edgecount -e: Edge count, required only for streaming analytics as exit criteria.\n";
help += " --idir -i: input directory\n";
help += " --odir -o: output directory. This option will also persist the edge log.\n";
//help += " --category -c: 0 for single stream graphs. Default: 0\n";
help += " --job -j: job number. Default: 0\n";
help += " --threadcount --t: Thread count. Default: Cores in your system - 1\n";
help += " --direction -d: Direction, 0 for undirected, 1 for directed, 2 for unidirected. Default: 0(undirected)\n";
help += " --source -s: Data source. 0 for text files, 1 for binary files. Default: text files\n";
help += " --residue or -r: Various meanings.\n";
cout << help << endl;
}
graph* g;
int main(int argc, char* argv[])
{
const struct option longopts[] =
{
{"vcount", required_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"idir", required_argument, 0, 'i'},
{"odir", required_argument, 0, 'o'},
{"category", required_argument, 0, 'c'},
{"job", required_argument, 0, 'j'},
{"residue", required_argument, 0, 'r'},
{"qfile", required_argument, 0, 'q'},
{"fileconf", required_argument, 0, 'f'},
{"threadcount", required_argument, 0, 't'},
{"edgecount", required_argument, 0, 'e'},
{"direction", required_argument, 0, 'd'},
{"source", required_argument, 0, 's'},
{0, 0, 0, 0},
};
int o;
int index = 0;
string typefile, idir, odir;
string queryfile;
int category = 0;
int job = 0;
THD_COUNT = omp_get_max_threads()-1;// - 3;
//int i = 0;
//while (i < 100000) { usleep(10); ++i; }
g = new graph;
while ((o = getopt_long(argc, argv, "i:c:j:o:q:t:f:r:v:e:d:s:h", longopts, &index)) != -1) {
switch(o) {
case 'v':
#ifdef B64
sscanf(optarg, "%ld", &_global_vcount);
#elif B32
sscanf(optarg, "%d", &_global_vcount);
#endif
cout << "Global vcount = " << _global_vcount << endl;
break;
case 'h':
print_usage();
return 0;
break;
case 'i':
idir = optarg;
cout << "input dir = " << idir << endl;
break;
case 'c':
category = atoi(optarg);
break;
case 'j':
job = atoi(optarg);
break;
case 'o':
odir = optarg;
_persist = 1;
cout << "output dir = " << odir << endl;
break;
case 'q':
queryfile = optarg;
break;
case 't':
//Thread thing
THD_COUNT = atoi(optarg);
break;
case 'f':
typefile = optarg;
break;
case 'e':
sscanf(optarg, "%ld", &_edge_count);
break;
case 'd':
sscanf(optarg, "%d", &_dir);
break;
case 's':
sscanf(optarg, "%d", &_source);
break;
case 'r':
sscanf(optarg, "%ld", &residue);
cout << "residue (multi-purpose) value) = " << residue << endl;
break;
default:
cout << "invalid input " << endl;
print_usage();
return 1;
}
}
cout << "Threads Count = " << THD_COUNT << endl;
g->set_odir(odir);
switch (category) {
case 0:
plain_test(_global_vcount, idir, odir, job);
break;
case 1:
multigraph_test(_global_vcount, idir, odir, job);
break;
#ifdef B64
case 2:
lubm_test(typefile, idir, odir, job);
break;
case 3:
ldbc_test(typefile, idir, odir, job);
break;
/*
case 5:
darshan_test0(typefile, idir, odir);
break;
*/
#endif
default:
break;
}
return 0;
}