From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id 4CCD73858D1E; Tue, 25 Apr 2023 08:10:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CCD73858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682410206; bh=91BiqQAGsMttTtYnAUnowxwer2eKyljHd8vDtUt9HT8=; h=From:To:Subject:Date:From; b=lStaqgbT2dL2wFvsLsIkpj9a3T0EpyRXPMJsaI9XedISeoxcK/n0oRA2oHCRGmxcZ TAZ/GNT3cXY4cDyVRvcUqcEFFVMXI9PWPVtTPQyYjgdYSe/z9X+vC7kendunDhrE4C CIT0zqupPEU1BRNk2Tg9406E3LkvlatjCOh5ioSU= 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)] changed from total size to exponential size X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: 54eac3378042a6543e03a2dd75673b6e1d67f5da X-Git-Newrev: 9a22679c15e02516b80d632401d46a8af2f1a865 Message-Id: <20230425081006.4CCD73858D1E@sourceware.org> Date: Tue, 25 Apr 2023 08:10:06 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9a22679c15e02516b80d632401d46a8af2f1a865 commit 9a22679c15e02516b80d632401d46a8af2f1a865 Author: kubaneko Date: Mon Apr 24 07:54:30 2023 +0000 changed from total size to exponential size Diff: --- gcc/cfgloop.cc | 8 +++++--- gcc/lto-streamer-in.cc | 7 +++++-- gcc/lto-streamer-out.cc | 4 +++- gcc/params.opt | 12 ++++++++---- gcc/profile.cc | 7 +++++-- gcc/tree-profile.cc | 7 +++---- gcc/value-prof.cc | 10 +++++----- libgcc/libgcov-profiler.c | 6 ++++-- 8 files changed, 38 insertions(+), 23 deletions(-) diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc index c8a010ca08b..e2c1bab996f 100644 --- a/gcc/cfgloop.cc +++ b/gcc/cfgloop.cc @@ -2189,7 +2189,7 @@ unsigned int hist_index (gcov_type_unsigned val) { unsigned int lin_size = param_profile_histogram_size_lin; - unsigned int tot_size = param_profile_histogram_size; + unsigned int tot_size = lin_size + param_profile_histogram_size_exp; if (val < lin_size) { return val; @@ -2230,7 +2230,8 @@ histogram_counters_minus_upper_bound (histogram_counters *&hist_c, hist_c->adjusted = true; auto &sum = hist_c->sum; unsigned int lin_size = param_profile_histogram_size_lin; - unsigned int tot_size = param_profile_histogram_size; + unsigned int tot_size + = param_profile_histogram_size_lin + param_profile_histogram_size_exp; // If the last linear counter does not contain other iterations unsigned int i = 1; for (; i < lin_size; i++) @@ -2304,7 +2305,8 @@ histogram_counters_div_upper_bound (histogram_counters *&hist_c, auto &hist = *(hist_c->hist); hist_c->adjusted = true; unsigned int lin_size = param_profile_histogram_size_lin; - unsigned int tot_size = param_profile_histogram_size; + unsigned int tot_size + = param_profile_histogram_size_lin + param_profile_histogram_size_exp; unsigned int i = 1; for (; i < lin_size && i < tot_size - 1; i++) { diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc index 110bffd0b4b..b08053d7ec3 100644 --- a/gcc/lto-streamer-in.cc +++ b/gcc/lto-streamer-in.cc @@ -1133,8 +1133,11 @@ input_cfg (class lto_input_block *ib, class data_in *data_in, loop->counters->sum = streamer_read_gcov_count (ib); loop->counters->hist = NULL; vec_safe_grow_cleared (loop->counters->hist, - param_profile_histogram_size); - for (int i = 0; i < param_profile_histogram_size; ++i) + param_profile_histogram_size_lin + + param_profile_histogram_size_exp); + for (int i = 0; i < param_profile_histogram_size_lin + + param_profile_histogram_size_exp; + ++i) { (*loop->counters->hist)[i] = streamer_read_gcov_count (ib); } diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc index 0908605ab8e..e6079c62af0 100644 --- a/gcc/lto-streamer-out.cc +++ b/gcc/lto-streamer-out.cc @@ -2186,7 +2186,9 @@ output_cfg (struct output_block *ob, struct function *fn) { streamer_write_gcov_count (ob, loop->counters->sum); for (unsigned int i = 0; - i < (unsigned int) param_profile_histogram_size; ++i) + i < (unsigned int) param_profile_histogram_size_lin + + param_profile_histogram_size_exp; + ++i) { streamer_write_gcov_count (ob, (*loop->counters->hist)[i]); } diff --git a/gcc/params.opt b/gcc/params.opt index 1b035bdb3e1..3aa952c20c0 100644 --- a/gcc/params.opt +++ b/gcc/params.opt @@ -874,13 +874,17 @@ 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(18) IntegerRange(0, 255) Param Optimization -Total size of the histogram counter for profile feedback. +-param=profile-histogram-size-exp= +Common Joined UInteger Var(param_profile_histogram_size_exp) Init(1) IntegerRange(1, 255) Param Optimization +Size of additional counters in exponential intervals after the linear section. + +-param=profile-histogram-size-mod= +Common Joined UInteger Var(param_profile_histogram_size_mod) Init(32) IntegerRange(0, 255) Param Optimization +Counts the modulo of loop iterations by its size. -param=profile-histogram-size-lin= Common Joined UInteger Var(param_profile_histogram_size_lin) Init(16) IntegerRange(0, 255) Param Optimization -Size of the linear portion of the histogram counter for profile feedback. Less then total size +Size of the linear portion of the histogram counter for profile feedback. -param=profile-histogram-peel-prcnt= Common Joined UInteger Var(param_profile_histogram_peel_prcnt) Init(6) Param Optimization diff --git a/gcc/profile.cc b/gcc/profile.cc index 5d87440af01..8199ed6350b 100644 --- a/gcc/profile.cc +++ b/gcc/profile.cc @@ -933,8 +933,11 @@ compute_value_histograms (histogram_values values, unsigned cfg_checksum, lp->counters->adjusted = false; lp->counters->hist = NULL; vec_safe_grow_cleared (lp->counters->hist, - param_profile_histogram_size); - for (int i = 0; i < param_profile_histogram_size; ++i) + param_profile_histogram_size_lin + + param_profile_histogram_size_exp); + for (int i = 0; i < param_profile_histogram_size_lin + + param_profile_histogram_size_exp; + ++i) { auto hst = lp->counters->hist; (*hst)[i] = act_count[t][i]; diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc index 0c1ceb3f758..a4ed11f2219 100644 --- a/gcc/tree-profile.cc +++ b/gcc/tree-profile.cc @@ -365,10 +365,9 @@ gimple_gen_histogram_profiler (histogram_value value, auto lp = value->hvalue.lp; gcc_assert (lp); tree ref_ptr = tree_coverage_counter_addr (tag, 0); - tree hist_size - = build_int_cst_type (gcov_type_node, - param_profile_histogram_size_lin - | (gcov_type (param_profile_histogram_size) << 32)); + tree hist_size = build_int_cst_type ( + gcov_type_node, param_profile_histogram_size_lin + | (gcov_type (param_profile_histogram_size_exp) << 32)); gcall *call; auto_vec exits = get_loop_exit_edges (lp); for (auto exit : exits) diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc index 6a5ee0f5cab..d7d7cd18ce8 100644 --- a/gcc/value-prof.cc +++ b/gcc/value-prof.cc @@ -274,9 +274,7 @@ dump_histogram_value (FILE *dump_file, histogram_value hist) } 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) + i < param_profile_histogram_size_exp + lin2_log; ++i) { fprintf ( dump_file, @@ -405,7 +403,8 @@ stream_in_histogram_value (class lto_input_block *ib, gimple *stmt) break; case HIST_TYPE_HISTOGRAM: - ncounters = param_profile_histogram_size; + ncounters = param_profile_histogram_size_lin + + param_profile_histogram_size_exp; break; case HIST_TYPE_POW2: case HIST_TYPE_AVERAGE: @@ -2010,7 +2009,8 @@ gimple_find_values_to_profile (histogram_values *values) break; case HIST_TYPE_HISTOGRAM: - hist->n_counters = param_profile_histogram_size; + hist->n_counters = param_profile_histogram_size_lin + + param_profile_histogram_size_exp; break; default: diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c index f0506e4b5f1..7063af3579f 100644 --- a/libgcc/libgcov-profiler.c +++ b/libgcc/libgcov-profiler.c @@ -62,9 +62,10 @@ void __gcov_histogram_profiler(gcov_type *counters, gcov_type value, gcc_assert(hist_sizes >= 0 && value >= 0); gcov_type_unsigned hist_size = hist_sizes; gcov_type_unsigned u_value = value; - gcov_type_unsigned tot_size = hist_size >> 32; + gcov_type_unsigned exp_size = hist_size >> 32; gcov_type_unsigned lin_size = hist_size & ((((gcov_type_unsigned)1) << 32) - 1); + gcov_type_unsigned tot_size = exp_size + lin_size; if (u_value < lin_size) { counters[value]++; } else { @@ -91,9 +92,10 @@ void __gcov_histogram_profiler_atomic(gcov_type *counters, gcov_type value, gcc_assert(hist_sizes >= 0 && value >= 0); gcov_type_unsigned hist_size = hist_sizes; gcov_type_unsigned u_value = value; - gcov_type_unsigned tot_size = hist_size >> 32; + gcov_type_unsigned exp_size = hist_size >> 32; gcov_type_unsigned lin_size = hist_size & ((((gcov_type_unsigned)1) << 32) - 1); + gcov_type_unsigned tot_size = lin_size + tot_size; if (u_value < lin_size) { __atomic_fetch_add(&counters[value], 1, __ATOMIC_RELAXED); } else {