public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] started with conversion to parametric histograms
@ 2023-02-16 16:28 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-16 16:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7556e7ef7d56248729be00a5d25e5165caca167b
commit 7556e7ef7d56248729be00a5d25e5165caca167b
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 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(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 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<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 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<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;
@@ -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 && 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] started with conversion to parametric histograms
@ 2023-02-23 23:22 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-23 23:22 UTC (permalink / raw)
To: gcc-cvs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] started with conversion to parametric histograms
@ 2022-12-31 21:33 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2022-12-31 21:33 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:998f5215c6acd0283d4076aa73b9cc289b2f8b5a
commit 998f5215c6acd0283d4076aa73b9cc289b2f8b5a
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 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(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 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<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 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<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;
@@ -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 && 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-23 23:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 16:28 [gcc(refs/users/kubaneko/heads/histogram)] started with conversion to parametric histograms Ondrej Kubanek
-- strict thread matches above, loose matches on Subject: below --
2023-02-23 23:22 Ondrej Kubanek
2022-12-31 21:33 Ondrej Kubanek
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).