Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
basic implem of MPI_Win_allocate_shared, MPI_Win_shared_query, MPI_Comm_split_type
authordegomme <augustin.degomme@unibas.ch>
Wed, 11 Apr 2018 20:05:58 +0000 (22:05 +0200)
committerdegomme <augustin.degomme@unibas.ch>
Wed, 11 Apr 2018 20:05:58 +0000 (22:05 +0200)
include/smpi/smpi.h
src/smpi/bindings/smpi_mpi.cpp
src/smpi/bindings/smpi_pmpi_comm.cpp
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/include/smpi_comm.hpp
src/smpi/include/smpi_win.hpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_win.cpp
teshsuite/smpi/mpich3-test/rma/CMakeLists.txt
teshsuite/smpi/mpich3-test/rma/testlist

index e82e2bb..4ef2ae6 100644 (file)
@@ -198,6 +198,8 @@ SG_BEGIN_DECL()
 #define MPI_WIN_BASE -1
 #define MPI_WIN_SIZE -2
 #define MPI_WIN_DISP_UNIT -3
+#define MPI_WIN_CREATE_FLAVOR -4
+#define MPI_WIN_MODEL -5
 
 typedef ptrdiff_t MPI_Aint;
 typedef long long MPI_Offset;
@@ -308,6 +310,11 @@ XBT_PUBLIC_DATA const MPI_Datatype MPI_INTEGER16;
 #define MPI_DOUBLE_PRECISION MPI_DOUBLE
 #define MPI_2DOUBLE_PRECISION MPI_2DOUBLE
 
+#define MPI_WIN_FLAVOR_CREATE 0
+#define MPI_WIN_FLAVOR_ALLOCATE 1
+#define MPI_WIN_FLAVOR_DYNAMIC 2
+#define MPI_WIN_FLAVOR_SHARED 3
+
 typedef void MPI_User_function(void *invec, void *inoutvec, int *len, MPI_Datatype * datatype);
 typedef SMPI_Op *MPI_Op;
 
@@ -589,6 +596,8 @@ MPI_CALL(XBT_PUBLIC int, MPI_Win_create,
          (void* base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win* win));
 MPI_CALL(XBT_PUBLIC int, MPI_Win_allocate,
          (MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void* base, MPI_Win* win));
+MPI_CALL(XBT_PUBLIC int, MPI_Win_allocate_shared,
+         (MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void* base, MPI_Win* win));
 MPI_CALL(XBT_PUBLIC int, MPI_Win_create_dynamic, (MPI_Info info, MPI_Comm comm, MPI_Win* win));
 MPI_CALL(XBT_PUBLIC int, MPI_Win_attach, (MPI_Win win, void* base, MPI_Aint size));
 MPI_CALL(XBT_PUBLIC int, MPI_Win_detach, (MPI_Win win, void* base));
@@ -617,6 +626,8 @@ MPI_CALL(XBT_PUBLIC int, MPI_Win_flush, (int rank, MPI_Win win));
 MPI_CALL(XBT_PUBLIC int, MPI_Win_flush_local, (int rank, MPI_Win win));
 MPI_CALL(XBT_PUBLIC int, MPI_Win_flush_all, (MPI_Win win));
 MPI_CALL(XBT_PUBLIC int, MPI_Win_flush_local_all, (MPI_Win win));
+MPI_CALL(XBT_PUBLIC int, MPI_Win_shared_query, (MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr));
+MPI_CALL(XBT_PUBLIC int, MPI_Win_sync, (MPI_Win win));
 MPI_CALL(XBT_PUBLIC MPI_Win, MPI_Win_f2c, (MPI_Fint win));
 MPI_CALL(XBT_PUBLIC MPI_Fint, MPI_Win_c2f, (MPI_Win win));
 
