Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Skeleton for MPI_IO
authorAugustin Degomme <adegomme@users.noreply.github.com>
Sun, 14 Apr 2019 23:53:02 +0000 (01:53 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Sun, 14 Apr 2019 23:53:02 +0000 (01:53 +0200)
include/smpi/forward.hpp
include/smpi/smpi.h
src/smpi/bindings/smpi_mpi.cpp
src/smpi/bindings/smpi_pmpi_file.cpp [new file with mode: 0644]
src/smpi/include/smpi_file.hpp [new file with mode: 0644]
src/smpi/mpi/smpi_file.cpp [new file with mode: 0644]
tools/cmake/DefinePackages.cmake

index b23b185..e3039c4 100644 (file)
@@ -17,6 +17,7 @@ class Coll;
 class Colls;
 class Comm;
 class Datatype;
+class File;
 class Group;
 class Info;
 class Keyval;
@@ -35,6 +36,7 @@ class Win;
 
 typedef simgrid::smpi::Comm SMPI_Comm;
 typedef simgrid::smpi::Datatype SMPI_Datatype;
+typedef simgrid::smpi::File SMPI_File;
 typedef simgrid::smpi::Group SMPI_Group;
 typedef simgrid::smpi::Info SMPI_Info;
 typedef simgrid::smpi::Op SMPI_Op;
@@ -49,6 +51,7 @@ typedef simgrid::smpi::Win SMPI_Win;
 
 typedef struct SMPI_Comm SMPI_Comm;
 typedef struct SMPI_Datatype SMPI_Datatype;
+typedef struct SMPI_File SMPI_File;
 typedef struct SMPI_Group SMPI_Group;
 typedef struct SMPI_Info SMPI_Info;
 typedef struct SMPI_Op SMPI_Op;
index 1f19913..4bd6284 100644 (file)
@@ -214,10 +214,7 @@ typedef ptrdiff_t MPI_Aint;
 typedef long long MPI_Offset;
 typedef long long MPI_Count;
 
-struct s_MPI_File;
-typedef struct s_MPI_File *MPI_File;
-
-
+typedef SMPI_File *MPI_File;
 typedef SMPI_Datatype *MPI_Datatype;
 
 typedef struct {
index 3a354e0..0305b39 100644 (file)
@@ -346,9 +346,9 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_call_errhandler,(MPI_File fh, int
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_create_errhandler,(MPI_File_errhandler_function *function, MPI_Errhandler *errhandler),(function, errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int, MPI_File_set_errhandler,( MPI_File file, MPI_Errhandler errhandler), (file, errhandler))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL_NOFAIL(int, MPI_File_get_errhandler,( MPI_File file, MPI_Errhandler *errhandler), (file, errhandler))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_open,(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh),(comm, filename, amode, info, fh))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_close,(MPI_File *fh), (fh))
-UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_delete,(char *filename, MPI_Info info), (filename, info))
+WRAPPED_PMPI_CALL(int, MPI_File_open,(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh),(comm, filename, amode, info, fh))
+WRAPPED_PMPI_CALL(int, MPI_File_close,(MPI_File *fh), (fh))
+WRAPPED_PMPI_CALL(int, MPI_File_delete,(char *filename, MPI_Info info), (filename, info))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_set_size,(MPI_File fh, MPI_Offset size), (fh, size))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_preallocate,(MPI_File fh, MPI_Offset size), (fh, size))
 UNIMPLEMENTED_WRAPPED_PMPI_CALL(int, MPI_File_get_size,(MPI_File fh, MPI_Offset *size), (fh, size))
diff --git a/src/smpi/bindings/smpi_pmpi_file.cpp b/src/smpi/bindings/smpi_pmpi_file.cpp
new file mode 100644 (file)
index 0000000..8af99f1
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */\r
+\r
+/* This program is free software; you can redistribute it and/or modify it\r
+ * under the terms of the license (GNU LGPL) which comes with this package. */\r
+\r
+#include "private.hpp"\r
+#include "smpi_file.hpp"\r
+\r
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);\r
+\r
+int PMPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh){\r
+  if (comm == MPI_COMM_NULL) {\r
+    return MPI_ERR_COMM;\r
+  } else if (filename == nullptr) {\r
+    return MPI_ERR_FILE;\r
+  } else if (amode < 0) {\r
+    return MPI_ERR_AMODE;\r
+  } else {\r
+    smpi_bench_end();\r
+    *fh =  new simgrid::smpi::File(comm, filename, amode, info);\r
+    smpi_bench_begin();\r
+    if((*fh)->size()==0 && not amode & MPI_MODE_CREATE){\r
+      delete fh;\r
+      return MPI_ERR_AMODE;\r
+    }\r
+    return MPI_SUCCESS;\r
+  }\r
+}\r
+\r
+int PMPI_File_close(MPI_File *fh){\r
+  if (fh==nullptr){\r
+    return MPI_ERR_ARG;\r
+  } else {\r
+    smpi_bench_end();\r
+    int ret = simgrid::smpi::File::close(fh);\r
+    *fh = MPI_FILE_NULL;\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
+  } else {\r
+    smpi_bench_end();\r
+    int ret = simgrid::smpi::File::del(filename, info);\r
+    smpi_bench_begin();\r
+    return ret;\r
+  }\r
+}
\ No newline at end of file
diff --git a/src/smpi/include/smpi_file.hpp b/src/smpi/include/smpi_file.hpp
new file mode 100644 (file)
index 0000000..9236747
--- /dev/null
@@ -0,0 +1,30 @@
+/* Copyright (c) 2010-2019. The SimGrid Team.\r
+ * All rights reserved.                                                     */\r
+\r
+/* This program is free software; you can redistribute it and/or modify it\r
+ * under the terms of the license (GNU LGPL) which comes with this package. */\r
+\r
+#ifndef SMPI_FILE_HPP_INCLUDED\r
+#define SMPI_FILE_HPP_INCLUDED\r
+#include "simgrid/plugins/file_system.h"\r
+\r
+\r
+namespace simgrid{\r
+namespace smpi{\r
+class File{\r
+  MPI_Comm comm_;\r
+  int flags_;\r
+  simgrid::s4u::File* file_;\r
+  MPI_Info info_;\r
+  public:\r
+  File(MPI_Comm comm, char *filename, int amode, MPI_Info info);\r
+  ~File();\r
+  int size();\r
+  int flags();\r
+  int sync();\r
+  static int close(MPI_File *fh);\r
+  static int del(char *filename, MPI_Info info);\r
+};\r
+}\r
+}\r
+#endif
\ No newline at end of file
diff --git a/src/smpi/mpi/smpi_file.cpp b/src/smpi/mpi/smpi_file.cpp
new file mode 100644 (file)
index 0000000..4cfbe05
--- /dev/null
@@ -0,0 +1,53 @@
+/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */\r
+\r
+/* This program is free software; you can redistribute it and/or modify it\r
+ * under the terms of the license (GNU LGPL) which comes with this package. */\r
+#include "private.hpp"\r
+\r
+#include "smpi_comm.hpp"\r
+#include "smpi_coll.hpp"\r
+#include "smpi_info.hpp"\r
+#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
+namespace simgrid{\r
+namespace smpi{\r
+  File::File(MPI_Comm comm, char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info){\r
+    file_= new simgrid::s4u::File(filename, nullptr);\r
+  }\r
+  \r
+  File::~File(){\r
+    delete file_;\r
+  }\r
+  \r
+  int File::close(MPI_File *fh){\r
+    (*fh)->sync();\r
+    if((*fh)->flags() & MPI_MODE_DELETE_ON_CLOSE)\r
+      (*fh)->file_->unlink();\r
+    delete fh;\r
+    return MPI_SUCCESS;\r
+  }\r
+  \r
+  int File::del(char *filename, MPI_Info info){\r
+    File* f = new File(MPI_COMM_SELF,filename,MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDWR, nullptr);\r
+    close(&f);\r
+    return MPI_SUCCESS;\r
+  }\r
+  \r
+  int File::size(){\r
+    return file_->size();\r
+  }\r
+  \r
+  int File::flags(){\r
+    return flags_;\r
+  }\r
+  int File::sync(){\r
+    //no idea\r
+    return simgrid::smpi::Colls::barrier(comm_);\r
+  }\r
+}\r
+}
\ No newline at end of file
index 3e7a0a1..b856d19 100644 (file)
@@ -92,6 +92,7 @@ set(SMPI_SRC
   src/smpi/bindings/smpi_pmpi.cpp
   src/smpi/bindings/smpi_pmpi_coll.cpp
   src/smpi/bindings/smpi_pmpi_comm.cpp
+  src/smpi/bindings/smpi_pmpi_file.cpp
   src/smpi/bindings/smpi_pmpi_group.cpp
   src/smpi/bindings/smpi_pmpi_info.cpp
   src/smpi/bindings/smpi_pmpi_op.cpp
@@ -226,6 +227,7 @@ set(SMPI_SRC
   src/smpi/mpi/smpi_datatype.cpp
   src/smpi/mpi/smpi_datatype_derived.cpp
   src/smpi/mpi/smpi_f2c.cpp
+  src/smpi/mpi/smpi_file.cpp
   src/smpi/mpi/smpi_group.cpp
   src/smpi/mpi/smpi_info.cpp
   src/smpi/mpi/smpi_keyvals.cpp
@@ -240,6 +242,7 @@ set(SMPI_SRC
   src/smpi/include/smpi_datatype_derived.hpp
   src/smpi/include/smpi_datatype.hpp
   src/smpi/include/smpi_f2c.hpp
+  src/smpi/include/smpi_file.hpp
   src/smpi/include/smpi_group.hpp
   src/smpi/include/smpi_host.hpp
   src/smpi/include/smpi_info.hpp