Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Read_at, Write, Write_at
[simgrid.git] / src / smpi / mpi / smpi_file.cpp
index 35e36d4..a7cfe39 100644 (file)
@@ -11,7 +11,6 @@
 #include "smpi_file.hpp"\r
 #include "simgrid/plugins/file_system.h"\r
 \r
-\r
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_io, smpi, "Logging specific to SMPI (RMA operations)");\r
 \r
 \r
@@ -61,18 +60,34 @@ namespace smpi{
     return MPI_SUCCESS;\r
   }\r
   \r
-  int File::read(void *buf, int count, MPI_Datatype datatype, MPI_Status *status){\r
+  int File::read(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){\r
     //get position first as we may be doing non contiguous reads and it will probably be updated badly\r
-    MPI_Offset position = file_->tell();\r
+    MPI_Offset position = fh->file_->tell();\r
     MPI_Offset movesize = datatype->get_extent()*count;\r
     MPI_Offset readsize = datatype->size()*count;\r
-    XBT_DEBUG("Position before read in MPI_File %s : %llu",file_->get_path(),file_->tell());\r
-    MPI_Offset read = file_->read(readsize);\r
-    XBT_DEBUG("Read in MPI_File %s, %lld bytes read, readsize %lld bytes, movesize %lld", file_->get_path(), read, readsize, movesize);\r
+    XBT_DEBUG("Position before read in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell());\r
+    MPI_Offset read = fh->file_->read(readsize);\r
+    XBT_DEBUG("Read in MPI_File %s, %lld bytes read, readsize %lld bytes, movesize %lld", fh->file_->get_path(), read, readsize, movesize);\r
     if(readsize!=movesize){\r
-      file_->seek(position+movesize, SEEK_SET);\r
+      fh->file_->seek(position+movesize, SEEK_SET);\r
+    }\r
+    XBT_DEBUG("Position after read in MPI_File %s : %llu",fh->file_->get_path(), fh->file_->tell());\r
+    return MPI_SUCCESS;\r
+  }\r
+\r
+\r
+  int File::write(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){\r
+    //get position first as we may be doing non contiguous reads and it will probably be updated badly\r
+    MPI_Offset position = fh->file_->tell();\r
+    MPI_Offset movesize = datatype->get_extent()*count;\r
+    MPI_Offset writesize = datatype->size()*count;\r
+    XBT_DEBUG("Position before write in MPI_File %s : %llu",fh->file_->get_path(),fh->file_->tell());\r
+    MPI_Offset write = fh->file_->write(writesize);\r
+    XBT_DEBUG("Write in MPI_File %s, %lld bytes read, readsize %lld bytes, movesize %lld", fh->file_->get_path(), write, writesize, movesize);\r
+    if(writesize!=movesize){\r
+      fh->file_->seek(position+movesize, SEEK_SET);\r
     }\r
-    XBT_DEBUG("Position after read in MPI_File %s : %llu",file_->get_path(), file_->tell());\r
+    XBT_DEBUG("Position after write in MPI_File %s : %llu",fh->file_->get_path(), fh->file_->tell());\r
     return MPI_SUCCESS;\r
   }\r
 \r