63 printf(
"Task %d load_graph_edges() %s start\n",
procid, input_filename);
68 MPI_Barrier(MPI_COMM_WORLD);
69 elt = omp_get_wtime();
72 FILE *infp = fopen(input_filename,
"rb");
76 fseek(infp, 0L, SEEK_END);
78 fseek(infp, 0L, SEEK_SET);
81 ggi->
m = nedges_global;
87 read_offset_end = 2*
sizeof(
uint32_t)*nedges_global;
89 uint64_t nedges = (read_offset_end - read_offset_start)/8;
93 printf(
"Task %d, read_offset_start %ld, read_offset_end %ld, nedges_global %ld, nedges: %ld\n",
procid, read_offset_start, read_offset_end, nedges_global, nedges);
98 if (gen_edges_read == NULL || gen_edges == NULL)
101 fseek(infp, read_offset_start, SEEK_SET);
102 fread(gen_edges_read, nedges, 2*
sizeof(
uint32_t), infp);
105 for (
uint64_t i = 0; i < nedges*2; ++i)
106 gen_edges[i] = (
uint64_t)gen_edges_read[i];
108 free(gen_edges_read);
112 elt = omp_get_wtime() - elt;
113 printf(
"Task %d read %lu edges, %9.6f (s)\n",
procid, nedges, elt);
118 if (gen_edges[i] > max_n)
119 max_n = gen_edges[i];
122 MPI_Allreduce(&max_n, &n_global, 1, MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD);
131 printf(
"Task %d, n %lu, n_offset %lu, n_local %lu\n",
135 if (
debug) { printf(
"Task %d load_graph_edges() success\n",
procid); }
142 if (
debug) { printf(
"Task %d load_graph_edges() start\n",
procid); }
146 MPI_Barrier(MPI_COMM_WORLD);
147 elt = omp_get_wtime();
150 FILE *infp = fopen(input_filename,
"rb");
154 fseek(infp, 0L, SEEK_END);
156 fseek(infp, 0L, SEEK_SET);
159 ggi->
m = nedges_global;
165 read_offset_end = 2*
sizeof(
uint64_t)*nedges_global;
167 uint64_t nedges = (read_offset_end - read_offset_start)/8;
171 printf(
"Task %d, read_offset_start %ld, read_offset_end %ld, nedges_global %ld, nedges: %ld\n",
procid, read_offset_start, read_offset_end, nedges_global, nedges);
175 if (gen_edges == NULL)
178 fseek(infp, read_offset_start, SEEK_SET);
179 fread(gen_edges, nedges, 2*
sizeof(
uint64_t), infp);
185 elt = omp_get_wtime() - elt;
186 printf(
"Task %d read %ld edges, %9.6f (s)\n",
procid, nedges, elt);
191 if (gen_edges[i] > max_n)
192 max_n = gen_edges[i];
195 MPI_Allreduce(&max_n, &n_global, 1, MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD);
204 printf(
"Task %d, n %lu, n_offset %lu, n_local %lu\n",
208 if (
debug) { printf(
"Task %d load_graph_edges() success\n",
procid); }
214 if (
debug) { printf(
"Task %d exchange_out_edges() start\n",
procid); }
217 MPI_Barrier(MPI_COMM_WORLD);
218 elt = omp_get_wtime();
223 for (
int i = 0; i <
nprocs; ++i)
225 temp_sendcounts[i] = 0;
226 temp_recvcounts[i] = 0;
234 temp_sendcounts[vert_task] += 2;
237 MPI_Alltoall(temp_sendcounts, 1, MPI_UINT64_T,
238 temp_recvcounts, 1, MPI_UINT64_T, MPI_COMM_WORLD);
244 total_recv += temp_recvcounts[i];
245 total_send += temp_sendcounts[i];
247 free(temp_sendcounts);
248 free(temp_recvcounts);
253 fprintf(stderr,
"Task %d Error: exchange_out_edges(), unable to allocate buffer\n",
procid);
254 MPI_Abort(MPI_COMM_WORLD, 1);
257 uint64_t max_transfer = total_send > total_recv ? total_send : total_recv;
259 MPI_Allreduce(MPI_IN_PLACE, &num_comms, 1,
260 MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD);
263 printf(
"Task %d exchange_out_edges() num_comms %lu total_send %lu total_recv %lu\n",
procid, num_comms, total_send, total_recv);
266 for (
uint64_t c = 0; c < num_comms; ++c)
270 if (c == (num_comms-1))
279 for (
int64_t i = send_begin; i < send_end; ++i)
286 MPI_Alltoall(comm->
sendcounts, 1, MPI_INT32_T,
287 comm->
recvcounts, 1, MPI_INT32_T, MPI_COMM_WORLD);
304 fprintf(stderr,
"Task %d Error: exchange_out_edges(), unable to allocate comm buffers",
procid);
305 MPI_Abort(MPI_COMM_WORLD, 1);
308 for (
uint64_t i = send_begin; i < send_end; ++i)
320 MPI_UINT64_T, MPI_COMM_WORLD);
321 sum_recv += cur_recv;
330 elt = omp_get_wtime() - elt;
331 printf(
"Task %d exchange_out_edges() sent %lu, recv %lu, m_local_out %lu, %9.6f (s)\n",
procid, total_send, total_recv, ggi->
m_local_out, elt);
334 if (
debug) { printf(
"Task %d exchange_out_edges() success\n",
procid); }
340 if (
debug) { printf(
"Task %d exchange_in_edges() start\n",
procid); }
343 MPI_Barrier(MPI_COMM_WORLD);
344 elt = omp_get_wtime();
349 for (
int i = 0; i <
nprocs; ++i)
351 temp_sendcounts[i] = 0;
352 temp_recvcounts[i] = 0;
360 temp_sendcounts[vert_task] += 2;
363 MPI_Alltoall(temp_sendcounts, 1, MPI_UINT64_T,
364 temp_recvcounts, 1, MPI_UINT64_T, MPI_COMM_WORLD);
370 total_recv += temp_recvcounts[i];
371 total_send += temp_sendcounts[i];
373 free(temp_sendcounts);
374 free(temp_recvcounts);
379 fprintf(stderr,
"Task %d Error: exchange_in_edges(), unable to allocate buffer\n",
procid);
380 MPI_Abort(MPI_COMM_WORLD, 1);
383 uint64_t max_transfer = total_send > total_recv ? total_send : total_recv;
385 MPI_Allreduce(MPI_IN_PLACE, &num_comms, 1,
386 MPI_UINT64_T, MPI_MAX, MPI_COMM_WORLD);
389 printf(
"Task %d exchange_in_edges() num_comms %li total_send %li total_recv %li\n",
procid, num_comms, total_send, total_recv);
392 for (
int64_t c = 0; c < num_comms; ++c)
396 if (c == (num_comms-1))
405 for (
uint64_t i = send_begin; i < send_end; ++i)
412 MPI_Alltoall(comm->
sendcounts, 1, MPI_INT32_T,
413 comm->
recvcounts, 1, MPI_INT32_T, MPI_COMM_WORLD);
430 fprintf(stderr,
"Task %d Error: exchange_in_edges(), unable to allocate comm buffers\n",
procid);
431 MPI_Abort(MPI_COMM_WORLD, 1);
434 for (
uint64_t i = send_begin; i < send_end; ++i)
446 MPI_UINT64_T, MPI_COMM_WORLD);
447 sum_recv += cur_recv;
455 elt = omp_get_wtime() - elt;
456 printf(
"Task %d exchange_in_edges() sent %ld, recv %ld, m_local_out %ld, %9.6f (s)\n",
procid, total_send, total_recv, ggi->
m_local_out, elt);
459 if (
debug) { printf(
"Task %d exchange_in_edges() success\n",
procid); }