#include "src/simix/smx_private.hpp"
#include "src/smpi/include/smpi_actor.hpp"
#include "xbt/config.hpp"
+#include "xbt/file.hpp"
#include <algorithm>
#include <boost/algorithm/string.hpp> /* split */
(static_cast<char*>(buff) >= smpi_data_exe_start) &&
(static_cast<char*>(buff) < smpi_data_exe_start + smpi_data_exe_size)) {
XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
- smpi_switch_data_segment(comm->src_actor_->iface());
+ smpi_switch_data_segment(comm->src_actor_->get_iface());
tmpbuff = xbt_malloc(buff_size);
memcpy_private(tmpbuff, buff, private_blocks);
}
((char*)comm->dst_buff_ >= smpi_data_exe_start) &&
((char*)comm->dst_buff_ < smpi_data_exe_start + smpi_data_exe_size)) {
XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
- smpi_switch_data_segment(comm->dst_actor_->iface());
+ smpi_switch_data_segment(comm->dst_actor_->get_iface());
}
XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff, comm->dst_buff_);
memcpy_private(comm->dst_buff_, tmpbuff, private_blocks);
#if not defined(__APPLE__) && not defined(__HAIKU__)
static int visit_libs(struct dl_phdr_info* info, size_t, void* data)
{
- auto* libname = static_cast<char*>(data);
- const char *path = info->dlpi_name;
- if(strstr(path, libname)){
- strncpy(libname, path, 512);
+ auto* libname = static_cast<std::string*>(data);
+ std::string path = info->dlpi_name;
+ if (path.find(*libname) != std::string::npos) {
+ *libname = std::move(path);
return 1;
}
-
return 0;
}
#endif
// load the library once to add it to the local libs, to get the absolute path
void* libhandle = dlopen(libname.c_str(), RTLD_LAZY);
// get library name from path
- char fullpath[512] = {'\0'};
- strncpy(fullpath, libname.c_str(), 511);
+ std::string fullpath = libname;
#if not defined(__APPLE__) && not defined(__HAIKU__)
- xbt_assert(0 != dl_iterate_phdr(visit_libs, fullpath),
- "Can't find a linked %s - check your settings in smpi/privatize-libs", fullpath);
- XBT_DEBUG("Extra lib to privatize '%s' found", fullpath);
+ xbt_assert(0 != dl_iterate_phdr(visit_libs, &fullpath),
+ "Can't find a linked %s - check your settings in smpi/privatize-libs", fullpath.c_str());
+ XBT_DEBUG("Extra lib to privatize '%s' found", fullpath.c_str());
#else
xbt_die("smpi/privatize-libs is not (yet) compatible with OSX nor with Haiku");
#endif
- privatize_libs_paths.emplace_back(fullpath);
+ privatize_libs_paths.emplace_back(std::move(fullpath));
dlclose(libhandle);
}
}
return std::function<void()>([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<std::string>("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.
unsigned int pad = 7;
if (libname.length() < pad)
pad = libname.length();
- std::string target_lib =
+ std::string target_lib = simgrid::config::get_value<std::string>("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);