Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix mpi_file set/get view to set shared pointer properly and return disp
authorAugustin Degomme <adegomme@users.noreply.github.com>
Tue, 9 Aug 2022 14:23:11 +0000 (16:23 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Tue, 9 Aug 2022 14:29:43 +0000 (16:29 +0200)
src/smpi/mpi/smpi_file.cpp

index 01c8a92..19ba9f8 100644 (file)
@@ -280,17 +280,25 @@ int File::write_ordered(MPI_File fh, const void* buf, int count, const Datatype*
   return ret;
 }
 
-int File::set_view(MPI_Offset /*disp*/, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info*)
+int File::set_view(MPI_Offset disp, MPI_Datatype etype, MPI_Datatype filetype, const char* datarep, const Info*)
 {
   etype_    = etype;
   filetype_ = filetype;
   datarep_  = std::string(datarep);
-  seek_shared(0, MPI_SEEK_SET);
+  disp_     = disp;
+  if (comm_->rank() == 0){
+    if(disp != MPI_DISPLACEMENT_CURRENT)
+      seek_shared(disp, MPI_SEEK_SET);
+    else
+      seek_shared(0, MPI_SEEK_CUR);
+  }
+  sync();
   return MPI_SUCCESS;
 }
 
-int File::get_view(MPI_Offset* /*disp*/, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep) const
+int File::get_view(MPI_Offset* disp, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep) const
 {
+  *disp     = disp_;
   *etype    = etype_;
   *filetype = filetype_;
   snprintf(datarep, MPI_MAX_NAME_STRING + 1, "%s", datarep_.c_str());