X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/26c83295361ea3da5cd2c45b867069ad1a1d7349..0ffe46c97f312f9af2b6eb0c4068a84d4523fb10:/src/smpi/smpi_bench.cpp diff --git a/src/smpi/smpi_bench.cpp b/src/smpi/smpi_bench.cpp index 21abd6161e..891b66338f 100644 --- a/src/smpi/smpi_bench.cpp +++ b/src/smpi/smpi_bench.cpp @@ -11,6 +11,7 @@ #include "src/internal_config.h" #include "private.h" +#include "private.hpp" #include "xbt/dict.h" #include "xbt/sysdep.h" #include "xbt/ex.h" @@ -251,6 +252,7 @@ void smpi_bench_end(void) if (MC_is_active() || MC_record_replay_is_active()) return; + double speedup = 1; xbt_os_timer_t timer = smpi_process_timer(); xbt_os_threadtimer_stop(timer); // smpi_switch_data_segment(smpi_process_count()); @@ -260,9 +262,21 @@ void smpi_bench_end(void) xbt_backtrace_display_current(); xbt_die("Aborting."); } + + if (xbt_cfg_get_string("smpi/comp-adjustment-file")[0] != '\0') { // Maybe we need to artificially speed up or slow + // down our computation based on our statistical analysis. + + smpi_trace_call_location_t* loc = smpi_process_get_call_location(); + std::string key = loc->get_composed_key(); + std::map::const_iterator it = location2speedup.find(key); + if (it != location2speedup.end()) { + speedup = it->second; + } + } + // Simulate the benchmarked computation unless disabled via command-line argument - if (xbt_cfg_get_boolean("smpi/simulate_computation")) { - smpi_execute(xbt_os_timer_elapsed(timer)); + if (xbt_cfg_get_boolean("smpi/simulate-computation")) { + smpi_execute(xbt_os_timer_elapsed(timer)/speedup); } smpi_total_benched_time += xbt_os_timer_elapsed(timer); @@ -481,7 +495,7 @@ void smpi_sample_3(int global, const char *file, int line) void *smpi_shared_malloc(size_t size, const char *file, int line) { void* mem; - if (xbt_cfg_get_boolean("smpi/use_shared_malloc")){ + if (xbt_cfg_get_boolean("smpi/use-shared-malloc")){ int fd; smpi_source_location loc(file, line); auto res = allocs.insert(std::make_pair(loc, shared_data_t())); @@ -497,7 +511,7 @@ void *smpi_shared_malloc(size_t size, const char *file, int line) case EEXIST: xbt_die("Please cleanup /dev/shm/%s", shmname); default: - xbt_die("An unhandled error occured while opening %s. shm_open: %s", shmname, strerror(errno)); + xbt_die("An unhandled error occurred while opening %s. shm_open: %s", shmname, strerror(errno)); } } data->second.fd = fd; @@ -524,7 +538,7 @@ void smpi_shared_free(void *ptr) { char loc[PTR_STRLEN]; - if (xbt_cfg_get_boolean("smpi/use_shared_malloc")){ + if (xbt_cfg_get_boolean("smpi/use-shared-malloc")){ snprintf(loc, PTR_STRLEN, "%p", ptr); auto meta = allocs_metadata.find(ptr); if (meta == allocs_metadata.end()) { @@ -723,3 +737,32 @@ void smpi_destroy_global_memory_segments(){ xbt_free(smpi_privatisation_regions); #endif } + +smpi_trace_call_location_t* smpi_trace_get_call_location() { + return smpi_process_get_call_location(); +} + +extern "C" { /** These functions will be called from the user code **/ + void smpi_trace_set_call_location(const char* file, const int line) { + smpi_trace_call_location_t* loc = smpi_process_get_call_location(); + + loc->previous_filename = loc->filename; + loc->previous_linenumber = loc->linenumber; + loc->filename = file; + loc->linenumber = line; + } + + /** + * Required for Fortran bindings + */ + void smpi_trace_set_call_location_(const char* file, int* line) { + smpi_trace_set_call_location(file, *line); + } + + /** + * Required for Fortran if -fsecond-underscore is activated + */ + void smpi_trace_set_call_location__(const char* file, int* line) { + smpi_trace_set_call_location(file, *line); + } +}