index ddf92bd..a708a8d 100644 (file)
@@ -92,6 +92,7 @@ WRAPPED_PMPI_CALL(int,MPI_Comm_rank,(MPI_Comm comm, int *rank),(comm, rank))
 WRAPPED_PMPI_CALL(int,MPI_Comm_set_attr ,(MPI_Comm comm, int comm_keyval, void *attribute_val),( comm, comm_keyval, attribute_val))
 WRAPPED_PMPI_CALL(int,MPI_Comm_size,(MPI_Comm comm, int *size),(comm, size))
 WRAPPED_PMPI_CALL(int,MPI_Comm_split,(MPI_Comm comm, int color, int key, MPI_Comm* comm_out),(comm, color, key, comm_out))
+WRAPPED_PMPI_CALL(int,MPI_Comm_split_type,(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm),(comm, split_type, key, info, newcomm))
 WRAPPED_PMPI_CALL(int,MPI_Comm_create_group,(MPI_Comm comm, MPI_Group group, int tag, MPI_Comm* comm_out),(comm, group, tag, comm_out))
 WRAPPED_PMPI_CALL(int,MPI_Compare_and_swap,(void *origin_addr, void *compare_addr,
         void *result_addr, MPI_Datatype datatype, int target_rank, MPI_Aint target_disp, MPI_Win win), (origin_addr, compare_addr, result_addr, datatype, target_rank, target_disp, win))
@@ -215,6 +216,7 @@ WRAPPED_PMPI_CALL(int,MPI_Waitsome,(int incount, MPI_Request requests[], int *ou
 WRAPPED_PMPI_CALL(int,MPI_Win_complete,(MPI_Win win),(win))
 WRAPPED_PMPI_CALL(int,MPI_Win_create,( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win),( base, size, disp_unit, info, comm,win))
 WRAPPED_PMPI_CALL(int,MPI_Win_allocate,(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win),(size, disp_unit, info, comm, base, win))
+WRAPPED_PMPI_CALL(int,MPI_Win_allocate_shared,(MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win),(size, disp_unit, info, comm, base, win))
 WRAPPED_PMPI_CALL(int,MPI_Win_attach,(MPI_Win win, void *base, MPI_Aint size),(win, base, size))
 WRAPPED_PMPI_CALL(int,MPI_Win_detach,(MPI_Win win, void *base),(win, base))
 WRAPPED_PMPI_CALL(int,MPI_Win_create_dynamic,( MPI_Info info, MPI_Comm comm, MPI_Win *win),(info, comm,win))
@@ -242,6 +244,7 @@ WRAPPED_PMPI_CALL(int,MPI_Win_delete_attr, (MPI_Win type, int comm_keyval), (typ
 WRAPPED_PMPI_CALL(int,MPI_Win_create_keyval,(MPI_Win_copy_attr_function* copy_fn,
                               MPI_Win_delete_attr_function* delete_fn, int* keyval, void* extra_state), (copy_fn, delete_fn, keyval, extra_state))
 WRAPPED_PMPI_CALL(int,MPI_Win_free_keyval,(int* keyval), (keyval))
+WRAPPED_PMPI_CALL(int,MPI_Win_shared_query,(MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr),(win, rank, size, disp_unit, baseptr))
 WRAPPED_PMPI_CALL(MPI_Comm, MPI_Comm_f2c,(MPI_Fint comm),(comm))
 WRAPPED_PMPI_CALL(MPI_Datatype, MPI_Type_f2c,(MPI_Fint datatype),(datatype))
 WRAPPED_PMPI_CALL(MPI_Fint, MPI_Comm_c2f,(MPI_Comm comm),(comm))
@@ -292,7 +295,6 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_info ,(MPI_Comm comm, MP
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Comm_set_name ,(MPI_Comm comm, char* name),(comm, name))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn,( char *command, char **argv, int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes),( command, argv, maxprocs, info, root, comm, intercomm, array_of_errcodes))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_spawn_multiple,(int count, char **array_of_commands, char*** array_of_argv, int* array_of_maxprocs, MPI_Info* array_of_info, int root, MPI_Comm comm, MPI_Comm *intercomm, int* array_of_errcodes), (count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, root, comm, intercomm, array_of_errcodes))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_split_type,(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm),(comm, split_type, key, info, newcomm))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Comm_test_inter,(MPI_Comm comm, int* flag) ,(comm, flag))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Errhandler_create,(MPI_Handler_function* function, MPI_Errhandler* errhandler) ,(function, errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Errhandler_free,(MPI_Errhandler* errhandler) ,(errhandler))
@@ -395,5 +397,6 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Unpack_external,(char *datarep, void *in
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Unpublish_name,( char *service_name, MPI_Info info, char *port_name),( service_name, info, port_name))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Win_set_errhandler,(MPI_Win win, MPI_Errhandler errhandler) ,(win, errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Win_test,(MPI_Win win, int *flag),(win, flag))
+UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int,MPI_Win_sync,(MPI_Win win),(win))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(MPI_Errhandler, MPI_Errhandler_f2c,(MPI_Fint errhandler),(errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(MPI_Fint, MPI_Errhandler_c2f,(MPI_Errhandler errhandler),(errhandler))
index be80206..4775ea2 100644 (file)
@@ -156,6 +156,24 @@ int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out)
   return retval;
 }
 
