Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to use non absolute path in MPI IO.
authorAugustin Degomme <adegomme@gmail.com>
Tue, 10 Dec 2019 16:16:43 +0000 (17:16 +0100)
committerAugustin Degomme <adegomme@gmail.com>
Tue, 10 Dec 2019 16:16:57 +0000 (17:16 +0100)
If no / is found in the name, we just pick the first mountpoint we find.

src/smpi/mpi/smpi_file.cpp
teshsuite/smpi/mpich3-test/io/rdwrord.c

index b0596cb..c743cf9 100644 (file)
@@ -13,6 +13,8 @@
 
 #include "smpi_file.hpp"
 #include "smpi_status.hpp"
+#include "simgrid/s4u/Disk.hpp"
+#include "simgrid/s4u/Host.hpp"
 #include "simgrid/plugins/file_system.h"
 
 #define FP_SIZE sizeof(MPI_Offset)
@@ -25,7 +27,24 @@ namespace simgrid{
 namespace smpi{
 
   File::File(MPI_Comm comm, const char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info) {
-    file_= new simgrid::s4u::File(filename, nullptr);
+    std::string fullname=filename;
+    if (simgrid::s4u::Host::current()->get_disks().empty())
+      xbt_die("SMPI/IO : Trying to open file on a diskless host ! Add one to your platform file");
+
+    size_t found=fullname.find('/');
+    //in case no fullpath is provided ... just pick the first mountpoint.
+    if(found==std::string::npos){
+      auto disk = simgrid::s4u::Host::current()->get_disks().front();
+      std::string mount;
+      if (disk->get_host() != simgrid::s4u::Host::current())
+        mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point(disk->get_host());
+      else
+        mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point();
+      XBT_DEBUG("No absolute path given for file opening, use '%s'", mount.c_str());
+      fullname.insert(0, mount);
+    }
+
+    file_= new simgrid::s4u::File(fullname, nullptr);
     list_=nullptr;
     if (comm_->rank() == 0) {
       int size= comm_->size() + FP_SIZE;
index e8dc8e1..e0e76d2 100644 (file)
@@ -24,7 +24,7 @@ int main(int argc, char *argv[])
     MTest_Init(&argc, &argv);
 
     comm = MPI_COMM_WORLD;
-    MPI_File_open(comm, (char *) "/scratch/test.ord",
+    MPI_File_open(comm, (char *) "test.ord",
                   MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
 
     MPI_Comm_size(comm, &size);