Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code cleanup, streamlining, removed some redundant function calls.
authormarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 12 Oct 2007 10:29:31 +0000 (10:29 +0000)
committermarkls <markls@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 12 Oct 2007 10:29:31 +0000 (10:29 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4820 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/smpi/smpi_global.c
src/smpi/smpi_mpi.c
src/smpi/smpi_receiver.c
src/smpi/smpi_sender.c

index 89771f5..ef58d88 100644 (file)
@@ -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;
index 1a2c3f3..b29243e 100644 (file)
@@ -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;
index eb5c887..0097875 100644 (file)
@@ -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);
                        }
index 983ded8..f02e0ab 100644 (file)
@@ -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);