Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / internals / smpi_bench.cpp
index 636c0f5..d8fd0ec 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -13,6 +13,7 @@
 #include "smpi_utils.hpp"
 #include "src/internal_config.h"
 #include "src/mc/mc_replay.hpp"
+#include "src/surf/surf_interface.hpp" // sg_surf_precision
 #include "xbt/config.hpp"
 #include "xbt/file.hpp"
 
@@ -253,22 +254,17 @@ double smpi_mpi_wtime()
   return time;
 }
 
-extern double sg_surf_precision;
+// Used by Akypuera (https://github.com/schnorr/akypuera)
 unsigned long long smpi_rastro_resolution ()
 {
   const SmpiBenchGuard suspend_bench;
-  double resolution = (1/sg_surf_precision);
-  return static_cast<unsigned long long>(resolution);
+  return static_cast<unsigned long long>(1.0 / sg_surf_precision);
 }
 
 unsigned long long smpi_rastro_timestamp ()
 {
   const SmpiBenchGuard suspend_bench;
-  double now = simgrid::s4u::Engine::get_clock();
-
-  auto sec               = static_cast<unsigned long long>(now);
-  unsigned long long pre = (now - sec) * smpi_rastro_resolution();
-  return sec * smpi_rastro_resolution() + pre;
+  return static_cast<unsigned long long>(simgrid::s4u::Engine::get_clock() / sg_surf_precision);
 }
 
 /* ****************************** Functions related to the SMPI_SAMPLE_ macros ************************************/
@@ -369,7 +365,7 @@ int smpi_sample_2(int global, const char *file,const char *tag, int iter_count)
       XBT_DEBUG("No benchmark (either no need, or just ran one): count (%d) >= iter (%d) (or <2) or stderr (%f) < thres (%f), or thresh is negative and ignored. "
               "Mean is %f, will be injected %d times",
               data.count, data.iters, data.relstderr, data.threshold, data.mean, iter_count);
-              
+
       //we ended benchmarking, let's inject all the time, now, and fast forward out of the loop.
       smpi_process()->set_sampling(0);
       smpi_execute(data.mean*iter_count);