From d52849cb783358b0e97e8c13b6f08cc084d273cc Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@uni-potsdam.de>
Date: Sun, 9 Jun 2024 21:47:02 +0200
Subject: [PATCH] zellularautomat: c: Drop custom time measurement

---
 src/benchmarks/zellularautomat/c/ca_common.c |  8 ++++----
 src/benchmarks/zellularautomat/c/ca_common.h | 11 +----------
 src/benchmarks/zellularautomat/c/ca_openmp.c |  8 +++-----
 src/benchmarks/zellularautomat/c/meson.build |  1 -
 4 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/src/benchmarks/zellularautomat/c/ca_common.c b/src/benchmarks/zellularautomat/c/ca_common.c
index b004ce8a..4793064d 100644
--- a/src/benchmarks/zellularautomat/c/ca_common.c
+++ b/src/benchmarks/zellularautomat/c/ca_common.c
@@ -61,9 +61,9 @@ static char* ca_buffer_to_hex_str(const uint8_t* buf, size_t buf_size)
   return retval;
 }
 
-static void ca_print_hash_and_time(const char *hash, const double time)
+static void ca_print_hash(const char *hash)
 {
-	printf("hash: %s\ttime: %.3f s\n", (hash ? hash : "ERROR"), time);
+	printf("hash: %s\n", (hash ? hash : "ERROR"));
 }
 
 static void ca_clean_ghost_zones(line_t *buf, int lines)
@@ -74,7 +74,7 @@ static void ca_clean_ghost_zones(line_t *buf, int lines)
 	}
 }
 
-void ca_hash_and_report(line_t *buf, int lines, double time_in_s)
+void ca_hash_and_report(line_t *buf, int lines)
 {
 	uint8_t hash[MD5_DIGEST_LENGTH];
 	uint32_t md_len;
@@ -87,7 +87,7 @@ void ca_hash_and_report(line_t *buf, int lines, double time_in_s)
 	EVP_DigestFinal_ex(ctx, hash, &md_len);
 
 	char* hash_str = ca_buffer_to_hex_str(hash, MD5_DIGEST_LENGTH);
-	ca_print_hash_and_time(hash_str, time_in_s);
+	ca_print_hash(hash_str);
 	free(hash_str);
 
 	EVP_MD_CTX_free(ctx);
diff --git a/src/benchmarks/zellularautomat/c/ca_common.h b/src/benchmarks/zellularautomat/c/ca_common.h
index 6ec6a889..532da415 100644
--- a/src/benchmarks/zellularautomat/c/ca_common.h
+++ b/src/benchmarks/zellularautomat/c/ca_common.h
@@ -3,7 +3,6 @@
 
 #include <stdint.h>
 #include <stddef.h>
-#include <time.h>
 
 /* a: pointer to array; x,y: coordinates; result: n-th element of anneal,
       where n is the number of neighbors */
@@ -12,14 +11,6 @@
            (a)[(y)-1][(x)  ] + (a)[(y)][(x)  ] + (a)[(y)+1][(x)  ] +\
            (a)[(y)-1][(x)+1] + (a)[(y)][(x)+1] + (a)[(y)+1][(x)+1]])
 
-#define TIME_GET(timer) \
-	struct timespec timer; \
-	clock_gettime(CLOCK_MONOTONIC, &timer)
-
-#define TIME_DIFF(timer1, timer2) \
-	((timer2.tv_sec * 1.0E+9 + timer2.tv_nsec) - \
-	 (timer1.tv_sec * 1.0E+9 + timer1.tv_nsec)) / 1.0E+9
-
 
 #ifdef __cplusplus
 extern "C" {
@@ -35,7 +26,7 @@ typedef cell_state_t line_t[XSIZE + 2];
 
 void ca_init(int argc, char** argv, int *lines, int *its);
 void ca_init_config(line_t *buf, int lines, int skip_lines);
-void ca_hash_and_report(line_t *buf, int lines, double time_in_s);
+void ca_hash_and_report(line_t *buf, int lines);
 
 #ifdef __cplusplus
 }
diff --git a/src/benchmarks/zellularautomat/c/ca_openmp.c b/src/benchmarks/zellularautomat/c/ca_openmp.c
index b42fc1ea..ad9166fb 100644
--- a/src/benchmarks/zellularautomat/c/ca_openmp.c
+++ b/src/benchmarks/zellularautomat/c/ca_openmp.c
@@ -33,7 +33,7 @@ static void boundary(line_t *buf, int lines)
 		for (int y = 0; y <= lines + 1; y++) {
 			/* copy rightmost column to the buffer column 0 */
 			buf[y][0] = buf[y][XSIZE];
-	
+
 			/* copy leftmost column to the buffer column XSIZE + 1 */
 			buf[y][XSIZE + 1] = buf[y][1];
 		}
@@ -43,7 +43,7 @@ static void boundary(line_t *buf, int lines)
 		for (int x = 0; x <= XSIZE + 1; x++) {
 			/* copy bottommost row to buffer row 0 */
 			buf[0][x] = buf[lines][x];
-	
+
 			/* copy topmost row to buffer row lines + 1 */
 			buf[lines + 1][x] = buf[1][x];
 		}
@@ -77,7 +77,6 @@ int main(int argc, char** argv)
 
 	ca_init_config(from, lines, 0);
 
-	TIME_GET(sim_start);
 	for (int i = 0; i < its; i++) {
 		boundary(from, lines);
 		simulate(from, to, lines);
@@ -86,9 +85,8 @@ int main(int argc, char** argv)
 		from = to;
 		to = temp;
 	}
-	TIME_GET(sim_stop);
 
-	ca_hash_and_report(from + 1, lines, TIME_DIFF(sim_start, sim_stop));
+	ca_hash_and_report(from + 1, lines);
 
 	free(from);
 	free(to);
diff --git a/src/benchmarks/zellularautomat/c/meson.build b/src/benchmarks/zellularautomat/c/meson.build
index 056fd2cf..f3642e62 100644
--- a/src/benchmarks/zellularautomat/c/meson.build
+++ b/src/benchmarks/zellularautomat/c/meson.build
@@ -8,7 +8,6 @@ sources = [
 dependencies = [
 	dependency('openmp'),
 	cc.find_library('crypto'),
-	cc.find_library('rt'),
 ]
 
 options = [
-- 
GitLab