Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Read_at, Write, Write_at
[simgrid.git] / src / smpi / bindings / smpi_pmpi_file.cpp
index fe35968..5844463 100644 (file)
@@ -79,10 +79,43 @@ int PMPI_File_read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_
     return ret;\r
   }\r
 }\r
+\r
+int PMPI_File_write(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){\r
+  CHECK_FILE(fh);
+  CHECK_BUFFER(buf, count);\r
+  CHECK_COUNT(count);\r
+  PASS_ZEROCOUNT(count);\r
+  CHECK_DATATYPE(datatype, count);\r
+  CHECK_STATUS(status);\r
+  CHECK_FLAGS(fh);\r
+  else {\r
+    smpi_bench_end();\r
+    int rank_traced = simgrid::s4u::this_actor::get_pid();\r
+    TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", static_cast<double>(count*datatype->size())));\r
+    int ret = simgrid::smpi::File::write(fh, buf, count, datatype, status);\r
+    TRACE_smpi_comm_out(rank_traced);\r
+    smpi_bench_begin();\r
+    return ret;\r
+  }\r
+}\r
+\r
+int PMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){\r
+  CHECK_FILE(fh);
+  CHECK_BUFFER(buf, count);\r
+  CHECK_OFFSET(offset);\r
+  CHECK_COUNT(count);\r
+  PASS_ZEROCOUNT(count);\r
+  CHECK_DATATYPE(datatype, count);\r
+  CHECK_STATUS(status);\r
+  CHECK_FLAGS(fh);\r
+  else {\r
     smpi_bench_end();\r
     int rank_traced = simgrid::s4u::this_actor::get_pid();\r
     TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", static_cast<double>(count*datatype->size())));\r
-    int ret = fh->read(buf, count, datatype, status);\r
+    int ret = fh->seek(offset,SEEK_SET);\r
+    if(ret!=MPI_SUCCESS)\r
+      return ret;\r
+    ret = simgrid::smpi::File::read(fh, buf, count, datatype, status);\r
     TRACE_smpi_comm_out(rank_traced);\r
     smpi_bench_begin();\r
     return ret;\r
@@ -90,6 +123,29 @@ int PMPI_File_read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_
 }\r
 \r
 \r
+int PMPI_File_write_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_Datatype datatype, MPI_Status *status){\r
+  CHECK_FILE(fh);
+  CHECK_BUFFER(buf, count);\r
+  CHECK_OFFSET(offset);\r
+  CHECK_COUNT(count);\r
+  PASS_ZEROCOUNT(count);\r
+  CHECK_DATATYPE(datatype, count);\r
+  CHECK_STATUS(status);\r
+  CHECK_FLAGS(fh);\r
+  else {\r
+    smpi_bench_end();\r
+    int rank_traced = simgrid::s4u::this_actor::get_pid();\r
+    TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", static_cast<double>(count*datatype->size())));\r
+    int ret = fh->seek(offset,SEEK_SET);\r
+    if(ret!=MPI_SUCCESS)\r
+      return ret;\r
+    ret = simgrid::smpi::File::write(fh, buf, count, datatype, status);\r
+    TRACE_smpi_comm_out(rank_traced);\r
+    smpi_bench_begin();\r
+    return ret;\r
+  }\r
+}\r
+\r
 int PMPI_File_delete(char *filename, MPI_Info info){\r
   if (filename == nullptr) {\r
     return MPI_ERR_FILE;\r