From 49609678d7329f0824ca7d5c6d5421fc9d358cbb Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Tue, 10 Dec 2019 17:16:43 +0100 Subject: [PATCH 1/1] Allow to use non absolute path in MPI IO. If no / is found in the name, we just pick the first mountpoint we find. --- src/smpi/mpi/smpi_file.cpp | 21 ++++++++++++++++++++- teshsuite/smpi/mpich3-test/io/rdwrord.c | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/smpi/mpi/smpi_file.cpp b/src/smpi/mpi/smpi_file.cpp index b0596cb1ae..c743cf9b89 100644 --- a/src/smpi/mpi/smpi_file.cpp +++ b/src/smpi/mpi/smpi_file.cpp @@ -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()->get_mount_point(disk->get_host()); + else + mount = disk->extension()->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; diff --git a/teshsuite/smpi/mpich3-test/io/rdwrord.c b/teshsuite/smpi/mpich3-test/io/rdwrord.c index e8dc8e15a7..e0e76d28d1 100644 --- a/teshsuite/smpi/mpich3-test/io/rdwrord.c +++ b/teshsuite/smpi/mpich3-test/io/rdwrord.c @@ -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); -- 2.20.1