diff --git a/Makefile b/Makefile index 29a2de7f90d944787ffdd3b643e8d40bad9c71ab..3cf988cfb57c553dc87e9c6339ac9f8ce3e37f2a 100644 --- a/Makefile +++ b/Makefile @@ -53,18 +53,19 @@ plugin: test: mkdir -p $(TESTD) mkdir -p $(DOTD) - echo "\n" + echo -e "\n" $(MAKE) $(TESTD)/test - echo "\n" + echo -e "\n" $(MAKE) $(TESTD)/test2 - echo "\n" + echo -e "\n" $(MAKE) $(TESTD)/test3 - echo "\n" + echo -e "\n" $(MAKE) $(TESTD)/test4 - echo "\n" - #$(MAKE) $(TESTD)/test_pragma1 - echo "\n" + echo -e "\n" + $(MAKE) $(TESTD)/test_pragma1 + echo -e "\n" $(MAKE) $(TESTD)/test_pragma2 + echo -e "\n" .PHONY: dots dots: @@ -72,7 +73,7 @@ dots: $(MAKE) $(shell find $(DOTD) -name "*.dot" | sed 's/\.dot/\.svg/') $(TESTD)/%: $(TESTSRCD)/%.c - $(CC) $(GDB_GCC) $(TEST_FLAGS) $(PLUGIN_FLAGS) $^ -o $@ + $(CC) $(GDB_GCC) $(TEST_FLAGS) $(PLUGIN_FLAGS) $^ -o $@ || echo "(exit 1)" $(OBJD)/%.o: $(SRCD)/%.cpp $(CXX) $(FLAGS) $(PLUGIN_INCLUDE) -c $^ -o $@ @@ -93,6 +94,11 @@ clean: rm -rf $(TESTD) rm -rf $(DOTD) +.PHONY: retest +retest: + rm -rf $(TESTD) + $(MAKE) test + .PHONY: style style: astyle $(SRCD)/*.cpp ./include/*.hpp -n -A1 -p -xj -J -xg -H -k3 -O -xC80 \ diff --git a/include/mpi_collective.hpp b/include/mpi_collective.hpp index e9e3bc15681a3057e3c86eb6f428ad750cce3ed8..c6f9e1f64be1bf138621bcac4d745bcc5fa001fa 100644 --- a/include/mpi_collective.hpp +++ b/include/mpi_collective.hpp @@ -1,8 +1,6 @@ #ifndef __MPI_COLLECTIVE_HPP_ #define __MPI_COLLECTIVE_HPP_ - - // dependance of tree-pass.H #include <gcc-plugin.h> // declare opt_pass diff --git a/src/mpi_collective_dominance.cpp b/src/mpi_collective_dominance.cpp index f4fb07c31e7029b21c1b3484c0c1b0f124c838e9..a96112d4ec95b68b4f0ce9c9570ee4a219336860 100644 --- a/src/mpi_collective_dominance.cpp +++ b/src/mpi_collective_dominance.cpp @@ -189,7 +189,8 @@ void pass_mpi_collective::__is_post_dom_bitmap(function *fun, { bb_dom_status = NOT_DOMINATED; } - else if (cursor_dom_status == DOMINATED && bb_dom_status != NOT_DOMINATED) + else if (cursor_dom_status == DOMINATED + && bb_dom_status != NOT_DOMINATED) { bb_dom_status = DOMINATED; } @@ -242,4 +243,3 @@ void pass_mpi_collective::get_post_dom_frontier(function *fun, } } } - diff --git a/src/mpi_collective_graphviz.cpp b/src/mpi_collective_graphviz.cpp index 54c7f5e1a39dd8fac6396d96c5d869a919341426..90f8e3af266846a5d1dabc6e71db78a28075e6ac 100644 --- a/src/mpi_collective_graphviz.cpp +++ b/src/mpi_collective_graphviz.cpp @@ -123,8 +123,8 @@ void pass_mpi_collective::cfgviz_dump(function *fun, const char *suffix) target_filename = cfgviz_generate_filename(fun, suffix); - printf("[GRAPHVIZ] Generating CFG of function %s in file <%s>\n", - current_function_name(), target_filename); + //printf("[GRAPHVIZ] Generating CFG of function %s in file <%s>\n", + // current_function_name(), target_filename); out = fopen(target_filename, "w"); diff --git a/src/mpi_collective_pass.cpp b/src/mpi_collective_pass.cpp index a258da5771123ce5a1d6bd3e716c17d9e3b48f88..fb436bdee0d83ab1bd53fb518bd2def2f7ea779c 100644 --- a/src/mpi_collective_pass.cpp +++ b/src/mpi_collective_pass.cpp @@ -44,22 +44,11 @@ pass_mpi_collective *pass_mpi_collective::clone() bool pass_mpi_collective::gate(function *fun) { - //{ printf("In gate of: %s\n", function_name(fun)); } - //iterating over our fun_vec seeing if fun is in there.. by comparing strings + //printf("In gate of: %s\n", function_name(fun)); + // iterating over our fun_vec seeing if fun is in there. + // by comparing strings //tree x; (void) fun; //warning shut-up - return true; -} - -unsigned int pass_mpi_collective::execute(function *fun) -{ - //printf("In execute of: %s\n", function_name(fun)); - - // need because pass objectis reused - for (int i = 0; i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; ++i) - { - collective_max_rank[i] = 0; - } bool to_process = false; tree x; @@ -67,17 +56,28 @@ unsigned int pass_mpi_collective::execute(function *fun) { if (!strcmp(IDENTIFIER_POINTER(x), function_name(fun))) { - printf("Verifying %s...\n", function_name(fun)); + //printf("Verifying %s...\n", function_name(fun)); to_process = true; } } - if (!to_process) - { return 0; }//skip processing if function not in pragma + //skip processing if function not in pragma + return to_process; +} + +unsigned int pass_mpi_collective::execute(function *fun) +{ + //printf("In execute of: %s\n", function_name(fun)); + + // need because pass objectis reused + for (int i = 0; i < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; ++i) + { + collective_max_rank[i] = 0; + } //print_tree(fun); split_blocks(fun); - //printf("\t--------------------------[split]---------------------------\n"); + //printf("\t-------------------------[split]--------------------------\n"); //print_tree(fun); alloc_bb_aux(fun); @@ -85,10 +85,10 @@ unsigned int pass_mpi_collective::execute(function *fun) calc_dom_data(); label_collec(fun); - label_dom(fun); - label_post_dom(fun); - label_dom_front(fun); - label_post_dom_front(fun); + //label_dom(fun); + //label_post_dom(fun); + //label_dom_front(fun); + //label_post_dom_front(fun); mark_edge(fun); rank_collective(fun); @@ -109,16 +109,18 @@ unsigned int pass_mpi_collective::execute(function *fun) free_dom_data(); free_bb_aux(fun); free_edge_aux(fun); - + //remove function that was processed in fun_vec + tree x; for (unsigned int ix = 0; fun_vec->iterate(ix, &x); ix++) { if (!strcmp(IDENTIFIER_POINTER(x), function_name(fun))) { - printf("Finished processing %s...\n", function_name(fun)); - fun_vec->ordered_remove(ix); //cannot do unordered due to locations.. sry + //printf("Finished processing %s...\n", function_name(fun)); + fun_vec->ordered_remove(ix); loc_vec->ordered_remove(ix); - } + //cannot do unordered due to locations.. sry + } } return 0; } diff --git a/src/mpi_collective_pragma.cpp b/src/mpi_collective_pragma.cpp index 2807741db571c22975831b9ae89f1d1c7a55e50e..0b2209629536c1ad429eb54013313fdacff3babd 100644 --- a/src/mpi_collective_pragma.cpp +++ b/src/mpi_collective_pragma.cpp @@ -29,8 +29,7 @@ void print_fun_vec() { printf("%s ", IDENTIFIER_POINTER(x)); } - printf("\n%i", fun_vec->length()); - printf("\n"); + printf("\n%i\n", fun_vec->length()); } //add x if not present in fun_vec @@ -40,9 +39,10 @@ void add_to_fun_vec(tree x, location_t loc) //raise warning if so. if (fun_vec->contains(x)) { - warning_at (loc,0 - , "repetition of function name %<%s%> in %<#pragma ProjetCA mpicoll_check%>" - , IDENTIFIER_POINTER(x)); + warning_at(loc, 0 + , "repetition of function name %<%s%>" + " in %<#pragma ProjetCA mpicoll_check%>" + , IDENTIFIER_POINTER(x)); return; } fun_vec->safe_push(x); @@ -61,8 +61,9 @@ void mpicoll_check_pragma(cpp_reader *) //not possible to use pragma inside function if (cfun) { - error_at (cfun->function_start_locus - , "%<#pragma ProjetCA mpicoll_check%> is not allowed inside functions"); + error_at(cfun->function_start_locus + , "%<#pragma ProjetCA mpicoll_check%> " + "is not allowed inside functions"); return; } @@ -74,7 +75,10 @@ void mpicoll_check_pragma(cpp_reader *) } if (token != CPP_NAME) - { error_at (loc, "%<#pragma ProjetCA mpicoll_check%> is not a valid name"); } + { + error_at(loc, "%<#pragma ProjetCA mpicoll_check%>" + " is not a valid name"); + } /* Strings are user options. */ else @@ -85,37 +89,46 @@ void mpicoll_check_pragma(cpp_reader *) strings. */ if (IDENTIFIER_LENGTH (x) > 0) //IDENTIFIER_LENGTH works - //just fine for just checking if we have a non-null token thingy here + //just fine for just checking if we have + //a non-null token thingy here { if (token != CPP_NAME) { //turns out this never happens.. - warning_at (loc, 0, "Unrecognized name %s", IDENTIFIER_POINTER(x)); + warning_at(loc, 0, "Unrecognized name %s", + IDENTIFIER_POINTER(x)); } //inform (loc, "Registering name %s", IDENTIFIER_POINTER(x)); - add_to_fun_vec(x,loc); - print_fun_vec(); + add_to_fun_vec(x, loc); + //print_fun_vec(); } - token = pragma_lex (&x,&loc); + token = pragma_lex (&x, &loc); while (token == CPP_COMMA) - { token = pragma_lex (&x,&loc); } + { + token = pragma_lex (&x, &loc); + } } while (token == CPP_NAME); if (close_paren_needed_p) { if (token == CPP_CLOSE_PAREN) - { token = pragma_lex (&x, &loc); } + { + token = pragma_lex (&x, &loc); + } else - error ("%<#pragma ProjetCA mpicoll_check (string [,string]...)%> does " - "not have a final %<)%>"); + { + error("%<#pragma ProjetCA mpicoll_check " + "(string [,string]...)%> does not have a final %<)%>"); + } } if (token != CPP_EOF) { - error_at (loc - , "%<#pragma ProjetCA mpicoll_check%> string is badly formed"); + error_at(loc + , "%<#pragma ProjetCA mpicoll_check%>" + " string is badly formed"); return; } } @@ -126,7 +139,7 @@ void verify_mpicoll_list(void *event_data, void *data) (void) event_data; (void) data; //printf("There are %i elm left in fun_vec\n",fun_vec->length()); - + //if there a still functions in fun_vec, it means it was not found //while processing ; warn user about that. tree x; @@ -134,10 +147,13 @@ void verify_mpicoll_list(void *event_data, void *data) { for (unsigned int ix = 0; fun_vec->iterate(ix, &x); ix++) { - warning_at ((*loc_vec)[ix], 0 - , "function %<%s%> was declared in a %<#pragma ProjetCA mpicoll_check%> but not found in file", IDENTIFIER_POINTER(x)); + warning_at((*loc_vec)[ix], 0 + , "function %<%s%> was declared in a" + " %<#pragma ProjetCA mpicoll_check%>" + " but not found in file", + IDENTIFIER_POINTER(x)); } } - fun_vec->release(); - loc_vec->release(); + fun_vec->release(); + loc_vec->release(); } diff --git a/src/mpi_collective_warnings.cpp b/src/mpi_collective_warnings.cpp index 522787afb89d15fcb35017cbd9fe7a368783f9a7..9fc800c74de609fb49a976332f61e7fcd5aff048 100644 --- a/src/mpi_collective_warnings.cpp +++ b/src/mpi_collective_warnings.cpp @@ -17,7 +17,6 @@ //error formating gcc-like #include <diagnostic.h> - //wrapper function void pass_mpi_collective::rank_collective(function *fun) { @@ -49,15 +48,17 @@ void pass_mpi_collective::__rank_collective(basic_block bb) //parent node) for (int mpi_code = 0; mpi_code < LAST_AND_UNUSED_MPI_COLLECTIVE_CODE; - ++mpi_code) //the rank is per collective, thus we test on each mpicode. + ++mpi_code) + //the rank is per collective, thus we test on each mpicode. { ((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) { - //if we are a new collective of this mpi_code, then we are in a new - //rank ; we increment to reflect that. + //if we are a new collective of this mpi_code, + //then we are in a new rank; + //we increment to reflect that. ((bb_data *) bb->aux)->collective_rank[mpi_code]++; //then we update the global max to be sure collective_max_rank[mpi_code] = @@ -176,12 +177,14 @@ void pass_mpi_collective::raise_warning_mpi_rank(function *fun) //debug_bitmap(pds); //debug_bitmap(pdf); - std::stack<int> bb_pdf_indx_stack; //indexes of bb forming the pdf - std::stack<int> bb_call_indx_stack; ///indexes of bb doing the mpi call + //indexes of bb forming the pdf + std::stack<int> bb_pdf_indx_stack; + //indexes of bb doing the mpi call + std::stack<int> bb_call_indx_stack; if (! bitmap_empty_p(pdf)) { //printf("MPI Collective %s incomplete rank at bbs: ", - // mpi_collective_name[mpi_code]); + // mpi_collective_name[mpi_code]); //we add every call to this mpi collective in our stack. EXECUTE_IF_SET_IN_BITMAP(nodes, 0, index, bi) @@ -191,7 +194,6 @@ void pass_mpi_collective::raise_warning_mpi_rank(function *fun) } } - while (! bitmap_empty_p(pdf)) { //we stack the iterative pdf into an other stack. @@ -228,17 +230,22 @@ void pass_mpi_collective::raise_warning_mpi_rank(function *fun) location_t loc; //first divergence possible loc = gimple_location( - get_first_non_mpi_stmt(get_bb_from_index(fun, bb_pdf_indx_stack.top()))); - warning_at (loc - , 0 - , "The MPI Collective %<%s%>(%i) might be unmatched in some MPI processes, diverging from here:" - , mpi_collective_name[mpi_code], rank); + get_first_non_mpi_stmt( + get_bb_from_index(fun, bb_pdf_indx_stack.top()))); + warning_at(loc + , 0 + , "The MPI Collective %<%s%>(%i) might be " + "unmatched in some MPI processes," + " diverging from here:" + , mpi_collective_name[mpi_code], rank); bb_pdf_indx_stack.pop(); while (!bb_call_indx_stack.empty()) { loc = gimple_location( - get_mpi_stmt(get_bb_from_index(fun, bb_call_indx_stack.top()))); + get_mpi_stmt( + get_bb_from_index( + fun, bb_call_indx_stack.top()))); inform (loc, "MPI collective %<%s%>(%i) called here." , mpi_collective_name[mpi_code], rank); bb_call_indx_stack.pop(); @@ -247,7 +254,9 @@ void pass_mpi_collective::raise_warning_mpi_rank(function *fun) while (!bb_pdf_indx_stack.empty()) { loc = gimple_location( - get_first_non_mpi_stmt(get_bb_from_index(fun, bb_pdf_indx_stack.top()))); + get_first_non_mpi_stmt( + get_bb_from_index( + fun, bb_pdf_indx_stack.top()))); inform (loc, "Diverging point might also be later at:"); bb_pdf_indx_stack.pop(); } @@ -309,8 +318,10 @@ void pass_mpi_collective::raise_warning_mpi_order(function *fun) continue; } - curr_coll_rank = -1;//other collective being tested against - diff_index = -1; //idx at which another collective call is found before + //other collective being tested against + curr_coll_rank = -1; + //idx at which another collective call is found before + diff_index = -1; coll_rank_diff = false; EXECUTE_IF_SET_IN_BITMAP(nodes, 0, index, bi) @@ -334,19 +345,21 @@ void pass_mpi_collective::raise_warning_mpi_order(function *fun) if (coll_rank_diff) { - // TODO make better warning messages //printf("======> WARNING !!! ====> MPI " - // "Collective rank missmatch for collective %s" - // " at MPI Collective %s at rank %i\n", - // mpi_collective_name[cursor_code], - // mpi_collective_name[mpi_code], rank); + // "Collective rank missmatch for collective %s" + // " at MPI Collective %s at rank %i\n", + // mpi_collective_name[cursor_code], + // mpi_collective_name[mpi_code], rank); location_t loc = gimple_location( - get_mpi_stmt(get_bb_from_index(fun, diff_index))); + get_mpi_stmt( + get_bb_from_index( + fun, diff_index))); warning_at (loc , 0 - , "MPI Collective %<%s%>(%i) might not be reachable due to a precedent %<%s%> call:" + , "MPI Collective %<%s%>(%i) might not be " + "reachable due to a precedent %<%s%> call:" , mpi_collective_name[mpi_code] , rank, mpi_collective_name[cursor_code]); @@ -355,16 +368,17 @@ void pass_mpi_collective::raise_warning_mpi_order(function *fun) if (index != diff_index) { loc = gimple_location( - get_mpi_stmt(get_bb_from_index(fun, index))); + get_mpi_stmt( + get_bb_from_index(fun, index))); inform (loc - , "reachable %<%s%>(%i) without a prior %<%s%> call:" + , "reachable %<%s%>(%i) without " + "a prior %<%s%> call:" , mpi_collective_name[mpi_code] , rank, mpi_collective_name[cursor_code]); } } } - } bitmap_clear(nodes); diff --git a/src/plugin.cpp b/src/plugin.cpp index c25775cc0f332592d07230c3b9067cfa751b67d1..dcf42b380c0df1abe136032535e7ce149a91e9f4 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -69,7 +69,6 @@ plugin_init(struct plugin_name_args *plugin_info, NULL, &pass_info); - register_callback(plugin_info->base_name, PLUGIN_PRAGMAS, register_mpicoll_check_pragma,