public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Ondrej Kubanek <kubaneko@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] started with conversion to parametric histograms Date: Thu, 23 Feb 2023 23:22:27 +0000 (GMT) [thread overview] Message-ID: <20230223232227.C47393858284@sourceware.org> (raw) https://gcc.gnu.org/g:ecf3c41ca0dd4b6cf8319b2a444e8b6e71d5c25f commit ecf3c41ca0dd4b6cf8319b2a444e8b6e71d5c25f Author: kubaneko <kubanek0ondrej@gmail.com> Date: Sat Dec 31 21:31:38 2022 +0000 started with conversion to parametric histograms Diff: --- gcc/cfgloop.h | 31 ++++++++++++++----------------- gcc/params.opt | 8 ++++++++ gcc/profile.cc | 2 +- gcc/value-prof.cc | 13 ++++++++----- libgcc/libgcov-profiler.c | 9 +++++++++ 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index 94a18e56e5e..8ec6bb03ad1 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -98,25 +98,22 @@ struct GTY(()) histogram_counters{ gcov_type sum; int histogram_size; gcov_type hist[69]; - - // need to think about overflows - // quantil function for the distribution - // returns index under which is koef part of the distribution - // int quantil(float koef){ - // gcc_assert(0<koef && koef<=1); - // gcov_type quant=0; - // int i=0; - // for (;i<69;++i) { - // if (quant+hist[i]<koef*sum) { - // quant+=hist[i]; - // } else { - // break; - // } - // } - // return i; - // }; }; +// quantil function for the distribution +// int quantil_asdf(float koef, histogram_counters* count){ +// gcc_assert(0<koef && koef<=1); +// gcov_type quant=0; +// int i=0; +// for (;i<69;++i) { +// if (quant+count->hist[i]<koef*count->sum) { +// quant+=count->hist[i]; +// } else { +// break; +// } +// } +// return i; +// }; typedef class loop *loop_p; diff --git a/gcc/params.opt b/gcc/params.opt index 41d8bef245e..804c5cdbe76 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -874,6 +874,14 @@ Min. ratio of insns to mem ops to enable prefetching in a loop. Common Joined UInteger Var(param_prefetch_minimum_stride) Init(-1) Param Optimization The minimum constant stride beyond which we should use prefetch hints for. +-param=profile-histogram-size= +Common Joined UInteger Var(param_profile_histogram_size) Init(69) Param Optimization +Total size of the histogram counter for profile feedback. + +-param=profile-histogram-size-lin= +Common Joined UInteger Var(param_profile_histogram_size_lin) Init(8) Param Optimization +Size of the linear portion of the histogram counter for profile feedback. + -param=profile-func-internal-id= Common Joined UInteger Var(param_profile_func_internal_id) IntegerRange(0, 1) Param Use internal function id in profile lookup. diff --git a/gcc/profile.cc b/gcc/profile.cc index 6e99a6501c3..5a6cedfaaec 100644 --- a/gcc/profile.cc +++ b/gcc/profile.cc @@ -930,7 +930,7 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum, if (act_count[t]){ lp->counters=ggc_alloc<histogram_counters>(); gcov_type sum=0; - for (int i=0;i<69;++i){ + for (int i=0;i<param_profile_histogram_size;++i){ lp->counters->hist[i]=act_count[t][i]; sum+=act_count[t][i]; } diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc index d81b210b068..133ed62118a 100644 --- a/gcc/value-prof.cc +++ b/gcc/value-prof.cc @@ -265,17 +265,20 @@ dump_histogram_value (FILE *dump_file, histogram_value hist) break; case HIST_TYPE_HISTOGRAM: if (hist->hvalue.counters){ - for (int i=0; i<=8; ++i){ + for (int i=0; i<=param_profile_histogram_size_lin; ++i){ fprintf (dump_file, "Histogram counter histogram%" PRId64 ":%" PRId64 ".\n", (int64_t) i, (int64_t) hist->hvalue.counters[i]); } - for (int64_t i=4; i<64; ++i){ + int lin2_log=floor_log2 (param_profile_histogram_size_lin); + for (int64_t i=lin2_log; + i<param_profile_histogram_size-param_profile_histogram_size_lin+lin2_log; + ++i){ fprintf (dump_file, "Histogram counter histogram%" PRId64 ":%" PRId64 ".\n", (int64_t) 1>>i, - (int64_t) hist->hvalue.counters[5+i]); + (int64_t) hist->hvalue.counters[(param_profile_histogram_size_lin-lin2_log)+i]); } } break; @@ -397,7 +400,7 @@ stream_in_histogram_value (class lto_input_block *ib, gimple *stmt) break; case HIST_TYPE_HISTOGRAM: - ncounters = 69; + ncounters = param_profile_histogram_size; break; case HIST_TYPE_POW2: case HIST_TYPE_AVERAGE: @@ -1998,7 +2001,7 @@ gimple_find_values_to_profile (histogram_values *values) break; case HIST_TYPE_HISTOGRAM: - hist->n_counters = 69; + hist->n_counters = param_profile_histogram_size; break; default: diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c index 5469276f8a7..739a30043c0 100644 --- a/libgcc/libgcov-profiler.c +++ b/libgcc/libgcov-profiler.c @@ -65,6 +65,15 @@ __gcov_histogram_profiler (gcov_type *counters, gcov_type value) } } +// if (value>=0 && value<param_profile_histogram_size_lin){ +// counters[value]++; +// }else{ +// gcc_assert(value>0); +// int pow2=floor_log2(value); +// counters[pow2+(param_profile_histogram_size_lin-floor_log2 +// (param_profile_histogram_size_lin))]++; +// } + #endif
next reply other threads:[~2023-02-23 23:22 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-23 23:22 Ondrej Kubanek [this message] -- strict thread matches above, loose matches on Subject: below -- 2023-02-16 16:28 Ondrej Kubanek 2022-12-31 21:33 Ondrej Kubanek
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230223232227.C47393858284@sourceware.org \ --to=kubaneko@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).