From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id C47393858284; Thu, 23 Feb 2023 23:22:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C47393858284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677194547; bh=ns4pPam+n46wgYqQiuZBHqda0REUJWOpeEP0WAUFZu4=; h=From:To:Subject:Date:From; b=YD5osAC8751CWA8/0L5Ltoj0yACQojHgq8wW3pAtatfSwZ4c90wtxprc950qQ9xHy GR1guoRswDWdxsDy2k1jfcQ/xn85xzMArvmZB/3IAupQ3cmZgLHLUPgJ1zfWYrbq+0 gIP3mE6J7E64RU3jCAOU6SR/nujCdTVV0XBfeasU= 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: 81285bf85e9aae5a45ba58fb11786bb8bab99486 X-Git-Newrev: ecf3c41ca0dd4b6cf8319b2a444e8b6e71d5c25f Message-Id: <20230223232227.C47393858284@sourceware.org> Date: Thu, 23 Feb 2023 23:22:27 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ecf3c41ca0dd4b6cf8319b2a444e8b6e71d5c25f commit ecf3c41ca0dd4b6cf8319b2a444e8b6e71d5c25f 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 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(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 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(); 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 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>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 && value0); +// int pow2=floor_log2(value); +// counters[pow2+(param_profile_histogram_size_lin-floor_log2 +// (param_profile_histogram_size_lin))]++; +// } + #endif