From cc5f23629704965d4636a40390deb3c9a68e7d38 Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Mon, 23 Sep 2019 18:09:34 +0100
Subject: [PATCH] Report deadtime when using a fixed delay, note how bad
 nanosleep is, must be a major source of mismatch in our timings

---
 swiftmpistepsim.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/swiftmpistepsim.c b/swiftmpistepsim.c
index 81b4900..d8a3a8b 100644
--- a/swiftmpistepsim.c
+++ b/swiftmpistepsim.c
@@ -95,7 +95,8 @@ static void injection_runner(int qid) {
        * are below that (we time the ticks this loop takes without any waiting
        * and use that). Otherwise we wait a while. Note we need to convert the
        * ticks of the log file into nanoseconds, that requires the original
-       * CPU frequency. */
+       * CPU frequency. Note nanosleep is not very accurate and seems to have
+       * a base line at 50us using tests on Durham COSMA. */
       if (dt > looptics) {
         struct timespec sleep;
         sleep.tv_sec = 0;
@@ -168,7 +169,7 @@ static void injection_runner(int qid) {
     message("%d injections completed, sends = %d, recvs = %d", ind_req[qid],
             nr_sends, nr_recvs);
     message("remaining sends = %d, recvs = %d", todo_send, todo_recv);
-    if (usetics) message("deadtime %.3f ms", deadtime / 1.0e6);
+    if (usetics|| waitns > 0) message("deadtime %.3f ms", deadtime / 1.0e6);
   }
   message("took %.3f %s.", clocks_from_ticks(getticks() - starttics),
           clocks_getunit());
-- 
GitLab