extern std::unordered_map<std::string, double> location2speedup;
// TODO: Move this to the right location (if we keep this...)
-void smpi_add_process(int adjusted_proc_id);
+void smpi_add_process(simgrid::s4u::ActorPtr actor);
/** @brief Returns the last call location (filename, linenumber). Process-specific. */
extern "C" {
msg_bar_t finalization_barrier_;
int return_value_ = 0;
smpi_trace_call_location_t trace_call_loc_;
- smx_actor_t process_ = nullptr;
+ simgrid::s4u::ActorPtr process_ = nullptr;
smpi_privatization_region_t privatized_region_;
#if HAVE_PAPI
/** Contains hardware data as read by PAPI **/
papi_counter_t papi_counter_data_;
#endif
public:
- explicit Process(int index, msg_bar_t barrier);
+ explicit Process(simgrid::s4u::ActorPtr actor, msg_bar_t barrier);
void set_data(int index, int* argc, char*** argv);
void finalize();
int finalized();
int return_value();
void set_return_value(int val);
static void init(int *argc, char ***argv);
- smx_actor_t process();
+ simgrid::s4u::ActorPtr process();
};
void smpi_execute_flops(double flops) {
XBT_DEBUG("Handle real computation time: %f flops", flops);
- smx_activity_t action = simcall_execution_start("computation", flops, 1, 0, smpi_process()->process()->host);
+ smx_activity_t action = simcall_execution_start("computation", flops, 1, 0, smpi_process()->process()->getImpl()->host);
simcall_set_category (action, TRACE_internal_smpi_get_category());
simcall_execution_wait(action);
smpi_switch_data_segment(smpi_process()->index());
, present_processes(0)
, comm_world(comm)
, finalization_barrier(finalization_barrier)
- {
- int cur_process_count = smpi_process_count();
- for (int i = 0; i < max_no_processes; i++) {
- smpi_add_process(cur_process_count + i);
- }
- }
+ { }
const char* name;
int size;
};
#endif
+using simgrid::s4u::Actor;
+using simgrid::s4u::ActorPtr;
std::unordered_map<std::string, double> location2speedup;
static std::map</*process_id*/ int, simgrid::smpi::Process*> process_data;
void (*smpi_comm_copy_data_callback) (smx_activity_t, void*, size_t) = &smpi_comm_copy_buffer_callback;
-void smpi_add_process(int smx_process)
+void smpi_add_process(ActorPtr actor)
{
process_data.insert(
- std::pair<int, simgrid::smpi::Process*>(smx_process, new simgrid::smpi::Process(smx_process, nullptr)));
+ {actor->getPid()-1, new simgrid::smpi::Process(actor, nullptr)});
}
int smpi_process_count()
simgrid::smpi::Process* smpi_process()
{
- smx_actor_t me = SIMIX_process_self();
+ ActorPtr me = Actor::self();
if (me == nullptr) // This happens sometimes (eg, when linking against NS3 because it pulls openMPI...)
return nullptr;
- simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->userdata);
+ simgrid::msg::ActorExt* msgExt = static_cast<simgrid::msg::ActorExt*>(me->getImpl()->userdata);
return static_cast<simgrid::smpi::Process*>(msgExt->data);
}
// Called either directly from the user code, or from the code called by smpirun
void SMPI_init(){
+ simgrid::s4u::Actor::onCreation.connect([](simgrid::s4u::ActorPtr actor) {
+ smpi_add_process(actor);
+ });
smpi_init_options();
smpi_global_init();
smpi_check_options();
namespace simgrid{
namespace smpi{
-Process::Process(int index, msg_bar_t finalization_barrier)
+using simgrid::s4u::ActorPtr;
+
+Process::Process(ActorPtr actor, msg_bar_t finalization_barrier)
: finalization_barrier_(finalization_barrier)
{
char name[MAILBOX_NAME_MAXLEN];
+ process_ = actor;
+ int index = actor->getPid() - 1; // TODO cheinrich: This needs to be removed! Just a quick hack to make the following 2 lines work
mailbox_ = simgrid::s4u::Mailbox::byName(get_mailbox_name(name, index));
mailbox_small_ = simgrid::s4u::Mailbox::byName(get_mailbox_name_small(name, index));
mailboxes_mutex_ = xbt_mutex_init();
instance_id_ = instance_id;
index_ = index;
- process_ = SIMIX_process_self();
- static_cast<simgrid::msg::ActorExt*>(process_->userdata)->data = this;
+ process_ = simgrid::s4u::Actor::self();
+ static_cast<simgrid::msg::ActorExt*>(process_->getImpl()->userdata)->data = this;
if (*argc > 3) {
memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2));
return data_;
}
-smx_actor_t Process::process(){
+ActorPtr Process::process(){
return process_;
}
xbt_die("SimGrid was not initialized properly before entering MPI_Init. Aborting, please check compilation process and use smpirun\n");
}
if (argc != nullptr && argv != nullptr) {
- smx_actor_t proc = SIMIX_process_self();
- proc->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
+ simgrid::s4u::ActorPtr proc = simgrid::s4u::Actor::self();
+ proc->getImpl()->context->set_cleanup(&MSG_process_cleanup_from_SIMIX);
- int index = proc->pid - 1; // The maestro process has always ID 0 but we don't need that process here
+ int index = proc->getPid() - 1; // The maestro process has always ID 0 but we don't need that process here
char* instance_id = (*argv)[1];
try {
Process* process = smpi_process_remote(index);
if(smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP){
/* Now using the segment index of this process */
- index = proc->segment_index;
+ index = proc->getImpl()->segment_index;
process->set_privatized_region(smpi_init_global_memory_segment_process());
/* Done at the process's creation */
SMPI_switch_data_segment(index);
// we make a copy here, as the size is modified by simix, and we may reuse the request in another receive later
real_size_=size_;
action_ = simcall_comm_irecv(
- process->process(), mailbox, buf_, &real_size_, &match_recv,
+ process->process()->getImpl(), mailbox, buf_, &real_size_, &match_recv,
process->replaying() ? &smpi_comm_null_copy_buffer_callback : smpi_comm_copy_data_callback, this, -1.0);
XBT_DEBUG("recv simcall posted");
if (smpi_iprobe_sleep > 0) {
smx_activity_t iprobe_sleep = simcall_execution_start(
"iprobe", /* flops to executek*/ nsleeps * smpi_iprobe_sleep * speed * maxrate, /* priority */ 1.0,
- /* performance bound */ maxrate * speed, smpi_process()->process()->host);
+ /* performance bound */ maxrate * speed, smpi_process()->process()->getImpl()->host);
simcall_execution_wait(iprobe_sleep);
}
// behave like a receive, but don't do it