From: Augustin Degomme Date: Tue, 17 Nov 2020 22:13:34 +0000 (+0100) Subject: move dlopen tmp files to tmp dir instead of executable dir, which could be not writeable. X-Git-Tag: v3.26~194 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f8856118321c58129177e1392dbd03be2db142af move dlopen tmp files to tmp dir instead of executable dir, which could be not writeable. todo : - check portability - move also smpirun tmp files there id this works. --- diff --git a/src/smpi/internals/smpi_config.cpp b/src/smpi/internals/smpi_config.cpp index f24680ceba..f9c3c31fbf 100644 --- a/src/smpi/internals/smpi_config.cpp +++ b/src/smpi/internals/smpi_config.cpp @@ -183,6 +183,7 @@ void smpi_init_options(){ return; simgrid::config::declare_flag("smpi/display-timing", "Whether we should display the timing after simulation.", false); simgrid::config::declare_flag("smpi/keep-temps", "Whether we should keep the generated temporary files.", false); + simgrid::config::declare_flag("smpi/tmpdir", "tmp dir for dlopen files", "/tmp"); simgrid::config::declare_flag("smpi/coll-selector", "Which collective selector to use", "default"); simgrid::config::declare_flag("smpi/gather", "Which collective to use for gather", ""); diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 6008469fcd..4528d48f88 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -14,6 +14,7 @@ #include "src/simix/smx_private.hpp" #include "src/smpi/include/smpi_actor.hpp" #include "xbt/config.hpp" +#include "xbt/file.hpp" #include #include /* split */ @@ -448,8 +449,9 @@ static void smpi_init_privatization_dlopen(const std::string& executable) return std::function([executable, fdin_size, args] { static std::size_t rank = 0; // Copy the dynamic library: - std::string target_executable = - executable + "_" + std::to_string(getpid()) + "_" + std::to_string(rank) + ".so"; + simgrid::xbt::Path path(executable); + std::string target_executable = simgrid::config::get_value("smpi/tmpdir") + "/" + + path.get_base_name() + "_" + std::to_string(getpid()) + "_" + std::to_string(rank) + ".so"; smpi_copy_file(executable, target_executable, fdin_size); // if smpi/privatize-libs is set, duplicate pointed lib and link each executable copy to a different one. @@ -472,7 +474,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable) unsigned int pad = 7; if (libname.length() < pad) pad = libname.length(); - std::string target_lib = + std::string target_lib = simgrid::config::get_value("smpi/tmpdir") + "/" + std::string(pad - std::to_string(rank).length(), '0') + std::to_string(rank) + libname.substr(pad); target_libs.push_back(target_lib); XBT_DEBUG("copy lib %s to %s, with size %lld", libpath.c_str(), target_lib.c_str(), (long long)fdin_size2); diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index 74523e1dcf..7946b34f2e 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -26,6 +26,8 @@ PRIVATIZE="--cfg=smpi/privatization:${SMPI_PRIVATIZATION:-@HAVE_PRIVATIZATION@}" SIMOPTS="--cfg=surf/precision:1e-9 --cfg=network/model:SMPI" +SMPITMPDIR="$(dirname $(mktemp -u))" + #usage to print the way this script should be called usage () { cat < # use that amount of processes from the hostfile. # By default, all processes of the hostfile are used. -no-privatize # Disable the globals privatization, that is activated by default + -tmpdir # Directory used to store temporary files. Defaults to system's. -trace-ti # activate time independent tracing (for replay, default in smpi_simgrid.txt) -trace # activate tracing (Paje, default in smpi_simgrid.trace) -trace-comment # put a comment on the top of the trace file @@ -168,6 +171,10 @@ while true; do MAPOPT=1 shift 1 ;; + "-tmpdir") + SMPITMPDIR="$2" + shift 1 + ;; "-trace") TRACE_ACTIVE="true" shift 1 @@ -257,6 +264,10 @@ while true; do esac done +#setup tmp dir +SIMOPTS="$SIMOPTS --cfg=smpi/tmpdir:$SMPITMPDIR" +export LD_LIBRARY_PATH="$SMPITMPDIR:$LD_LIBRARY_PATH" + if [ -n "${APP_TRACES}" ] ; then if [ $# -eq 0 ] ; then EXEC="@SMPIREPLAYMAIN@"