public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] added atomic counter
@ 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:2ec0ddcc2d8a42904b3b41e67662584e5ae7008c
commit 2ec0ddcc2d8a42904b3b41e67662584e5ae7008c
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Tue Nov 1 14:46:59 2022 +0000
added atomic counter
Diff:
---
libgcc/Makefile.in | 3 ++-
libgcc/libgcov-profiler.c | 32 ++++++++++++++++++++++++++++++++
libgcc/libgcov.h | 1 +
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index db430e0b6af..52c0c250b0c 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -907,7 +907,8 @@ LIBGCOV_PROFILER = _gcov_interval_profiler \
_gcov_ior_profiler_atomic \
_gcov_indirect_call_profiler_v4 \
_gcov_time_profiler \
- _gcov_histogram_profiler
+ _gcov_histogram_profiler \
+ _gcov_histogram_profiler_atomic
LIBGCOV_INTERFACE = _gcov_dump _gcov_fork \
_gcov_execl _gcov_execlp \
_gcov_execle _gcov_execv _gcov_execvp _gcov_execve _gcov_reset \
diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c
index eb944158a3c..f150d75fee1 100644
--- a/libgcc/libgcov-profiler.c
+++ b/libgcc/libgcov-profiler.c
@@ -56,6 +56,38 @@ __gcov_histogram_profiler (gcov_type *counters, gcov_type value)
#endif
+
+#if defined(L_gcov_histogram_profiler_atomic) && GCOV_SUPPORTS_ATOMIC
+
+/*
+ * If value is less then 8 we increment corresponding counter
+ * otherwise we take its logarithm and increment corresponding counter
+ */
+
+void
+__gcov_histogram_profiler_atomic (gcov_type *counters, gcov_type value)
+{
+ if (value>=0 && value<8){
+ __atomic_fetch_add (&counters[value], 1, __ATOMIC_RELAXED);
+ }else{
+ gcc_assert(value>0);
+ int pow2 = 3;
+ while (1 << pow2 <= value || 1 << pow2 > 1 << (pow2 + 1)){
+ ++pow2;
+ }
+ // pow2 is first bigger power of 2
+ // we increment closer power of 2
+ if ((1<<pow2+1<<(pow2-1))>>1<value){
+ __atomic_fetch_add (&counters[6+(pow2-3)], 1, __ATOMIC_RELAXED);
+ }
+ else{
+ __atomic_fetch_add (&counters[7+(pow2-3)], 1, __ATOMIC_RELAXED);
+ }
+ }
+}
+
+#endif
+
#ifdef L_gcov_interval_profiler
/* If VALUE is in interval <START, START + STEPS - 1>, then increases the
corresponding counter in COUNTERS. If the VALUE is above or below
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h
index c01b5afe04b..b32f50ddec3 100644
--- a/libgcc/libgcov.h
+++ b/libgcc/libgcov.h
@@ -318,6 +318,7 @@ extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned);
extern void __gcov_interval_profiler_atomic (gcov_type *, gcov_type, int,
unsigned);
extern void __gcov_histogram_profiler (gcov_type *, gcov_type);
+extern void __gcov_histogram_profiler_atomic (gcov_type *, gcov_type);
extern void __gcov_pow2_profiler (gcov_type *, gcov_type);
extern void __gcov_pow2_profiler_atomic (gcov_type *, gcov_type);
extern void __gcov_topn_values_profiler (gcov_type *, gcov_type);
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] added atomic counter
@ 2023-02-23 23:21 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-23 23:21 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8a387e2c25edb5c0a8df049f2a1ccf76e2c922f5
commit 8a387e2c25edb5c0a8df049f2a1ccf76e2c922f5
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Tue Nov 1 14:46:59 2022 +0000
added atomic counter
Diff:
---
libgcc/Makefile.in | 3 ++-
libgcc/libgcov-profiler.c | 32 ++++++++++++++++++++++++++++++++
libgcc/libgcov.h | 1 +
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 74e3602347a..b3847db58bd 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -907,7 +907,8 @@ LIBGCOV_PROFILER = _gcov_interval_profiler \
_gcov_ior_profiler_atomic \
_gcov_indirect_call_profiler_v4 \
_gcov_time_profiler \
- _gcov_histogram_profiler
+ _gcov_histogram_profiler \
+ _gcov_histogram_profiler_atomic
LIBGCOV_INTERFACE = _gcov_dump _gcov_fork \
_gcov_execl _gcov_execlp \
_gcov_execle _gcov_execv _gcov_execvp _gcov_execve _gcov_reset \
diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c
index b36584723d5..4b1a3b423e2 100644
--- a/libgcc/libgcov-profiler.c
+++ b/libgcc/libgcov-profiler.c
@@ -56,6 +56,38 @@ __gcov_histogram_profiler (gcov_type *counters, gcov_type value)
#endif
+
+#if defined(L_gcov_histogram_profiler_atomic) && GCOV_SUPPORTS_ATOMIC
+
+/*
+ * If value is less then 8 we increment corresponding counter
+ * otherwise we take its logarithm and increment corresponding counter
+ */
+
+void
+__gcov_histogram_profiler_atomic (gcov_type *counters, gcov_type value)
+{
+ if (value>=0 && value<8){
+ __atomic_fetch_add (&counters[value], 1, __ATOMIC_RELAXED);
+ }else{
+ gcc_assert(value>0);
+ int pow2 = 3;
+ while (1 << pow2 <= value || 1 << pow2 > 1 << (pow2 + 1)){
+ ++pow2;
+ }
+ // pow2 is first bigger power of 2
+ // we increment closer power of 2
+ if ((1<<pow2+1<<(pow2-1))>>1<value){
+ __atomic_fetch_add (&counters[6+(pow2-3)], 1, __ATOMIC_RELAXED);
+ }
+ else{
+ __atomic_fetch_add (&counters[7+(pow2-3)], 1, __ATOMIC_RELAXED);
+ }
+ }
+}
+
+#endif
+
#ifdef L_gcov_interval_profiler
/* If VALUE is in interval <START, START + STEPS - 1>, then increases the
corresponding counter in COUNTERS. If the VALUE is above or below
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h
index d3eac74b766..cd2f48c4d6d 100644
--- a/libgcc/libgcov.h
+++ b/libgcc/libgcov.h
@@ -318,6 +318,7 @@ extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned);
extern void __gcov_interval_profiler_atomic (gcov_type *, gcov_type, int,
unsigned);
extern void __gcov_histogram_profiler (gcov_type *, gcov_type);
+extern void __gcov_histogram_profiler_atomic (gcov_type *, gcov_type);
extern void __gcov_pow2_profiler (gcov_type *, gcov_type);
extern void __gcov_pow2_profiler_atomic (gcov_type *, gcov_type);
extern void __gcov_topn_values_profiler (gcov_type *, gcov_type);
^ permalink raw reply [flat|nested] 3+ messages in thread
* [gcc(refs/users/kubaneko/heads/histogram)] added atomic counter
@ 2022-11-22 13:13 Ondrej Kubanek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2022-11-22 13:13 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6d710a27d95879ade1841a8ace7854cdfd1ad5ac
commit 6d710a27d95879ade1841a8ace7854cdfd1ad5ac
Author: kubaneko <kubanek0ondrej@gmail.com>
Date: Tue Nov 1 14:46:59 2022 +0000
added atomic counter
Diff:
---
libgcc/Makefile.in | 3 ++-
libgcc/libgcov-profiler.c | 32 ++++++++++++++++++++++++++++++++
libgcc/libgcov.h | 1 +
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index db430e0b6af..52c0c250b0c 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -907,7 +907,8 @@ LIBGCOV_PROFILER = _gcov_interval_profiler \
_gcov_ior_profiler_atomic \
_gcov_indirect_call_profiler_v4 \
_gcov_time_profiler \
- _gcov_histogram_profiler
+ _gcov_histogram_profiler \
+ _gcov_histogram_profiler_atomic
LIBGCOV_INTERFACE = _gcov_dump _gcov_fork \
_gcov_execl _gcov_execlp \
_gcov_execle _gcov_execv _gcov_execvp _gcov_execve _gcov_reset \
diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c
index eb944158a3c..f150d75fee1 100644
--- a/libgcc/libgcov-profiler.c
+++ b/libgcc/libgcov-profiler.c
@@ -56,6 +56,38 @@ __gcov_histogram_profiler (gcov_type *counters, gcov_type value)
#endif
+
+#if defined(L_gcov_histogram_profiler_atomic) && GCOV_SUPPORTS_ATOMIC
+
+/*
+ * If value is less then 8 we increment corresponding counter
+ * otherwise we take its logarithm and increment corresponding counter
+ */
+
+void
+__gcov_histogram_profiler_atomic (gcov_type *counters, gcov_type value)
+{
+ if (value>=0 && value<8){
+ __atomic_fetch_add (&counters[value], 1, __ATOMIC_RELAXED);
+ }else{
+ gcc_assert(value>0);
+ int pow2 = 3;
+ while (1 << pow2 <= value || 1 << pow2 > 1 << (pow2 + 1)){
+ ++pow2;
+ }
+ // pow2 is first bigger power of 2
+ // we increment closer power of 2
+ if ((1<<pow2+1<<(pow2-1))>>1<value){
+ __atomic_fetch_add (&counters[6+(pow2-3)], 1, __ATOMIC_RELAXED);
+ }
+ else{
+ __atomic_fetch_add (&counters[7+(pow2-3)], 1, __ATOMIC_RELAXED);
+ }
+ }
+}
+
+#endif
+
#ifdef L_gcov_interval_profiler
/* If VALUE is in interval <START, START + STEPS - 1>, then increases the
corresponding counter in COUNTERS. If the VALUE is above or below
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h
index c01b5afe04b..b32f50ddec3 100644
--- a/libgcc/libgcov.h
+++ b/libgcc/libgcov.h
@@ -318,6 +318,7 @@ extern void __gcov_interval_profiler (gcov_type *, gcov_type, int, unsigned);
extern void __gcov_interval_profiler_atomic (gcov_type *, gcov_type, int,
unsigned);
extern void __gcov_histogram_profiler (gcov_type *, gcov_type);
+extern void __gcov_histogram_profiler_atomic (gcov_type *, gcov_type);
extern void __gcov_pow2_profiler (gcov_type *, gcov_type);
extern void __gcov_pow2_profiler_atomic (gcov_type *, gcov_type);
extern void __gcov_topn_values_profiler (gcov_type *, gcov_type);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-23 23:21 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)] added atomic counter Ondrej Kubanek
-- strict thread matches above, loose matches on Subject: below --
2023-02-23 23:21 Ondrej Kubanek
2022-11-22 13:13 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).