|
From: falcovorbis <fal...@us...> - 2024-10-21 05:16:09
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 9ced3a9b8b3f0cbbce7c5c1dc83cfa9376fa3e7d (commit)
from f3be5205f542e667ff8d39cca0b9b2024276c2ce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 9ced3a9b8b3f0cbbce7c5c1dc83cfa9376fa3e7d
Author: Paul Cercueil <pa...@cr...>
Date: Mon Oct 21 07:15:35 2024 +0200
perf_monitor: Add macro for branch likeliness analysis (#826)
Introduce a new perf_monitor_if() macro.
This macro is designed to be used inside an "if" expression, for instance:
if (perf_monitor_if(!strcmp("test", str))) {
...
}
The resulting performance monitor will measure the number of calls, and
the number of times the branch was taken (in event1) and the number of
time it was not (in event0).
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/include/dc/perf_monitor.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/kernel/arch/dreamcast/include/dc/perf_monitor.h b/kernel/arch/dreamcast/include/dc/perf_monitor.h
index cdf20cdf..20617623 100644
--- a/kernel/arch/dreamcast/include/dc/perf_monitor.h
+++ b/kernel/arch/dreamcast/include/dc/perf_monitor.h
@@ -59,6 +59,15 @@ struct perf_monitor *__start_perf_monitor(struct perf_monitor *monitor);
__start_perf_monitor(&__perf_monitor_##l)
#define _perf_monitor(f, l) __perf_monitor(f, l)
+
+#define __perf_monitor_if(f, l, tst) ({ \
+ static struct perf_monitor __perf_monitor_##l \
+ __attribute__((section(".monitors"))) = { f, l, }; \
+ __perf_monitor_##l.calls++; \
+ (tst) ? (__perf_monitor_##l.event1++,1) : (__perf_monitor_##l.event0++,0); \
+})
+
+#define _perf_monitor_if(f, l, tst) __perf_monitor_if(f, l, tst)
/** /endcond */
/** \brief Register a performance monitor in the current functional block
@@ -68,6 +77,20 @@ struct perf_monitor *__start_perf_monitor(struct perf_monitor *monitor);
*/
#define perf_monitor() _perf_monitor(__func__, __LINE__)
+/** \brief Register a performance monitor for branch likeliness analysis
+
+ This macro is designed to be used inside an "if" expression, for instance:
+ if (perf_monitor_if(!strcmp("test", str))) { ... }
+
+ The resulting performance monitor will measure the number of calls, and
+ the number of times the branch was taken (in event1) and the number of
+ time it was not (in event0).
+
+ \param tst The boolean expression that is normally used inside
+ the "if" check
+*/
+#define perf_monitor_if(tst) _perf_monitor_if(__func__, __LINE__, tst)
+
/** \brief Initialize the performance monitor system
Set up the performance monitor system. Note that using the performance
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|