diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 78fb1fcefe78e8a695ea479d1f738fac922cdea0..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.gdb_history diff --git a/include/pass_mpi_collective.hpp b/include/pass_mpi_collective.hpp index 73fe91feb6a4fab05089186096c9b18305fe23e2..01e895493643b78eec7f5237b69ea2b207a1b211 100644 --- a/include/pass_mpi_collective.hpp +++ b/include/pass_mpi_collective.hpp @@ -94,8 +94,12 @@ public: //post-dom set of same-rank collectives bool __is_pd_set_mpi_coll_rank(function *fun, basic_block bb, int rank - , int mpi_code, bitmap pd); - bitmap_head __get_set_mpi_coll_rank(function *fun, int rank, int mpi_code); + + , int mpi_code, bitmap pds); + bitmap_head get_set_mpi_coll_rank(function *fun, int rank, int mpi_code); + + //post-dom set frontier + bitmap_head get_frontier_from_pds(function *fun, bitmap pds); void better_rank_collective(function *fun); int __better_rank_collective(basic_block bb, diff --git a/src/pass_mpi_collective.cpp b/src/pass_mpi_collective.cpp index 660caf4bc7c7beef94739fa7f0646843dff30ded..69e43ad574df8518c41420cee3549cf4b2523640 100644 --- a/src/pass_mpi_collective.cpp +++ b/src/pass_mpi_collective.cpp @@ -71,9 +71,13 @@ unsigned int pass_mpi_collective::execute(function *fun) rank_collective(fun); //better_rank_collective(fun); - bitmap_head pdbitmap = __get_set_mpi_coll_rank(fun, 2, MPI_BARRIER); + bitmap_head pdbitmap = get_set_mpi_coll_rank(fun, 2, MPI_BARRIER); + debug_bitmap(&pdbitmap); + bitmap_head pdf = get_frontier_from_pds(fun, &pdbitmap); + debug_bitmap(&pdf); + cfgviz_dump(fun, "_split"); free_dom_data(); @@ -591,7 +595,7 @@ void pass_mpi_collective::better_rank_collective(function *fun) } int pass_mpi_collective::__better_rank_collective(basic_block bb, - mpi_collective_code mpi_code, int rank) + mpi_collective_code mpi_code, int rank) { edge e; edge_iterator ei; @@ -632,10 +636,10 @@ int pass_mpi_collective::__better_rank_collective(basic_block bb, } bool pass_mpi_collective::__is_pd_set_mpi_coll_rank(function *fun - , basic_block bb - , int rank - , int mpi_code - , bitmap pds) + , basic_block bb + , int rank + , int mpi_code + , bitmap pds) { edge e; edge_iterator ei; @@ -643,15 +647,19 @@ bool pass_mpi_collective::__is_pd_set_mpi_coll_rank(function *fun //printf("entered bb->index : %i\n",bb->index); ((bb_data *) bb->aux)->mark1 = 1; - if (((bb_data *) bb->aux)->collective_rank[mpi_code] + + if (((bb_data *) bb->aux)->mpi_code == mpi_code + && ((bb_data *) bb->aux)->collective_rank[mpi_code] == rank) //if we are in the pd set { + //printf("They are my people, %i is 1\n", bb->index); bitmap_set_bit(pds, bb->index); return true; } if (bb == EXIT_BLOCK_PTR_FOR_FN(fun)) { + //printf("Exit block ; %i is 0\n", bb->index); return false; } @@ -682,6 +690,7 @@ bool pass_mpi_collective::__is_pd_set_mpi_coll_rank(function *fun if (count_edges == 0) { + //printf("Leaf ; %i is 0\n", bb->index); return false; //we are in a leaf } @@ -693,9 +702,10 @@ bool pass_mpi_collective::__is_pd_set_mpi_coll_rank(function *fun return is_pd_by_set; } -bitmap_head pass_mpi_collective::__get_set_mpi_coll_rank(function *fun - , int rank - , int mpi_code) + +bitmap_head pass_mpi_collective::get_set_mpi_coll_rank(function *fun + , int rank + , int mpi_code) { bitmap_head set_post_dommed; bitmap_initialize(&set_post_dommed, &bitmap_default_obstack); @@ -705,11 +715,58 @@ bitmap_head pass_mpi_collective::__get_set_mpi_coll_rank(function *fun return set_post_dommed; } + +bitmap_head pass_mpi_collective::get_frontier_from_pds(function *fun + , bitmap pds) +{ + //we check each bb, if a bb is in the postdom set, we check its + //most adjacents preds. If a pred is not in the postdom set, it + //is a elm of the frontier of set. + basic_block bb; + edge e; + edge_iterator ei; + + bitmap_head pdf; + bitmap_initialize(&pdf, &bitmap_default_obstack); + + FOR_ALL_BB_FN(bb, fun) + { + if (bitmap_bit_p(pds, bb->index)) + { + printf("entering %i\n", bb->index); + FOR_EACH_EDGE(e, ei, bb->preds) + { + printf("\tchecking out my parent %i\n", e->src->index); + if (!bitmap_bit_p(pds, e->src->index)) + { + bitmap_set_bit(&pdf, e->src->index); + } + } + } + } + return pdf; +} +/* +void pass_mpi_collective::raise_warning_if_mpi_very_wrong(function *fun) +{ + for (int mpi_code = 0; mpi_code < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; + ++mpi_code) + { + unsigned int i; + bitmap_head pdf; + do + { + pdf = get_set_mpi_coll_rank(fun, i, mpi_code) + if bit + while () + } +} +*/ //============================ GRAPHVIZ ===================================== /* Build a filename (as a string) based on function name */ char *pass_mpi_collective::cfgviz_generate_filename(function *fun, - const char *suffix) + const char *suffix) { char *target_filename; int line; diff --git a/test/test b/test/test new file mode 100755 index 0000000000000000000000000000000000000000..7ed21381c1fcad565569d9392156f4385df00542 Binary files /dev/null and b/test/test differ diff --git a/test/test2 b/test/test2 new file mode 100755 index 0000000000000000000000000000000000000000..ada2e70dd8cbd006dc49777195a1d4f561092d78 Binary files /dev/null and b/test/test2 differ diff --git a/test/test3 b/test/test3 new file mode 100755 index 0000000000000000000000000000000000000000..ad5f88dcd881128bd4077c115b29efe9c490478d Binary files /dev/null and b/test/test3 differ