-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrape_connector.cpp
More file actions
212 lines (194 loc) · 6.36 KB
/
Copy pathgrape_connector.cpp
File metadata and controls
212 lines (194 loc) · 6.36 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
//@HEADER
// *****************************************************************************
//
// XtraPuLP: Xtreme-Scale Graph Partitioning using Label Propagation
// Copyright (2016) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact George M. Slota (gmslota@sandia.gov)
// Siva Rajamanickam (srajama@sandia.gov)
// Kamesh Madduri (madduri@cse.psu.edu)
//
// *****************************************************************************
//@HEADER
*/
#include <getopt.h>
#include <mpi.h>
#include <omp.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <time.h>
#include <time.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <thread>
#include "xtrapulp.h"
#include "grape_connector.h"
#include "comms.h"
#include "dist_graph.h"
#include "generate.h"
#include "io_pp.h"
#include "pulp_util.h"
#include "util.h"
namespace pulp {
#ifdef VID_64BIT
#define EFFORMAT "%I64u%I64u%n\n"
#else
#define EFFORMAT "%u%u%n\n"
#endif
MPI_Comm pulp_comm;
void grape_connector(MPI_Comm comm_, int workernum, int workerID, int partnum,
std::vector<VertexID> input_edges, int32_t*& final_parts,
uint64_t& total_vnum, uint64_t file_size, double vert_balance,
double edge_balance) {
srand(time(0));
setbuf(stdout, 0);
verbose = false;
debug = false;
verify = false;
// time_t start_time, end_time;
char input_filename[1024];
input_filename[0] = '\0';
char graphname[1024];
graphname[0] = '\0';
char ouput_graph[] = "output.path";
char* graph_name = ouput_graph;
nprocs = workernum;
procid = workerID;
pulp_comm = comm_;
MPI_Barrier(pulp_comm);
char num_parts_str[10];
sprintf(num_parts_str, "%d", partnum);
char parts_out[1024];
parts_out[0] = '\0';
char parts_in[1024];
parts_in[0] = '\0';
strcat(input_filename, graph_name);
int32_t num_parts = partnum;
if (vert_balance <= 1) {
LOG(INFO) << "vert_balance should be larger than 1";
LOG(INFO) << "original vert_balance is " << vert_balance
<< " which is not larger than 1";
LOG(INFO) << "vert_balance is changed to default value(1.1)";
vert_balance = 1.1;
}
if (edge_balance <= 1) {
LOG(INFO) << "edge_balance should be larger than 1";
LOG(INFO) << "original edge_balance is " << vert_balance
<< " which is not larger than 1";
LOG(INFO) << "edge_balance is changed to default value(1.1)";
edge_balance = 1.1;
}
uint64_t num_runs = 1;
// bool output_time = true;
bool output_quality = false;
// bool gen_rmat = false;
// bool gen_rand = false;
// bool gen_hd = false;
// uint64_t gen_n = 0;
// uint64_t gen_m_per_n = 16;
bool offset_vids = false;
int pulp_seed = rand();
bool do_bfs_init = true;
bool do_lp_init = false;
bool do_repart = false;
bool do_edge_balance = true;
bool do_maxcut_balance = false;
// VertexID* origin_edges;
uint64_t edge_num = input_edges.size() / 2;
// char c;
graph_gen_data_t ggi;
dist_graph_t g;
pulp_part_control_t ppc = {vert_balance, edge_balance, do_lp_init,
do_bfs_init, do_repart, do_edge_balance,
do_maxcut_balance, false, pulp_seed};
mpi_data_t comm;
init_comm_data(&comm);
// double elt = omp_get_wtime();
strcat(graphname, input_filename);
pulp::load_graph_edges_32(input_edges, &ggi, offset_vids, file_size,
&edge_num, total_vnum);
if (nprocs > 1) {
exchange_edges(&ggi, &comm);
create_graph(&ggi, &g);
relabel_edges(&g);
} else {
create_graph_serial(&ggi, &g);
}
queue_data_t q;
init_queue_data(&g, &q);
get_ghost_degrees(&g, &comm, &q);
pulp_data_t pulp;
init_pulp_data(&g, &pulp, num_parts);
double total_elt = 0.0;
for (uint32_t i = 0; i < num_runs; ++i) {
double elt = 0.0;
if (parts_in[0] != '\0') {
elt = omp_get_wtime();
read_parts(parts_in, &g, &pulp, offset_vids);
}
elt = omp_get_wtime();
xtrapulp(&g, &ppc, &comm, &pulp, &q);
total_elt += omp_get_wtime() - elt;
if (output_quality) {
part_eval(&g, &pulp);
}
char temp_out[1024];
temp_out[0] = '\0';
strcat(temp_out, parts_out);
if (strlen(temp_out) == 0) {
strcat(temp_out, graph_name);
strcat(temp_out, ".parts.");
strcat(temp_out, num_parts_str);
}
if (num_runs > 1) {
std::stringstream ss;
ss << "." << i;
strcat(temp_out, ss.str().c_str());
}
elt = omp_get_wtime();
output_parts(temp_out, &g, pulp.local_parts, offset_vids, final_parts);
}
clear_graph(&g);
clear_comm_data(&comm);
clear_queue_data(&q);
MPI_Barrier(pulp_comm);
return;
}
void FinalizeXtraPulp(int32_t *&final_parts) {
free(final_parts);
return;
}
}