Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add MPI_Win_allocate, MPI_Win_create_dynamic, MPI_Win_attach, MPI_Win_detach, MPI_Win...
authordegomme <augustin.degomme@unibas.ch>
Fri, 24 Mar 2017 14:52:34 +0000 (15:52 +0100)
committerdegomme <augustin.degomme@unibas.ch>
Mon, 27 Mar 2017 21:20:56 +0000 (23:20 +0200)
include/smpi/smpi.h
src/smpi/smpi_mpi.cpp
src/smpi/smpi_pmpi.cpp
src/smpi/smpi_win.cpp
src/smpi/smpi_win.hpp
teshsuite/smpi/mpich3-test/rma/CMakeLists.txt
teshsuite/smpi/mpich3-test/rma/testlist
teshsuite/smpi/mpich3-test/rma/win_info.c

index beb7c7b..c57139b 100644 (file)
@@ -536,8 +536,16 @@ MPI_CALL(XBT_PUBLIC(int), MPI_Reduce_local,(void *inbuf, void *inoutbuf, int cou
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_free,( MPI_Win* win));
 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_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));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_set_name,(MPI_Win  win, char * name));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_name,(MPI_Win  win, char * name, int* len));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_set_info,(MPI_Win  win, MPI_Info info));
+MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_info,(MPI_Win  win, MPI_Info* info));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_group,(MPI_Win  win, MPI_Group * group));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_fence,( int assert,  MPI_Win win));
 MPI_CALL(XBT_PUBLIC(int), MPI_Win_get_attr, (MPI_Win type, int type_keyval, void *attribute_val, int* flag));
index ef09726..3099f4f 100644 (file)
@@ -183,12 +183,18 @@ WRAPPED_PMPI_CALL(int,MPI_Wait,(MPI_Request * request, MPI_Status * status),(req
 WRAPPED_PMPI_CALL(int,MPI_Waitsome,(int incount, MPI_Request requests[], int *outcount, int *indices, MPI_Status status[]),(incount, requests, outcount, indices, status))
 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_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))
 WRAPPED_PMPI_CALL(int,MPI_Win_fence,( int assert,MPI_Win win),( assert, win))
 WRAPPED_PMPI_CALL(int,MPI_Win_free,( MPI_Win* win),(win))
 WRAPPED_PMPI_CALL(int,MPI_Win_get_group,(MPI_Win win, MPI_Group * group),(win, group))
 WRAPPED_PMPI_CALL(int,MPI_Win_get_name,(MPI_Win win, char * name, int* len),(win,name,len))
+WRAPPED_PMPI_CALL(int,MPI_Win_get_info,(MPI_Win win, MPI_Info * info),(win,info))
 WRAPPED_PMPI_CALL(int,MPI_Win_post,(MPI_Group group, int assert, MPI_Win win),(group, assert, win))
 WRAPPED_PMPI_CALL(int,MPI_Win_set_name,(MPI_Win win, char * name),(win, name))
+WRAPPED_PMPI_CALL(int,MPI_Win_set_info,(MPI_Win win, MPI_Info info),(win,info))
 WRAPPED_PMPI_CALL(int,MPI_Win_start,(MPI_Group group, int assert, MPI_Win win),(group, assert, win))
 WRAPPED_PMPI_CALL(int,MPI_Win_wait,(MPI_Win win),(win))
 WRAPPED_PMPI_CALL(int,MPI_Win_lock,(int lock_type, int rank, int assert, MPI_Win win) ,(lock_type, rank, assert, win))
index 5b41eb6..d14354c 100644 (file)
@@ -2451,6 +2451,67 @@ int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MP
   return retval;
 }
 
