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

implement prof new bad algo for ranking collective

parent 162ea917
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -31,7 +31,7 @@ struct bb_data
std::set<basic_block> post_dom_front;
int mark1; // for graph parkour
int mark2;
int collective_rank;
int *collective_rank;
};
struct edge_data
......@@ -83,7 +83,10 @@ public:
// rank definition
void rank_collective(function *fun);
int __rank_collective(basic_block bb,
void __rank_collective(basic_block bb);
void better_rank_collective(function *fun);
int __better_rank_collective(basic_block bb,
mpi_collective_code mpi_code, int rank);
private:
......
......@@ -66,7 +66,8 @@ unsigned int pass_mpi_collective::execute(function *fun)
alloc_edge_aux(fun);
mark_edge(fun);
rank_collective(fun);
//rank_collective(fun);
better_rank_collective(fun);
cfgviz_dump(fun, "_split");
......@@ -196,6 +197,13 @@ void pass_mpi_collective::alloc_bb_aux(function *fun)
FOR_ALL_BB_FN(bb, fun)
{
bb->aux = (bb_data *) new bb_data();
((bb_data *) bb->aux)->collective_rank =
new int[(int) LAST_AND_UNUSED_MPI_COLLECTIVE_CODE];
for (int i = 0; i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; ++i)
{
((bb_data *) bb->aux)->collective_rank[i] = 0;
}
}
}
......@@ -229,6 +237,7 @@ void pass_mpi_collective::free_bb_aux(function *fun)
{
if (bb->aux != NULL)
{
delete ((bb_data *) bb->aux)->collective_rank;
delete (bb_data *) bb->aux;
bb->aux = NULL;
}
......@@ -390,28 +399,30 @@ void pass_mpi_collective::free_edge_aux(function *fun)
}
// naive version of mark_edge (work but Omax(2^n))
//void pass_mpi_collective::mark_edge(function *fun)
//{
// mark_edge(ENTRY_BLOCK_PTR_FOR_FN(fun));
//}
//
//void pass_mpi_collective::mark_edge(basic_block bb)
//{
// edge e;
// edge_iterator ei;
//
// ((bb_data *) bb->aux)->mark = 1;
// FOR_EACH_EDGE(e, ei, bb->succs)
// {
// if (((bb_data *) e->dest->aux)->mark)
// {
// ((edge_data *) e->aux)->loop = true;
// } else {
// mark_edge(e->dest);
// }
// }
// ((bb_data *) bb->aux)->mark = 0;
//}
void pass_mpi_collective::mark_edge_naif(function *fun)
{
mark_edge(ENTRY_BLOCK_PTR_FOR_FN(fun));
}
void pass_mpi_collective::mark_edge_naif(basic_block bb)
{
edge e;
edge_iterator ei;
((bb_data *) bb->aux)->mark = 1;
FOR_EACH_EDGE(e, ei, bb->succs)
{
if (((bb_data *) e->dest->aux)->mark)
{
((edge_data *) e->aux)->loop = true;
}
else
{
mark_edge(e->dest);
}
}
((bb_data *) bb->aux)->mark = 0;
}
void pass_mpi_collective::mark_edge(function *fun)
{
......@@ -486,20 +497,101 @@ void pass_mpi_collective::mark_edge(function *fun)
reset_bb_mark(fun);
}
// WIP for new mark edge
//struct basic_block_elem {
// bitmap_head seen;
// basic_block bb;
//}
//
//struct basic_block_elem *new_bb_elem(){
// return new
//}
//
//void free_bb_elem(){
//
//}
//
//
//void mark_loop(){
// vect<struct basic_block_elem> pile;
// struct basic_block_elem *first;
//
// first = new_bb_elem();
// first->bb = ENTRY_BLOCK_PTR_FOR_FN(fun);
// pile.push(first);
//
// while(pile.length() != 0){
// // mettre a jour edge & already seen
//
// }
//
//}
//
//void pass_mpi_collective::mark_edge(function *fun)
//{
// edge e;
// edge_iterator ei;
// std::list<basic_block> nodes;
// basic_block bb;
//
//
//
//}
void pass_mpi_collective::rank_collective(function *fun)
{
__rank_collective(EXIT_BLOCK_PTR_FOR_FN(fun));
reset_bb_mark(fun);
}
void pass_mpi_collective::__rank_collective(basic_block bb)
{
edge e;
edge_iterator ei;
((bb_data *) bb->aux)->mark1 = 1;
FOR_EACH_EDGE(e, ei, bb->preds)
{
if (((edge_data *) e->aux)->loop)
{
continue;
}
if (! ((bb_data *) e->src->aux)->mark1)
{
__rank_collective(e->src);
}
for (int mpi_code = 0;
mpi_code < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE;
++mpi_code)
{
((bb_data *) bb->aux)->collective_rank[mpi_code] =
std::max(((bb_data *) bb->aux)->collective_rank[mpi_code],
((bb_data *) e->src->aux)->collective_rank[mpi_code]);
if (((bb_data *) bb->aux)->mpi_code == mpi_code)
{
((bb_data *) bb->aux)->collective_rank[mpi_code]++;
}
}
}
return;
}
void pass_mpi_collective::better_rank_collective(function *fun)
{
size_t i;
int next_rank = 1;
int next_rank = 0;
for (i = 0; i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; ++i)
{
next_rank = __rank_collective(EXIT_BLOCK_PTR_FOR_FN(fun),
next_rank = __better_rank_collective(EXIT_BLOCK_PTR_FOR_FN(fun),
(enum mpi_collective_code) i, next_rank);
reset_bb_mark(fun);
}
reset_bb_mark(fun);
}
int pass_mpi_collective::__rank_collective(basic_block bb,
int pass_mpi_collective::__better_rank_collective(basic_block bb,
mpi_collective_code mpi_code, int rank)
{
edge e;
......@@ -507,6 +599,8 @@ int pass_mpi_collective::__rank_collective(basic_block bb,
int next_rank;
next_rank = rank;
((bb_data *) bb->aux)->mark1 = mpi_code + 1;
FOR_EACH_EDGE(e, ei, bb->preds)
{
if (((edge_data *) e->aux)->loop)
......@@ -515,25 +609,25 @@ int pass_mpi_collective::__rank_collective(basic_block bb,
}
// cache or travell
if (((bb_data *) e->src->aux)->mark1)
if (((bb_data *) e->src->aux)->mark1 <= mpi_code)
{
next_rank = std::max(next_rank,
((bb_data *) e->src->aux)->mark1);
__better_rank_collective(e->src, mpi_code, rank));
}
else
{
next_rank = std::max(next_rank,
__rank_collective(e->src, mpi_code, rank));
((bb_data *) e->src->aux)->collective_rank[mpi_code]);
}
}
// set mpi code
if (((bb_data *) bb->aux)->mpi_code == mpi_code)
{
((bb_data *) bb->aux)->collective_rank = next_rank;
next_rank++;
printf("set rank %d at %d for coll %d\n", next_rank, bb->index, mpi_code);
}
// set mark before recusion
((bb_data *) bb->aux)->mark1 = next_rank;
((bb_data *) bb->aux)->collective_rank[mpi_code] = next_rank;
return next_rank;
}
......@@ -578,7 +672,7 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out)
if (data->mpi_code != LAST_AND_UNUSED_MPI_COLLECTIVE_CODE)
{
fprintf(out, "|%s (%d) ", mpi_collective_name[data->mpi_code],
data->collective_rank);
data->collective_rank[data->mpi_code]);
}
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