From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id 029883858D1E; Sat, 31 Dec 2022 21:33:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 029883858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672522421; bh=yzmjTcFn+LD7rSOIFKrwCv1kvllXSs7lN8j1GLDsTPc=; h=From:To:Subject:Date:From; b=SlJU+bkY4RuFiVKYMbhGQ2nLfNj8r/QQ5Gw7VntkbQ/By75BlgM9EH6Lj7m8f566/ TMHbMV1fri7+CCRzotTBQz0Wk9HjOi052MxTf3dILfeDvYKmbgUL80ZA0W3r90KSFw ylua/7nCHG/yXdsquHoOjLEMFJYALSMLMhBf4bwI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ondrej Kubanek To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] started with conversion to parametric histograms X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: add65e4443356d735c2e667995d6b467d59ef65d X-Git-Newrev: 998f5215c6acd0283d4076aa73b9cc289b2f8b5a Message-Id: <20221231213341.029883858D1E@sourceware.org> Date: Sat, 31 Dec 2022 21:33:40 +0000 (GMT) List-Id: https://gcc.gnu.org/g:998f5215c6acd0283d4076aa73b9cc289b2f8b5a commit 998f5215c6acd0283d4076aa73b9cc289b2f8b5a Author: kubaneko 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 3b795902e2e..6f09698bc3c 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(0hist[i]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 3001566e641..3f6f1c0e211 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -862,6 +862,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 17f6aaa1573..7282d97ad01 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(); gcov_type sum=0; - for (int i=0;i<69;++i){ + for (int i=0;icounters->hist[i]=act_count[t][i]; sum+=act_count[t][i]; } diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc index 1ca2524e862..f0a86a9010c 100644 --- a/gcc/value-prof.cc +++ b/gcc/value-prof.cc @@ -266,17 +266,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>i, - (int64_t) hist->hvalue.counters[5+i]); + (int64_t) hist->hvalue.counters[(param_profile_histogram_size_lin-lin2_log)+i]); } } break; @@ -398,7 +401,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: @@ -1999,7 +2002,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 b5912f53917..087ee6080a6 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 && value0); +// int pow2=floor_log2(value); +// counters[pow2+(param_profile_histogram_size_lin-floor_log2 +// (param_profile_histogram_size_lin))]++; +// } + #endif