+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin("MPI_Comm_compare");
+ return retval;
+}
+
+int MPI_Comm_dup(MPI_Comm comm, MPI_Comm* newcomm) {
+ int retval;
+
+ smpi_bench_end();
+ if(comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else if(newcomm == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *newcomm = smpi_comm_new(smpi_comm_group(comm));
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin("MPI_Comm_dup");
+ return retval;
+}
+
+int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm* newcomm) {
+ int retval;
+
+ smpi_bench_end();
+ if(comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else if(group == MPI_GROUP_NULL) {
+ retval = MPI_ERR_GROUP;
+ } else if(newcomm == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *newcomm = smpi_comm_new(group);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin("MPI_Comm_create");
+ return retval;
+}
+
+int MPI_Comm_free(MPI_Comm* comm) {
+ int retval;
+
+ smpi_bench_end();
+ if(comm == NULL) {
+ retval = MPI_ERR_ARG;
+ } else if(*comm == MPI_COMM_NULL) {
+ retval = MPI_ERR_COMM;
+ } else {
+ smpi_comm_destroy(*comm);
+ *comm = MPI_COMM_NULL;
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin("MPI_Comm_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;
+
+ smpi_bench_end();
+ if(request == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm);
+ retval = MPI_SUCCESS;
+ }
+ smpi_bench_begin("MPI_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;
+
+ smpi_bench_end();
+ if(request == NULL) {
+ retval = MPI_ERR_ARG;
+ } else {
+ *request = smpi_mpi_isend(buf, count, datatype, dst, tag, comm);
+ retval = MPI_SUCCESS;
+ }
+ 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("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("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("MPI_Sendrecv");
+ return MPI_SUCCESS;
+}
+
+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;
+
+ smpi_bench_end();
+ 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;