From 9945be269638d7c9c3ce6f7bdaececb5424ec1e7 Mon Sep 17 00:00:00 2001
From: Florian Schmaus <flow@cs.fau.de>
Date: Tue, 31 Jul 2018 16:17:51 +0200
Subject: [PATCH] eval?Locality: experiment

---
 eval/Locality.cpp | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/eval/Locality.cpp b/eval/Locality.cpp
index 084a4b3f..80a337af 100644
--- a/eval/Locality.cpp
+++ b/eval/Locality.cpp
@@ -127,19 +127,27 @@ static void performRound(State& state,
 
 				uint8_t* fiberData = fiberArgs->fiberData;
 				unsigned int bytesPerFiber = fiberArgs->state->bytesPerFiber;
-				// 75% Chance that this fiber will do work.
-				if (fiberData[0] < 192) {
-					for (unsigned int i = 0; i < bytesPerFiber; i++) {
-						fiberData[i] += fiberArgs->roundData;
+				for (unsigned int i = 0; i < bytesPerFiber; i++) {
+					unsigned int next = (i + L1_DCACHE_SIZE + fiberData[i]) % bytesPerFiber;
+					fiberData[i] -= fiberData[next];
+
+					fiberData[i] += fiberArgs->roundData;
+					/*
+					if (fiberData[i] < 128) {
+						fiberData[i] += fiberArgs->roundData / 2;
+					}
+					if (fiberData[i] > 192) {
+						fiberData[i] -= (fiberArgs->roundData * 4);
+					}
+					*/
+					if (i == (bytesPerFiber * 0.75)) {
 						if (fiberData[i] < 128) {
-							fiberData[i] += fiberArgs->roundData / 2;
-						}
-						if (fiberData[i] > 192) {
-							fiberData[i] -= (fiberArgs->roundData * 4);
+							break;
 						}
 					}
 				}
 
+
 #ifdef FIBER_METADATA
 				fiberMetadata->end = std::chrono::high_resolution_clock::now();
 #endif
@@ -201,8 +209,8 @@ int main(UNUSED_ARG int argc, UNUSED_ARG char *argv[]) {
 	enableStacktraceOnAborts();
 
 	RuntimeVariant runtimeVariant = ws;
-	unsigned int rounds = 10;
-	unsigned int seed = 42;
+	unsigned int rounds = 20;
+	unsigned int seed = 4231;
 
 	int opt;
 	while ((opt = getopt(argc, argv, "m:")) != -1) {
@@ -225,8 +233,8 @@ int main(UNUSED_ARG int argc, UNUSED_ARG char *argv[]) {
 	}
 
 	unsigned int coreCount = 4;
-	unsigned int bytesPerFiber = L1_DCACHE_SIZE / 4;
-	unsigned int fiberCount = coreCount * 6;
+	unsigned int bytesPerFiber = L1_DCACHE_SIZE / 2;
+	unsigned int fiberCount = coreCount * 4;
 
 	std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
 
-- 
GitLab