Repository navigation
Expand file tree
/
Copy pathbulksync_functional_test.cpp
More file actions
101 lines (79 loc) · 2.77 KB
/
Copy pathbulksync_functional_test.cpp
File metadata and controls
101 lines (79 loc) · 2.77 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
/**
* @file
* @author Aapo Kyrola <[email protected]>
* @version 1.0
*
* @section LICENSE
*
* Copyright [2012] [Aapo Kyrola, Guy Blelloch, Carlos Guestrin / Carnegie Mellon University]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @section DESCRIPTION
*
* Simple smoke test for the bulk synchronous functional api.
*/
#define RANDOMRESETPROB 0.15
#include <string>
#include <fstream>
#include <cmath>
#include "util/cmdopts.hpp"
#include "api/graphchi_context.hpp"
#include "api/graph_objects.hpp"
#include "api/ischeduler.hpp"
#include "api/functional/functional_api.hpp"
#include "metrics/metrics.hpp"
#include "metrics/reps/basic_reporter.hpp"
#include "util/toplist.hpp"
using namespace graphchi;
struct smoketest_program : public functional_kernel<int, int> {
/* Initial value - on first iteration */
int initial_value(graphchi_context &info, vertex_info& myvertex) {
return 0;
}
/* Called before first "gather" */
int reset() {
return 0;
}
// Note: Unweighted version, edge value should also be passed
// "Gather"
int op_neighborval(graphchi_context &info, vertex_info& myvertex, vid_t nbid, int nbval) {
assert(nbval == (int) info.iteration - 1);
return nbval;
}
// "Sum"
int plus(int curval, int toadd) {
assert(curval == 0 || toadd == curval);
return toadd;
}
// "Apply"
int compute_vertexvalue(graphchi_context &ginfo, vertex_info& myvertex, int nbvalsum) {
return ginfo.iteration;
}
// "Scatter
int value_to_neighbor(graphchi_context &info, vertex_info& myvertex, vid_t nbid, int myval) {
assert(myval == (int) info.iteration);
return myval;
}
};
int main(int argc, const char ** argv) {
graphchi_init(argc, argv);
metrics m("test-functional");
std::string filename = get_option_string("file");
int niters = get_option_int("niters", 5);
std::string mode = get_option_string("mode", "semisync");
logstream(LOG_INFO) << "Running bulk sync smoke test." << std::endl;
run_functional_unweighted_synchronous<smoketest_program>(filename, niters, m);
logstream(LOG_INFO) << "Smoketest passed successfully! Your system is working!" << std::endl;
return 0;
}