From faadf7094570d311fb7e262472b69f5c82d4637c Mon Sep 17 00:00:00 2001
From: Nicolas Pfeiffer <nicolas.pfeiffer@fau.de>
Date: Thu, 9 Jan 2020 18:15:28 +0100
Subject: [PATCH] clean up in benchmarks

---
 benchmarks/emper_continuation/CMakeLists.txt  | 14 ++++++
 .../emper_continuation/emper_continuation.h   | 47 ++++---------------
 2 files changed, 24 insertions(+), 37 deletions(-)

diff --git a/benchmarks/emper_continuation/CMakeLists.txt b/benchmarks/emper_continuation/CMakeLists.txt
index 5277380a..d6473281 100644
--- a/benchmarks/emper_continuation/CMakeLists.txt
+++ b/benchmarks/emper_continuation/CMakeLists.txt
@@ -37,3 +37,17 @@ target_link_libraries(rectmul_emper_continuation Threads::Threads emper)
 
 add_executable(strassen_emper_continuation ../strassen.cpp)
 target_link_libraries(strassen_emper_continuation Threads::Threads emper)
+
+
+add_test(cholesky cholesky_emper_continuation)
+add_test(fft fft_emper_continuation)
+add_test(fib fib_emper_continuation)
+add_test(heat heat_emper_continuation)
+add_test(integrate integrate_emper_continuation)
+add_test(knapsack knapsack_emper_continuation)
+add_test(lu lu_emper_continuation)
+add_test(matmul matmul_emper_continuation)
+add_test(nqueens nqueens_emper_continuation)
+add_test(quicksort quicksort_emper_continuation)
+add_test(rectmul rectmul_emper_continuation)
+add_test(strassen strassen_emper_continuation)
diff --git a/benchmarks/emper_continuation/emper_continuation.h b/benchmarks/emper_continuation/emper_continuation.h
index fd91f0eb..0edac087 100644
--- a/benchmarks/emper_continuation/emper_continuation.h
+++ b/benchmarks/emper_continuation/emper_continuation.h
@@ -40,47 +40,20 @@ public:
 
 #include "fork.h"
 
-#ifndef EMPER_LOCKED_FIBRIL
-
-#define fibril_fork_nrt(fp, fn, ag) do { \
-	auto _fibril_##fn##_fork = [](_fibril_defs ag fibril_t * f) __attribute__((noinline, hot, optimize(3))) { \
-		(*f)->cont.ip = __builtin_return_address(0); \
-		if (!(*f)->incremented) { \
-			(*f)->incremented = 1; \
-			(*f)->count.fetch_add(1, std::memory_order_relaxed); \
-		} \
-		Runtime* runtime = Runtime::getRuntime(); \
-		runtime->pushBottom(**f); \
-		fn(_fibril_args ag); \
-		if (!runtime->popBottom()) { \
-			(*f)->resume(); \
-		} \
-	}; \
-	membar(_fibril_##fn##_fork(_fibril_expand ag fp)); \
-} while (0);
-
-#define fibril_fork_wrt(fp, rt, fn, ag) do { \
-	auto _fibril_##fn##_fork = [](_fibril_defs ag fibril_t * f, __typeof__(rt) p) __attribute__((noinline, hot, optimize(3))) { \
-		(*f)->cont.ip = __builtin_return_address(0); \
-		if (!(*f)->incremented) { \
-			(*f)->incremented = 1; \
-			(*f)->count.fetch_add(1, std::memory_order_relaxed); \
-		} \
-		Runtime* runtime = Runtime::getRuntime(); \
-		runtime->pushBottom(**f); \
-		*p = fn(_fibril_args ag); \
-		if (!runtime->popBottom()) { \
-			(*f)->resume(); \
-		} \
-	}; \
-	membar(_fibril_##fn##_fork(_fibril_expand ag fp, rt)); \
-} while (0);
-
+#ifdef EMPER_LOCKED_FIBRIL
+#define _fibril_inc_count(f)
 #else
+#define _fibril_inc_count(f) \
+	if (!(*f)->incremented) { \
+		(*f)->incremented = 1; \
+		(*f)->count.fetch_add(1, std::memory_order_relaxed); \
+	}
+#endif
 
 #define fibril_fork_nrt(fp, fn, ag) do { \
 	auto _fibril_##fn##_fork = [](_fibril_defs ag fibril_t * f) __attribute__((noinline, hot, optimize(3))) { \
 		(*f)->cont.ip = __builtin_return_address(0); \
+		_fibril_inc_count(f); \
 		Runtime* runtime = Runtime::getRuntime(); \
 		runtime->pushBottom(**f); \
 		fn(_fibril_args ag); \
@@ -94,6 +67,7 @@ public:
 #define fibril_fork_wrt(fp, rt, fn, ag) do { \
 	auto _fibril_##fn##_fork = [](_fibril_defs ag fibril_t * f, __typeof__(rt) p) __attribute__((noinline, hot, optimize(3))) { \
 		(*f)->cont.ip = __builtin_return_address(0); \
+		_fibril_inc_count(f); \
 		Runtime* runtime = Runtime::getRuntime(); \
 		runtime->pushBottom(**f); \
 		*p = fn(_fibril_args ag); \
@@ -104,7 +78,6 @@ public:
 	membar(_fibril_##fn##_fork(_fibril_expand ag fp, rt)); \
 } while (0);
 
-#endif
 
 #define fibril_rt_init(n) Runtime runtime; runtime.executeAndWait([&] () {
 //#define fibril_rt_init(n) Runtime runtime(2); runtime.executeAndWait([&] () {
-- 
GitLab