+
+int MPI_Request_free(MPI_Request* request) {
+ int retval;
+ MPI_Comm comm = (*request)->comm;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+ smpi_bench_end(rank, "Request_free");
+ if(request == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ smpi_mpi_request_free(request);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Request_free");
+ return retval;
+}
+
+int MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request) {
+ int retval;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+ smpi_bench_end(rank, "Irecv");
+ if(request == NULL) {
+ retval = MPI_ERR_ARG;
+ } else if (comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else {
+ *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Irecv");
+ return retval;
+}
+
+int MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request) {
+ int retval;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+ smpi_bench_end(rank, "Isend");
+ if(request == NULL) {
+ retval = MPI_ERR_ARG;
+ } else if (comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else {
+ *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Isend");
+ return retval;
+}
+
+int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status) {
+ int retval;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+ smpi_bench_end(rank, "Recv");
+ if (comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else {
+ smpi_mpi_recv(buf, count, datatype, src, tag, comm, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Recv");
+ return retval;
+}
+
+int MPI_Send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
+ int retval;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+ smpi_bench_end(rank, "Send");
+ if (comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else {
+ smpi_mpi_send(buf, count, datatype, dst, tag, comm);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Send");
+ return retval;
+}
+
+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) {
+ int retval;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+ smpi_bench_end(rank, "Sendrecv");
+ if (comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else if (sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) {
+ retval = MPI_ERR_TYPE;
+ } else {
+ smpi_mpi_sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src, recvtag, comm, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Sendrecv");
+ return retval;
+}
+
+int MPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst, int sendtag, int src, int recvtag, MPI_Comm comm, MPI_Status* status) {
+ //TODO: suboptimal implementation
+ void* recvbuf;
+ int retval, size;
+
+ size = smpi_datatype_size(datatype) * count;
+ recvbuf = xbt_new(char, size);
+ retval = MPI_Sendrecv(buf, count, datatype, dst, sendtag, recvbuf, count, datatype, src, recvtag, comm, status);
+ memcpy(buf, recvbuf, size * sizeof(char));
+ xbt_free(recvbuf);
+ return retval;
+}
+
+int MPI_Test(MPI_Request* request, int* flag, MPI_Status* status) {
+ int retval;
+ int rank = request && (*request)->comm != MPI_COMM_NULL
+ ? smpi_comm_rank((*request)->comm)
+ : -1;
+
+ smpi_bench_end(rank, "Test");
+ if(request == NULL || flag == NULL) {
+ retval = MPI_ERR_ARG;
+ } else if(*request == MPI_REQUEST_NULL) {
+ retval = MPI_ERR_REQUEST;
+ } else {
+ *flag = smpi_mpi_test(request, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Test");
+ return retval;
+}
+
+int MPI_Testany(int count, MPI_Request requests[], int* index, int* flag, MPI_Status* status) {
+ int retval;
+
+ smpi_bench_end(-1, NULL); //FIXME
+ if(index == NULL || flag == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *flag = smpi_mpi_testany(count, requests, index, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(-1, NULL);
+ return retval;
+}
+
+int MPI_Wait(MPI_Request* request, MPI_Status* status) {
+ int retval;
+ int rank = request && (*request)->comm != MPI_COMM_NULL
+ ? smpi_comm_rank((*request)->comm)
+ : -1;
+
+ smpi_bench_end(rank, "Wait");
+ if(request == NULL) {
+ retval = MPI_ERR_ARG;
+ } else if(*request == MPI_REQUEST_NULL) {
+ retval = MPI_ERR_REQUEST;
+ } else {
+ smpi_mpi_wait(request, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Wait");
+ return retval;
+}
+
+int MPI_Waitany(int count, MPI_Request requests[], int* index, MPI_Status* status) {
+ int retval;
+
+ smpi_bench_end(-1, NULL); //FIXME
+ if(index == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *index = smpi_mpi_waitany(count, requests, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(-1, NULL);
+ return retval;
+}
+
+int MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]) {
+ smpi_bench_end(-1, NULL); //FIXME
+ smpi_mpi_waitall(count, requests, status);
+ smpi_bench_begin(-1, NULL);
+ return MPI_SUCCESS;
+}
+
+int MPI_Waitsome(int incount, MPI_Request requests[], int* outcount, int* indices, MPI_Status status[]) {
+ int retval;
+
+ smpi_bench_end(-1, NULL); //FIXME
+ if(outcount == NULL || indices == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *outcount = smpi_mpi_waitsome(incount, requests, indices, status);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(-1, NULL);
+ return retval;
+}
+
+int MPI_Bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm) {
+ int retval;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+#ifdef HAVE_TRACING
+ int root_traced = smpi_group_rank(smpi_comm_group(comm), root);
+ TRACE_smpi_collective_in (rank, root_traced, __FUNCTION__);
+#endif
+ smpi_bench_end(rank, "Bcast");
+ if(comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else {
+ smpi_mpi_bcast(buf, count, datatype, root, comm);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin(rank, "Bcast");
+#ifdef HAVE_TRACING
+ TRACE_smpi_collective_out (rank, root_traced, __FUNCTION__);
+#endif
+ return retval;
+}
+
+int MPI_Barrier(MPI_Comm comm) {
+ int retval;
+ int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+#ifdef HAVE_TRACING
+ TRACE_smpi_collective_in (rank, -1, __FUNCTION__);