From fa5821e46784328e7e2a71843e124254e8141d11 Mon Sep 17 00:00:00 2001 From: markls Date: Wed, 7 Nov 2007 09:49:46 +0000 Subject: [PATCH] updated smpirun to use new xml format and made changes to benchmark code to (hopefully) make it more accurate. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4988 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/smpi/private.h | 5 +++-- src/smpi/smpi_bench.c | 37 ++++++++++--------------------------- src/smpi/smpi_global.c | 15 +++++++-------- src/smpi/smpirun.in | 22 +++++++++++----------- 4 files changed, 31 insertions(+), 48 deletions(-) diff --git a/src/smpi/private.h b/src/smpi/private.h index 1a8c584550..f3379e6a9f 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -100,8 +100,9 @@ typedef struct smpi_global_t { int running_hosts_count; smx_mutex_t running_hosts_count_mutex; - xbt_os_timer_t *timers; - smx_mutex_t *timers_mutexes; + xbt_os_timer_t timer; + smx_mutex_t timer_mutex; + smx_cond_t timer_cond; } s_smpi_global_t; typedef struct smpi_global_t *smpi_global_t; diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 9bd1f19aa9..b43a1280f7 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -5,45 +5,28 @@ void smpi_bench_begin() { - int index = smpi_host_index(); - - SIMIX_mutex_lock(smpi_global->timers_mutexes[index]); - - xbt_os_timer_start(smpi_global->timers[index]); - + SIMIX_mutex_lock(smpi_global->timer_mutex); + xbt_os_timer_start(smpi_global->timer); return; } void smpi_bench_end() { - int index = smpi_host_index(); double duration; smx_host_t host; char computation[] = "computation"; smx_action_t action; - smx_mutex_t mutex; - smx_cond_t cond; - - xbt_os_timer_stop(smpi_global->timers[index]); - - duration = xbt_os_timer_elapsed(smpi_global->timers[index]); - - SIMIX_mutex_unlock(smpi_global->timers_mutexes[index]); - host = smpi_global->hosts[index]; - action = SIMIX_action_execute(host, computation, duration * SMPI_DEFAULT_SPEED); - mutex = SIMIX_mutex_init(); - cond = SIMIX_cond_init(); + xbt_os_timer_stop(smpi_global->timer); + duration = xbt_os_timer_elapsed(smpi_global->timer); + host = SIMIX_host_self(); + action = SIMIX_action_execute(host, computation, duration * SMPI_DEFAULT_SPEED); - SIMIX_mutex_lock(mutex); - SIMIX_register_action_to_condition(action, cond); - SIMIX_cond_wait(cond, mutex); - SIMIX_unregister_action_to_condition(action, cond); - SIMIX_mutex_unlock(mutex); + SIMIX_register_action_to_condition(action, smpi_global->timer_cond); + SIMIX_cond_wait(smpi_global->timer_cond, smpi_global->timer_mutex); + SIMIX_unregister_action_to_condition(action, smpi_global->timer_cond); - SIMIX_mutex_destroy(mutex); - SIMIX_cond_destroy(cond); - //SIMIX_action_destroy(action); + SIMIX_mutex_unlock(smpi_global->timer_mutex); return; } diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index ef58d883c3..a0786cddbb 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -162,8 +162,9 @@ void smpi_global_init() smpi_global->receiver_processes = xbt_new(smx_process_t, size); // timers - smpi_global->timers = xbt_new(xbt_os_timer_t, size); - smpi_global->timers_mutexes = xbt_new(smx_mutex_t, size); + smpi_global->timer = xbt_os_timer_new(); + smpi_global->timer_mutex = SIMIX_mutex_init(); + smpi_global->timer_cond = SIMIX_cond_init(); for(i = 0; i < size; i++) { smpi_global->pending_send_request_queues[i] = xbt_fifo_new(); @@ -172,8 +173,6 @@ void smpi_global_init() smpi_global->pending_recv_request_queues_mutexes[i] = SIMIX_mutex_init(); smpi_global->received_message_queues[i] = xbt_fifo_new(); smpi_global->received_message_queues_mutexes[i] = SIMIX_mutex_init(); - smpi_global->timers[i] = xbt_os_timer_new(); - smpi_global->timers_mutexes[i] = SIMIX_mutex_init(); } } @@ -199,6 +198,10 @@ void smpi_global_destroy() xbt_mallocator_free(smpi_global->request_mallocator); xbt_mallocator_free(smpi_global->message_mallocator); + xbt_os_timer_free(smpi_global->timer); + SIMIX_mutex_destroy(smpi_global->timer_mutex); + SIMIX_cond_destroy(smpi_global->timer_cond); + for(i = 0; i < size; i++) { xbt_fifo_free(smpi_global->pending_send_request_queues[i]); SIMIX_mutex_destroy(smpi_global->pending_send_request_queues_mutexes[i]); @@ -206,8 +209,6 @@ void smpi_global_destroy() SIMIX_mutex_destroy(smpi_global->pending_recv_request_queues_mutexes[i]); xbt_fifo_free(smpi_global->received_message_queues[i]); SIMIX_mutex_destroy(smpi_global->received_message_queues_mutexes[i]); - xbt_os_timer_free(smpi_global->timers[i]); - SIMIX_mutex_destroy(smpi_global->timers_mutexes[i]); } xbt_free(smpi_global->pending_send_request_queues); @@ -216,8 +217,6 @@ void smpi_global_destroy() xbt_free(smpi_global->pending_recv_request_queues_mutexes); xbt_free(smpi_global->received_message_queues); xbt_free(smpi_global->received_message_queues_mutexes); - xbt_free(smpi_global->timers); - xbt_free(smpi_global->timers_mutexes); xbt_free(smpi_global); diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index 78aba1941a..5d25da17a3 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -41,28 +41,28 @@ PLATFORMTMP="$(mktemp tmpXXXXXX)" cat > ${PLATFORMTMP} < - - + + PLATFORMHEAD for (( i=${NUMPROCS}; $i ; i=$i-1 )) do - echo " " >> ${PLATFORMTMP} - echo " " >> ${PLATFORMTMP} - echo " " >> ${PLATFORMTMP} + echo " " >> ${PLATFORMTMP} + echo " " >> ${PLATFORMTMP} + echo " " >> ${PLATFORMTMP} done for (( i=${NUMPROCS}; $i ; i=$i-1 )) do for (( j=${NUMPROCS}; $j ; j=$j-1 )) do if [ $i -eq $j ]; then - echo " " >> ${PLATFORMTMP} + echo " " >> ${PLATFORMTMP} else - echo " " >> ${PLATFORMTMP} + echo " " >> ${PLATFORMTMP} fi done done cat >> ${PLATFORMTMP} < + PLATFORMFOOT APPLICATIONTMP="$(mktemp tmpXXXXXX)" @@ -70,8 +70,8 @@ APPLICATIONTMP="$(mktemp tmpXXXXXX)" cat > ${APPLICATIONTMP} < - - + + APPLICATIONHEAD for (( i=${NUMPROCS}; $i ; i=$i-1 )) do @@ -88,7 +88,7 @@ for (( i=${NUMPROCS}; $i ; i=$i-1 )) do done cat >> ${APPLICATIONTMP} < + APPLICATIONFOOT ${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP} -- 2.20.1