Skip to content
Extraits de code Groupes Projets
Valider 39519d89 rédigé par Nicolas MARIE's avatar Nicolas MARIE
Parcourir les fichiers

rank collectives sequences

parent c1737900
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -30,6 +30,7 @@ struct bb_data ...@@ -30,6 +30,7 @@ struct bb_data
std::set<basic_block> dom_front; std::set<basic_block> dom_front;
std::set<basic_block> post_dom_front; std::set<basic_block> post_dom_front;
int mark; // for graph parkour int mark; // for graph parkour
int collective_rank;
}; };
struct edge_data struct edge_data
...@@ -78,6 +79,11 @@ public: ...@@ -78,6 +79,11 @@ public:
void mark_edge(function *fun); void mark_edge(function *fun);
void mark_edge(basic_block bb, int mark); void mark_edge(basic_block bb, int mark);
// rank definition
void rank_collective(function *fun);
int rank_collective(basic_block bb,
mpi_collective_code mpi_code, int rank);
private: private:
// MPI function / collectives detections // MPI function / collectives detections
bool __is_mpi_func(gimple *stmt); bool __is_mpi_func(gimple *stmt);
......
...@@ -66,6 +66,8 @@ unsigned int pass_mpi_collective::execute(function *fun) ...@@ -66,6 +66,8 @@ unsigned int pass_mpi_collective::execute(function *fun)
mark_edge(fun); mark_edge(fun);
reset_bb_mark(fun); reset_bb_mark(fun);
rank_collective(fun);
cfgviz_dump(fun, "_split"); cfgviz_dump(fun, "_split");
free_dom_data(); free_dom_data();
...@@ -98,7 +100,8 @@ void pass_mpi_collective::print_tree(function *fun) ...@@ -98,7 +100,8 @@ void pass_mpi_collective::print_tree(function *fun)
{ {
printf("\t\t\tStatement is a MPI function call (%s)\n", printf("\t\t\tStatement is a MPI function call (%s)\n",
fndecl_name(gimple_call_fndecl(stmt))); fndecl_name(gimple_call_fndecl(stmt)));
if (__is_mpi_collec(stmt) != LAST_AND_UNUSED_MPI_COLLECTIVE_CODE) if (__is_mpi_collec(stmt)
!= LAST_AND_UNUSED_MPI_COLLECTIVE_CODE)
{ {
printf("\t\t\t\tStatement is a MPI collective (%s)\n", printf("\t\t\t\tStatement is a MPI collective (%s)\n",
fndecl_name(gimple_call_fndecl(stmt))); fndecl_name(gimple_call_fndecl(stmt)));
...@@ -131,15 +134,13 @@ mpi_collective_code pass_mpi_collective::__is_mpi_collec(gimple *stmt) ...@@ -131,15 +134,13 @@ mpi_collective_code pass_mpi_collective::__is_mpi_collec(gimple *stmt)
size_t i; size_t i;
const char *callee_name; const char *callee_name;
i = 0;
callee_name = fndecl_name(gimple_call_fndecl(stmt)); callee_name = fndecl_name(gimple_call_fndecl(stmt));
while (i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE) for (i = 0; i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; ++i)
{ {
if (strcmp(mpi_collective_name[i], callee_name) == 0) if (strcmp(mpi_collective_name[i], callee_name) == 0)
{ {
return (enum mpi_collective_code) i; return (enum mpi_collective_code) i;
} }
++i;
} }
return LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; return LAST_AND_UNUSED_MPI_COLLECTIVE_CODE;
} }
...@@ -419,16 +420,60 @@ void pass_mpi_collective::mark_edge(basic_block bb, int mark) ...@@ -419,16 +420,60 @@ void pass_mpi_collective::mark_edge(basic_block bb, int mark)
{ {
((edge_data *) e->aux)->loop = true; ((edge_data *) e->aux)->loop = true;
} }
if (((bb_data *) bb_dest->aux)->mark == 0)
{
mark_edge(bb_dest, mark + 1);
}
}
} }
FOR_EACH_EDGE(e, ei, bb->succs) void pass_mpi_collective::rank_collective(function *fun)
{ {
bb_dest = e->dest; size_t i;
if (((bb_data *) bb_dest->aux)->mark == 0) int next_rank = 1;
for (i = 0; i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; ++i)
{ {
mark_edge(bb_dest, mark + 1); next_rank = rank_collective(EXIT_BLOCK_PTR_FOR_FN(fun),
(enum mpi_collective_code) i, next_rank);
reset_bb_mark(fun);
} }
} }
int pass_mpi_collective::rank_collective(basic_block bb,
mpi_collective_code mpi_code, int rank)
{
edge e;
edge_iterator ei;
int next_rank;
next_rank = rank;
FOR_EACH_EDGE(e, ei, bb->preds)
{
if (((edge_data *) e->aux)->loop)
{
continue;
}
if (((bb_data *) e->src->aux)->mark)
{
//printf("caching from %d to %d\n", e->src->index, bb->index);
next_rank = std::max(next_rank,
((bb_data *) e->src->aux)->mark);
}
else
{
//printf("going from %d to %d\n", e->src->index, bb->index);
next_rank = std::max(next_rank,
rank_collective(e->src, mpi_code, rank));
}
}
if (((bb_data *) bb->aux)->mpi_code == mpi_code)
{
((bb_data *) bb->aux)->collective_rank = next_rank;
next_rank++;
}
((bb_data *) bb->aux)->mark = next_rank;
return next_rank;
} }
//============================ GRAPHVIZ ===================================== //============================ GRAPHVIZ =====================================
...@@ -471,8 +516,8 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out) ...@@ -471,8 +516,8 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out)
fprintf(out, "%d [label=\"BB %d", bb->index, bb->index); fprintf(out, "%d [label=\"BB %d", bb->index, bb->index);
if (data->mpi_code != LAST_AND_UNUSED_MPI_COLLECTIVE_CODE) if (data->mpi_code != LAST_AND_UNUSED_MPI_COLLECTIVE_CODE)
{ {
fprintf(out, "|%s (%d) ", mpi_collective_name[data->mpi_code],
fprintf(out, "|%s", mpi_collective_name[data->mpi_code]); data->collective_rank);
} }
if (! data->dom.empty()) if (! data->dom.empty())
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter