Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add mpi_info_* support to fortran, and activate relevant tests
[simgrid.git] / src / smpi / smpi_pmpi.c
index d2fe7cf..6a66706 100644 (file)
@@ -3000,6 +3000,14 @@ MPI_Fint PMPI_Comm_c2f(MPI_Comm comm){
   return smpi_comm_c2f(comm);
 }
 
+MPI_Info PMPI_Info_f2c(MPI_Fint info){
+  return smpi_info_f2c(info);
+}
+
+MPI_Fint PMPI_Info_c2f(MPI_Info info){
+  return smpi_info_c2f(info);
+}
+
 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
   return smpi_comm_keyval_create(copy_fn, delete_fn, keyval, extra_state);
 }
@@ -3110,6 +3118,7 @@ int PMPI_Info_create( MPI_Info *info){
     return MPI_ERR_ARG;
   *info = xbt_new(s_smpi_mpi_info_t, 1);
   (*info)->info_dict= xbt_dict_new_homogeneous(NULL);
+  (*info)->refcount=1;
   return MPI_SUCCESS;
 }
 
@@ -3124,8 +3133,11 @@ int PMPI_Info_set( MPI_Info info, char *key, char *value){
 int PMPI_Info_free( MPI_Info *info){
   if (info == NULL || *info==NULL)
     return MPI_ERR_ARG;
-  xbt_dict_free(&((*info)->info_dict));
-  xbt_free(*info);
+  (*info)->refcount--;
+  if((*info)->refcount==0){
+    xbt_dict_free(&((*info)->info_dict));
+    xbt_free(*info);
+  }
   *info=MPI_INFO_NULL;
   return MPI_SUCCESS;
 }
@@ -3189,7 +3201,7 @@ int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
   int num=0;
   xbt_dict_foreach(info->info_dict,cursor,keyn,data){
     if(num==n){
-     memcpy(key,keyn, strlen(keyn));
+     strcpy(key,keyn);
       return MPI_SUCCESS;
     }
     num++;
@@ -3209,6 +3221,40 @@ int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
   return MPI_SUCCESS;
 }
 
+int PMPI_Unpack(void* inbuf, int incount, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
+  if(incount<0 || outcount < 0 || inbuf==NULL || outbuf==NULL)
+    return MPI_ERR_ARG;
+  if(!is_datatype_valid(type))
+    return MPI_ERR_TYPE;
+  if(comm==MPI_COMM_NULL)
+    return MPI_ERR_COMM;
+  return smpi_mpi_unpack(inbuf, incount, position, outbuf,outcount,type, comm);
+}
+
+int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
+  if(incount<0 || outcount < 0|| inbuf==NULL || outbuf==NULL)
+    return MPI_ERR_ARG;
+  if(!is_datatype_valid(type))
+    return MPI_ERR_TYPE;
+  if(comm==MPI_COMM_NULL)
+    return MPI_ERR_COMM;
+  return smpi_mpi_pack(inbuf, incount, type, outbuf,outcount,position, comm);
+}
+
+int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
+  if(incount<0)
+    return MPI_ERR_ARG;
+  if(!is_datatype_valid(datatype))
+    return MPI_ERR_TYPE;
+  if(comm==MPI_COMM_NULL)
+    return MPI_ERR_COMM;
+    
+  *size=incount*smpi_datatype_size(datatype);
+  
+  return MPI_SUCCESS;
+}
+
+
 /* The following calls are not yet implemented and will fail at runtime. */
 /* Once implemented, please move them above this notice. */
 
@@ -3217,15 +3263,6 @@ int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
     return MPI_SUCCESS;                                                 \
   }
 
-
-MPI_Info PMPI_Info_f2c(MPI_Fint info){
-  NOT_YET_IMPLEMENTED
-}
-
-MPI_Fint PMPI_Info_c2f(MPI_Info info){
-  NOT_YET_IMPLEMENTED
-}
-
 MPI_Errhandler PMPI_Errhandler_f2c(MPI_Fint errhandler){
   NOT_YET_IMPLEMENTED
 }
@@ -3234,16 +3271,10 @@ MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhandler){
   NOT_YET_IMPLEMENTED
 }
 
-int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) {
-  NOT_YET_IMPLEMENTED
-}
-
-
 int PMPI_Cart_map(MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank) {
   NOT_YET_IMPLEMENTED
 }
 
-
 int PMPI_Graph_create(MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph) {
   NOT_YET_IMPLEMENTED
 }
@@ -3325,9 +3356,6 @@ int PMPI_Pcontrol(const int level )
   NOT_YET_IMPLEMENTED
 }
 
-int PMPI_Unpack(void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) {
-  NOT_YET_IMPLEMENTED
-}
 
 int PMPI_Intercomm_create(MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out) {
   NOT_YET_IMPLEMENTED
@@ -3373,9 +3401,7 @@ int PMPI_Test_cancelled(MPI_Status* status, int* flag) {
   NOT_YET_IMPLEMENTED
 }
 
-int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) {
-  NOT_YET_IMPLEMENTED
-}
+
 
 int PMPI_Pack_external_size(char *datarep, int incount, MPI_Datatype datatype, MPI_Aint *size){
   NOT_YET_IMPLEMENTED