Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix copyright headers
[simgrid.git] / src / smpi / smpi_mpi.c
index aab96e3..fa6bcd9 100644 (file)
@@ -1,4 +1,8 @@
-/* $Id$tag */
+/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "private.h"
 #include "smpi_coll_private.h"
@@ -681,6 +685,88 @@ int MPI_Comm_free(MPI_Comm* comm) {
   return retval;
 }
 
+int MPI_Send_init(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, "Send_init");
+  if(request == NULL) {
+    retval = MPI_ERR_ARG;
+  } else if (comm == MPI_COMM_NULL) {
+    retval = MPI_ERR_COMM;
+  } else {
+    *request = smpi_mpi_send_init(buf, count, datatype, dst, tag, comm);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin(rank, "Send_init");
+  return retval;
+}
+
+int MPI_Recv_init(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, "Recv_init");
+  if(request == NULL) {
+    retval = MPI_ERR_ARG;
+  } else if (comm == MPI_COMM_NULL) {
+    retval = MPI_ERR_COMM;
+  } else {
+    *request = smpi_mpi_recv_init(buf, count, datatype, src, tag, comm);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin(rank, "Recv_init");
+  return retval;
+}
+
+int MPI_Start(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, "Start");
+  if(request == NULL) {
+    retval = MPI_ERR_ARG;
+  } else {
+    smpi_mpi_start(*request);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin(rank, "Start");
+  return retval;
+}
+
+int MPI_Startall(int count, MPI_Request* requests) {
+  int retval;
+  MPI_Comm comm = count > 0 && requests ? requests[0]->comm : MPI_COMM_NULL;
+  int rank = comm != MPI_COMM_NULL ? smpi_comm_rank(comm) : -1;
+
+  smpi_bench_end(rank, "Startall");
+  if(requests == NULL) {
+    retval = MPI_ERR_ARG;
+  } else {
+    smpi_mpi_startall(count, requests);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin(rank, "Startall");
+  return retval;
+}
+
+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;
@@ -775,30 +861,6 @@ int MPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst, i
   return retval;
 }
 
-int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count) {
-  int retval;
-/*
- * Returns the number of entries received. (Again, we count entries, each of type datatype, not bytes.) 
- * The datatype argument should match the argument provided by the receive call that set the status variable.
- * If the size of the datatype is zero, this routine will return a count of zero. 
- * If the amount of data in status is not an exact multiple of the size of datatype 
- * (so that count would not be integral), a count of MPI_UNDEFINED is returned instead.
- *
- */
-  smpi_bench_end(-1, NULL); //FIXME
-
-  if( 0==smpi_datatype_size(datatype)) {
-          // also check that the type is 'committed' when we have MPI_Type_commit (s.g. 23/03/21010)
-           retval = MPI_ERR_TYPE;
-  } else {
-           smpi_mpi_get_count(status, datatype, count);
-           retval = MPI_SUCCESS;
-  }
-  smpi_bench_begin(-1, NULL);
-  return retval;
-}
-
-
 int MPI_Test(MPI_Request* request, int* flag, MPI_Status* status) {
   int retval;
   int rank = request && (*request)->comm != MPI_COMM_NULL
@@ -1148,7 +1210,7 @@ int MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype s
   } else if(sendcounts == NULL || senddisps == NULL || recvcounts == NULL || recvdisps == NULL) {
     retval = MPI_ERR_ARG;
   } else {
-    retval = smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm); 
+    retval = smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps, sendtype, recvbuf, recvcounts, recvdisps, recvtype, comm);
   }
   smpi_bench_begin(rank, "Alltoallv");
   return retval;