From b3dacce3e1335666291ae3adca15df255d3a7340 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Mon, 8 Apr 2024 17:32:13 -0400 Subject: [PATCH] $ZAM_PROFILE_ALL set tells ZAM to profile function bodies even if not executed --- src/script_opt/ZAM/ZBody.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/script_opt/ZAM/ZBody.cc b/src/script_opt/ZAM/ZBody.cc index df90aec4eb..3646829a5f 100644 --- a/src/script_opt/ZAM/ZBody.cc +++ b/src/script_opt/ZAM/ZBody.cc @@ -82,6 +82,7 @@ void estimate_ZAM_profiling_overhead() { #ifdef ENABLE_ZAM_PROFILE static std::vector caller_locs; +static bool profile_all = getenv("ZAM_PROFILE_ALL") != nullptr; #define DO_ZAM_PROFILE \ if ( do_profile ) { \ @@ -117,6 +118,8 @@ static std::vector caller_locs; #define ZAM_PROFILE_PRE_CALL #define ZAM_PROFILE_POST_CALL +static bool profile_all = false; + #endif using std::vector; @@ -144,7 +147,7 @@ void report_ZOP_profile() { } for ( int i = 1; i <= OP_NOP; ++i ) - if ( ZOP_count[i] > 0 ) { + if ( ZOP_count[i] > 0 || profile_all ) { auto CPU = std::max(ZOP_CPU[i] - ZOP_count[i] * CPU_prof_overhead, 0.0); fprintf(analysis_options.profile_file, "%s\t%d\t%.06f\n", ZOP_name(ZOp(i)), ZOP_count[i], CPU); } @@ -465,7 +468,8 @@ void ZBody::ReportExecutionProfile(ProfMap& pm) { if ( dpv[0].num_samples == 0 && prof_vecs.empty() ) { fprintf(analysis_options.profile_file, "%s did not execute\n", func_name.c_str()); - return; + if ( ! profile_all ) + return; } int total_samples = ncall + ninst; @@ -477,7 +481,7 @@ void ZBody::ReportExecutionProfile(ProfMap& pm) { fprintf(analysis_options.profile_file, "%s CPU time %.06f, %" PRIu64 " memory, %d calls, %d sampled instructions\n", func_name.c_str(), adj_CPU_time, tot_mem, ncall, ninst); - if ( dpv[0].num_samples != 0 ) + if ( dpv[0].num_samples != 0 || profile_all ) ReportProfile(pm, dpv, "", {}); for ( auto& pv : prof_vecs ) {