From: pini Date: Mon, 8 Mar 2010 13:04:59 +0000 (+0000) Subject: Cosmetics + basic support for printing the simulated time spent in MPI calls (use... X-Git-Tag: SVN~534 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5b6830658ae00f48fbca5a43ed666c98301b163c?hp=0d1840a527cbbc437e17dbd7d09c94ef48fbb07b Cosmetics + basic support for printing the simulated time spent in MPI calls (use with --cfg=SMPE:1). git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7205 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/smpi/private.h b/src/smpi/private.h index 3962ca02e9..07e645a089 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -20,19 +20,22 @@ typedef struct s_smpi_mpi_request { int complete; } s_smpi_mpi_request_t; -smpi_process_data_t smpi_process_data(void); -smpi_process_data_t smpi_process_remote_data(int index); -void smpi_global_init(void); -void smpi_global_destroy(void); - void smpi_process_init(int* argc, char*** argv); void smpi_process_destroy(void); + +smpi_process_data_t smpi_process_data(void); +smpi_process_data_t smpi_process_remote_data(int index); int smpi_process_count(void); int smpi_process_index(void); xbt_os_timer_t smpi_process_timer(void); +void smpi_process_simulated_reset(void); +double smpi_process_simulated_elapsed(void); void smpi_process_post_send(MPI_Comm comm, MPI_Request request); void smpi_process_post_recv(MPI_Request request); +void smpi_global_init(void); +void smpi_global_destroy(void); + size_t smpi_datatype_size(MPI_Datatype datatype); MPI_Aint smpi_datatype_lb(MPI_Datatype datatype); MPI_Aint smpi_datatype_ub(MPI_Datatype datatype); @@ -90,10 +93,7 @@ int smpi_coll_tuned_alltoall_pairwise(void* sendbuf, int sendcount, MPI_Datatype int smpi_coll_basic_alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtype, void* recvbuf, int *recvcounts, int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm); // utilities -void smpi_bench_init(void); -void smpi_bench_destroy(void); -void smpi_execute(double duration); -void smpi_bench_begin(void); +void smpi_bench_begin(const char* mpi_call); void smpi_bench_end(void); #endif diff --git a/src/smpi/smpi_base.c b/src/smpi/smpi_base.c index 96028af185..40b1b5891a 100644 --- a/src/smpi/smpi_base.c +++ b/src/smpi/smpi_base.c @@ -22,12 +22,12 @@ void smpi_process_init(int* argc, char*** argv) { index = atoi((*argv)[1]); data = smpi_process_remote_data(index); SIMIX_process_set_data(proc, data); - DEBUG2("<%d> New process in the game: %p", index, proc); if (*argc > 2) { memmove(&(*argv)[1], &(*argv)[2], sizeof(char *) * (*argc - 2)); (*argv)[(*argc) - 1] = NULL; } (*argc)--; + DEBUG2("<%d> New process in the game: %p", index, proc); } void smpi_process_destroy(void) { diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 31dbd250d5..06ce7c4b2c 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -4,8 +4,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi, "Logging specific to SMPI (benchmarking)"); -void smpi_execute(double duration) -{ +static void smpi_execute(double duration) { smx_host_t host; smx_action_t action; smx_mutex_t mutex; @@ -21,9 +20,9 @@ void smpi_execute(double duration) action = SIMIX_action_execute(host, "computation", duration); SIMIX_mutex_lock(mutex); SIMIX_register_action_to_condition(action, cond); - for (state = SIMIX_action_get_state(action); - state == SURF_ACTION_READY || - state == SURF_ACTION_RUNNING; state = SIMIX_action_get_state(action)) { + for(state = SIMIX_action_get_state(action); + state == SURF_ACTION_READY || + state == SURF_ACTION_RUNNING; state = SIMIX_action_get_state(action)) { SIMIX_cond_wait(cond, mutex); } SIMIX_unregister_action_to_condition(action, cond); @@ -34,17 +33,21 @@ void smpi_execute(double duration) } } -void smpi_bench_begin() -{ +void smpi_bench_begin(const char* mpi_call) { + double simulated = smpi_process_simulated_elapsed(); + + if(mpi_call && xbt_cfg_get_int(_surf_cfg_set, "SMPE")) { + INFO2("SMPE: %s in %fs", mpi_call, simulated); + } xbt_os_timer_start(smpi_process_timer()); } -void smpi_bench_end() -{ +void smpi_bench_end() { xbt_os_timer_t timer = smpi_process_timer(); xbt_os_timer_stop(timer); smpi_execute(xbt_os_timer_elapsed(timer)); + smpi_process_simulated_reset(); } /* diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index 403d5d631e..cf49cf98e6 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -13,6 +13,7 @@ typedef struct s_smpi_process_data { xbt_fifo_t pending_sent; xbt_fifo_t pending_recv; xbt_os_timer_t timer; + double simulated; } s_smpi_process_data_t; static smpi_process_data_t* process_data = NULL; @@ -44,6 +45,18 @@ xbt_os_timer_t smpi_process_timer(void) { return data->timer; } +void smpi_process_simulated_reset(void) { + smpi_process_data_t data = smpi_process_data(); + + data->simulated = SIMIX_get_clock(); +} + +double smpi_process_simulated_elapsed(void) { + smpi_process_data_t data = smpi_process_data(); + + return SIMIX_get_clock() - data->simulated; +} + void smpi_process_post_send(MPI_Comm comm, MPI_Request request) { int index = smpi_group_index(smpi_comm_group(comm), request->dst); smpi_process_data_t data = smpi_process_remote_data(index); @@ -102,6 +115,7 @@ void smpi_process_post_recv(MPI_Request request) { } void smpi_global_init(void) { + double clock = SIMIX_get_clock(); int i; MPI_Group group; @@ -114,6 +128,7 @@ void smpi_global_init(void) { process_data[i]->pending_sent = xbt_fifo_new(); process_data[i]->pending_recv = xbt_fifo_new(); process_data[i]->timer = xbt_os_timer_new(); + process_data[i]->simulated = clock; } group = smpi_group_new(process_count); MPI_COMM_WORLD = smpi_comm_new(group); @@ -152,6 +167,11 @@ int main(int argc, char **argv) "Boolean indicating whether we should display the timing after simulation.", xbt_cfgelm_int, &default_display_timing, 1, 1, NULL, NULL); + int default_display_smpe = 0; + xbt_cfg_register(&_surf_cfg_set, "SMPE", + "Boolean indicating whether we should display simulated time spent in MPI calls.", + xbt_cfgelm_int, &default_display_smpe, 1, 1, NULL, NULL); + SIMIX_global_init(&argc, argv); // parse the platform file: get the host list diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.c index 5436c0a4cc..6258fd9469 100644 --- a/src/smpi/smpi_mpi.c +++ b/src/smpi/smpi_mpi.c @@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, int MPI_Init(int* argc, char*** argv) { smpi_process_init(argc, argv); - smpi_bench_begin(); + smpi_bench_begin(NULL); return MPI_SUCCESS; } @@ -38,7 +38,7 @@ int MPI_Query_thread(int* provided) { *provided = MPI_THREAD_MULTIPLE; retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Query_thread"); return retval; } @@ -52,7 +52,7 @@ int MPI_Is_thread_main(int* flag) { *flag = smpi_process_index() == 0; retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Is_thread_main"); return retval; } @@ -69,7 +69,7 @@ double MPI_Wtime(void) { smpi_bench_end(); time = SIMIX_get_clock(); - smpi_bench_begin(); + smpi_bench_begin("MPI_Wtime"); return time; } @@ -85,7 +85,7 @@ int MPI_Type_size(MPI_Datatype datatype, size_t* size) { *size = smpi_datatype_size(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Type_size"); return retval; } @@ -100,7 +100,7 @@ int MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint* extent) { } else { retval = smpi_datatype_extent(datatype, lb, extent); } - smpi_bench_begin(); + smpi_bench_begin("MPI_Type_get_extent"); return retval; } @@ -116,7 +116,7 @@ int MPI_Type_lb(MPI_Datatype datatype, MPI_Aint* disp) { *disp = smpi_datatype_lb(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Type_lb"); return retval; } @@ -132,7 +132,7 @@ int MPI_Type_ub(MPI_Datatype datatype, MPI_Aint* disp) { *disp = smpi_datatype_ub(datatype); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Type_ub"); return retval; } @@ -146,7 +146,7 @@ int MPI_Op_create(MPI_User_function* function, int commute, MPI_Op* op) { *op = smpi_op_new(function, commute); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Op_create"); return retval; } @@ -163,7 +163,7 @@ int MPI_Op_free(MPI_Op* op) { *op = MPI_OP_NULL; retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Op_free"); return retval; } @@ -178,7 +178,7 @@ int MPI_Group_free(MPI_Group *group) { *group = MPI_GROUP_NULL; retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_free"); return retval; } @@ -194,7 +194,7 @@ int MPI_Group_size(MPI_Group group, int* size) { *size = smpi_group_size(group); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_size"); return retval; } @@ -210,7 +210,7 @@ int MPI_Group_rank(MPI_Group group, int* rank) { *rank = smpi_group_rank(group, smpi_process_index()); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_rank"); return retval; } @@ -227,7 +227,7 @@ int MPI_Group_translate_ranks (MPI_Group group1, int n, int* ranks1, MPI_Group g } retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_translate_ranks"); return retval; } @@ -243,7 +243,7 @@ int MPI_Group_compare(MPI_Group group1, MPI_Group group2, int* result) { *result = smpi_group_compare(group1, group2); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_compare"); return retval; } @@ -282,7 +282,7 @@ int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup) { smpi_group_use(*newgroup); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_union"); return retval; } @@ -320,7 +320,7 @@ int MPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group* newgro smpi_group_use(*newgroup); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_intersection"); return retval; } @@ -356,7 +356,7 @@ int MPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup smpi_group_use(*newgroup); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_difference"); return retval; } @@ -383,7 +383,7 @@ int MPI_Group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup) { smpi_group_use(*newgroup); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_incl"); return retval; } @@ -420,7 +420,7 @@ int MPI_Group_excl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup) { smpi_group_use(*newgroup); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_excl"); return retval; } @@ -463,7 +463,7 @@ int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], MPI_Group* new smpi_group_use(*newgroup); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_range_incl"); return retval; } @@ -514,7 +514,7 @@ int MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group* new smpi_group_use(*newgroup); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Group_range_excl"); return retval; } @@ -528,7 +528,7 @@ int MPI_Comm_rank(MPI_Comm comm, int* rank) { *rank = smpi_comm_rank(comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Comm_rank"); return retval; } @@ -544,7 +544,7 @@ int MPI_Comm_size(MPI_Comm comm, int* size) { *size = smpi_comm_size(comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Comm_size"); return retval; } @@ -560,7 +560,7 @@ int MPI_Comm_group(MPI_Comm comm, MPI_Group* group) { *group = smpi_comm_group(comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Comm_group"); return retval; } @@ -583,7 +583,7 @@ int MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int* result) { } retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Comm_compare"); return retval; } @@ -599,7 +599,7 @@ int MPI_Comm_dup(MPI_Comm comm, MPI_Comm* newcomm) { *newcomm = smpi_comm_new(smpi_comm_group(comm)); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Comm_dup"); return retval; } @@ -617,7 +617,7 @@ int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm* newcomm) { *newcomm = smpi_comm_new(group); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Comm_create"); return retval; } @@ -634,7 +634,7 @@ int MPI_Comm_free(MPI_Comm* comm) { *comm = MPI_COMM_NULL; retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Comm_free"); return retval; } @@ -648,7 +648,7 @@ int MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Irecv"); return retval; } @@ -662,28 +662,28 @@ int MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Isend"); return retval; } int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status) { smpi_bench_end(); smpi_mpi_recv(buf, count, datatype, src, tag, comm, status); - smpi_bench_begin(); + smpi_bench_begin("MPI_Recv"); return MPI_SUCCESS; } int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { smpi_bench_end(); smpi_mpi_send(buf, count, datatype, dst, tag, comm); - smpi_bench_begin(); + smpi_bench_begin("MPI_Send"); return MPI_SUCCESS; } int MPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status) { smpi_bench_end(); smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src, recvtag, comm, status); - smpi_bench_begin(); + smpi_bench_begin("MPI_Sendrecv"); return MPI_SUCCESS; } @@ -712,7 +712,7 @@ int MPI_Test(MPI_Request* request, int* flag, MPI_Status* status) { *flag = smpi_mpi_test(request, status); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Test"); return retval; } @@ -726,7 +726,7 @@ int MPI_Testany(int count, MPI_Request requests[], int* index, int* flag, MPI_St *flag = smpi_mpi_testany(count, requests, index, status); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Testany"); return retval; } @@ -742,7 +742,7 @@ int MPI_Wait(MPI_Request* request, MPI_Status* status) { smpi_mpi_wait(request, status); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Wait"); return retval; } @@ -756,14 +756,14 @@ int MPI_Waitany(int count, MPI_Request requests[], int* index, MPI_Status* statu *index = smpi_mpi_waitany(count, requests, status); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Waitany"); return retval; } int MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]) { smpi_bench_end(); smpi_mpi_waitall(count, requests, status); - smpi_bench_begin(); + smpi_bench_begin("MPI_Waitall"); return MPI_SUCCESS; } @@ -777,7 +777,7 @@ int MPI_Waitsome(int incount, MPI_Request requests[], int* outcount, int* indice *outcount = smpi_mpi_waitsome(incount, requests, indices, status); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Waitsome"); return retval; } @@ -791,7 +791,7 @@ int MPI_Bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm co smpi_mpi_bcast(buf, count, datatype, root, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Bcast"); return retval; } @@ -805,7 +805,7 @@ int MPI_Barrier(MPI_Comm comm) { smpi_mpi_barrier(comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Barrier"); return retval; } @@ -821,7 +821,7 @@ int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbu smpi_mpi_gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Gather"); return retval; } @@ -839,7 +839,7 @@ int MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvb smpi_mpi_gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Gatherv"); return retval; } @@ -855,7 +855,7 @@ int MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* rec smpi_mpi_allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Allgather"); return retval; } @@ -873,7 +873,7 @@ int MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* re smpi_mpi_allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Allgatherv"); return retval; } @@ -889,7 +889,7 @@ int MPI_Scatter(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvb smpi_mpi_scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Scatter"); return retval; } @@ -907,7 +907,7 @@ int MPI_Scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendt smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Scatterv"); return retval; } @@ -923,7 +923,7 @@ int MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, M smpi_mpi_reduce(sendbuf, recvbuf, count, datatype, op, root, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Reduce"); return retval; } @@ -941,7 +941,7 @@ int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype smpi_mpi_allreduce(sendbuf, recvbuf, count, datatype, op, comm); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Allreduce"); return retval; } @@ -974,7 +974,7 @@ int MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int* recvcounts, MPI_Dataty xbt_free(displs); retval = MPI_SUCCESS; } - smpi_bench_begin(); + smpi_bench_begin("MPI_Reduce_scatter"); return retval; } @@ -1004,7 +1004,7 @@ int MPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recv retval = smpi_coll_tuned_alltoall_pairwise(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); } } - smpi_bench_begin(); + smpi_bench_begin("MPI_Alltoall"); return retval; } @@ -1021,6 +1021,6 @@ int MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype s } else { retval = smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm); } - smpi_bench_begin(); + smpi_bench_begin("MPI_Alltoallv"); return retval; }