X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7199337dd7a6f3d50377a83a301d4212a97474fb..a7c708d3570410ce5a1316a54f9dda55d2bb46ca:/src/smpi/internals/smpi_bench.cpp diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index 58c3c70f7e..b71adc7edd 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -1,15 +1,16 @@ -/* Copyright (c) 2007, 2009-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2007, 2009-2018. 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. */ -#include "private.h" #include "private.hpp" +#include "simgrid/host.h" #include "simgrid/modelchecker.h" #include "smpi_comm.hpp" #include "smpi_process.hpp" #include "src/internal_config.h" -#include "src/mc/mc_replay.h" +#include "src/mc/mc_replay.hpp" +#include "src/simix/ActorImpl.hpp" #include #ifndef WIN32 @@ -28,15 +29,14 @@ double smpi_host_speed; shared_malloc_type smpi_cfg_shared_malloc = shmalloc_global; double smpi_total_benched_time = 0; -smpi_privatization_region_t smpi_privatization_regions; -extern "C" XBT_PUBLIC(void) smpi_execute_flops_(double *flops); +extern "C" XBT_PUBLIC void smpi_execute_flops_(double* flops); void smpi_execute_flops_(double *flops) { smpi_execute_flops(*flops); } -extern "C" XBT_PUBLIC(void) smpi_execute_(double *duration); +extern "C" XBT_PUBLIC void smpi_execute_(double* duration); void smpi_execute_(double *duration) { smpi_execute(*duration); @@ -44,10 +44,10 @@ void smpi_execute_(double *duration) void smpi_execute_flops(double flops) { XBT_DEBUG("Handle real computation time: %f flops", flops); - smx_activity_t action = simcall_execution_start("computation", flops, 1, 0); + smx_activity_t action = simcall_execution_start("computation", flops, 1, 0, smpi_process()->process()->getHost()); simcall_set_category (action, TRACE_internal_smpi_get_category()); simcall_execution_wait(action); - smpi_switch_data_segment(smpi_process()->index()); + smpi_switch_data_segment(simgrid::s4u::Actor::self()); } void smpi_execute(double duration) @@ -55,11 +55,8 @@ void smpi_execute(double duration) if (duration >= smpi_cpu_threshold) { XBT_DEBUG("Sleep for %g to handle real computation time", duration); double flops = duration * smpi_host_speed; - int rank = smpi_process()->index(); - instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); - extra->type=TRACING_COMPUTING; - extra->comp_size=flops; - TRACE_smpi_computing_in(rank, extra); + int rank = simgrid::s4u::Actor::self()->getPid(); + TRACE_smpi_computing_in(rank, flops); smpi_execute_flops(flops); @@ -74,21 +71,22 @@ void smpi_execute(double duration) void smpi_execute_benched(double duration) { smpi_bench_end(); - smpi_execute(duration); + double speed = sg_host_speed(sg_host_self()); + smpi_execute_flops(duration*speed); smpi_bench_begin(); } void smpi_bench_begin() { if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) { - smpi_switch_data_segment(smpi_process()->index()); + smpi_switch_data_segment(simgrid::s4u::Actor::self()); } if (MC_is_active() || MC_record_replay_is_active()) return; #if HAVE_PAPI - if (xbt_cfg_get_string("smpi/papi-events")[0] != '\0') { + if (not xbt_cfg_get_string("smpi/papi-events").empty()) { int event_set = smpi_process()->papi_event_set(); // PAPI_start sets everything to 0! See man(3) PAPI_start if (PAPI_LOW_LEVEL_INITED == PAPI_is_initialized()) { @@ -128,8 +126,6 @@ void smpi_bench_end() } else { for (unsigned int i = 0; i < counter_data.size(); i++) { counter_data[i].second += event_values[i]; - // XBT_DEBUG("[%i] PAPI: Counter %s: Value is now %lli (got increment by %lli\n", smpi_process()->index(), - // counter_data[i].first.c_str(), counter_data[i].second, event_values[i]); } } } @@ -160,14 +156,13 @@ void smpi_bench_end() #if HAVE_PAPI if (xbt_cfg_get_string("smpi/papi-events")[0] != '\0' && TRACE_smpi_is_enabled()) { - char container_name[INSTR_DEFAULT_STR_SIZE]; - smpi_container(smpi_process()->index(), container_name, INSTR_DEFAULT_STR_SIZE); - container_t container = PJ_container_get(container_name); + container_t container = + new simgrid::instr::Container(std::string("rank-") + std::to_string(simgrid::s4u::Actor::self()->getPid())); papi_counter_t& counter_data = smpi_process()->papi_counters(); for (auto const& pair : counter_data) { - new_pajeSetVariable(surf_get_clock(), container, - PJ_type_get(/* countername */ pair.first.c_str(), container->type), pair.second); + new simgrid::instr::SetVariableEvent( + surf_get_clock(), container, PJ_type_get(/* countername */ pair.first.c_str(), container->type), pair.second); } } #endif @@ -182,10 +177,7 @@ static unsigned int private_sleep(double secs) XBT_DEBUG("Sleep for: %lf secs", secs); int rank = MPI_COMM_WORLD->rank(); - instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); - extra->type=TRACING_SLEEPING; - extra->sleep_duration=secs; - TRACE_smpi_sleeping_in(rank, extra); + TRACE_smpi_sleeping_in(rank, secs); simcall_process_sleep(secs); @@ -206,13 +198,13 @@ int smpi_usleep(useconds_t usecs) } #if _POSIX_TIMERS > 0 -int smpi_nanosleep(const struct timespec *tp, struct timespec * t) +int smpi_nanosleep(const struct timespec* tp, struct timespec* /*t*/) { return static_cast(private_sleep(static_cast(tp->tv_sec + tp->tv_nsec / 1000000000.0))); } #endif -int smpi_gettimeofday(struct timeval *tv, void* tz) +int smpi_gettimeofday(struct timeval* tv, void* /*tz*/) { smpi_bench_end(); double now = SIMIX_get_clock(); @@ -229,7 +221,7 @@ int smpi_gettimeofday(struct timeval *tv, void* tz) } #if _POSIX_TIMERS > 0 -int smpi_clock_gettime(clockid_t clk_id, struct timespec *tp) +int smpi_clock_gettime(clockid_t /*clk_id*/, struct timespec* tp) { //there is only one time in SMPI, so clk_id is ignored. smpi_bench_end(); @@ -265,7 +257,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(simgrid::s4u::Actor::self()->getPid())); + } +}; + +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 +281,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 +295,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 +333,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 +363,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);