X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/138e6f86566611611b1115c957cae0a1c6a85a4b..ab1a94e98438ed2d29533aca9e613d667237c3d0:/src/smpi/smpi_bench.cpp diff --git a/src/smpi/smpi_bench.cpp b/src/smpi/smpi_bench.cpp index e6998c378f..e9b4773355 100644 --- a/src/smpi/smpi_bench.cpp +++ b/src/smpi/smpi_bench.cpp @@ -230,8 +230,6 @@ void smpi_execute(double duration) } } -void smpi_switch_data_segment(int dest); - void smpi_bench_begin(void) { if (smpi_privatize_global_variables) { @@ -309,6 +307,13 @@ int smpi_usleep(useconds_t usecs) return static_cast(private_sleep(static_cast(usecs) / 1000000.0)); } +#if _POSIX_TIMERS > 0 +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) { double now; @@ -326,6 +331,22 @@ int smpi_gettimeofday(struct timeval *tv, void* tz) return 0; } +#if _POSIX_TIMERS > 0 +int smpi_clock_gettime(clockid_t clk_id, struct timespec *tp) +{ + //there is only one time in SMPI, so clk_id is ignored. + double now; + smpi_bench_end(); + now = SIMIX_get_clock(); + if (tp) { + tp->tv_sec = static_cast(now); + tp->tv_nsec = static_cast((now - tp->tv_sec) * 1e9); + } + smpi_bench_begin(); + return 0; +} +#endif + extern double sg_surf_precision; unsigned long long smpi_rastro_resolution (void) { @@ -606,12 +627,11 @@ void* smpi_shared_set_call(const char* func, const char* input, void* data) { return data; } -#define TOPAGE(addr) (void *)(((unsigned long)(addr) / xbt_pagesize) * xbt_pagesize) /** Map a given SMPI privatization segment (make a SMPI process active) */ -void smpi_switch_data_segment(int dest){ - if (smpi_loaded_page==dest)//no need to switch either - return; +void smpi_switch_data_segment(int dest) { + if (smpi_loaded_page == dest)//no need to switch, we've already loaded the one we want + return; // So the job: smpi_really_switch_data_segment(dest); @@ -646,7 +666,7 @@ void smpi_really_switch_data_segment(int dest) { int smpi_is_privatisation_file(char* file) { - return strncmp("/dev/shm/my-buffer-", file, 19) == 0; + return strncmp("/dev/shm/my-buffer-", file, std::strlen("/dev/shm/my-buffer-")) == 0; } void smpi_initialize_global_memory_segments(){