Skip to content

Commit

Permalink
Modified pulp updates to read multiple vertex weights correctly; Chan…
Browse files Browse the repository at this point in the history
…ged vertex_weight_sum and operations for multi vertex weights.
  • Loading branch information
yongescobar committed Jul 21, 2017
1 parent 4c64463 commit 04a23b0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
33 changes: 27 additions & 6 deletions xtrapulp/0.2/dist_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,20 @@ int create_graph(dist_graph_t* g,
if (vertex_weights != NULL)
{
g->vertex_weights = vertex_weights;
g->vertex_weights_sum = 0;
for (uint64_t i = 0; i < g->n_local; ++i)
g->vertex_weights_sum += g->vertex_weights[i];

for (int wc = 0; wc < g->vertex_weights_num; ++wc)
{
g->vertex_weights_sum[wc] = 0;
}

for (uint64_t i = 0; i < g->n_local; ++i)
{
for (int wc = 0; wc < g->vertex_weights_num; ++wc)
{
g->vertex_weights_sum[wc] += g->vertex_weights[i*(g->vertex_weights_num) + wc];
}
}

MPI_Allreduce(MPI_IN_PLACE, &g->vertex_weights_sum, 1,
MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD);
}
Expand Down Expand Up @@ -283,9 +294,19 @@ int create_graph_serial(dist_graph_t* g,
if (vertex_weights != NULL)
{
g->vertex_weights = vertex_weights;
g->vertex_weights_sum = 0;
for (uint64_t i = 0; i < g->n; ++i)
g->vertex_weights_sum += g->vertex_weights[i];

for (int wc = 0; wc < g->vertex_weights_num; ++wc)
{
g->vertex_weights_sum[wc] = 0;
}

for (uint64_t i = 0; i < g->n_local; ++i)
{
for (int wc = 0; wc < g->vertex_weights_num; ++wc)
{
g->vertex_weights_sum[wc] += g->vertex_weights[i*(g->vertex_weights_num) + wc];
}
}
}
else g->vertex_weights = NULL;
if (edge_weights != NULL) g->edge_weights = edge_weights;
Expand Down
8 changes: 4 additions & 4 deletions xtrapulp/0.2/pulp_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ void clear_thread_pulp(thread_pulp_t* tp)
//if (debug) printf("Task %d clear_thread_pulp() success\n", procid);
}

void init_pulp_data(dist_graph_t* g, pulp_data_t* pulp, int32_t num_parts)
void init_pulp_data(dist_graph_t* g, pulp_data_t* pulp, int32_t num_parts, uint64_t wc)
{
if (debug) printf("Task %d init_pulp_data() start\n", procid);

pulp->num_parts = num_parts;
if (g->edge_weights == NULL && g->vertex_weights == NULL)
pulp->avg_size = (double)g->n / (double)pulp->num_parts;
else
pulp->avg_size = (double)g->vertex_weights_sum / (double)pulp->num_parts;
pulp->avg_size = (double)g->vertex_weights_sum[wc] / (double)pulp->num_parts;
pulp->avg_edge_size = (double)g->m*2 / (double)pulp->num_parts;
pulp->avg_cut_size = 0.0;
pulp->max_v = 0.0;
Expand Down Expand Up @@ -194,7 +194,7 @@ void update_pulp_data(dist_graph_t* g, pulp_data_t* pulp)
}
}

