From 303b40221fe17c4b778a37a5ed3757f8600cc532 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Tue, 9 Aug 2022 16:23:11 +0200 Subject: [PATCH] fix mpi_file set/get view to set shared pointer properly and return disp --- src/smpi/mpi/smpi_file.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/smpi/mpi/smpi_file.cpp b/src/smpi/mpi/smpi_file.cpp index 01c8a92d35..19ba9f8ddf 100644 --- a/src/smpi/mpi/smpi_file.cpp +++ b/src/smpi/mpi/smpi_file.cpp @@ -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()); -- 2.20.1