X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7b2fe943182bff869b3ae80333a4f2d2bf0fb7cf..37f5b9a91a456e44ca9a312f84201b3c562e90c6:/src/smpi/smpi_bench.c diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 15fdb676a4..b97f86e4e8 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -209,40 +209,36 @@ void smpi_bench_end(void) smpi_execute(xbt_os_timer_elapsed(timer)); } -unsigned int smpi_sleep(unsigned int secs) +/* Private sleep function used by smpi_sleep() and smpi_usleep() */ +static unsigned int private_sleep(double secs) { - smx_action_t action; - smpi_bench_end(); - double flops = (double) secs*simcall_host_get_speed(SIMIX_host_self()); - XBT_DEBUG("Sleep for: %f flops", flops); - action = simcall_host_execute("computation", SIMIX_host_self(), flops, 1, 0, 0); + XBT_DEBUG("Sleep for: %lf secs", secs); #ifdef HAVE_TRACING - simcall_set_category (action, TRACE_internal_smpi_get_category()); - #endif - simcall_host_execution_wait(action); + int rank = smpi_comm_rank(MPI_COMM_WORLD); + 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); +#endif + simcall_process_sleep(secs); +#ifdef HAVE_TRACING + TRACE_smpi_sleeping_out(rank); +#endif smpi_bench_begin(); - return secs; + return 0; } -int smpi_usleep(useconds_t usecs) +unsigned int smpi_sleep(unsigned int secs) { - smx_action_t action; - - smpi_bench_end(); - - double flops = (double) (usecs/1000000.0)*simcall_host_get_speed(SIMIX_host_self()); - XBT_DEBUG("Sleep for: %f flops", flops); - action = simcall_host_execute("computation", SIMIX_host_self(), flops, 1, 0, 0); - #ifdef HAVE_TRACING - simcall_set_category (action, TRACE_internal_smpi_get_category()); - #endif - simcall_host_execution_wait(action); + return private_sleep((double)secs); +} - smpi_bench_begin(); - return 0; +int smpi_usleep(useconds_t usecs) +{ + return (int)private_sleep((double)usecs / 1000000.0); }