+int PMPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm)
+{
+  int retval = 0;
+  smpi_bench_end();
+
+  if (newcomm == nullptr) {
+    retval = MPI_ERR_ARG;
+  } else if (comm == MPI_COMM_NULL) {
+    retval = MPI_ERR_COMM;
+  } else {
+    *newcomm = comm->split_type(split_type, key, info);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin();
+
+  return retval;
+}
+
 int PMPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int, MPI_Comm* comm_out)
 {
   int retval = 0;
index 3842cbb..3dfcf2e 100644 (file)
@@ -49,6 +49,33 @@ int PMPI_Win_allocate( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm com
   return retval;
 }
 
+int PMPI_Win_allocate_shared( MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *base, MPI_Win *win){
+  int retval = 0;
+  smpi_bench_end();
+  if (comm == MPI_COMM_NULL) {
+    retval= MPI_ERR_COMM;
+  }else if (disp_unit <= 0 || size < 0 ){
+    retval= MPI_ERR_OTHER;
+  }else{
+    void* ptr = nullptr;
+    int rank = comm->rank();
+    if(rank==0){
+       ptr = xbt_malloc(size*comm->size());
+       if(ptr==nullptr)
+         return MPI_ERR_NO_MEM;
+    }
+    
+    simgrid::smpi::Colls::bcast(&ptr, sizeof(void*), MPI_BYTE, 0, comm);
+    simgrid::smpi::Colls::barrier(comm);
+    
+    *static_cast<void**>(base) = (char*)ptr+rank*size;
+    *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,rank==0);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
 int PMPI_Win_create_dynamic( MPI_Info info, MPI_Comm comm, MPI_Win *win){
   int retval = 0;
   smpi_bench_end();
@@ -746,6 +773,13 @@ int PMPI_Win_flush_local_all(MPI_Win win){
   return retval;
 }
 
+int PMPI_Win_shared_query (MPI_Win win, int rank, MPI_Aint* size, int* disp_unit, void* baseptr)
+{
+  if (win==MPI_WIN_NULL)
+    return MPI_ERR_TYPE;
+  else
+    return win->shared_query(rank, size, disp_unit, baseptr);
+}
 
 int PMPI_Win_get_attr (MPI_Win win, int keyval, void *attribute_val, int* flag)
 {
index d0727c0..5cb1b7a 100644 (file)
@@ -69,6 +69,7 @@ class Comm : public F2C, public Keyval{
     void add_rma_win(MPI_Win win);
     void remove_rma_win(MPI_Win win);
     void finish_rma_calls();
+    MPI_Comm split_type(int type, int key, MPI_Info info);
 
 };
 
index 20010ad..d29f96a 100644 (file)
@@ -90,6 +90,7 @@ public:
   int flush_local_all();
   int finish_comms();
   int finish_comms(int rank);
+  int shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr);
 };
 
 
index af7bd41..5a7ddbb 100644 (file)
@@ -491,6 +491,17 @@ void Comm::finish_rma_calls(){
   }
 }
 
+MPI_Comm Comm::split_type(int type, int key, MPI_Info info)
+{
+  if(type != MPI_COMM_TYPE_SHARED){
+    return MPI_COMM_NULL;
+  }
+  this->init_smp();
+  this->ref();
+  this->get_intra_comm()->ref();
+  return this->get_intra_comm();
+}
+
 }
 }
 
