From e59916214d3d02cf81ba07116bfc240dc8dc4f59 Mon Sep 17 00:00:00 2001 From: Giuliano Belinassi Date: Wed, 9 Jun 2021 10:48:16 -0300 Subject: Print statistics --- gcc/cgraphunit.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ gcc/langhooks.c | 1 + gcc/lto-partition.c | 38 +++++++++++++++++++++++++++++++++++++- gcc/toplev.c | 10 ++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 12d2d19..7e01c9d 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2782,6 +2782,8 @@ static bool is_number (const char *str) static int childno = -1; +void print_partitions_statistics (); + static bool maybe_compile_in_parallel (void) { @@ -2800,6 +2802,10 @@ maybe_compile_in_parallel (void) if (!flag_parallel_jobs || !split_outputs) return false; + + struct timeval start, end; + gettimeofday(&start, NULL); + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode) { ipa_size_summary *ss = ipa_size_summaries->get (cnode); @@ -2869,6 +2875,10 @@ maybe_compile_in_parallel (void) return false; } + + //print_partitions_statistics(); + //exit(0); + /* Find out statics that need to be promoted to globals with hidden visibility because they are accessed from multiple partitions. */ @@ -2902,6 +2912,16 @@ maybe_compile_in_parallel (void) jobserver_return_token ('p'); } + + gettimeofday(&end, NULL); + + long seconds = (end.tv_sec - start.tv_sec); + long micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); + + printf("Partitioner: %ld.%06ld\n", seconds, micros); + + gettimeofday(&start, NULL); + /* Spawn processes. Spawn as soon as there is a free slot. */ for (j = 0, i = -num_jobs; i < partitions; i++, j++) { @@ -2942,6 +2962,14 @@ maybe_compile_in_parallel (void) now. */ if (jobserver) jobserver_get_token (); + + + gettimeofday(&end, NULL); + + seconds = (end.tv_sec - start.tv_sec); + micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); + + printf("LTRANS: %ld.%06ld\n", seconds, micros); exit (0); } @@ -2951,6 +2979,9 @@ maybe_compile_in_parallel (void) void symbol_table::compile (void) { + struct timeval start, end; + long seconds, micros; + if (seen_error ()) return; @@ -2970,8 +3001,18 @@ symbol_table::compile (void) /* Don't run the IPA passes if there was any error or sorry messages. */ if (!seen_error ()) { + timevar_start (TV_CGRAPH_IPA_PASSES); + + gettimeofday(&start, NULL); ipa_passes (); + gettimeofday(&end, NULL); + + seconds = (end.tv_sec - start.tv_sec); + micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); + + printf("IPA: %ld.%06ld micros\n", seconds, micros); + maybe_compile_in_parallel (); timevar_stop (TV_CGRAPH_IPA_PASSES); } @@ -2984,6 +3025,9 @@ symbol_table::compile (void) return; } + + gettimeofday(&start, NULL); + global_info_ready = true; if (dump_file) { @@ -3051,6 +3095,13 @@ symbol_table::compile (void) state = FINISHED; output_weakrefs (); + gettimeofday(&end, NULL); + + seconds = (end.tv_sec - start.tv_sec); + micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); + + printf("Intraprocedural: %ld.%06ld\n", seconds, micros); + if (dump_file) { fprintf (dump_file, "\nFinal "); diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 3cbe04c..f9d6e6f 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -304,6 +304,7 @@ global_decl_processing (void) tree globals, decl, *vec; int len, i; + timevar_stop (TV_PHASE_PARSING); timevar_start (TV_PHASE_DEFERRED); /* Really define vars that have had only a tentative definition. diff --git a/gcc/lto-partition.c b/gcc/lto-partition.c index d70ee2b..51a9946 100644 --- a/gcc/lto-partition.c +++ b/gcc/lto-partition.c @@ -376,6 +376,43 @@ lto_max_map (void) new_partition ("empty"); } +void print_partitions_statistics() +{ + int n_partitions = ltrans_partitions.length(); + int i; + + printf ("Number of partitions: %d\n", n_partitions); + + for (i = 0; i < n_partitions; i++) + { + ltrans_partition part = ltrans_partitions[i]; + printf ("Partition: %d, Nr of insns: %d, Symbols: %d\n", i, part->insns, + part->symbols); + + lto_symtab_encoder_iterator lsei; + lto_symtab_encoder_t encoder = part->encoder; + + for (lsei = lsei_start (encoder); !lsei_end_p (lsei); lsei_next (&lsei)) + { + if (cgraph_node *cnode = dyn_cast(lsei_node (lsei))) + { + if (cnode->get_partitioning_class () == SYMBOL_PARTITION) + { + ipa_size_summary *summary = ipa_size_summaries->get (cnode); + if (summary) + printf (" Node id: %d, name: %s, insns: %d\n", cnode->order, cnode->name (), summary->size); + } + /* + else + printf (" Node: %s, Boundary\n", cnode->name ()); + */ + } + } + } + + fflush (stdout); +} + /* Class implementing a union-find algorithm. */ class union_find @@ -488,7 +525,6 @@ balance_partitions (union_find *ds, int n, int jobs) ipa_size_summary *summary = ipa_size_summaries->get (cnode); if (summary) { - printf("%s; %d\n", cnode->name (), summary->size); sizes[root] += summary->size; } else diff --git a/gcc/toplev.c b/gcc/toplev.c index 9545088..314bdcd 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -456,9 +456,19 @@ compile_file (void) timevar_start (TV_PHASE_PARSING); timevar_push (TV_PARSE_GLOBAL); + struct timeval start, end; + + gettimeofday(&start, NULL); /* Parse entire file and generate initial debug information. */ lang_hooks.parse_file (); + gettimeofday(&end, NULL); + + long seconds = (end.tv_sec - start.tv_sec); + long micros = ((seconds * 1000000) + end.tv_usec) - (start.tv_usec); + + printf("Parsing: %ld.%06ld\n", seconds, micros); + timevar_pop (TV_PARSE_GLOBAL); timevar_stop (TV_PHASE_PARSING); -- cgit v1.1