X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7199337dd7a6f3d50377a83a301d4212a97474fb..5f1dc33c9f76ee99973ba93f034f031451398ebe:/src/smpi/internals/smpi_bench.cpp diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index 58c3c70f7e..5b05ac59db 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -265,7 +265,17 @@ unsigned long long smpi_rastro_timestamp () /* ****************************** Functions related to the SMPI_SAMPLE_ macros ************************************/ namespace { -struct LocalData { +class SampleLocation : public std::string { +public: + SampleLocation(bool global, const char* file, int line) : std::string(std::string(file) + ":" + std::to_string(line)) + { + if (not global) + this->append(":" + std::to_string(smpi_process()->index())); + } +}; + +class LocalData { +public: double threshold; /* maximal stderr requested (if positive) */ double relstderr; /* observed stderr so far */ double mean; /* mean of benched times, to be used if the block is disabled */ @@ -279,16 +289,7 @@ struct LocalData { }; } -std::unordered_map samples; - -static std::string sample_location(int global, const char* file, int line) -{ - if (global) { - return std::string(file) + ":" + std::to_string(line); - } else { - return std::string(file) + ":" + std::to_string(line) + ":" + std::to_string(smpi_process()->index()); - } -} +std::unordered_map> samples; bool LocalData::need_more_benchs() const { @@ -302,7 +303,7 @@ bool LocalData::need_more_benchs() const void smpi_sample_1(int global, const char *file, int line, int iters, double threshold) { - std::string loc = sample_location(global, file, line); + SampleLocation loc(global, file, line); smpi_bench_end(); /* Take time from previous, unrelated computation into account */ smpi_process()->set_sampling(1); @@ -340,7 +341,7 @@ void smpi_sample_1(int global, const char *file, int line, int iters, double thr int smpi_sample_2(int global, const char *file, int line) { - std::string loc = sample_location(global, file, line); + SampleLocation loc(global, file, line); int res; XBT_DEBUG("sample2 %s", loc.c_str()); @@ -370,7 +371,7 @@ int smpi_sample_2(int global, const char *file, int line) void smpi_sample_3(int global, const char *file, int line) { - std::string loc = sample_location(global, file, line); + SampleLocation loc(global, file, line); XBT_DEBUG("sample3 %s", loc.c_str()); auto sample = samples.find(loc);