forked from the-data-lab/GraphOne
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
162 lines (152 loc) · 5.49 KB
/
main.cpp
File metadata and controls
162 lines (152 loc) · 5.49 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
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; //system thread count
vid_t _global_vcount = 0; //global vertex count
index_t _edge_count = 0; // edge count
int _dir = 0;//undirected, 1 is the graph is directed
int _persist = 0;//no, if persist the edge log to out directory
int _source = 0;//text, data source type. 0 for text files, 1 for binary files
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': // get vertex count
#ifdef B64
sscanf(optarg, "%ld", &_global_vcount);
#elif B32
sscanf(optarg, "%d", &_global_vcount);
#endif
cout << "Global vcount = " << _global_vcount << endl;
break;
case 'h': //help
print_usage();
return 0;
break;
case 'i': //input directory, graph data comes from
idir = optarg;
cout << "input dir = " << idir << endl;
break;
case 'c': //plain or multi-graph, default plain .
category = atoi(optarg);
break;
case 'j': //job type
job = atoi(optarg);
break;
case 'o': //out put diretory, this option will also persist edge log
odir = optarg;
_persist = 1; // persist the edge log
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': // edge count
sscanf(optarg, "%ld", &_edge_count);
break;
case 'd': //direction, 0 for undirected, 1 for directed, 2 for uni-directed
sscanf(optarg, "%d", &_dir);
break;
case 's': // source graph data type, 0 for text files, 1 for binary files
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); //set out directory.
switch (category) {
case 0: //default
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;
}