Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add two more functions
[simgrid.git] / src / smpi / smpi_pmpi.c
index 8feabee..f3269fd 100644 (file)
@@ -27,6 +27,7 @@ void TRACE_smpi_set_category(const char *category)
 int PMPI_Init(int *argc, char ***argv)
 {
   smpi_process_init(argc, argv);
+  smpi_process_mark_as_initialized();
 #ifdef HAVE_TRACING
   int rank = smpi_process_index();
   TRACE_smpi_init(rank);
@@ -1865,9 +1866,9 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
              || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
     retval = MPI_ERR_TYPE;
   } else {
-
-    if(recvbuf==MPI_IN_PLACE){
-       recvcount=0;
+    if (recvbuf == MPI_IN_PLACE) {
+        recvtype=sendtype;
+        recvcount=sendcount;
     }
     mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount,
                      recvtype, root, comm);
@@ -1902,11 +1903,10 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
              || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) {
     retval = MPI_ERR_TYPE;
   } else {
-
-    if(recvbuf==MPI_IN_PLACE){
-       recvcount=0;
+    if (recvbuf == MPI_IN_PLACE) {
+        recvtype=sendtype;
+        recvcount=sendcounts[smpi_comm_rank(comm)];
     }
-
     smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
                       recvcount, recvtype, root, comm);
     retval = MPI_SUCCESS;
@@ -1937,17 +1937,7 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count,
     retval = MPI_ERR_ARG;
   } else {
 
-    char* sendtmpbuf = (char*) sendbuf;
-    if( sendbuf == MPI_IN_PLACE ) {
-      sendtmpbuf = (char *)xbt_malloc(count*smpi_datatype_get_extent(datatype));
-      smpi_datatype_copy(recvbuf, count, datatype,sendtmpbuf, count, datatype);
-    }
-
-    mpi_coll_reduce_fun(sendtmpbuf, recvbuf, count, datatype, op, root, comm);
-
-    if( sendbuf == MPI_IN_PLACE ) {
-      xbt_free(sendtmpbuf);
-    }
+    mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm);
 
     retval = MPI_SUCCESS;
   }
@@ -2327,6 +2317,21 @@ int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_
   return retval;
 }
 
+int PMPI_Type_create_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
+  int retval;
+
+  smpi_bench_end();
+  if (old_type == MPI_DATATYPE_NULL) {
+    retval = MPI_ERR_TYPE;
+  } else if (count<0){
+    retval = MPI_ERR_COUNT;
+  } else {
+    retval = smpi_datatype_indexed(count, blocklens, indices, old_type, new_type);
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
 int PMPI_Type_create_indexed_block(int count, int blocklength, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval,i;
 
@@ -2361,6 +2366,10 @@ int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatyp
   return retval;
 }
 
+int PMPI_Type_create_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
+  return PMPI_Type_hindexed(count, blocklens,indices,old_type,new_type);
+}
+
 int PMPI_Type_create_hindexed_block(int count, int blocklength, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type) {
   int retval,i;
 
@@ -2406,7 +2415,7 @@ int PMPI_Error_class(int errorcode, int* errorclass) {
 
 
 int PMPI_Initialized(int* flag) {
-   *flag=(smpi_process_data()!=NULL);
+   *flag=smpi_process_initialized();
    return MPI_SUCCESS;
 }