From 70e4dad5ffd1ba6f56eb7bc97408411b9a73119b Mon Sep 17 00:00:00 2001 From: markls Date: Fri, 12 Oct 2007 10:29:31 +0000 Subject: [PATCH 1/1] code cleanup, streamlining, removed some redundant function calls. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4820 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/smpi/smpi_global.c | 4 ++-- src/smpi/smpi_mpi.c | 36 +++++++++++------------------------- src/smpi/smpi_receiver.c | 2 +- src/smpi/smpi_sender.c | 2 +- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index 89771f5068..ef58d883c3 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -84,7 +84,7 @@ int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype, smpi_mpi_request_t request = NULL; - // FIXME: make sure requestptr is not null + // parameter checking prob belongs in smpi_mpi, but this is less repeat code if (NULL == buf) { retval = MPI_ERR_INTERN; } else if (0 > count) { @@ -100,7 +100,7 @@ int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype, } else if (NULL == comm) { retval = MPI_ERR_COMM; } else if (NULL == requestptr) { - retval = MPI_ERR_INTERN; + retval = MPI_ERR_ARG; } else { request = xbt_mallocator_get(smpi_global->request_mallocator); request->comm = comm; diff --git a/src/smpi/smpi_mpi.c b/src/smpi/smpi_mpi.c index 1a2c3f3858..b29243e007 100644 --- a/src/smpi/smpi_mpi.c +++ b/src/smpi/smpi_mpi.c @@ -104,14 +104,9 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI smpi_bench_end(); - if (NULL == request) { - retval = MPI_ERR_ARG; - } else { - int dst = 0; - retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, request); - if (NULL != *request && MPI_SUCCESS == retval) { - retval = smpi_mpi_irecv(*request); - } + retval = smpi_create_request(buf, count, datatype, src, 0, tag, comm, request); + if (NULL != *request && MPI_SUCCESS == retval) { + retval = smpi_mpi_irecv(*request); } smpi_bench_begin(); @@ -122,12 +117,11 @@ int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status *status) { int retval = MPI_SUCCESS; - int dst = 0; smpi_mpi_request_t request; smpi_bench_end(); - retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &request); + retval = smpi_create_request(buf, count, datatype, src, 0, tag, comm, &request); if (NULL != request && MPI_SUCCESS == retval) { retval = smpi_mpi_irecv(request); if (MPI_SUCCESS == retval) { @@ -147,14 +141,9 @@ int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI smpi_bench_end(); - if (NULL == request) { - retval = MPI_ERR_ARG; - } else { - int src = 0; - retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, request); - if (NULL != *request && MPI_SUCCESS == retval) { - retval = smpi_mpi_isend(*request); - } + retval = smpi_create_request(buf, count, datatype, 0, dst, tag, comm, request); + if (NULL != *request && MPI_SUCCESS == retval) { + retval = smpi_mpi_isend(*request); } smpi_bench_begin(); @@ -165,12 +154,11 @@ int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { int retval = MPI_SUCCESS; - int src = 0; smpi_mpi_request_t request; smpi_bench_end(); - retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &request); + retval = smpi_create_request(buf, count, datatype, 0, dst, tag, comm, &request); if (NULL != request && MPI_SUCCESS == retval) { retval = smpi_mpi_isend(request); if (MPI_SUCCESS == retval) { @@ -184,7 +172,6 @@ int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_ return retval; } -// FIXME: overly simplistic int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm) { int retval = MPI_SUCCESS; @@ -199,15 +186,14 @@ int MPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm co retval = smpi_create_request(buf, count, datatype, root, (root + 1) % comm->size, 0, comm, &request); request->forward = comm->size - 1; smpi_mpi_isend(request); - smpi_mpi_wait(request, MPI_STATUS_IGNORE); - xbt_mallocator_release(smpi_global->request_mallocator, request); } else { retval = smpi_create_request(buf, count, datatype, MPI_ANY_SOURCE, rank, 0, comm, &request); smpi_mpi_irecv(request); - smpi_mpi_wait(request, MPI_STATUS_IGNORE); - xbt_mallocator_release(smpi_global->request_mallocator, request); } + smpi_mpi_wait(request, MPI_STATUS_IGNORE); + xbt_mallocator_release(smpi_global->request_mallocator, request); + smpi_bench_begin(); return retval; diff --git a/src/smpi/smpi_receiver.c b/src/smpi/smpi_receiver.c index eb5c887cbf..0097875810 100644 --- a/src/smpi/smpi_receiver.c +++ b/src/smpi/smpi_receiver.c @@ -90,7 +90,7 @@ stopsearch: request->completed = 1; SIMIX_cond_broadcast(request->cond); } else { - request->src = smpi_mpi_comm_rank(request->comm); + request->src = request->comm->index_to_rank_map[index]; request->dst = (request->src + 1) % request->comm->size; smpi_mpi_isend(request); } diff --git a/src/smpi/smpi_sender.c b/src/smpi/smpi_sender.c index 983ded806f..f02e0abfa0 100644 --- a/src/smpi/smpi_sender.c +++ b/src/smpi/smpi_sender.c @@ -66,7 +66,7 @@ int smpi_sender(int argc, char **argv) SIMIX_mutex_lock(request->mutex); message->comm = request->comm; - message->src = smpi_mpi_comm_rank(request->comm); + message->src = request->comm->index_to_rank_map[index]; message->tag = request->tag; message->data = request->data; message->buf = xbt_malloc(request->datatype->size * request->count); -- 2.20.1