diff --git a/Makefile b/Makefile index 813093fc4dfc4d0a8d361b0e4ed3dec40b7e8619..854139eaf8c04b5b4b7e7751ce0084229f7c6170 100644 --- a/Makefile +++ b/Makefile @@ -86,4 +86,4 @@ clean: .PHONY: style style: astyle $(SRCD)/*.cpp ./include/*.hpp -n -A1 -p -xj -J -xg -H -k3 -O -xC80 \ - -t2 -xt1 -m0 + -t4 -xt1 -m0 diff --git a/include/pass_mpi_collective.hpp b/include/pass_mpi_collective.hpp index cbeb7abd22ddea5709bbf692b6ed329e9b7e7c6a..d883b48b360234aa12ac700cd4e7dab4a7093956 100644 --- a/include/pass_mpi_collective.hpp +++ b/include/pass_mpi_collective.hpp @@ -92,22 +92,22 @@ public: void rank_collective(function *fun); 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); + //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 pds); - void get_set_mpi_coll_rank(function *fun, - int rank, int mpi_code, bitmap pds); + bool __is_post_dom_mpi_coll_rank( + function *fun, basic_block bb, int rank, int mpi_code, bitmap pds); + void get_post_dom_mpi_coll_rank( + function *fun, int rank, int mpi_code, bitmap pds); //post-dom set frontier - void get_frontier_from_pds(function *fun, bitmap pds, bitmap pdf); + void get_post_dom_frontier(function *fun, bitmap pds, bitmap pdf); //err warning void raise_warning_if_mpi_wrong(function *fun); - void better_rank_collective(function *fun); - int __better_rank_collective(basic_block bb, - mpi_collective_code mpi_code, int rank); - // GRAPHVIZ char *cfgviz_generate_filename(function *fun, const char *suffix); diff --git a/src/pass_mpi_collective.cpp b/src/pass_mpi_collective.cpp index cd4ac195948bbfcb9776653773d337aa825bca0f..b0a2a163db7142437337a19b0f9de6586263e0a1 100644 --- a/src/pass_mpi_collective.cpp +++ b/src/pass_mpi_collective.cpp @@ -210,13 +210,13 @@ void pass_mpi_collective::split_blocks(function *fun) void pass_mpi_collective::alloc_bb_aux(function *fun) { basic_block bb; - + FOR_ALL_BB_FN(bb, fun) { bb->aux = (bb_data *) new bb_data(); bb_data *data = ((bb_data *) bb->aux); data->mpi_code = LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; - bitmap_initialize(&data->dom, &bitmap_default_obstack); + bitmap_initialize(&data->dom, &bitmap_default_obstack); bitmap_initialize(&data->post_dom, &bitmap_default_obstack); bitmap_initialize(&data->dom_front, &bitmap_default_obstack); bitmap_initialize(&data->post_dom_front, &bitmap_default_obstack); @@ -586,14 +586,14 @@ void pass_mpi_collective::__rank_collective(basic_block bb) ++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]); + 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]++; - collective_max_rank[mpi_code] = std::max( - collective_max_rank[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]); } } } @@ -614,7 +614,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; @@ -634,14 +634,14 @@ int pass_mpi_collective::__better_rank_collective(basic_block bb, if (((bb_data *) e->src->aux)->mark1 <= mpi_code) { next_rank = - std::max(next_rank, - __better_rank_collective(e->src, mpi_code, rank)); + std::max(next_rank, + __better_rank_collective(e->src, mpi_code, rank)); } else { next_rank = - std::max(next_rank, - ((bb_data *) e->src->aux)->collective_rank[mpi_code]); + std::max(next_rank, + ((bb_data *) e->src->aux)->collective_rank[mpi_code]); } } // set mpi code @@ -653,8 +653,8 @@ int pass_mpi_collective::__better_rank_collective(basic_block bb, return next_rank; } -bool pass_mpi_collective::__is_pd_set_mpi_coll_rank(function *fun, - basic_block bb, int rank, int mpi_code, bitmap pds) +bool pass_mpi_collective::__is_post_dom_mpi_coll_rank(function *fun, + basic_block bb, int rank, int mpi_code, bitmap pds) { edge e; edge_iterator ei; @@ -697,8 +697,8 @@ bool pass_mpi_collective::__is_pd_set_mpi_coll_rank(function *fun, else { is_pd_by_set = - __is_pd_set_mpi_coll_rank(fun, e->dest, rank, mpi_code, pds) - && is_pd_by_set; + __is_post_dom_mpi_coll_rank(fun, e->dest, rank, mpi_code, pds) + && is_pd_by_set; } } @@ -718,16 +718,16 @@ bool pass_mpi_collective::__is_pd_set_mpi_coll_rank(function *fun, return is_pd_by_set; } -void pass_mpi_collective::get_set_mpi_coll_rank(function *fun, - int rank, int mpi_code, bitmap pds) +void pass_mpi_collective::get_post_dom_mpi_coll_rank(function *fun, + int rank, int mpi_code, bitmap pds) { - __is_pd_set_mpi_coll_rank(fun, ENTRY_BLOCK_PTR_FOR_FN(fun), - rank, mpi_code, pds); + __is_post_dom_mpi_coll_rank(fun, ENTRY_BLOCK_PTR_FOR_FN(fun), + rank, mpi_code, pds); reset_bb_mark(fun); } -void pass_mpi_collective::get_frontier_from_pds(function *fun, - bitmap pds, bitmap pdf) +void pass_mpi_collective::get_post_dom_frontier(function *fun, + bitmap pds, bitmap pdf) { //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 @@ -744,7 +744,8 @@ void pass_mpi_collective::get_frontier_from_pds(function *fun, FOR_EACH_EDGE(e, ei, bb->preds) { //printf("\tchecking out my parent %i\n", e->src->index); - if (! ((edge_data *) e->aux)->loop && !bitmap_bit_p(pds, e->src->index)) + if (! ((edge_data *) e->aux)->loop + && !bitmap_bit_p(pds, e->src->index)) { bitmap_set_bit(pdf, e->src->index); } @@ -763,7 +764,7 @@ void pass_mpi_collective::raise_warning_if_mpi_wrong(function *fun) bitmap pds = &pds_head; bitmap pdf = &pdf_head; bitmap tmp = NULL; - + bitmap_initialize(pds, &bitmap_default_obstack); bitmap_initialize(pdf, &bitmap_default_obstack); int stop = 0; @@ -771,28 +772,29 @@ void pass_mpi_collective::raise_warning_if_mpi_wrong(function *fun) for (int i = 1 ; i < collective_max_rank[mpi_code] + 1 ; i++) { printf("mpi_code: %i at rank: %i\n", mpi_code, i); - // TODO: split in 2, get mpi set & find set post dom - get_set_mpi_coll_rank(fun, i, mpi_code, pds); + // TODO: split in 2, get mpi set & find set post dom + get_post_dom_mpi_coll_rank(fun, i, mpi_code, pds); - while(! bitmap_empty_p(pds)){ + while (! bitmap_empty_p(pds)) + { stop++; - if(stop > 10) - return; - get_frontier_from_pds(fun, pds, pdf); - + if (stop > 10) + { return; } + get_post_dom_frontier(fun, pds, pdf); + printf("----\n"); debug_bitmap(pds); debug_bitmap(pdf); bitmap_clear(pds); - + // swap pds & pdf { tmp = pdf; pdf = pds; pds = tmp; } - // pds = + // pds = } } } @@ -802,7 +804,7 @@ void pass_mpi_collective::raise_warning_if_mpi_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; @@ -810,8 +812,8 @@ char *pass_mpi_collective::cfgviz_generate_filename(function *fun, target_filename = (char *)xmalloc(1024 * sizeof(char)); line = LOCATION_LINE(fun->function_start_locus); const char *mfilename = - std::filesystem::path(LOCATION_FILE(fun->function_start_locus)) - .filename().c_str(); + std::filesystem::path(LOCATION_FILE(fun->function_start_locus)) + .filename().c_str(); snprintf(target_filename, 1024, "%s%s_%s_%d_%s.dot", "dot/", @@ -848,9 +850,10 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out) if (! bitmap_empty_p(&data->dom)) { fprintf(out, "|dom("); - - EXECUTE_IF_SET_IN_BITMAP(&data->dom, 0, index, bi){ - fprintf(out, "%d,", index); + + EXECUTE_IF_SET_IN_BITMAP(&data->dom, 0, index, bi) + { + fprintf(out, "%d,", index); } fprintf(out, ")"); } @@ -858,7 +861,8 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out) if (! bitmap_empty_p(&data->post_dom)) { fprintf(out, "|post_dom("); - EXECUTE_IF_SET_IN_BITMAP(&data->post_dom, 0, index, bi){ + EXECUTE_IF_SET_IN_BITMAP(&data->post_dom, 0, index, bi) + { fprintf(out, "%d,", index); } fprintf(out, ")"); @@ -867,7 +871,8 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out) if (! bitmap_empty_p(&data->dom_front)) { fprintf(out, "|dom_front("); - EXECUTE_IF_SET_IN_BITMAP(&data->dom_front, 0, index, bi){ + EXECUTE_IF_SET_IN_BITMAP(&data->dom_front, 0, index, bi) + { fprintf(out, "%d,", index); } fprintf(out, ")"); @@ -876,7 +881,8 @@ void pass_mpi_collective::cfgviz_internal_dump(function *fun, FILE *out) if (! bitmap_empty_p(&data->post_dom_front)) { fprintf(out, "|post_dom_front("); - EXECUTE_IF_SET_IN_BITMAP(&data->post_dom_front, 0, index, bi){ + EXECUTE_IF_SET_IN_BITMAP(&data->post_dom_front, 0, index, bi) + { fprintf(out, "%d,", index); } fprintf(out, ")");