Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
getting rid of workstation_KCCFLN05_private.h
[simgrid.git] / src / smpi / smpi_mpi.c
index b21ccbf..c378d86 100644 (file)
@@ -19,7 +19,6 @@ int MPI_Finalize()
 int MPI_Abort(MPI_Comm comm, int errorcode)
 {
        smpi_exit(errorcode);
-
        return 0;
 }
 
@@ -53,7 +52,7 @@ int MPI_Comm_rank(MPI_Comm comm, int *rank)
        } else if (NULL == rank) {
                retval = MPI_ERR_ARG;
        } else {
-               *rank = smpi_comm_rank(comm, SIMIX_host_self());
+               *rank = smpi_mpi_comm_rank(comm);
        }
 
        smpi_bench_begin();
@@ -82,72 +81,103 @@ int MPI_Type_size(MPI_Datatype datatype, size_t *size)
 
 int MPI_Barrier(MPI_Comm comm)
 {
+       int retval = MPI_SUCCESS;
+
        smpi_bench_end();
-       smpi_barrier(comm);
+
+       if (NULL == comm) {
+               retval = MPI_ERR_COMM;
+       } else {
+               retval = smpi_mpi_barrier(comm);
+       }
+
        smpi_bench_begin();
-       return MPI_SUCCESS;
+
+       return retval;
 }
 
 int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request *request)
 {
        int retval = MPI_SUCCESS;
-       int dst;
+
        smpi_bench_end();
-       dst = smpi_mpi_comm_rank_self(comm);
-       retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, request);
-       if (NULL != *request) {
-               smpi_irecv(*request);
+
+       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);
+               }
        }
+
        smpi_bench_begin();
+
        return retval;
 }
 
 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;
-       smpi_mpi_request_t *request;
+       int dst = 0;
+       smpi_mpi_request_t request;
+
        smpi_bench_end();
-       dst = smpi_mpi_comm_rank_self(comm);
+
        retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &request);
-       if (NULL != request) {
-               smpi_irecv(request);
-               smpi_wait(request, status);
-               // FIXME: mallocator
-               //xbt_free(request);
+       if (NULL != request && MPI_SUCCESS == retval) {
+               retval = smpi_mpi_irecv(request);
+               if (MPI_SUCCESS == retval) {
+                       retval = smpi_mpi_wait(request, status);
+               }
+               xbt_mallocator_release(smpi_global->request_mallocator, request);
        }
+
        smpi_bench_begin();
+
        return retval;
 }
 
 int MPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request *request)
 {
        int retval = MPI_SUCCESS;
-       int src;
+
        smpi_bench_end();
-       src = smpi_mpi_comm_rank_self(comm);
-       retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, request);
-       if (NULL != *request) {
-               smpi_isend(*request);
+
+       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);
+               }
        }
+
        smpi_bench_begin();
+
        return retval;
 }
 
 int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm)
 {
        int retval = MPI_SUCCESS;
-       int src;
-       smpi_mpi_request_t *request;
+       int src = 0;
+       smpi_mpi_request_t request;
+
        smpi_bench_end();
-       src = smpi_mpi_comm_rank_self(comm);
+
        retval = smpi_create_request(buf, count, datatype, src, dst, tag, comm, &request);
-       if (NULL != request) {
-               smpi_isend(request);
-               smpi_wait(request, MPI_STATUS_IGNORE);
-               // FIXME: mallocator
-               //xbt_free(request)
+       if (NULL != request && MPI_SUCCESS == retval) {
+               retval = smpi_mpi_isend(request);
+               if (MPI_SUCCESS == retval) {
+                       smpi_mpi_wait(request, MPI_STATUS_IGNORE);
+               }
+               xbt_mallocator_release(smpi_global->request_mallocator, request);
        }
+
        smpi_bench_begin();
+
        return retval;
 }