Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MPI_Address didn't return MPI_SUCCESS on success
[simgrid.git] / src / smpi / smpi_pmpi.c
index 561ad0d..d730222 100644 (file)
@@ -125,6 +125,7 @@ int PMPI_Address(void *location, MPI_Aint * address)
     retval = MPI_ERR_ARG;
   } else {
     *address = (MPI_Aint) location;
+    retval = MPI_SUCCESS;
   }
   smpi_bench_begin();
   return retval;
@@ -138,8 +139,8 @@ int PMPI_Type_free(MPI_Datatype * datatype)
   if (!datatype) {
     retval = MPI_ERR_ARG;
   } else {
-    // FIXME: always fail for now
-    retval = MPI_ERR_TYPE;
+    smpi_datatype_free(datatype);
+    retval = MPI_SUCCESS;
   }
   smpi_bench_begin();
   return retval;
@@ -922,6 +923,7 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src,
   return retval;
 }
 
+
 int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
               int tag, MPI_Comm comm, MPI_Request * request)
 {
@@ -952,6 +954,8 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst,
   return retval;
 }
 
+
+
 int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag,
              MPI_Comm comm, MPI_Status * status)
 {
@@ -1098,7 +1102,20 @@ int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag,
   return retval;
 }
 
+int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses)
+{
+  int retval;
 
+  smpi_bench_end();
+  if (flag == NULL) {
+    retval = MPI_ERR_ARG;
+  } else {
+    *flag = smpi_mpi_testall(count, requests, statuses);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin();
+  return retval;
+}
 
 int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) {
   int retval;
@@ -1793,12 +1810,117 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count)
   return retval;
 }
 
+int PMPI_Type_contiguous(int count, 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_contiguous(count, old_type, new_type);
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+int PMPI_Type_commit(MPI_Datatype* datatype) {
+  int retval;
+
+  smpi_bench_end();
+  if (datatype == MPI_DATATYPE_NULL) {
+    retval = MPI_ERR_TYPE;
+  } else {
+    smpi_datatype_commit(datatype);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+
+int PMPI_Type_vector(int count, int blocklen, int stride, 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 || blocklen<=0){
+    retval = MPI_ERR_COUNT;
+  } else {
+    retval = smpi_datatype_vector(count, blocklen, stride, old_type, new_type);
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, 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 || blocklen<=0){
+    retval = MPI_ERR_COUNT;
+  } else {
+    retval = smpi_datatype_hvector(count, blocklen, stride, old_type, new_type);
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+
+int PMPI_Type_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_hindexed(int count, int* blocklens, MPI_Aint* 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_hindexed(count, blocklens, indices, old_type, new_type);
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+
+int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type) {
+  int retval;
+
+  smpi_bench_end();
+  if (count<=0){
+    retval = MPI_ERR_COUNT;
+  } else {
+    retval = smpi_datatype_struct(count, blocklens, indices, old_types, new_type);
+  }
+  smpi_bench_begin();
+  return retval;}
+
+
 /* The following calls are not yet implemented and will fail at runtime. */
 /* Once implemented, please move them above this notice. */
 
 static int not_yet_implemented(void) {
-   xbt_die("Not yet implemented");
-   return MPI_ERR_OTHER;
+         XBT_WARN("Not yet implemented");
+   return MPI_SUCCESS;
 }
 
 int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
@@ -1889,9 +2011,6 @@ int PMPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler errhandler) {
    return not_yet_implemented();
 }
 
-int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* newtype) {
-   return not_yet_implemented();
-}
 
 int PMPI_Cancel(MPI_Request* request) {
    return not_yet_implemented();
@@ -1917,30 +2036,6 @@ int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcou
    return not_yet_implemented();
 }
 
-int PMPI_Type_commit(MPI_Datatype* datatype) {
-   return not_yet_implemented();
-}
-
-int PMPI_Type_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* newtype) {
-   return not_yet_implemented();
-}
-
-int PMPI_Type_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* newtype) {
-   return not_yet_implemented();
-}
-
-int PMPI_Type_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* newtype) {
-   return not_yet_implemented();
-}
-
-int PMPI_Type_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* newtype) {
-   return not_yet_implemented();
-}
-
-int PMPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* newtype) {
-   return not_yet_implemented();
-}
-
 int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
    return not_yet_implemented();
 }
@@ -1982,7 +2077,6 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dest, int tag,
 }
 
 
-
 int PMPI_Attr_delete(MPI_Comm comm, int keyval) {
    return not_yet_implemented();
 }
@@ -2023,10 +2117,6 @@ int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int out
    return not_yet_implemented();
 }
 
-int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* statuses) {
-   return not_yet_implemented();
-}
-
 int PMPI_Get_elements(MPI_Status* status, MPI_Datatype datatype, int* elements) {
    return not_yet_implemented();
 }