Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
smpi io: restore position after calls which should not modify it (add seek calls...
[simgrid.git] / src / smpi / bindings / smpi_pmpi_file.cpp
index e87680f..2fa04be 100644 (file)
@@ -200,9 +200,12 @@ int PMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_D
   const SmpiBenchGuard suspend_bench;
   aid_t rank_traced = simgrid::s4u::this_actor::get_pid();
   TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", count * datatype->size()));
+  MPI_Offset prev;
+  fh->get_position(&prev);
   int ret = fh->seek(offset,MPI_SEEK_SET);
   if (ret == MPI_SUCCESS)
     ret = simgrid::smpi::File::read(fh, buf, count, datatype, status);
+  fh->seek(prev,MPI_SEEK_SET);
   TRACE_smpi_comm_out(rank_traced);
   return ret;
 }
@@ -215,9 +218,12 @@ int PMPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count,M
   aid_t rank_traced = simgrid::s4u::this_actor::get_pid();
   TRACE_smpi_comm_in(rank_traced, __func__,
                      new simgrid::instr::CpuTIData("IO - read_at_all", count * datatype->size()));
+  MPI_Offset prev;
+  fh->get_position(&prev);
   int ret = fh->seek(offset,MPI_SEEK_SET);
   if (ret == MPI_SUCCESS)
     ret = fh->op_all<simgrid::smpi::File::read>(buf, count, datatype, status);
+  fh->seek(prev,MPI_SEEK_SET);
   TRACE_smpi_comm_out(rank_traced);
   return ret;
 }
@@ -229,9 +235,12 @@ int PMPI_File_write_at(MPI_File fh, MPI_Offset offset, const void *buf, int coun
   const SmpiBenchGuard suspend_bench;
   aid_t rank_traced = simgrid::s4u::this_actor::get_pid();
   TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", count * datatype->size()));
+  MPI_Offset prev;
+  fh->get_position(&prev);
   int ret = fh->seek(offset,MPI_SEEK_SET);
   if (ret == MPI_SUCCESS)
     ret = simgrid::smpi::File::write(fh, const_cast<void*>(buf), count, datatype, status);
+  fh->seek(prev,MPI_SEEK_SET);
   TRACE_smpi_comm_out(rank_traced);
   return ret;
 }
@@ -244,9 +253,12 @@ int PMPI_File_write_at_all(MPI_File fh, MPI_Offset offset, const void *buf, int
   aid_t rank_traced = simgrid::s4u::this_actor::get_pid();
   TRACE_smpi_comm_in(rank_traced, __func__,
                      new simgrid::instr::CpuTIData("IO - write_at_all", count * datatype->size()));
+  MPI_Offset prev;
+  fh->get_position(&prev);
   int ret = fh->seek(offset,MPI_SEEK_SET);
   if (ret == MPI_SUCCESS)
     ret = fh->op_all<simgrid::smpi::File::write>(const_cast<void*>(buf), count, datatype, status);
+  fh->seek(prev,MPI_SEEK_SET);
   TRACE_smpi_comm_out(rank_traced);
   return ret;
 }
@@ -367,3 +379,31 @@ int PMPI_File_call_errhandler(MPI_File file,int errorcode){
   simgrid::smpi::Errhandler::unref(err);
   return MPI_SUCCESS;
 }
+
+int PMPI_File_get_type_extent(MPI_File fh, MPI_Datatype
+    datatype, MPI_Aint *extent){
+  CHECK_FILE(1, fh)
+  CHECK_TYPE(2, datatype)
+  CHECK_NULL(3, MPI_ERR_OTHER, extent)
+  *extent = datatype->get_extent();
+  return MPI_SUCCESS;
+}
+
+int PMPI_File_set_atomicity(MPI_File fh, int a){
+  CHECK_FILE(1, fh)
+  fh->set_atomicity(a != 0);
+  return MPI_SUCCESS;
+}
+
+int PMPI_File_get_atomicity(MPI_File fh, int* a){
+  CHECK_FILE(1, fh)
+  *a = fh->get_atomicity();
+  return MPI_SUCCESS;
+}
+
+int PMPI_File_get_byte_offset(MPI_File fh, MPI_Offset offset, MPI_Offset *disp){
+  CHECK_FILE(1, fh)
+  CHECK_NULL(3, MPI_ERR_OTHER, disp)
+  *disp = offset * fh->etype()->get_extent();
+  return MPI_SUCCESS;
+}