bool iwannadie;
Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
+ Context(const Context&) = delete;
+ Context& operator=(const Context&) = delete;
+
void operator()() { code_(); }
bool has_code() const { return static_cast<bool>(code_); }
smx_actor_t process() { return this->process_; }
Session::Session(pid_t pid, int socket)
{
std::unique_ptr<simgrid::mc::RemoteClient> process(new simgrid::mc::RemoteClient(pid, socket));
+#if HAVE_SMPI
// TODO, automatic detection of the config from the process
process->privatized(smpi_privatize_global_variables != SmpiPrivStrategies::NONE);
+#else
+ process->privatized(false);
+#endif
modelChecker_ = std::unique_ptr<ModelChecker>(
new simgrid::mc::ModelChecker(std::move(process)));
xbt_assert(mc_model_checker == nullptr);
#include "src/mc/mc_state.hpp"
#include "src/mc/remote/Client.hpp"
+#if HAVE_SMPI
#include "smpi_request.hpp"
+#endif
#include <cstdint>
pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid_;
pattern->src_host = MC_smx_actor_get_host_name(issuer);
+#if HAVE_SMPI
simgrid::smpi::Request mpi_request = mc_model_checker->process().read<simgrid::smpi::Request>(
RemotePtr<simgrid::smpi::Request>((std::uint64_t)simcall_comm_isend__get__data(request)));
pattern->tag = mpi_request.tag();
+#endif
if (synchro->src_buff != nullptr) {
pattern->data.resize(synchro->src_buff_size);
mc_model_checker->process().read_bytes(pattern->data.data(), pattern->data.size(), remote(synchro->src_buff));
}
+#if HAVE_SMPI
if(mpi_request.detached()){
if (not this->initial_communications_pattern_done) {
/* Store comm pattern */
}
return;
}
+#endif
} else if (call_type == MC_CALL_TYPE_RECV) {
pattern->type = simgrid::mc::PatternCommunicationType::receive;
pattern->comm_addr = static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_irecv__getraw__result(request));
+#if HAVE_SMPI
simgrid::smpi::Request mpi_request;
mc_model_checker->process().read(&mpi_request,
remote((simgrid::smpi::Request*)simcall_comm_irecv__get__data(request)));
pattern->tag = mpi_request.tag();
+#endif
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm,
const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index,
ReadOptions options) const
{
+#if HAVE_SMPI
if (process_index != simgrid::mc::ProcessIndexDisabled) {
std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->find_object_info_rw(address);
-// Segment overlap is not handled.
-#if HAVE_SMPI
+ // Segment overlap is not handled.
if (info.get() && this->privatized(*info)) {
if (process_index < 0)
xbt_die("Missing process index");
size_t offset = address.address() - (std::uint64_t)info->start_rw;
address = remote((char*)privatization_region.address + offset);
}
-#endif
}
+#endif
if (pread_whole(this->memory_file, buffer, size, (size_t)address.address()) < 0)
xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
return buffer;
#include "simgrid/plugins/dvfs.h"
#include "simgrid/plugins/load.h"
#include "simgrid/s4u/Engine.hpp"
+#include "src/internal_config.h" // HAVE_SMPI
#include "src/kernel/activity/ExecImpl.hpp"
#include "src/plugins/vm/VirtualMachineImpl.hpp"
+#if HAVE_SMPI
#include "src/smpi/plugins/ampi/ampi.hpp"
+#endif
#include <xbt/config.hpp>
#include <boost/algorithm/string.hpp>
explicit Adagio(simgrid::s4u::Host* ptr)
: Governor(ptr), rates(100, std::vector<double>(ptr->get_pstate_count(), 0.0))
{
+#if HAVE_SMPI
simgrid::smpi::plugin::ampi::on_iteration_in.connect([this](simgrid::s4u::ActorPtr actor) {
// Every instance of this class subscribes to this event, so one per host
// This means that for any actor, all 'hosts' are normally notified of these
task_id = 0;
}
});
+#endif
simgrid::kernel::activity::ExecImpl::on_creation.connect([this](simgrid::kernel::activity::ExecImplPtr activity) {
if (activity->host_ == get_host())
pre_task();
for (int i = 1; i < get_host()->get_pstate_count(); i++) {
rates[task_id][i] = rates[task_id][0] * (get_host()->get_pstate_speed(i) / get_host()->get_speed());
}
- is_initialized = true;
}
for (int pstate = get_host()->get_pstate_count() - 1; pstate >= 0; pstate--) {
#include "src/smpi/include/smpi_actor.hpp"
#include "xbt/config.hpp"
+#include <algorithm>
#include <cfloat> /* DBL_MAX */
#include <dlfcn.h>
#include <fcntl.h>
static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector<std::string> args)
{
- int argc_saved = args.size();
- int argc=argc_saved;
- char** argv = new char*[argc + 1];
- for (int i = 0; i != argc; ++i)
- argv[i] = xbt_strdup(args[i].c_str());
- argv[argc] = nullptr;
- char* name = argv[0];
- char* instance = argv[1];
+ // copy C strings, we need them writable
+ std::vector<char*>* args4argv = new std::vector<char*>(args.size());
+ std::transform(begin(args), end(args), begin(*args4argv), [](const std::string& s) { return xbt_strdup(s.c_str()); });
+
+ // take a copy of args4argv to keep reference of the allocated strings
+ const std::vector<char*> args2str(*args4argv);
+ int argc = args4argv->size();
+ args4argv->push_back(nullptr);
+ char** argv = args4argv->data();
+
simgrid::smpi::ActorExt::init(&argc, &argv);
#if SMPI_IFORT
for_rtl_init_ (&argc, argv);
#if SMPI_IFORT
for_rtl_finish_ ();
#else
- for (int i = 0; i != argc; ++i)
- xbt_free(argv[i]);
- if (argc_saved > 3) {
- xbt_free(instance);
- xbt_free(name);
- }
- delete[] argv;
+ for (char* s : args2str)
+ xbt_free(s);
+ delete args4argv;
#endif
if (res != 0){
free(ptr);
}
+#include "ampi.hpp"
#include <smpi/sampi.h>
namespace simgrid {
namespace smpi {
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#ifndef AMPI_HPP
+#define AMPI_HPP
+
#include <simgrid/s4u.hpp>
namespace simgrid {
}
}
+#endif
has been received.
*/
+#define STR_SIZE 200
+
/*
Add a predefined MPI type to the tests. _count instances of the
type will be sent.
outbufs[cnt] = (void *)malloc(sizeof(_ctype) * (_count)); \
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i] = 0; \
- myname = (char *)malloc(100);\
+ myname = (char *)malloc(STR_SIZE);\
MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
- snprintf(myname, 100, "Contig type %s", _basename); \
+ snprintf(myname, STR_SIZE, "Contig type %s", _basename); \
MPI_Type_set_name(types[cnt], myname); \
free(myname); \
counts[cnt] = 1; bytesize[cnt] = sizeof(_ctype) * (_count); cnt++; }
outbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1); \
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = 0; \
- myname = (char *)malloc(100);\
+ myname = (char *)malloc(STR_SIZE);\
MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
- snprintf(myname, 100, "Vector type %s", _basename); \
+ snprintf(myname, STR_SIZE, "Vector type %s", _basename); \
MPI_Type_set_name(types[cnt], myname); \
free(myname); \
counts[cnt] = 1; bytesize[cnt] = sizeof(_ctype) * (_count) * (_stride) ;\
outbufs[cnt] = (void *)malloc(sizeof(_ctype) * (_count)); \
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i] = 0; \
- myname = (char *)malloc(100);\
+ myname = (char *)malloc(STR_SIZE);\
MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
- snprintf(myname, 100, "Index type %s", _basename); \
+ snprintf(myname, STR_SIZE, "Index type %s", _basename); \
MPI_Type_set_name(types[cnt], myname); \
free(myname); \
counts[cnt] = 1; bytesize[cnt] = sizeof(_ctype) * (_count); cnt++; }
a[i].a2 = i; } \
a = (struct name *)outbufs[cnt]; for (i=0; i<(_count); i++) { a[i].a1 = 0; \
a[i].a2 = 0; } \
- myname = (char *)malloc(100); \
- snprintf(myname, 100, "Struct type %s", _tname); \
+ myname = (char *)malloc(STR_SIZE); \
+ snprintf(myname, STR_SIZE, "Struct type %s", _tname); \
MPI_Type_set_name(types[cnt], myname); \
free(myname); \
counts[cnt] = (_count); bytesize[cnt] = sizeof(struct name) * (_count);cnt++; }
outbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1);\
a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = i; \
a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = 0; \
- myname = (char *)malloc(100); \
+ myname = (char *)malloc(STR_SIZE); \
MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
- snprintf(myname, 100, "Struct (MPI_UB) type %s", _basename); \
+ snprintf(myname, STR_SIZE, "Struct (MPI_UB) type %s", _basename); \
MPI_Type_set_name(types[cnt], myname); \
free(myname); \
counts[cnt] = (_count); \