Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
bcast on one process is a no-op
[simgrid.git] / src / smpi / smpi_pmpi.cpp
index a9927ed..707e29f 100644 (file)
@@ -159,7 +159,7 @@ int PMPI_Type_free(MPI_Datatype * datatype)
   if (*datatype == MPI_DATATYPE_NULL) {
     retval = MPI_ERR_ARG;
   } else {
-    smpi_datatype_free(datatype);
+    smpi_datatype_unuse(*datatype);
     retval = MPI_SUCCESS;
   }
   return retval;
@@ -718,7 +718,7 @@ int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group)
   } else {
     *group = smpi_comm_group(comm);
     if(*group!= smpi_comm_group(MPI_COMM_WORLD) && *group != MPI_GROUP_NULL
-              && *group != smpi_comm_group(MPI_COMM_SELF) && *group != MPI_GROUP_EMPTY)
+              && *group != MPI_GROUP_EMPTY)
     smpi_group_use(*group);
     retval = MPI_SUCCESS;
   }
@@ -775,7 +775,7 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm)
     *newcomm= MPI_COMM_NULL;
     retval = MPI_SUCCESS;
   }else{
-
+    smpi_group_use(group);
     *newcomm = smpi_comm_new(group, NULL);
     retval = MPI_SUCCESS;
   }
@@ -1494,11 +1494,14 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta
   smpi_bench_end();
   //save requests information for tracing
   int i;
-  int *srcs = xbt_new0(int, count);
-  int *dsts = xbt_new0(int, count);
-  int *recvs = xbt_new0(int, count);
-  MPI_Comm *comms = xbt_new0(MPI_Comm, count);
-
+  int *srcs = NULL, *dsts = NULL, *recvs = NULL;
+  MPI_Comm* comms = NULL;
+  if(count>0){
+    srcs = xbt_new0(int, count);
+    dsts = xbt_new0(int, count);
+    recvs = xbt_new0(int, count);
+    comms = xbt_new0(MPI_Comm, count);
+  }
   for (i = 0; i < count; i++) {
     MPI_Request req = requests[i];      //already received requests are no longer valid
     if (req) {
@@ -1651,11 +1654,11 @@ int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm c
     dt_size_send = smpi_datatype_size(datatype);
   extra->send_size = count*dt_size_send;
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra);
-
+  if(smpi_comm_size(comm)>1)
     mpi_coll_bcast_fun(buf, count, datatype, root, comm);
-    retval = MPI_SUCCESS;
+  retval = MPI_SUCCESS;
 
-    TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
+  TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
   }
 
   smpi_bench_begin();
@@ -2635,7 +2638,7 @@ int PMPI_Type_create_resized(MPI_Datatype oldtype,MPI_Aint lb, MPI_Aint 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);
+    smpi_datatype_create(newtype,oldtype->size, lb, lb + extent, sizeof(s_smpi_mpi_struct_t) , subtype, DT_FLAG_VECTOR);
 
     (*newtype)->flags &= ~DT_FLAG_COMMITED;
     return MPI_SUCCESS;