Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
don't do the call if an error is caught before
[simgrid.git] / src / smpi / smpi_pmpi.c
index d5d9ecf..4a9a8d2 100644 (file)
@@ -1,3 +1,4 @@
+
 /* Copyright (c) 2007-2014. The SimGrid Team.
  * All rights reserved.                                                     */
 
@@ -2586,20 +2587,16 @@ int PMPI_Initialized(int* flag) {
 
 int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int reorder, MPI_Comm* comm_cart) {
   int retval = 0;
-  smpi_bench_end();
   if (comm_old == MPI_COMM_NULL){
-    return  MPI_ERR_COMM;
-  }
-  else if (ndims < 0 ||
+    retval =  MPI_ERR_COMM;
+  } else if (ndims < 0 ||
            (ndims > 0 && (dims == NULL || 
                           periodic == NULL)) ||
            comm_cart == NULL) {
-    return MPI_ERR_ARG;
+    retval = MPI_ERR_ARG;
+  } else{
+    retval = smpi_mpi_cart_create(comm_old, ndims, dims, periodic, reorder, comm_cart);
   }
-  retval = smpi_mpi_cart_create(comm_old, ndims, dims, periodic, reorder, comm_cart);
-
-  smpi_bench_begin();
-
   return retval;
 }
 
@@ -2680,6 +2677,25 @@ int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
   return smpi_mpi_cart_sub(comm, remain_dims, comm_new);
 }
 
+int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
+    if(oldtype == MPI_DATATYPE_NULL) {
+        return MPI_ERR_TYPE;
+    }
+    int blocks[3] = { 1, 1, 1 };
+    MPI_Aint disps[3] = { lb, 0, lb+extent };
+    MPI_Datatype types[3] = { MPI_LB, oldtype, MPI_UB };
+        
+    s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocks,
+                                                                disps,
+                                                                3,
+                                                                types
+                                                                );
+    smpi_datatype_create(newtype,oldtype->size, lb, lb + extent, 1 , subtype, DT_FLAG_VECTOR);
+
+    (*newtype)->flags &= ~DT_FLAG_COMMITED;
+    return MPI_SUCCESS;
+}
+
 
 /* The following calls are not yet implemented and will fail at runtime. */
 /* Once implemented, please move them above this notice. */
@@ -2689,10 +2705,6 @@ int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) {
     return MPI_SUCCESS;                                                 \
   }
 
-int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint extent, MPI_Datatype *newtype){
-  NOT_YET_IMPLEMENTED
-}
-
 int PMPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype){
   NOT_YET_IMPLEMENTED
 }