diff --git a/functions/frontier.c b/functions/frontier.c index 60c628f50f63634af90a9238b0e14217649ed682..9945134b2a736f24fd45d5e364b4ebb744288ac2 100644 --- a/functions/frontier.c +++ b/functions/frontier.c @@ -226,25 +226,104 @@ void bitmap_mpi_iterated_pdf_union(function * fun) } } - //bitmap_set_pdf_intersect(ipdf_set, pfrontiers, &mpi_ipdf, fun); bitmap_print( stdout, &ipdf_set, "iterated PDF: ", "\n\n" ) ; - bitmap_and_into(&ipdf_set, &mpi_set); - bitmap_print( stdout, &ipdf_set, "MPI iterated PDF: ", "\n\n" ) ; + bitmap_and(&mpi_ipdf, &mpi_set,&ipdf_set); + bitmap_print( stdout, &mpi_ipdf, "MPI iterated PDF: ", "\n\n" ) ; bitmap_print( stdout, &mpi_set, "MPI set: ", "\n\n" ) ; + + bitmap_head test; + bitmap_initialize( &test, &bitmap_default_obstack); + if(bitmap_intersect_p(&ipdf_set, &mpi_set)){ + printf("! WARNING ! \n"); + }else + { + printf("No potential deadlock detected\n"); + } + free_dominance_info(fun, CDI_POST_DOMINATORS); +} + +void detect_potential_deadlock(function * fun) +{ + printf("\n------------------\n"); + printf("---MPI Analysis---\n"); + printf("------------------\n\n"); + //init + calculate_dominance_info(CDI_POST_DOMINATORS); + bitmap_head *pfrontiers; + basic_block bb; + pfrontiers = XNEWVEC (bitmap_head, last_basic_block_for_fn (fun)); + + FOR_ALL_BB_FN (bb, cfun) + { + bitmap_initialize (&pfrontiers[bb->index], &bitmap_default_obstack); + } + + bitmap_head node_set ; + bitmap_initialize( &node_set, &bitmap_default_obstack); + + FOR_ALL_BB_FN (bb, cfun) + { + bitmap_set_bit( &node_set, bb->index ) ; + } + + bitmap_head pdf_set; + bitmap_initialize (&pdf_set, &bitmap_default_obstack); + + bitmap_post_dominance_frontiers (pfrontiers, fun); + bitmap_set_pdf_union(node_set, pfrontiers, &pdf_set, fun); + + bitmap_head ipdf_set; + bitmap_initialize (&ipdf_set, &bitmap_default_obstack); + + iterated_post_dominance(pdf_set, pfrontiers, &ipdf_set, fun); + + bitmap_head mpi_set, mpi_ipdf; + bitmap_initialize( &mpi_set, &bitmap_default_obstack); + bitmap_initialize( &mpi_ipdf, &bitmap_default_obstack); + + FOR_ALL_BB_FN (bb, cfun) + { + if (bb->aux !=NULL && *((int *)bb->aux)>=0) + { + bitmap_set_bit( &mpi_set, bb->index ) ; + } + } + + bitmap_and(&mpi_ipdf, &mpi_set,&ipdf_set); + + bitmap_head test; + bitmap_initialize( &test, &bitmap_default_obstack); + if(bitmap_intersect_p(&ipdf_set, &mpi_set)){ + printf("! WARNING ! \n"); + bitmap_print( stdout, &ipdf_set, "Potential problems blocks : ", "\n\n" ) ; + }else + { + printf("No potential deadlock detected\n"); + } + issue_warnings(ipdf_set,fun); free_dominance_info(fun, CDI_POST_DOMINATORS); } -//void bitmap_set_pdf_intersect(bitmap_head node_set, bitmap_head *pdf, bitmap_head * pdf_set, function * fun) -//{ -// basic_block bb; -// -// /* Create the union of each PDF */ -// FOR_ALL_BB_FN( bb, fun ) -// { -// if ( bitmap_bit_p( &node_set, bb->index ) && bb->aux !=NULL && *((int *)bb->aux)>=0) -// { -// bitmap_ior_into( pdf_set, &node_set ) ; -// } -// } -// -// -//} + +void issue_warnings (bitmap_head ipdf_set, function * fun) +{ + basic_block bb; + gimple_stmt_iterator gsi; + gimple *stmt; + + + + printf("\n----------- WHICH LINES ---------\n\n"); + + FOR_EACH_BB_FN( bb, fun ) + { + if(bitmap_bit_p(&ipdf_set, bb->index)) + { + gsi = gsi_start_bb(bb); + stmt = gsi_stmt(gsi); + + printf("/!\\ /!\\ /!\\ Basic Block %d (line %d) might cause an issue\n", bb->index, gimple_lineno(stmt)); + } + } + +printf("\n"); +} diff --git a/functions/frontier.h b/functions/frontier.h index aff8db3454c30389d94987927d7481ef50d3c49f..979145a7d7a975feeefc0ad33e79cebdd946e266 100644 --- a/functions/frontier.h +++ b/functions/frontier.h @@ -8,4 +8,6 @@ void iterated_post_dominance(bitmap_head pdf_node_set, bitmap_head *pdf, bitmap_ void bitmap_iterated_pdf_union(function * fun); void bitmap_mpi_iterated_pdf_union(function * fun); void bitmap_set_pdf_intersect(bitmap_head node_set, bitmap_head *pdf, bitmap_head * pdf_set, function * fun); +void detect_potential_deadlock(function * fun); +void issue_warnings (bitmap_head ipdf_set, function * fun); #endif diff --git a/plugin.cpp b/plugin.cpp index d5d9f5d9c96fdbf2500931cec95f7767076971b5..27dad8b9b295eac888bae41919eef1d79d2ac8d5 100755 --- a/plugin.cpp +++ b/plugin.cpp @@ -109,17 +109,18 @@ class split_count_pass : public gimple_opt_pass //writing corresponding MPI Call in corresponding basic block edit_all_aux_value(fun,(int*)NULL); write_mpi_code(fun); - print_bb_aux(fun); + //print_bb_aux(fun); /* Skip system header functions */ if ( !in_system_header_at( fun->function_start_locus ) ) cfgviz_dump( fun, function_name(fun), 1 ) ; //edit_all_aux_value(fun,(int*)LAST_AND_UNUSED_MPI_COLLECTIVE_CODE); //write_mpi_code(fun); - bitmap_pdf(fun); - bitmap_pdf_union(fun); - bitmap_iterated_pdf_union(fun); - bitmap_mpi_iterated_pdf_union(fun); + //bitmap_pdf(fun); + //bitmap_pdf_union(fun); + //bitmap_iterated_pdf_union(fun); + //bitmap_mpi_iterated_pdf_union(fun); + detect_potential_deadlock(fun); return 0; } };