+int PMPI_Win_allocate( 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 = xbt_malloc(size);
+    if(ptr==nullptr)
+      return MPI_ERR_NO_MEM;
+    *static_cast<void**>(base) = ptr;
+    *win = new simgrid::smpi::Win( ptr, size, disp_unit, info, comm,1);
+    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();
+  if (comm == MPI_COMM_NULL) {
+    retval= MPI_ERR_COMM;
+  }else{
+    *win = new simgrid::smpi::Win(info, comm);
+    retval = MPI_SUCCESS;
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+int PMPI_Win_attach(MPI_Win win, void *base, MPI_Aint size){
+  int retval = 0;
+  smpi_bench_end();
+  if(win == MPI_WIN_NULL){
+    retval = MPI_ERR_WIN;
+  } else if ((base == nullptr && size != 0) || size < 0 ){
+    retval= MPI_ERR_OTHER;
+  }else{
+    retval = win->attach(base, size);
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+int PMPI_Win_detach(MPI_Win win,  void *base){
+  int retval = 0;
+  smpi_bench_end();
+  if(win == MPI_WIN_NULL){
+    retval = MPI_ERR_WIN;
+  } else if (base == nullptr){
+    retval= MPI_ERR_OTHER;
+  }else{
+    retval = win->detach(base);
+  }
+  smpi_bench_begin();
+  return retval;
+}
+
+
 int PMPI_Win_free( MPI_Win* win){
   int retval = 0;
   smpi_bench_end();
@@ -2488,6 +2549,26 @@ int PMPI_Win_get_name(MPI_Win  win, char * name, int* len)
   }
 }
 
+int PMPI_Win_get_info(MPI_Win  win, MPI_Info* info)
+{
+  if (win == MPI_WIN_NULL)  {
+    return MPI_ERR_WIN;
+  } else {
+    *info = win->info();
+    return MPI_SUCCESS;
+  }
+}
+
+int PMPI_Win_set_info(MPI_Win  win, MPI_Info info)
+{
+  if (win == MPI_WIN_NULL)  {
+    return MPI_ERR_TYPE;
+  } else {
+    win->set_info(info);
+    return MPI_SUCCESS;
+  }
+}
+
 int PMPI_Win_get_group(MPI_Win  win, MPI_Group * group){
   if (win == MPI_WIN_NULL)  {
     return MPI_ERR_WIN;
index 5dbebb9..4db32e7 100644 (file)
@@ -14,7 +14,7 @@ namespace smpi{
 std::unordered_map<int, smpi_key_elem> Win::keyvals_;
 int Win::keyval_id_=0;
 
-Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm): base_(base), size_(size), disp_unit_(disp_unit), assert_(0), info_(info), comm_(comm){
+Win::Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated): base_(base), size_(size), disp_unit_(disp_unit), assert_(0), info_(info), comm_(comm), allocated_(allocated){
   int comm_size = comm->size();
   rank_      = comm->rank();
   XBT_DEBUG("Creating window");
@@ -69,9 +69,26 @@ Win::~Win(){
   xbt_mutex_destroy(mut_);
   xbt_mutex_destroy(lock_mut_);
 
+  if(allocated_ !=0)
+    xbt_free(base_);
+
   cleanup_attr<Win>();
 }
 
+int Win::attach (void *base, MPI_Aint size){
+  if (!(base_ == MPI_BOTTOM || base_ == 0))
+    return MPI_ERR_ARG;
+  base_=0;//actually the address will be given in the RMA calls, as being the disp.
+  size_+=size;
+  return MPI_SUCCESS;
+}
+
+int Win::detach (void *base){
+  base_=MPI_BOTTOM;
+  size_=-1;
+  return MPI_SUCCESS;
+}
+
 void Win::get_name(char* name, int* length){
   if(name_==nullptr){
     *length=0;
@@ -90,6 +107,13 @@ void Win::get_group(MPI_Group* group){
   }
 }
 
+MPI_Info Win::info(){
+  if(info_== MPI_INFO_NULL)
+    info_ = new Info();
+  info_->ref();
+  return info_;
+}
+
 int Win::rank(){
   return rank_;
 }
@@ -106,6 +130,11 @@ int Win::disp_unit(){
   return disp_unit_;
 }
 
+void Win::set_info(MPI_Info info){
+  if(info_!= MPI_INFO_NULL)
+    info->ref();
+  info_=info;
+}
 
 void Win::set_name(char* name){
   name_ = xbt_strdup(name);
index 52aa4cf..13dde7b 100644 (file)
@@ -34,13 +34,17 @@ class Win : public F2C, public Keyval {
   std::list<int> lockers_;
   int rank_; // to identify owner for barriers in MPI_COMM_WORLD
   int mode_; // exclusive or shared lock
+  int allocated_;
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
   static int keyval_id_;
 
-  Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm);
+  Win(void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, int allocated = 0);
+  Win(MPI_Info info, MPI_Comm comm) : Win(MPI_BOTTOM, 0, 1, info, comm) {};
   ~Win();
+  int attach (void *base, MPI_Aint size);
+  int detach (void *base);
   void get_name( char* name, int* length);
   void get_group( MPI_Group* group);
   void set_name( char* name);
@@ -48,6 +52,8 @@ public:
   int start(MPI_Group group, int assert);
   int post(MPI_Group group, int assert);
   int complete();
+  MPI_Info info();
+  void set_info( MPI_Info info);
   int wait();
   MPI_Aint size();
   void* base();
index 4caa6f2..66616ab 100644 (file)
@@ -12,8 +12,8 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
 
   foreach(file accfence1 accfence2_am accfence2 accpscw1 allocmem epochtest getfence1 getgroup manyrma3 nullpscw lockcontention lockopts contig_displ
           putfence1 putfidx putpscw1 test1_am test1 test1_dt test2_am test2 test3 test4 test5_am test5 transpose1 transpose2 lockcontention2
-          transpose3 transpose4 transpose5 transpose6 transpose7 window_creation selfrma locknull
-          at_complete  acc-pairtype manyget large-small-acc lock_dt
+          transpose3 transpose4 transpose5 transpose6 transpose7 window_creation selfrma locknull win_info
+          at_complete  acc-pairtype manyget large-small-acc lock_dt win_dynamic_acc
           lock_nested winname attrorderwin baseattrwin fkeyvalwin strided_acc_indexed strided_getacc_indexed
      strided_acc_onelock strided_get_indexed strided_putget_indexed contention_put contention_putget)
     # not compiled files: acc-loc adlb_mimic1  badrma  compare_and_swap contention_put
@@ -23,7 +23,7 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
     #  manyrma2 mcs-mutex mixedsync mutex_bench lockcontention3
     # pscw_ordering put_base put_bottom req_example reqops rmanull rmazero rma-contig selfrma  
     # strided_getacc_indexed_shared 
-    # win_dynamic_acc win_flavors win_info  win_shared win_shared_noncontig win_shared_noncontig_put 
+    # win_flavors win_shared win_shared_noncontig win_shared_noncontig_put 
     # win_large_shm win_zero wintest get-struct atomic_rmw_fop atomic_rmw_gacc rget-unlock atomic_get atomic_rmw_cas
     # win_shared_zerobyte aint derived-acc-flush_local large-acc-flush_local lockall_dt lockall_dt_flushall
     # lockall_dt_flushlocalall lockall_dt_flushlocal lock_contention_dt  lock_dt_flush lock_dt_flushlocal 
@@ -33,6 +33,10 @@ if(enable_smpi AND enable_smpi_MPICH3_testsuite)
     target_link_libraries(${file} simgrid mtest_c)
     set_target_properties(${file} PROPERTIES COMPILE_FLAGS "${MPICH_FLAGS}")
   endforeach()
+
+    add_executable(transpose3_shm transpose3.c)
+    target_link_libraries(transpose3_shm simgrid mtest_c)
+    set_target_properties(transpose3_shm PROPERTIES COMPILE_FLAGS "${MPICH_FLAGS} -DUSE_WIN_ALLOCATE")
 endif()
 
 if (enable_smpi_MPICH3_testsuite AND HAVE_RAW_CONTEXTS)
index 17cc1c6..f659fa1 100644 (file)
@@ -14,7 +14,7 @@ transpose1 2
 transpose2 2
 transpose3 2
 #Needs MPI_Win_allocate
-#transpose3_shm 2
+transpose3_shm 2
 transpose5 2
 transpose6 1
 transpose7 2
@@ -95,7 +95,7 @@ manyrma3 2
 #win_shared_noncontig 4 mpiversion=3.0
 #win_shared_noncontig_put 4 mpiversion=3.0
 #win_zero 4 mpiversion=3.0
-#win_dynamic_acc 4 mpiversion=3.0
+win_dynamic_acc 4
 #get_acc_local 1 mpiversion=3.0
 #linked_list 4 mpiversion=3.0
 #linked_list_fop 4 mpiversion=3.0
@@ -117,7 +117,7 @@ manyrma3 2
 #flush 4 mpiversion=3.0
 #reqops 4 mpiversion=3.0
 #req_example 4 mpiversion=3.0
-#win_info 4 mpiversion=3.0
+win_info 4
 #linked_list_lockall 4 mpiversion=3.0
 #pscw_ordering 4 mpiversion=3.0
 #linked_list_bench_lock_all 4 mpiversion=3.0
index 3eb4380..9f80fd3 100644 (file)
@@ -31,13 +31,13 @@ int main(int argc, char **argv)
     /* Test#1: setting a valid key at window-create time */
 
     MPI_Info_create(&info_in);
-    MPI_Info_set(info_in, "no_locks", "true");
+    MPI_Info_set(info_in, (char *)"no_locks", (char *)"true");
 
     MPI_Win_allocate(sizeof(int), sizeof(int), info_in, MPI_COMM_WORLD, &base, &win);
 
     MPI_Win_get_info(win, &info_out);
 
-    MPI_Info_get(info_out, "no_locks", MPI_MAX_INFO_VAL, buf, &flag);
+    MPI_Info_get(info_out, (char *)"no_locks", MPI_MAX_INFO_VAL, buf, &flag);
     if (!flag || strncmp(buf, "true", strlen("true")) != 0) {
         if (!flag)
             printf("%d: no_locks is not defined\n", rank);
@@ -58,13 +58,13 @@ int main(int argc, char **argv)
     /* Test#2: setting and getting invalid key */
 
     MPI_Info_create(&info_in);
-    MPI_Info_set(info_in, invalid_key, "true");
+    MPI_Info_set(info_in, invalid_key, (char *)"true");
 
     MPI_Win_set_info(win, info_in);
     MPI_Win_get_info(win, &info_out);
 
     MPI_Info_get(info_out, invalid_key, MPI_MAX_INFO_VAL, buf, &flag);
-#ifndef USE_STRICT_MPI
+#ifdef USE_STRICT_MPI
     /* Check if our invalid key was ignored.  Note, this check's MPICH's
      * behavior, but this behavior may not be required for a standard
      * conforming MPI implementation. */
@@ -80,12 +80,12 @@ int main(int argc, char **argv)
     /* Test#3: setting info key "no_lock" to false and getting the key */
 
     MPI_Info_create(&info_in);
-    MPI_Info_set(info_in, "no_locks", "false");
+    MPI_Info_set(info_in, (char *)"no_locks", (char *)"false");
 
     MPI_Win_set_info(win, info_in);
     MPI_Win_get_info(win, &info_out);
 
-    MPI_Info_get(info_out, "no_locks", MPI_MAX_INFO_VAL, buf, &flag);
+    MPI_Info_get(info_out, (char *)"no_locks", MPI_MAX_INFO_VAL, buf, &flag);
     if (!flag || strncmp(buf, "false", strlen("false")) != 0) {
         if (!flag)
             printf("%d: no_locks is not defined\n", rank);
@@ -102,12 +102,12 @@ int main(int argc, char **argv)
     /* Test#4: setting info key "no_lock" to true and getting the key */
 
     MPI_Info_create(&info_in);
-    MPI_Info_set(info_in, "no_locks", "true");
+    MPI_Info_set(info_in, (char *)"no_locks", (char *)"true");
 
     MPI_Win_set_info(win, info_in);
     MPI_Win_get_info(win, &info_out);
 
-    MPI_Info_get(info_out, "no_locks", MPI_MAX_INFO_VAL, buf, &flag);
+    MPI_Info_get(info_out, (char *)"no_locks", MPI_MAX_INFO_VAL, buf, &flag);
     if (!flag || strncmp(buf, "true", strlen("true")) != 0) {
         if (!flag)
             printf("%d: no_locks is not defined\n", rank);
@@ -125,19 +125,19 @@ int main(int argc, char **argv)
 
     MPI_Win_get_info(win, &info_out);
 
-    MPI_Info_get(info_out, "accumulate_ordering", MPI_MAX_INFO_VAL, buf, &flag);
+    MPI_Info_get(info_out, (char *)"accumulate_ordering", MPI_MAX_INFO_VAL, buf, &flag);
     if (flag && VERBOSE)
         printf("%d: accumulate_ordering = %s\n", rank, buf);
 
-    MPI_Info_get(info_out, "accumulate_ops", MPI_MAX_INFO_VAL, buf, &flag);
+    MPI_Info_get(info_out, (char *)"accumulate_ops", MPI_MAX_INFO_VAL, buf, &flag);
     if (flag && VERBOSE)
         printf("%d: accumulate_ops = %s\n", rank, buf);
 
-    MPI_Info_get(info_out, "same_size", MPI_MAX_INFO_VAL, buf, &flag);
+    MPI_Info_get(info_out, (char *)"same_size", MPI_MAX_INFO_VAL, buf, &flag);
     if (flag && VERBOSE)
         printf("%d: same_size = %s\n", rank, buf);
 
-    MPI_Info_get(info_out, "alloc_shm", MPI_MAX_INFO_VAL, buf, &flag);
+    MPI_Info_get(info_out, (char *)"alloc_shm", MPI_MAX_INFO_VAL, buf, &flag);
     if (flag && VERBOSE)
         printf("%d: alloc_shm = %s\n", rank, buf);