From f665c6ab1f7493d42f0eed500eee7d6e2e8f6ad8 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Tue, 4 May 2021 23:07:33 -0400 Subject: [PATCH] refactor: generic thread --- runtime/include/generic_thread.h | 19 +------------------ runtime/src/generic_thread.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/runtime/include/generic_thread.h b/runtime/include/generic_thread.h index a600e58..135b68e 100644 --- a/runtime/include/generic_thread.h +++ b/runtime/include/generic_thread.h @@ -2,25 +2,8 @@ #include -#include "arch/getcycles.h" -#include "debuglog.h" - extern __thread uint64_t generic_thread_lock_duration; extern __thread uint64_t generic_thread_start_timestamp; -/** - * Reports lock contention - */ -static inline void -generic_thread_dump_lock_overhead() -{ -#ifndef NDEBUG -#ifdef LOG_LOCK_OVERHEAD - uint64_t duration = __getcycles() - generic_thread_start_timestamp; - debuglog("Locks consumed %lu / %lu cycles, or %f%%\n", generic_thread_lock_duration, duration, - (double)generic_thread_lock_duration / duration * 100); -#endif -#endif -} - +void generic_thread_dump_lock_overhead(); void generic_thread_initialize(); diff --git a/runtime/src/generic_thread.c b/runtime/src/generic_thread.c index 1fb9f9c..3deea4c 100644 --- a/runtime/src/generic_thread.c +++ b/runtime/src/generic_thread.c @@ -1,6 +1,7 @@ #include #include "arch/getcycles.h" +#include "debuglog.h" /* Implemented by listener and workers */ @@ -13,3 +14,18 @@ generic_thread_initialize() generic_thread_start_timestamp = __getcycles(); generic_thread_lock_duration = 0; } + +/** + * Reports lock contention + */ +void +generic_thread_dump_lock_overhead() +{ +#ifndef NDEBUG +#ifdef LOG_LOCK_OVERHEAD + uint64_t duration = __getcycles() - generic_thread_start_timestamp; + debuglog("Locks consumed %lu / %lu cycles, or %f%%\n", generic_thread_lock_duration, duration, + (double)generic_thread_lock_duration / duration * 100); +#endif +#endif +}