diff --git a/include/pass_mpi_collective.hpp b/include/pass_mpi_collective.hpp index 01e895493643b78eec7f5237b69ea2b207a1b211..b26df08071ce5b3ede9ed9327ff5beb056283780 100644 --- a/include/pass_mpi_collective.hpp +++ b/include/pass_mpi_collective.hpp @@ -47,8 +47,10 @@ class pass_mpi_collective : public opt_pass { public: + int *collective_max_rank; pass_mpi_collective(gcc::context *ctxt); + ~pass_mpi_collective(); pass_mpi_collective *clone(); bool gate(function *fun); diff --git a/src/pass_mpi_collective.cpp b/src/pass_mpi_collective.cpp index 69e43ad574df8518c41420cee3549cf4b2523640..b781025fa71c2aaa96dc24bed9e9955444a7b8cd 100644 --- a/src/pass_mpi_collective.cpp +++ b/src/pass_mpi_collective.cpp @@ -36,7 +36,20 @@ const pass_data my_pass_data = // Class functions pass_mpi_collective::pass_mpi_collective(gcc::context *ctxt) - : opt_pass(my_pass_data, ctxt) {} + : opt_pass(my_pass_data, ctxt) +{ + collective_max_rank = + new int[(int) LAST_AND_UNUSED_MPI_COLLECTIVE_CODE]; + for (int i = 0; i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; ++i) + { + collective_max_rank[i] = 0; + } +} + +pass_mpi_collective::~pass_mpi_collective() +{ + delete collective_max_rank; +} pass_mpi_collective *pass_mpi_collective::clone() { @@ -575,6 +588,9 @@ void pass_mpi_collective::__rank_collective(basic_block bb) if (((bb_data *) bb->aux)->mpi_code == mpi_code) { ((bb_data *) bb->aux)->collective_rank[mpi_code]++; + collective_max_rank[mpi_code] = std::max( + collective_max_rank[mpi_code], + ((bb_data *) bb->aux)->collective_rank[mpi_code]); } } } @@ -595,7 +611,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; @@ -636,10 +652,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; @@ -647,7 +663,6 @@ 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)->mpi_code == mpi_code && ((bb_data *) bb->aux)->collective_rank[mpi_code] == rank) //if we are in the pd set @@ -702,10 +717,9 @@ 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) + , int rank + , int mpi_code) { bitmap_head set_post_dommed; bitmap_initialize(&set_post_dommed, &bitmap_default_obstack); @@ -717,7 +731,7 @@ bitmap_head pass_mpi_collective::get_set_mpi_coll_rank(function *fun } bitmap_head pass_mpi_collective::get_frontier_from_pds(function *fun - , bitmap pds) + , 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 @@ -750,12 +764,12 @@ bitmap_head pass_mpi_collective::get_frontier_from_pds(function *fun 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) + ++mpi_code) { unsigned int i; - bitmap_head pdf; + bitmap_head pdf; do - { + { pdf = get_set_mpi_coll_rank(fun, i, mpi_code) if bit while () @@ -766,7 +780,7 @@ void pass_mpi_collective::raise_warning_if_mpi_very_wrong(function *fun) /* 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;