index d564511..39d4756 100644 (file)
@@ -44,6 +44,7 @@ Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm,
   mode_=0;
 
   comm->add_rma_win(this);
+  comm->ref();
 
   Colls::allgather(&(connected_wins_[rank_]), sizeof(MPI_Win), MPI_BYTE, connected_wins_, sizeof(MPI_Win),
                          MPI_BYTE, comm);
@@ -72,6 +73,8 @@ Win::~Win(){
   comm_->remove_rma_win(this);
 
   Colls::barrier(comm_);
+  Comm::unref(comm_);
+  
   if (rank_ == 0)
     MSG_barrier_destroy(bar_);
   xbt_mutex_destroy(mut_);
@@ -719,5 +722,27 @@ int Win::finish_comms(int rank){
 }
 
 
+int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr){
+
+  if(rank!=MPI_PROC_NULL){
+    MPI_Win target_win = connected_wins_[rank];
+    *size=target_win->size_;
+    *disp_unit=target_win->disp_unit_;
+    *static_cast<void**>(baseptr)=target_win->base_;
+  }else{
+    for(int i=0; i<comm_->size();i++){
+      MPI_Win target_win = connected_wins_[i];
+      if(target_win->size_>0){
+        *size=target_win->size_;
+        *disp_unit=target_win->disp_unit_;
+        *static_cast<void**>(baseptr)=target_win->base_;
+        return MPI_SUCCESS;
+      }
+    }
+    *size=0;
+    *static_cast<void**>(baseptr)=xbt_malloc(0);
+  }
+  return MPI_SUCCESS;
+  }
 }
 }
index 51bcf55..3b4dcd3 100644 (file)
@@ -19,12 +19,12 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
      strided_acc_onelock strided_get_indexed strided_putget_indexed contention_put contention_putget
      adlb_mimic1 lock_contention_dt acc-loc get_acc_local get_accumulate put_base put_bottom
      linked_list_bench_lock_all linked_list_bench_lock_excl manyrma2 pscw_ordering rma-contig get-struct
-     rput_local_comp racc_local_comp rget-testall)
+     rput_local_comp racc_local_comp rget-testall win_shared)
     # fence_shm fetchandadd_am fetchandadd fetchandadd_tree_am fetchandadd_tree 
     #  linked_list_bench_lock_shr linked_list linked_list_fop linked_list_lockall 
     #   mcs-mutex mixedsync mutex_bench lockcontention3 reqops
     # strided_getacc_indexed_shared rget-unlock 
-    # win_flavors win_shared win_shared_noncontig win_shared_noncontig_put 
+    # win_flavors  win_shared_noncontig win_shared_noncontig_put 
     # win_large_shm win_zero wintest  atomic_rmw_fop atomic_rmw_gacc  atomic_get atomic_rmw_cas
     # win_shared_zerobyte aint derived-acc-flush_local large-acc-flush_local
     #  win_shared_create win_shared_put_flush_get win_shared_rma_flush_load
index 527b45b..e2562a8 100644 (file)
@@ -84,7 +84,7 @@ put_bottom 2
 #win_flavors 3 mpiversion=3.0
 manyrma2 2 timeLimit=500
 manyrma3 2
-#win_shared 4 mpiversion=3.0
+win_shared 4
 #win_shared_create_allocshm 4 mpiversion=3.0
 #win_shared_create_no_allocshm 4 mpiversion=3.0
 #win_shared_noncontig 4 mpiversion=3.0