void update_pulp_data_weighted(dist_graph_t* g, pulp_data_t* pulp)
void update_pulp_data_weighted(dist_graph_t* g, pulp_data_t* pulp, uint64_t wc)
{
bool has_vwgts = (g->vertex_weights != NULL);
bool has_ewgts = (g->edge_weights != NULL);
Expand All @@ -215,7 +215,7 @@ void update_pulp_data_weighted(dist_graph_t* g, pulp_data_t* pulp)
uint64_t vert_index = i;
int32_t part = pulp->local_parts[vert_index];
if (has_vwgts)
pulp->part_sizes[part] += g->vertex_weights[vert_index];
pulp->part_sizes[part] += g->vertex_weights[vert_index*(g->vertex_weights_num) + wc];
else
++pulp->part_sizes[part];

Expand Down
4 changes: 2 additions & 2 deletions xtrapulp/0.2/pulp_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ void init_thread_pulp(thread_pulp_t* tp, pulp_data_t* pulp);

void clear_thread_pulp(thread_pulp_t* tp);

void init_pulp_data(dist_graph_t* g, pulp_data_t* pulp, int32_t num_parts);
void init_pulp_data(dist_graph_t* g, pulp_data_t* pulp, int32_t num_parts, uint64_t wc = 0);

void update_pulp_data(dist_graph_t* g, pulp_data_t* pulp);

void update_pulp_data_weighted(dist_graph_t* g, pulp_data_t* pulp);
void update_pulp_data_weighted(dist_graph_t* g, pulp_data_t* pulp, uint64_t wc = 0);

void clear_pulp_data(pulp_data_t* pulp);

Expand Down
10 changes: 5 additions & 5 deletions xtrapulp/0.2/pulp_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ int pulp_v_weighted(dist_graph_t* g, mpi_data_t* comm, queue_data_t* q,
pulp_data_t *pulp,
uint64_t outer_iter,
uint64_t balance_iter, uint64_t refine_iter,
double vert_balance, double edge_balance, int index)
double vert_balance, double edge_balance, int wc)
{
if (debug) { printf("Task %d pulp_v_weighted() start\n", procid); }
double elt = 0.0;
Expand All @@ -486,9 +486,9 @@ int pulp_v_weighted(dist_graph_t* g, mpi_data_t* comm, queue_data_t* q,
elt = omp_get_wtime();
}

// prints out whatever vertices and weights each process has
/* prints out vertex weights for each process
int jump = 0;
/*std::cout << "This process has: " << g->n_local << " vertices, each with " << g->vertex_weights_num << " weights. The weights this graph has is: " << std::endl;
std::cout << "This process has: " << g->n_local << " vertices, each with " << g->vertex_weights_num << " weights. The weights this graph has is: " << std::endl;
for(int i = 0; i < g->vertex_weights_num * (g->n_local); ++i)
{
std::cout << g->vertex_weights[i] << " ";
Expand Down Expand Up @@ -569,7 +569,7 @@ for (uint64_t cur_outer_iter = 0; cur_outer_iter < outer_iter; ++cur_outer_iter)
int32_t part = pulp->local_parts[vert_index];
int32_t vert_weight = 1;

if (has_vwgts) vert_weight = g->vertex_weights[vert_index * g->vertex_weights_num +index];
if (has_vwgts) vert_weight = g->vertex_weights[vert_index * g->vertex_weights_num + wc];
//std::cout << "Vertex Weight used for index " << vert_index << ": " << vert_weight << std::endl;

//resets the count of each partition's size
Expand Down Expand Up @@ -751,7 +751,7 @@ for (uint64_t cur_outer_iter = 0; cur_outer_iter < outer_iter; ++cur_outer_iter)
{
int32_t part = pulp->local_parts[vert_index];
int32_t vert_weight = 1;
if (has_vwgts) vert_weight = g->vertex_weights[vert_index * g->vertex_weights_num +index];
if (has_vwgts) vert_weight = g->vertex_weights[vert_index * g->vertex_weights_num + wc];

for (int32_t p = 0; p < pulp->num_parts; ++p)
tp.part_counts[p] = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion xtrapulp/0.2/xtrapulp.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct dist_graph_t {

int32_t* vertex_weights;
int32_t* edge_weights;
uint64_t vertex_weights_sum;
uint64_t* vertex_weights_sum;
uint64_t vertex_weights_num;

uint64_t* local_unmap;
Expand Down

0 comments on commit 04a23b0

Please sign in to comment.