From 106cdcfec867eefb8285ef6263a47edcc69a83eb Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@uni-potsdam.de>
Date: Thu, 13 Jun 2024 10:08:16 +0200
Subject: [PATCH] rodinia-srad: Add script to compare and validate two
 benchmark results

---
 src/benchmarks/rodinia-srad/validate.py | 38 +++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 src/benchmarks/rodinia-srad/validate.py

diff --git a/src/benchmarks/rodinia-srad/validate.py b/src/benchmarks/rodinia-srad/validate.py
new file mode 100644
index 00000000..d77238eb
--- /dev/null
+++ b/src/benchmarks/rodinia-srad/validate.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+from __future__ import annotations
+
+import sys
+from pathlib import Path
+
+def main(args: list[str]) -> int:
+	outputA: Path = Path(args[0])
+	outputB: Path = Path(args[1])
+
+	linesA: list[str] = outputA.read_text().splitlines()
+	linesB: list[str] = outputB.read_text().splitlines()
+
+	assert len(linesA) == len(linesB)
+	assert linesA[0] == linesB[0]
+	assert linesA[1] == linesB[1]
+
+	errors: list[float] = []
+
+	for i in range(2, len(linesA) - 2):
+		floatsA: list[float] = [float(x) for x in linesA[i].strip().split(' ')]
+		floatsB: list[float] = [float(x) for x in linesB[i].strip().split(' ')]
+
+		assert len(floatsA) == len(floatsB)
+
+		for j in range(0, len(floatsA)):
+			errors.append(abs(floatsA[j] - floatsB[j]))
+
+	assert linesA[-1] == linesB[-1]
+
+	print(f"Absolute Error: {sum(errors)}")
+	print(f"Average Error: {sum(errors) / len(errors)}")
+	print(f"Min Error: {min(errors)}")
+	print(f"Max Error: {max(errors)}")
+
+if __name__ == "__main__":
+	sys.exit(main(sys.argv[1:]))
-- 
GitLab