From: Martin Quinson Date: Tue, 10 May 2016 20:03:33 +0000 (+0200) Subject: Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid X-Git-Tag: v3_14~1245 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/48efae676c3604efffe21365b2d525e578fd22e5?hp=48d7293b28a54e1fb0bbeef9ed605bb8dfc4b513 Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid --- diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index ee53c52c49..d2450b4701 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -484,7 +484,7 @@ XBT_PUBLIC(void) MSG_mailbox_set_async(const char *alias); * @param mailbox The mailbox concerned by the operation. * @return The task at the head of the mailbox. */ -XBT_PUBLIC(msg_task_t) MSG_mailbox_get_head(msg_mailbox_t mailbox); +XBT_PUBLIC(msg_task_t) MSG_mailbox_front(msg_mailbox_t mailbox); XBT_PUBLIC(msg_error_t) MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task, msg_host_t host, double timeout); @@ -597,5 +597,10 @@ xbt_dynar_t MSG_vm_get_list_from_hosts(msg_dynar_t) /* Used only by the bindings -- unclean pimple, please ignore if you're not writing a binding */ XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(msg_process_t process); + +/* Functions renamed in 3.14 */ +#define MSG_mailbox_get_head(m) MSG_mailbox_front(m) + + SG_END_DECL() #endif diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index 8c6e1fc723..24790755b2 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -95,9 +95,9 @@ public: void send(Mailbox &chan, void*payload, size_t simulatedSize); protected: - smx_process_t getInferior() {return inferior_;} + smx_process_t getInferior() {return pimpl_;} private: - smx_process_t inferior_; + smx_process_t pimpl_; }; }} // namespace simgrid::s4u diff --git a/include/simgrid/s4u/async.hpp b/include/simgrid/s4u/async.hpp index 9ef1778171..2f12e795ee 100644 --- a/include/simgrid/s4u/async.hpp +++ b/include/simgrid/s4u/async.hpp @@ -34,7 +34,7 @@ protected: virtual ~Async(); private: - simgrid::simix::Synchro *inferior_ = NULL; + simgrid::simix::Synchro *pimpl_ = NULL; private: e_s4u_async_state_t state_ = inited; diff --git a/include/simgrid/s4u/file.hpp b/include/simgrid/s4u/file.hpp index 63c3563bbc..0e976337eb 100644 --- a/include/simgrid/s4u/file.hpp +++ b/include/simgrid/s4u/file.hpp @@ -29,7 +29,7 @@ public: File(const char *fullpath, void* userdata); ~File(); private: - smx_file_t inferior_; + smx_file_t pimpl_; const char *path_; public: diff --git a/include/simgrid/s4u/mailbox.hpp b/include/simgrid/s4u/mailbox.hpp index aa5f3278de..3d1b6abd2e 100644 --- a/include/simgrid/s4u/mailbox.hpp +++ b/include/simgrid/s4u/mailbox.hpp @@ -33,7 +33,7 @@ public: ~Mailbox(); protected: - smx_mailbox_t getInferior() { return inferior_; } + smx_mailbox_t getInferior() { return pimpl_; } public: /** Get the name of that mailbox */ @@ -54,7 +54,7 @@ public: private: std::string name_; - smx_mailbox_t inferior_; + smx_mailbox_t pimpl_; static boost::unordered_map *mailboxes; friend s4u::Engine; }; diff --git a/include/simgrid/s4u/storage.hpp b/include/simgrid/s4u/storage.hpp index e67a1a9093..3d9dd19da2 100644 --- a/include/simgrid/s4u/storage.hpp +++ b/include/simgrid/s4u/storage.hpp @@ -44,7 +44,7 @@ private: static boost::unordered_map *storages_; std::string name_; - smx_storage_t inferior_; + smx_storage_t pimpl_; public: diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 0cfad7fddc..59b4c3da9a 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -137,9 +137,6 @@ typedef smx_process_t (*smx_creation_func_t) ( */ typedef struct s_smx_mailbox *smx_mailbox_t; -XBT_PUBLIC(void*) SIMIX_comm_get_src_data(smx_synchro_t synchro); -XBT_PUBLIC(void*) SIMIX_comm_get_dst_data(smx_synchro_t synchro); - /* Process creation/destruction callbacks */ typedef void (*void_pfn_smxprocess_t) (smx_process_t); /* for auto-restart function */ @@ -281,10 +278,7 @@ XBT_PUBLIC(smx_synchro_t) simcall_execution_parallel_start(const char *name, double *bytes_amount, double amount, double rate); -XBT_PUBLIC(void) simcall_execution_destroy(smx_synchro_t execution); XBT_PUBLIC(void) simcall_execution_cancel(smx_synchro_t execution); -XBT_PUBLIC(double) simcall_execution_get_remains(smx_synchro_t execution); -XBT_PUBLIC(e_smx_state_t) simcall_execution_get_state(smx_synchro_t execution); XBT_PUBLIC(void) simcall_execution_set_priority(smx_synchro_t execution, double priority); XBT_PUBLIC(void) simcall_execution_set_bound(smx_synchro_t execution, double bound); XBT_PUBLIC(void) simcall_execution_set_affinity(smx_synchro_t execution, sg_host_t host, unsigned long mask); @@ -353,8 +347,7 @@ XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration); XBT_PUBLIC(smx_mailbox_t) simcall_mbox_create(const char *name); XBT_PUBLIC(smx_mailbox_t) simcall_mbox_get_by_name(const char *name); -XBT_PUBLIC(smx_synchro_t) simcall_mbox_get_head(smx_mailbox_t mbox); -XBT_PUBLIC(smx_process_t) simcall_mbox_get_receiver(smx_mailbox_t mbox); +XBT_PUBLIC(smx_synchro_t) simcall_mbox_front(smx_mailbox_t mbox); XBT_PUBLIC(void) simcall_mbox_set_receiver(smx_mailbox_t mbox , smx_process_t process); /***** Communication simcalls *****/ @@ -397,12 +390,6 @@ XBT_PUBLIC(void) simcall_comm_wait(smx_synchro_t comm, double timeout); XBT_PUBLIC(int) simcall_comm_test(smx_synchro_t comm); XBT_PUBLIC(int) simcall_comm_testany(xbt_dynar_t comms); -/* Getters and setters */ -XBT_PUBLIC(void *) simcall_comm_get_src_data(smx_synchro_t comm); -XBT_PUBLIC(void *) simcall_comm_get_dst_data(smx_synchro_t comm); -XBT_PUBLIC(smx_process_t) simcall_comm_get_src_proc(smx_synchro_t comm); -XBT_PUBLIC(smx_process_t) simcall_comm_get_dst_proc(smx_synchro_t comm); - /************************** Tracing handling **********************************/ XBT_PUBLIC(void) simcall_set_category(smx_synchro_t synchro, const char *category); diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index ec226a7b94..1867677b68 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -733,14 +733,16 @@ msg_task_t MSG_comm_get_task(msg_comm_t comm) * \param buff the data copied * \param buff_size size of the buffer */ -void MSG_comm_copy_data_from_SIMIX(smx_synchro_t comm, void* buff, size_t buff_size) { - // copy the task +void MSG_comm_copy_data_from_SIMIX(smx_synchro_t synchro, void* buff, size_t buff_size) +{ + simgrid::simix::Comm *comm = static_cast(synchro); + SIMIX_comm_copy_pointer_callback(comm, buff, buff_size); // notify the user callback if any if (msg_global->task_copy_callback) { msg_task_t task = (msg_task_t) buff; - msg_global->task_copy_callback(task, simcall_comm_get_src_proc(comm), simcall_comm_get_dst_proc(comm)); + msg_global->task_copy_callback(task, comm->src_proc, comm->dst_proc); } } @@ -915,7 +917,7 @@ int MSG_task_listen_from(const char *alias) { msg_task_t task; - if (NULL == (task = MSG_mailbox_get_head(MSG_mailbox_get_by_alias(alias)))) + if (NULL == (task = MSG_mailbox_front(MSG_mailbox_get_by_alias(alias)))) return -1; return MSG_process_get_PID(task->simdata->sender); diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp index 11ce7d86fc..1594821770 100644 --- a/src/msg/msg_mailbox.cpp +++ b/src/msg/msg_mailbox.cpp @@ -18,17 +18,17 @@ msg_mailbox_t MSG_mailbox_new(const char *alias) int MSG_mailbox_is_empty(msg_mailbox_t mailbox) { - return (NULL == simcall_mbox_get_head(mailbox)); + return (NULL == simcall_mbox_front(mailbox)); } -msg_task_t MSG_mailbox_get_head(msg_mailbox_t mailbox) +msg_task_t MSG_mailbox_front(msg_mailbox_t mailbox) { - smx_synchro_t comm = simcall_mbox_get_head(mailbox); + simgrid::simix::Comm* comm = static_cast(simcall_mbox_front(mailbox)); if (!comm) return NULL; - return (msg_task_t) simcall_comm_get_src_data(comm); + return (msg_task_t) comm->src_data; } msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias) diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 33a386ed0e..a3b6d203ee 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -196,7 +196,6 @@ void MSG_task_set_name(msg_task_t task, const char *name) */ msg_error_t MSG_task_destroy(msg_task_t task) { - smx_synchro_t action = NULL; xbt_assert((task != NULL), "Invalid parameter"); if (task->simdata->isused) { @@ -207,9 +206,8 @@ msg_error_t MSG_task_destroy(msg_task_t task) xbt_free(task->name); - action = task->simdata->compute; - if (action) - simcall_execution_destroy(action); + if (task->simdata->compute) + task->simdata->compute->unref(); /* parallel tasks only */ xbt_free(task->simdata->host_list); @@ -252,7 +250,7 @@ msg_error_t MSG_task_cancel(msg_task_t task) */ double MSG_task_get_flops_amount(msg_task_t task) { if (task->simdata->compute) { - return simcall_execution_get_remains(task->simdata->compute); + return task->simdata->compute->remains(); } else { return task->simdata->flops_amount; } diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index b29b9ee30b..04962097b5 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -27,15 +27,15 @@ static int s4u_actor_runner(int argc, char **argv) using namespace simgrid; s4u::Actor::Actor(smx_process_t smx_proc) { - inferior_ = smx_proc; + pimpl_ = smx_proc; } s4u::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv) : s4u::Actor::Actor(name,host, argc,argv, -1) { } s4u::Actor::Actor(const char *name, s4u::Host *host, int argc, char **argv, double killTime) { - inferior_ = simcall_process_create(name, s4u_actor_runner, this, host->name().c_str(), killTime, argc, argv, NULL/*properties*/,0); + pimpl_ = simcall_process_create(name, s4u_actor_runner, this, host->name().c_str(), killTime, argc, argv, NULL/*properties*/,0); - xbt_assert(inferior_,"Cannot create the actor"); + xbt_assert(pimpl_,"Cannot create the actor"); // TRACE_msg_process_create(procname, simcall_process_get_PID(p_smx_process), host->getInferior()); // simcall_process_on_exit(p_smx_process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,p_smx_process); } @@ -54,30 +54,30 @@ s4u::Actor &s4u::Actor::self() } void s4u::Actor::setAutoRestart(bool autorestart) { - simcall_process_auto_restart_set(inferior_,autorestart); + simcall_process_auto_restart_set(pimpl_,autorestart); } s4u::Host *s4u::Actor::getHost() { - return s4u::Host::by_name(sg_host_get_name(simcall_process_get_host(inferior_))); + return s4u::Host::by_name(sg_host_get_name(simcall_process_get_host(pimpl_))); } const char* s4u::Actor::getName() { - return simcall_process_get_name(inferior_); + return simcall_process_get_name(pimpl_); } int s4u::Actor::getPid(){ - return simcall_process_get_PID(inferior_); + return simcall_process_get_PID(pimpl_); } void s4u::Actor::setKillTime(double time) { - simcall_process_set_kill_time(inferior_,time); + simcall_process_set_kill_time(pimpl_,time); } double s4u::Actor::getKillTime() { - return simcall_process_get_kill_time(inferior_); + return simcall_process_get_kill_time(pimpl_); } void s4u::Actor::killAll() { simcall_process_killall(1); } void s4u::Actor::kill() { - simcall_process_kill(inferior_); + simcall_process_kill(pimpl_); } void s4u::Actor::sleep(double duration) { diff --git a/src/s4u/s4u_comm.cpp b/src/s4u/s4u_comm.cpp index e19a0529fb..1415742844 100644 --- a/src/s4u/s4u_comm.cpp +++ b/src/s4u/s4u_comm.cpp @@ -73,12 +73,12 @@ void s4u::Comm::start() { xbt_assert(state_ == inited); if (srcBuff_ != NULL) { // Sender side - inferior_ = simcall_comm_isend(sender_->getInferior(), mailbox_->getInferior(), remains_, rate_, + pimpl_ = simcall_comm_isend(sender_->getInferior(), mailbox_->getInferior(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_, cleanFunction_, copyDataFunction_, userData_, detached_); } else if (dstBuff_ != NULL) { // Receiver side - inferior_ = simcall_comm_irecv(receiver_->getInferior(), mailbox_->getInferior(), dstBuff_, &dstBuffSize_, + pimpl_ = simcall_comm_irecv(receiver_->getInferior(), mailbox_->getInferior(), dstBuff_, &dstBuffSize_, matchFunction_, copyDataFunction_, userData_, rate_); @@ -91,7 +91,7 @@ void s4u::Comm::wait() { xbt_assert(state_ == started || state_ == inited); if (state_ == started) - simcall_comm_wait(inferior_, -1/*timeout*/); + simcall_comm_wait(pimpl_, -1/*timeout*/); else {// p_state == inited. Save a simcall and do directly a blocking send/recv if (srcBuff_ != NULL) { simcall_comm_send(sender_->getInferior(), mailbox_->getInferior(), remains_, rate_, @@ -110,7 +110,7 @@ void s4u::Comm::wait(double timeout) { xbt_assert(state_ == started || state_ == inited); if (state_ == started) { - simcall_comm_wait(inferior_, timeout); + simcall_comm_wait(pimpl_, timeout); state_ = finished; return; } diff --git a/src/s4u/s4u_file.cpp b/src/s4u/s4u_file.cpp index 65c4557019..2f61275aa3 100644 --- a/src/s4u/s4u_file.cpp +++ b/src/s4u/s4u_file.cpp @@ -22,36 +22,36 @@ namespace s4u { File::File(const char*fullpath, void *userdata) { // this cannot fail because we get a xbt_die if the mountpoint does not exist - inferior_ = simcall_file_open(fullpath, Host::current()); + pimpl_ = simcall_file_open(fullpath, Host::current()); path_ = fullpath; } File::~File() { - simcall_file_close(inferior_, Host::current()); + simcall_file_close(pimpl_, Host::current()); } sg_size_t File::read(sg_size_t size) { - return simcall_file_read(inferior_, size, Host::current()); + return simcall_file_read(pimpl_, size, Host::current()); } sg_size_t File::write(sg_size_t size) { - return simcall_file_write(inferior_,size, Host::current()); + return simcall_file_write(pimpl_,size, Host::current()); } sg_size_t File::size() { - return simcall_file_get_size(inferior_); + return simcall_file_get_size(pimpl_); } void File::seek(sg_size_t pos) { - simcall_file_seek(inferior_,pos,SEEK_SET); + simcall_file_seek(pimpl_,pos,SEEK_SET); } sg_size_t File::tell() { - return simcall_file_tell(inferior_); + return simcall_file_tell(pimpl_); } void File::move(const char*fullpath) { - simcall_file_move(inferior_,fullpath); + simcall_file_move(pimpl_,fullpath); } void File::unlink() { sg_host_t attached = Host::current(); // FIXME: we should check where this file is attached - simcall_file_unlink(inferior_,attached); + simcall_file_unlink(pimpl_,attached); } }} // namespace simgrid::s4u diff --git a/src/s4u/s4u_mailbox.cpp b/src/s4u/s4u_mailbox.cpp index ace9d8cf2c..f2661289e1 100644 --- a/src/s4u/s4u_mailbox.cpp +++ b/src/s4u/s4u_mailbox.cpp @@ -6,6 +6,7 @@ #include "xbt/log.h" #include "src/msg/msg_private.h" +#include "src/simix/smx_network_private.h" #include "simgrid/s4u/mailbox.hpp" @@ -19,7 +20,7 @@ boost::unordered_map *s4u::Mailbox::mailboxes = ne s4u::Mailbox::Mailbox(const char*name, smx_mailbox_t inferior) { - inferior_ = inferior; + pimpl_ = inferior; name_ = name; mailboxes->insert({name, this}); } @@ -42,14 +43,15 @@ s4u::Mailbox *s4u::Mailbox::byName(const char*name) { } bool s4u::Mailbox::empty() { - return nullptr == simcall_mbox_get_head(inferior_); + return nullptr == simcall_mbox_front(pimpl_); } void s4u::Mailbox::setReceiver(smx_process_t process) { - simcall_mbox_set_receiver(inferior_, process); + simcall_mbox_set_receiver(pimpl_, process); } +/** @brief get the receiver (process associated to the mailbox) */ smx_process_t s4u::Mailbox::receiver() { - return simcall_mbox_get_receiver(inferior_); + return pimpl_->permanent_receiver; } /*------- C functions -------*/ diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index 6b99ef8bde..afc3401bcc 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -15,7 +15,7 @@ namespace s4u { boost::unordered_map *Storage::storages_ = new boost::unordered_map (); Storage::Storage(std::string name, smx_storage_t inferior) { name_ = name; - inferior_ = inferior; + pimpl_ = inferior; storages_->insert({name, this}); } @@ -25,7 +25,7 @@ Storage::~Storage() { } smx_storage_t Storage::inferior() { - return inferior_; + return pimpl_; } Storage &Storage::byName(const char*name) { s4u::Storage *res = NULL; @@ -46,13 +46,13 @@ const char*Storage::name() { } sg_size_t Storage::sizeFree() { - return simcall_storage_get_free_size(inferior_); + return simcall_storage_get_free_size(pimpl_); } sg_size_t Storage::sizeUsed() { - return simcall_storage_get_used_size(inferior_); + return simcall_storage_get_used_size(pimpl_); } sg_size_t Storage::size() { - return SIMIX_storage_get_size(inferior_); + return SIMIX_storage_get_size(pimpl_); } } /* namespace s4u */ diff --git a/src/simix/Synchro.cpp b/src/simix/Synchro.cpp index c10c46c616..9d94aba497 100644 --- a/src/simix/Synchro.cpp +++ b/src/simix/Synchro.cpp @@ -13,3 +13,18 @@ simgrid::simix::Synchro::~Synchro() { xbt_fifo_free(simcalls); xbt_free(name); } + +void simgrid::simix::Synchro::ref() +{ + refcount++; +} +void simgrid::simix::Synchro::unref() +{ + xbt_assert(refcount > 0, + "This synchro has a negative refcount! You can only call test() or wait() once per synchronization."); + + refcount--; + if (refcount>0) + return; + delete this; +} diff --git a/src/simix/Synchro.h b/src/simix/Synchro.h index d119a8d251..05b28a1009 100644 --- a/src/simix/Synchro.h +++ b/src/simix/Synchro.h @@ -25,6 +25,12 @@ namespace simix { virtual void suspend()=0; virtual void resume()=0; + virtual void post() =0; // What to do when a simcall terminates + + void ref(); + void unref(); + private: + int refcount=1; }; }} // namespace simgrid::simix #else /* not C++ */ diff --git a/src/simix/SynchroComm.cpp b/src/simix/SynchroComm.cpp index 74f8492059..4342cb107e 100644 --- a/src/simix/SynchroComm.cpp +++ b/src/simix/SynchroComm.cpp @@ -14,13 +14,32 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_network); simgrid::simix::Comm::Comm(e_smx_comm_type_t _type) { state = SIMIX_WAITING; this->type = _type; - refcount = 1; src_data=NULL; dst_data=NULL; XBT_DEBUG("Create communicate synchro %p", this); } -void simgrid::simix::Comm::suspend() { + +simgrid::simix::Comm::~Comm() +{ + XBT_DEBUG("Really free communication %p", this); + + cleanupSurf(); + + if (detached && state != SIMIX_DONE) { + /* the communication has failed and was detached: + * we have to free the buffer */ + if (clean_fun) + clean_fun(src_buff); + src_buff = NULL; + } + + if(mbox) + SIMIX_mbox_remove(mbox, this); + +} +void simgrid::simix::Comm::suspend() +{ /* FIXME: shall we suspend also the timeout synchro? */ if (surf_comm) surf_comm->suspend(); @@ -28,14 +47,16 @@ void simgrid::simix::Comm::suspend() { } -void simgrid::simix::Comm::resume() { +void simgrid::simix::Comm::resume() +{ /*FIXME: check what happen with the timeouts */ if (surf_comm) surf_comm->resume(); /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */ } -void simgrid::simix::Comm::cancel() { +void simgrid::simix::Comm::cancel() +{ /* if the synchro is a waiting state means that it is still in a mbox */ /* so remove from it and delete it */ if (state == SIMIX_WAITING) { @@ -51,7 +72,8 @@ void simgrid::simix::Comm::cancel() { } /** @brief get the amount remaining from the communication */ -double simgrid::simix::Comm::remains() { +double simgrid::simix::Comm::remains() +{ switch (state) { case SIMIX_RUNNING: @@ -68,3 +90,49 @@ double simgrid::simix::Comm::remains() { break; } } + +/** @brief This is part of the cleanup process, probably an internal command */ +void simgrid::simix::Comm::cleanupSurf() +{ + if (surf_comm){ + surf_comm->unref(); + surf_comm = NULL; + } + + if (src_timeout){ + src_timeout->unref(); + src_timeout = NULL; + } + + if (dst_timeout){ + dst_timeout->unref(); + dst_timeout = NULL; + } +} + +void simgrid::simix::Comm::post() +{ + /* Update synchro state */ + if (src_timeout && src_timeout->getState() == simgrid::surf::Action::State::done) + state = SIMIX_SRC_TIMEOUT; + else if (dst_timeout && dst_timeout->getState() == simgrid::surf::Action::State::done) + state = SIMIX_DST_TIMEOUT; + else if (src_timeout && src_timeout->getState() == simgrid::surf::Action::State::failed) + state = SIMIX_SRC_HOST_FAILURE; + else if (dst_timeout && dst_timeout->getState() == simgrid::surf::Action::State::failed) + state = SIMIX_DST_HOST_FAILURE; + else if (surf_comm && surf_comm->getState() == simgrid::surf::Action::State::failed) { + state = SIMIX_LINK_FAILURE; + } else + state = SIMIX_DONE; + + XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", + this, (int)state, src_proc, dst_proc, detached); + + /* destroy the surf actions associated with the Simix communication */ + cleanupSurf(); + + /* if there are simcalls associated with the synchro, then answer them */ + if (xbt_fifo_size(simcalls)) + SIMIX_comm_finish(this); +} diff --git a/src/simix/SynchroComm.hpp b/src/simix/SynchroComm.hpp index bdcc41e6a2..b58c83cf22 100644 --- a/src/simix/SynchroComm.hpp +++ b/src/simix/SynchroComm.hpp @@ -20,12 +20,15 @@ namespace simgrid { namespace simix { XBT_PUBLIC_CLASS Comm : public Synchro { + ~Comm(); public: Comm(e_smx_comm_type_t type); void suspend(); void resume(); + void post() override; void cancel(); double remains(); + void cleanupSurf(); // FIXME: make me protected e_smx_comm_type_t type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */ smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */ @@ -35,8 +38,7 @@ namespace simix { (comm.mbox set to NULL when the communication is removed from the mailbox (used as garbage collector)) */ #endif - int refcount = 1; /* Number of processes involved in the cond */ - int detached = 0; /* If detached or not */ + bool detached = false; /* If detached or not */ void (*clean_fun)(void*); /* Function to clean the detached src_buf if something goes wrong */ int (*match_fun)(void*,void*,smx_synchro_t); /* Filter function used by the other side. It is used when @@ -58,7 +60,7 @@ namespace simix { void *dst_buff = nullptr; size_t src_buff_size; size_t *dst_buff_size; - unsigned copied = 0; /* whether the data were already copied */ + bool copied = false; /* whether the data were already copied */ void* src_data; /* User data associated to communication */ void* dst_data; diff --git a/src/simix/SynchroExec.cpp b/src/simix/SynchroExec.cpp index db79ea0cad..3b0f2c84b2 100644 --- a/src/simix/SynchroExec.cpp +++ b/src/simix/SynchroExec.cpp @@ -5,7 +5,13 @@ #include "src/simix/SynchroExec.hpp" #include "src/surf/surf_interface.hpp" +#include "src/simix/smx_host_private.h" +simgrid::simix::Exec::~Exec() +{ + if (surf_exec) + surf_exec->unref(); +} void simgrid::simix::Exec::suspend() { if (surf_exec) @@ -17,3 +23,34 @@ void simgrid::simix::Exec::resume() if (surf_exec) surf_exec->resume(); } + +double simgrid::simix::Exec::remains() +{ + if (state == SIMIX_RUNNING) + return surf_exec->getRemains(); + + return 0; +} + +void simgrid::simix::Exec::post() +{ + if (host && host->isOff()) {/* FIMXE: handle resource failure for parallel tasks too */ + /* If the host running the synchro failed, notice it. This way, the asking + * process can be killed if it runs on that host itself */ + state = SIMIX_FAILED; + } else if (surf_exec->getState() == simgrid::surf::Action::State::failed) { + /* If the host running the synchro didn't fail, then the synchro was canceled */ + state = SIMIX_CANCELED; + } else { + state = SIMIX_DONE; + } + + if (surf_exec) { + surf_exec->unref(); + surf_exec = NULL; + } + + /* If there are simcalls associated with the synchro, then answer them */ + if (xbt_fifo_size(simcalls)) + SIMIX_execution_finish(this); +} diff --git a/src/simix/SynchroExec.hpp b/src/simix/SynchroExec.hpp index c81b6b7b0f..d0abb299c2 100644 --- a/src/simix/SynchroExec.hpp +++ b/src/simix/SynchroExec.hpp @@ -13,9 +13,12 @@ namespace simgrid { namespace simix { XBT_PUBLIC_CLASS Exec : public Synchro { + ~Exec(); public: void suspend(); void resume(); + void post() override; + double remains(); sg_host_t host; /* The host where the execution takes place */ surf_action_t surf_exec; /* The Surf execution action encapsulated */ diff --git a/src/simix/SynchroIo.cpp b/src/simix/SynchroIo.cpp index e27e5f573b..dd2f2e240c 100644 --- a/src/simix/SynchroIo.cpp +++ b/src/simix/SynchroIo.cpp @@ -5,6 +5,8 @@ #include "src/simix/SynchroIo.hpp" #include "src/surf/surf_interface.hpp" +#include "src/simix/popping_private.h" +#include "src/simix/smx_private.h" void simgrid::simix::Io::suspend() { @@ -17,3 +19,51 @@ void simgrid::simix::Io::resume() if (surf_io) surf_io->resume(); } + +void simgrid::simix::Io::post() +{ + xbt_fifo_item_t i; + smx_simcall_t simcall; + + xbt_fifo_foreach(simcalls,i,simcall,smx_simcall_t) { + switch (simcall->call) { + case SIMCALL_FILE_OPEN: { + smx_file_t tmp = xbt_new(s_smx_file_t,1); + tmp->surf_file = surf_storage_action_get_file(surf_io); + simcall_file_open__set__result(simcall, tmp); + break; + } + case SIMCALL_FILE_CLOSE: + xbt_free(simcall_file_close__get__fd(simcall)); + simcall_file_close__set__result(simcall, 0); + break; + case SIMCALL_FILE_WRITE: + simcall_file_write__set__result(simcall, surf_io->getCost()); + break; + + case SIMCALL_FILE_READ: + simcall_file_read__set__result(simcall, surf_io->getCost()); + break; + + default: + break; + } + } + + switch (surf_io->getState()) { + + case simgrid::surf::Action::State::failed: + state = SIMIX_FAILED; + break; + + case simgrid::surf::Action::State::done: + state = SIMIX_DONE; + break; + + default: + THROW_IMPOSSIBLE; + break; + } + + SIMIX_io_finish(this); +} diff --git a/src/simix/SynchroIo.hpp b/src/simix/SynchroIo.hpp index 3d0aa2b2d3..afe6041cd9 100644 --- a/src/simix/SynchroIo.hpp +++ b/src/simix/SynchroIo.hpp @@ -16,6 +16,7 @@ namespace simix { public: void suspend(); void resume(); + void post() override; sg_host_t host; surf_action_t surf_io; diff --git a/src/simix/SynchroRaw.cpp b/src/simix/SynchroRaw.cpp index e73fe3d27c..872cf47b52 100644 --- a/src/simix/SynchroRaw.cpp +++ b/src/simix/SynchroRaw.cpp @@ -5,12 +5,28 @@ #include "src/simix/SynchroRaw.hpp" #include "src/surf/surf_interface.hpp" +#include "src/simix/smx_synchro_private.h" -void simgrid::simix::Raw::suspend() { +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_synchro); + +void simgrid::simix::Raw::suspend() +{ /* The suspension of raw synchros is delayed to when the process is rescheduled. */ } -void simgrid::simix::Raw::resume() { +void simgrid::simix::Raw::resume() +{ /* I cannot resume raw synchros directly. This is delayed to when the process is rescheduled at * the end of the synchro. */ } +void simgrid::simix::Raw::post() +{ + XBT_IN("(%p)",this); + if (sleep->getState() == simgrid::surf::Action::State::failed) + state = SIMIX_FAILED; + else if(sleep->getState() == simgrid::surf::Action::State::done) + state = SIMIX_SRC_TIMEOUT; + + SIMIX_synchro_finish(this); + XBT_OUT(); +} diff --git a/src/simix/SynchroRaw.hpp b/src/simix/SynchroRaw.hpp index c0a34442a7..25d4c2de32 100644 --- a/src/simix/SynchroRaw.hpp +++ b/src/simix/SynchroRaw.hpp @@ -17,6 +17,7 @@ namespace simix { public: void suspend(); void resume(); + void post() override; surf_action_t sleep; }; diff --git a/src/simix/SynchroSleep.cpp b/src/simix/SynchroSleep.cpp index 23959509e3..853dd316da 100644 --- a/src/simix/SynchroSleep.cpp +++ b/src/simix/SynchroSleep.cpp @@ -5,11 +5,56 @@ #include "src/simix/SynchroSleep.hpp" #include "src/surf/surf_interface.hpp" +#include "src/simix/popping_private.h" +#include "src/simix/smx_process_private.h" -void simgrid::simix::Sleep::suspend() { +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process); + +void simgrid::simix::Sleep::suspend() +{ surf_sleep->suspend(); } -void simgrid::simix::Sleep::resume() { +void simgrid::simix::Sleep::resume() +{ surf_sleep->resume(); } + +void simgrid::simix::Sleep::post() +{ + smx_simcall_t simcall; + e_smx_state_t state; + + while ((simcall = (smx_simcall_t) xbt_fifo_shift(simcalls))) { + + switch (surf_sleep->getState()){ + case simgrid::surf::Action::State::failed: + simcall->issuer->context->iwannadie = 1; + //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed"); + state = SIMIX_SRC_HOST_FAILURE; + break; + + case simgrid::surf::Action::State::done: + state = SIMIX_DONE; + break; + + default: + THROW_IMPOSSIBLE; + break; + } + if (simcall->issuer->host->isOff()) { + simcall->issuer->context->iwannadie = 1; + } + simcall_process_sleep__set__result(simcall, state); + simcall->issuer->waiting_synchro = NULL; + if (simcall->issuer->suspended) { + XBT_DEBUG("Wait! This process is suspended and can't wake up now."); + simcall->issuer->suspended = 0; + simcall_HANDLER_process_suspend(simcall, simcall->issuer); + } else { + SIMIX_simcall_answer(simcall); + } + } + + SIMIX_process_sleep_destroy(this); +} diff --git a/src/simix/SynchroSleep.hpp b/src/simix/SynchroSleep.hpp index 5a87136e40..b999526d17 100644 --- a/src/simix/SynchroSleep.hpp +++ b/src/simix/SynchroSleep.hpp @@ -16,6 +16,7 @@ namespace simix { public: void suspend(); void resume(); + void post() override; sg_host_t host; /* The host that is sleeping */ surf_action_t surf_sleep; /* The Surf sleeping action encapsulated */ diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index f15f002165..bbea457dd7 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -125,18 +125,6 @@ smx_synchro_t simcall_execution_parallel_start(const char *name, } -/** - * \ingroup simix_process_management - * \brief Destroys an execution synchro. - * - * Destroys a synchro, freeing its memory. This function cannot be called if there are a conditional waiting for it. - * \param execution The execution synchro to destroy - */ -void simcall_execution_destroy(smx_synchro_t execution) -{ - simcall_BODY_execution_destroy(execution); -} - /** * \ingroup simix_process_management * \brief Cancels an execution synchro. @@ -149,30 +137,6 @@ void simcall_execution_cancel(smx_synchro_t execution) simcall_BODY_execution_cancel(execution); } -/** - * \ingroup simix_process_management - * \brief Returns how much of an execution synchro remains to be done. - * - * \param execution The execution synchro - * \return The remaining amount - */ -double simcall_execution_get_remains(smx_synchro_t execution) -{ - return simcall_BODY_execution_get_remains(execution); -} - -/** - * \ingroup simix_process_management - * \brief Returns the state of an execution synchro. - * - * \param execution The execution synchro - * \return The state - */ -e_smx_state_t simcall_execution_get_state(smx_synchro_t execution) -{ - return simcall_BODY_execution_get_state(execution); -} - /** * \ingroup simix_process_management * \brief Changes the priority of an execution synchro. @@ -710,9 +674,10 @@ smx_mailbox_t simcall_mbox_get_by_name(const char *name) * \param mbox The rendez-vous point * \return The communication or NULL if empty */ -smx_synchro_t simcall_mbox_get_head(smx_mailbox_t mbox) +smx_synchro_t simcall_mbox_front(smx_mailbox_t mbox) { - return simcall_BODY_mbox_get_head(mbox); + + return mbox->comm_queue->empty()? nullptr:mbox->comm_queue->front(); } void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process) @@ -720,11 +685,6 @@ void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process) simcall_BODY_mbox_set_receiver(mbox, process); } -smx_process_t simcall_mbox_get_receiver(smx_mailbox_t mbox) -{ - return simcall_BODY_mbox_get_receiver(mbox); -} - /** * \ingroup simix_comm_management */ @@ -888,42 +848,6 @@ int simcall_comm_test(smx_synchro_t comm) return simcall_BODY_comm_test(comm); } -/** - * \ingroup simix_comm_management - * - */ -void *simcall_comm_get_src_data(smx_synchro_t comm) -{ - return simcall_BODY_comm_get_src_data(comm); -} - -/** - * \ingroup simix_comm_management - * - */ -void *simcall_comm_get_dst_data(smx_synchro_t comm) -{ - return simcall_BODY_comm_get_dst_data(comm); -} - -/** - * \ingroup simix_comm_management - * - */ -smx_process_t simcall_comm_get_src_proc(smx_synchro_t comm) -{ - return simcall_BODY_comm_get_src_proc(comm); -} - -/** - * \ingroup simix_comm_management - * - */ -smx_process_t simcall_comm_get_dst_proc(smx_synchro_t comm) -{ - return simcall_BODY_comm_get_dst_proc(comm); -} - /** * \ingroup simix_synchro_management * diff --git a/src/simix/popping.cpp b/src/simix/popping.cpp index e4a621b274..631bc80f22 100644 --- a/src/simix/popping.cpp +++ b/src/simix/popping.cpp @@ -37,35 +37,7 @@ void SIMIX_simcall_answer(smx_simcall_t simcall) void SIMIX_simcall_exit(smx_synchro_t synchro) { - simgrid::simix::Exec *exec = dynamic_cast(synchro); - if (exec != nullptr) { - SIMIX_post_host_execute(synchro); - return; - } - - simgrid::simix::Comm *comm = dynamic_cast(synchro); - if (comm != nullptr) { - SIMIX_post_comm(synchro); - return; - } - - simgrid::simix::Sleep *sleep = dynamic_cast(synchro); - if (sleep != nullptr) { - SIMIX_post_process_sleep(synchro); - return; - } - - simgrid::simix::Raw *raw = dynamic_cast(synchro); - if (raw != nullptr) { - SIMIX_post_synchro(synchro); - return; - } - - simgrid::simix::Io *io = dynamic_cast(synchro); - if (io != nullptr) { - SIMIX_post_io(synchro); - return; - } + synchro->post(); } void SIMIX_run_kernel(void* code) diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index c694b14a63..f5f1a3fdca 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -289,13 +289,6 @@ static inline void simcall_execution_parallel_start__set__result(smx_simcall_t s simcall->result.dp = result; } -static inline smx_synchro_t simcall_execution_destroy__get__execution(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_execution_destroy__set__execution(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} - static inline smx_synchro_t simcall_execution_cancel__get__execution(smx_simcall_t simcall) { return (smx_synchro_t) simcall->args[0].dp; } @@ -303,32 +296,6 @@ static inline void simcall_execution_cancel__set__execution(smx_simcall_t simcal simcall->args[0].dp = arg; } -static inline smx_synchro_t simcall_execution_get_remains__get__execution(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_execution_get_remains__set__execution(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline double simcall_execution_get_remains__get__result(smx_simcall_t simcall){ - return simcall->result.d; -} -static inline void simcall_execution_get_remains__set__result(smx_simcall_t simcall, double result){ - simcall->result.d = result; -} - -static inline smx_synchro_t simcall_execution_get_state__get__execution(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_execution_get_state__set__execution(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline e_smx_state_t simcall_execution_get_state__get__result(smx_simcall_t simcall){ - return (e_smx_state_t) simcall->result.i; -} -static inline void simcall_execution_get_state__set__result(smx_simcall_t simcall, int result){ - simcall->result.i = result; -} - static inline smx_synchro_t simcall_execution_set_priority__get__execution(smx_simcall_t simcall) { return (smx_synchro_t) simcall->args[0].dp; } @@ -445,19 +412,6 @@ static inline void simcall_mbox_create__set__result(smx_simcall_t simcall, void* simcall->result.dp = result; } -static inline smx_mailbox_t simcall_mbox_get_head__get__mbox(smx_simcall_t simcall) { - return (smx_mailbox_t) simcall->args[0].dp; -} -static inline void simcall_mbox_get_head__set__mbox(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline smx_synchro_t simcall_mbox_get_head__get__result(smx_simcall_t simcall){ - return (smx_synchro_t) simcall->result.dp; -} -static inline void simcall_mbox_get_head__set__result(smx_simcall_t simcall, void* result){ - simcall->result.dp = result; -} - static inline smx_mailbox_t simcall_mbox_set_receiver__get__mbox(smx_simcall_t simcall) { return (smx_mailbox_t) simcall->args[0].dp; } @@ -471,19 +425,6 @@ static inline void simcall_mbox_set_receiver__set__receiver(smx_simcall_t simcal simcall->args[1].dp = arg; } -static inline smx_mailbox_t simcall_mbox_get_receiver__get__mbox(smx_simcall_t simcall) { - return (smx_mailbox_t) simcall->args[0].dp; -} -static inline void simcall_mbox_get_receiver__set__mbox(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline smx_process_t simcall_mbox_get_receiver__get__result(smx_simcall_t simcall){ - return (smx_process_t) simcall->result.dp; -} -static inline void simcall_mbox_get_receiver__set__result(smx_simcall_t simcall, void* result){ - simcall->result.dp = result; -} - static inline smx_mailbox_t simcall_comm_iprobe__get__mbox(smx_simcall_t simcall) { return (smx_mailbox_t) simcall->args[0].dp; } @@ -823,58 +764,6 @@ static inline void simcall_comm_testany__set__result(smx_simcall_t simcall, int simcall->result.i = result; } -static inline smx_synchro_t simcall_comm_get_src_data__get__comm(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_comm_get_src_data__set__comm(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline void* simcall_comm_get_src_data__get__result(smx_simcall_t simcall){ - return simcall->result.dp; -} -static inline void simcall_comm_get_src_data__set__result(smx_simcall_t simcall, void* result){ - simcall->result.dp = result; -} - -static inline smx_synchro_t simcall_comm_get_dst_data__get__comm(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_comm_get_dst_data__set__comm(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline void* simcall_comm_get_dst_data__get__result(smx_simcall_t simcall){ - return simcall->result.dp; -} -static inline void simcall_comm_get_dst_data__set__result(smx_simcall_t simcall, void* result){ - simcall->result.dp = result; -} - -static inline smx_synchro_t simcall_comm_get_src_proc__get__comm(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_comm_get_src_proc__set__comm(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline smx_process_t simcall_comm_get_src_proc__get__result(smx_simcall_t simcall){ - return (smx_process_t) simcall->result.dp; -} -static inline void simcall_comm_get_src_proc__set__result(smx_simcall_t simcall, void* result){ - simcall->result.dp = result; -} - -static inline smx_synchro_t simcall_comm_get_dst_proc__get__comm(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_comm_get_dst_proc__set__comm(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline smx_process_t simcall_comm_get_dst_proc__get__result(smx_simcall_t simcall){ - return (smx_process_t) simcall->result.dp; -} -static inline void simcall_comm_get_dst_proc__set__result(smx_simcall_t simcall, void* result){ - simcall->result.dp = result; -} - static inline smx_mutex_t simcall_mutex_init__get__result(smx_simcall_t simcall){ return (smx_mutex_t) simcall->result.dp; } diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 4c1e438c3e..b872bbbf8c 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -395,27 +395,6 @@ inline static smx_synchro_t simcall_BODY_execution_parallel_start(const char* na return (smx_synchro_t) self->simcall.result.dp; } -inline static void simcall_BODY_execution_destroy(smx_synchro_t execution) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_execution_destroy(execution); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_EXECUTION_DESTROY; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) execution; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - - } - inline static void simcall_BODY_execution_cancel(smx_synchro_t execution) { smx_process_t self = SIMIX_process_self(); @@ -437,48 +416,6 @@ inline static void simcall_BODY_execution_cancel(smx_synchro_t execution) { } -inline static double simcall_BODY_execution_get_remains(smx_synchro_t execution) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_execution_get_remains(execution); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_EXECUTION_GET_REMAINS; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) execution; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (double) self->simcall.result.d; - } - -inline static e_smx_state_t simcall_BODY_execution_get_state(smx_synchro_t execution) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_execution_get_state(execution); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_EXECUTION_GET_STATE; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) execution; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (e_smx_state_t) self->simcall.result.i; - } - inline static void simcall_BODY_execution_set_priority(smx_synchro_t execution, double priority) { smx_process_t self = SIMIX_process_self(); @@ -654,27 +591,6 @@ inline static smx_mailbox_t simcall_BODY_mbox_create(const char* name) { return (smx_mailbox_t) self->simcall.result.dp; } -inline static smx_synchro_t simcall_BODY_mbox_get_head(smx_mailbox_t mbox) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_mbox_get_head(mbox); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_MBOX_GET_HEAD; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) mbox; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (smx_synchro_t) self->simcall.result.dp; - } - inline static void simcall_BODY_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t receiver) { smx_process_t self = SIMIX_process_self(); @@ -697,27 +613,6 @@ inline static void simcall_BODY_mbox_set_receiver(smx_mailbox_t mbox, smx_proces } -inline static smx_process_t simcall_BODY_mbox_get_receiver(smx_mailbox_t mbox) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_mbox_get_receiver(mbox); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_MBOX_GET_RECEIVER; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) mbox; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (smx_process_t) self->simcall.result.dp; - } - inline static smx_synchro_t simcall_BODY_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, simix_match_func_t match_fun, void* data) { smx_process_t self = SIMIX_process_self(); @@ -947,90 +842,6 @@ inline static int simcall_BODY_comm_testany(xbt_dynar_t comms) { return (int) self->simcall.result.i; } -inline static void* simcall_BODY_comm_get_src_data(smx_synchro_t comm) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_comm_get_src_data(comm); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_COMM_GET_SRC_DATA; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) comm; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (void*) self->simcall.result.dp; - } - -inline static void* simcall_BODY_comm_get_dst_data(smx_synchro_t comm) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_comm_get_dst_data(comm); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_COMM_GET_DST_DATA; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) comm; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (void*) self->simcall.result.dp; - } - -inline static smx_process_t simcall_BODY_comm_get_src_proc(smx_synchro_t comm) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_comm_get_src_proc(comm); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_COMM_GET_SRC_PROC; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) comm; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (smx_process_t) self->simcall.result.dp; - } - -inline static smx_process_t simcall_BODY_comm_get_dst_proc(smx_synchro_t comm) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_comm_get_dst_proc(comm); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_COMM_GET_DST_PROC; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) comm; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (smx_process_t) self->simcall.result.dp; - } - inline static smx_mutex_t simcall_BODY_mutex_init() { smx_process_t self = SIMIX_process_self(); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index fca277b8a1..5185e8e705 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -35,10 +35,7 @@ typedef enum { SIMCALL_PROCESS_SLEEP, SIMCALL_EXECUTION_START, SIMCALL_EXECUTION_PARALLEL_START, - SIMCALL_EXECUTION_DESTROY, SIMCALL_EXECUTION_CANCEL, - SIMCALL_EXECUTION_GET_REMAINS, - SIMCALL_EXECUTION_GET_STATE, SIMCALL_EXECUTION_SET_PRIORITY, SIMCALL_EXECUTION_SET_BOUND, SIMCALL_EXECUTION_SET_AFFINITY, @@ -47,9 +44,7 @@ typedef enum { SIMCALL_PROCESS_AUTO_RESTART_SET, SIMCALL_PROCESS_RESTART, SIMCALL_MBOX_CREATE, - SIMCALL_MBOX_GET_HEAD, SIMCALL_MBOX_SET_RECEIVER, - SIMCALL_MBOX_GET_RECEIVER, SIMCALL_COMM_IPROBE, SIMCALL_COMM_SEND, SIMCALL_COMM_ISEND, @@ -59,10 +54,6 @@ typedef enum { SIMCALL_COMM_WAIT, SIMCALL_COMM_TEST, SIMCALL_COMM_TESTANY, - SIMCALL_COMM_GET_SRC_DATA, - SIMCALL_COMM_GET_DST_DATA, - SIMCALL_COMM_GET_SRC_PROC, - SIMCALL_COMM_GET_DST_PROC, SIMCALL_MUTEX_INIT, SIMCALL_MUTEX_LOCK, SIMCALL_MUTEX_TRYLOCK, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 5e9e1e09c5..c572811aad 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -40,10 +40,7 @@ const char* simcall_names[] = { "SIMCALL_PROCESS_SLEEP", "SIMCALL_EXECUTION_START", "SIMCALL_EXECUTION_PARALLEL_START", - "SIMCALL_EXECUTION_DESTROY", "SIMCALL_EXECUTION_CANCEL", - "SIMCALL_EXECUTION_GET_REMAINS", - "SIMCALL_EXECUTION_GET_STATE", "SIMCALL_EXECUTION_SET_PRIORITY", "SIMCALL_EXECUTION_SET_BOUND", "SIMCALL_EXECUTION_SET_AFFINITY", @@ -52,9 +49,7 @@ const char* simcall_names[] = { "SIMCALL_PROCESS_AUTO_RESTART_SET", "SIMCALL_PROCESS_RESTART", "SIMCALL_MBOX_CREATE", - "SIMCALL_MBOX_GET_HEAD", "SIMCALL_MBOX_SET_RECEIVER", - "SIMCALL_MBOX_GET_RECEIVER", "SIMCALL_COMM_IPROBE", "SIMCALL_COMM_SEND", "SIMCALL_COMM_ISEND", @@ -64,10 +59,6 @@ const char* simcall_names[] = { "SIMCALL_COMM_WAIT", "SIMCALL_COMM_TEST", "SIMCALL_COMM_TESTANY", - "SIMCALL_COMM_GET_SRC_DATA", - "SIMCALL_COMM_GET_DST_DATA", - "SIMCALL_COMM_GET_SRC_PROC", - "SIMCALL_COMM_GET_DST_PROC", "SIMCALL_MUTEX_INIT", "SIMCALL_MUTEX_LOCK", "SIMCALL_MUTEX_TRYLOCK", @@ -195,26 +186,11 @@ case SIMCALL_EXECUTION_PARALLEL_START: SIMIX_simcall_answer(simcall); break; -case SIMCALL_EXECUTION_DESTROY: - SIMIX_execution_destroy((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_EXECUTION_CANCEL: SIMIX_execution_cancel((smx_synchro_t) simcall->args[0].dp); SIMIX_simcall_answer(simcall); break; -case SIMCALL_EXECUTION_GET_REMAINS: - simcall->result.d = SIMIX_execution_get_remains((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_EXECUTION_GET_STATE: - simcall->result.i = SIMIX_execution_get_state((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_EXECUTION_SET_PRIORITY: SIMIX_execution_set_priority((smx_synchro_t) simcall->args[0].dp, simcall->args[1].d); SIMIX_simcall_answer(simcall); @@ -254,21 +230,11 @@ case SIMCALL_MBOX_CREATE: SIMIX_simcall_answer(simcall); break; -case SIMCALL_MBOX_GET_HEAD: - simcall->result.dp = SIMIX_mbox_get_head((smx_mailbox_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_MBOX_SET_RECEIVER: SIMIX_mbox_set_receiver((smx_mailbox_t) simcall->args[0].dp,(smx_process_t) simcall->args[1].dp); SIMIX_simcall_answer(simcall); break; -case SIMCALL_MBOX_GET_RECEIVER: - simcall->result.dp = SIMIX_mbox_get_receiver((smx_mailbox_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_COMM_IPROBE: simcall->result.dp = simcall_HANDLER_comm_iprobe(simcall , (smx_mailbox_t) simcall->args[0].dp, simcall->args[1].i, simcall->args[2].i, simcall->args[3].i, (simix_match_func_t) simcall->args[4].fp, simcall->args[5].dp); SIMIX_simcall_answer(simcall); @@ -308,26 +274,6 @@ case SIMCALL_COMM_TESTANY: simcall_HANDLER_comm_testany(simcall , (xbt_dynar_t) simcall->args[0].dp); break; -case SIMCALL_COMM_GET_SRC_DATA: - simcall->result.dp = SIMIX_comm_get_src_data((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_COMM_GET_DST_DATA: - simcall->result.dp = SIMIX_comm_get_dst_data((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_COMM_GET_SRC_PROC: - simcall->result.dp = SIMIX_comm_get_src_proc((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - -case SIMCALL_COMM_GET_DST_PROC: - simcall->result.dp = SIMIX_comm_get_dst_proc((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_MUTEX_INIT: simcall->result.dp = simcall_HANDLER_mutex_init(simcall ); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 8e2315cbf7..e867deba46 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -65,10 +65,7 @@ Blck H process_sleep (int) (duration, double) Func H execution_start (void*, smx_synchro_t) (name, const char*) (flops_amount, double) (priority, double) (bound, double) (affinity_mask, unsigned long) Func - execution_parallel_start (void*, smx_synchro_t) (name, const char*) (host_nb, int) (host_list, void*, sg_host_t*) (flops_amount, void*, double*) (bytes_amount, void*, double*) (amount, double) (rate, double) -Proc - execution_destroy (void) (execution, void*, smx_synchro_t) Proc - execution_cancel (void) (execution, void*, smx_synchro_t) -Func - execution_get_remains (double) (execution, void*, smx_synchro_t) -Func - execution_get_state (int, e_smx_state_t) (execution, void*, smx_synchro_t) Proc - execution_set_priority (void) (execution, void*, smx_synchro_t) (priority, double) Proc - execution_set_bound (void) (execution, void*, smx_synchro_t) (bound, double) Proc - execution_set_affinity (void) (execution, void*, smx_synchro_t) (ws, void*, sg_host_t) (mask, unsigned long) @@ -79,9 +76,7 @@ Proc - process_auto_restart_set (void) (process, void*, smx_process_t) (auto_res Func H process_restart (void*, smx_process_t) (process, void*, smx_process_t) Func - mbox_create (void*, smx_mailbox_t) (name, const char*) -Func - mbox_get_head (void*, smx_synchro_t) (mbox, void*, smx_mailbox_t) Proc - mbox_set_receiver (void) (mbox, void*, smx_mailbox_t) (receiver, void*, smx_process_t) -Func - mbox_get_receiver (void*, smx_process_t) (mbox, void*, smx_mailbox_t) Func H comm_iprobe (void*, smx_synchro_t) (mbox, void*, smx_mailbox_t) (type, int) (src, int) (tag, int) (match_fun, FPtr, simix_match_func_t) (data, void*) Blck H comm_send (void) (sender, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (timeout, double) @@ -92,10 +87,6 @@ Blck H comm_waitany (int) (comms, void*, xbt_dynar_t) Blck H comm_wait (void) (comm, void*, smx_synchro_t) (timeout, double) Blck H comm_test (int) (comm, void*, smx_synchro_t) Blck H comm_testany (int) (comms, void*, xbt_dynar_t) -Func - comm_get_src_data (void*) (comm, void*, smx_synchro_t) -Func - comm_get_dst_data (void*) (comm, void*, smx_synchro_t) -Func - comm_get_src_proc (void*, smx_process_t) (comm, void*, smx_synchro_t) -Func - comm_get_dst_proc (void*, smx_process_t) (comm, void*, smx_synchro_t) Func H mutex_init (void*, smx_mutex_t) Blck H mutex_lock (void) (mutex, void*, smx_mutex_t) diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 2115a8090d..2fc7eb416c 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -16,8 +16,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix, "SIMIX hosts"); -static void SIMIX_execution_finish(smx_synchro_t synchro); - /** * \brief Internal function to create a SIMIX host. * \param name name of the host to create @@ -332,18 +330,6 @@ smx_synchro_t SIMIX_execution_parallel_start(const char *name, return exec; } -void SIMIX_execution_destroy(smx_synchro_t synchro) -{ - XBT_DEBUG("Destroy synchro %p", synchro); - simgrid::simix::Exec *exec = static_cast(synchro); - - if (exec->surf_exec) { - exec->surf_exec->unref(); - exec->surf_exec = NULL; - } - delete exec; -} - void SIMIX_execution_cancel(smx_synchro_t synchro) { XBT_DEBUG("Cancel synchro %p", synchro); @@ -353,22 +339,6 @@ void SIMIX_execution_cancel(smx_synchro_t synchro) exec->surf_exec->cancel(); } -double SIMIX_execution_get_remains(smx_synchro_t synchro) -{ - double result = 0.0; - simgrid::simix::Exec *exec = static_cast(synchro); - - if (synchro->state == SIMIX_RUNNING) - result = exec->surf_exec->getRemains(); - - return result; -} - -e_smx_state_t SIMIX_execution_get_state(smx_synchro_t synchro) -{ - return synchro->state; -} - void SIMIX_execution_set_priority(smx_synchro_t synchro, double priority) { simgrid::simix::Exec *exec = static_cast(synchro); @@ -395,7 +365,7 @@ void SIMIX_execution_set_affinity(smx_synchro_t synchro, sg_host_t host, unsigne void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_synchro_t synchro) { - + simgrid::simix::Exec *exec = static_cast(synchro); XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state); /* Associate this simcall to the synchro */ @@ -405,13 +375,13 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_synchro_t synchro /* set surf's synchro */ if (MC_is_active() || MC_record_replay_is_active()) { synchro->state = SIMIX_DONE; - SIMIX_execution_finish(synchro); + SIMIX_execution_finish(exec); return; } /* If the synchro is already finished then perform the error handling */ if (synchro->state != SIMIX_RUNNING) - SIMIX_execution_finish(synchro); + SIMIX_execution_finish(exec); } void SIMIX_execution_suspend(smx_synchro_t synchro) @@ -424,14 +394,14 @@ void SIMIX_execution_resume(smx_synchro_t synchro) synchro->resume(); // FIXME: USELESS } -void SIMIX_execution_finish(smx_synchro_t synchro) +void SIMIX_execution_finish(simgrid::simix::Exec *exec) { xbt_fifo_item_t item; smx_simcall_t simcall; - xbt_fifo_foreach(synchro->simcalls, item, simcall, smx_simcall_t) { + xbt_fifo_foreach(exec->simcalls, item, simcall, smx_simcall_t) { - switch (synchro->state) { + switch (exec->state) { case SIMIX_DONE: /* do nothing, synchro done */ @@ -451,51 +421,21 @@ void SIMIX_execution_finish(smx_synchro_t synchro) default: xbt_die("Internal error in SIMIX_execution_finish: unexpected synchro state %d", - (int)synchro->state); + (int)exec->state); } - /* check if the host is down */ - if (simcall->issuer->host->isOff()) { + /* Fail the process if the host is down */ + if (simcall->issuer->host->isOff()) simcall->issuer->context->iwannadie = 1; - } - simcall->issuer->waiting_synchro = NULL; - simcall_execution_wait__set__result(simcall, synchro->state); + simcall->issuer->waiting_synchro = NULL; + simcall_execution_wait__set__result(simcall, exec->state); SIMIX_simcall_answer(simcall); } /* We no longer need it */ - SIMIX_execution_destroy(synchro); -} - - -void SIMIX_post_host_execute(smx_synchro_t synchro) -{ - simgrid::simix::Exec *exec = dynamic_cast(synchro); - - if (exec != nullptr && exec->host && /* FIMXE: handle resource failure for parallel tasks too */ - exec->host->isOff()) { - /* If the host running the synchro failed, notice it. This way, the asking - * process can be killed if it runs on that host itself */ - synchro->state = SIMIX_FAILED; - } else if (exec->surf_exec->getState() == simgrid::surf::Action::State::failed) { - /* If the host running the synchro didn't fail, then the synchro was canceled */ - synchro->state = SIMIX_CANCELED; - } else { - synchro->state = SIMIX_DONE; - } - - if (exec != nullptr && exec->surf_exec) { - exec->surf_exec->unref(); - exec->surf_exec = NULL; - } - - /* If there are simcalls associated with the synchro, then answer them */ - if (xbt_fifo_size(synchro->simcalls)) { - SIMIX_execution_finish(synchro); - } + exec->unref(); } - void SIMIX_set_category(smx_synchro_t synchro, const char *category) { if (synchro->state != SIMIX_RUNNING) return; diff --git a/src/simix/smx_host_private.h b/src/simix/smx_host_private.h index 8393d9a886..a96e5de954 100644 --- a/src/simix/smx_host_private.h +++ b/src/simix/smx_host_private.h @@ -12,6 +12,8 @@ #include "simgrid/simix.h" #include "popping_private.h" +#include "src/simix/SynchroExec.hpp" + SG_BEGIN_DECL() /** @brief Host datatype from SIMIX POV */ @@ -43,18 +45,15 @@ XBT_PRIVATE smx_synchro_t SIMIX_execution_parallel_start(const char *name, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double amount, double rate); -XBT_PRIVATE void SIMIX_execution_destroy(smx_synchro_t synchro); XBT_PRIVATE void SIMIX_execution_cancel(smx_synchro_t synchro); -XBT_PRIVATE double SIMIX_execution_get_remains(smx_synchro_t synchro); -XBT_PRIVATE e_smx_state_t SIMIX_execution_get_state(smx_synchro_t synchro); XBT_PRIVATE void SIMIX_execution_set_priority(smx_synchro_t synchro, double priority); XBT_PRIVATE void SIMIX_execution_set_bound(smx_synchro_t synchro, double bound); XBT_PRIVATE void SIMIX_execution_set_affinity(smx_synchro_t synchro, sg_host_t host, unsigned long mask); XBT_PRIVATE void SIMIX_execution_suspend(smx_synchro_t synchro); XBT_PRIVATE void SIMIX_execution_resume(smx_synchro_t synchro); +XBT_PRIVATE void SIMIX_execution_finish(simgrid::simix::Exec *exec); -XBT_PRIVATE void SIMIX_post_host_execute(smx_synchro_t synchro); XBT_PRIVATE void SIMIX_set_category(smx_synchro_t synchro, const char *category); /* vm related stuff */ diff --git a/src/simix/smx_io.cpp b/src/simix/smx_io.cpp index 755f531da5..0834120291 100644 --- a/src/simix/smx_io.cpp +++ b/src/simix/smx_io.cpp @@ -255,52 +255,6 @@ const char* SIMIX_storage_get_host(smx_storage_t storage){ void SIMIX_post_io(smx_synchro_t synchro) { - xbt_fifo_item_t i; - smx_simcall_t simcall; - - simgrid::simix::Io *io = static_cast(synchro); - - xbt_fifo_foreach(synchro->simcalls,i,simcall,smx_simcall_t) { - switch (simcall->call) { - case SIMCALL_FILE_OPEN: { - smx_file_t tmp = xbt_new(s_smx_file_t,1); - tmp->surf_file = surf_storage_action_get_file(io->surf_io); - simcall_file_open__set__result(simcall, tmp); - break; - } - case SIMCALL_FILE_CLOSE: - xbt_free(simcall_file_close__get__fd(simcall)); - simcall_file_close__set__result(simcall, 0); - break; - case SIMCALL_FILE_WRITE: - simcall_file_write__set__result(simcall, io->surf_io->getCost()); - break; - - case SIMCALL_FILE_READ: - simcall_file_read__set__result(simcall, io->surf_io->getCost()); - break; - - default: - break; - } - } - - switch (io->surf_io->getState()) { - - case simgrid::surf::Action::State::failed: - synchro->state = SIMIX_FAILED; - break; - - case simgrid::surf::Action::State::done: - synchro->state = SIMIX_DONE; - break; - - default: - THROW_IMPOSSIBLE; - break; - } - - SIMIX_io_finish(synchro); } void SIMIX_io_destroy(smx_synchro_t synchro) diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 9272704bb6..51a5ab74aa 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -69,21 +69,6 @@ smx_mailbox_t SIMIX_mbox_get_by_name(const char *name) return (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name); } -smx_synchro_t SIMIX_mbox_get_head(smx_mailbox_t mbox) -{ - return mbox->comm_queue->empty()? nullptr:mbox->comm_queue->front(); -} - -/** - * \brief get the receiver (process associated to the mailbox) - * \param mbox The rendez-vous point - * \return process The receiving process (NULL if not set) - */ -smx_process_t SIMIX_mbox_get_receiver(smx_mailbox_t mbox) -{ - return mbox->permanent_receiver; -} - /** * \brief set the receiver of the rendez vous point to allow eager sends * \param mbox The rendez-vous point @@ -152,7 +137,7 @@ static smx_synchro_t _find_matching_comm(std::deque *deque, e_smx XBT_DEBUG("Found a matching communication synchro %p", comm); if (remove_matching) deque->erase(it); - comm->refcount++; + comm->ref(); #if HAVE_MC comm->mbox_cpy = comm->mbox; #endif @@ -170,62 +155,6 @@ static smx_synchro_t _find_matching_comm(std::deque *deque, e_smx /******************************************************************************/ /* Communication synchros */ /******************************************************************************/ - -/** - * \brief Destroy a communicate synchro - * \param synchro The communicate synchro to be destroyed - */ -void SIMIX_comm_destroy(smx_synchro_t synchro) -{ - simgrid::simix::Comm *comm = static_cast(synchro); - - XBT_DEBUG("Destroy synchro %p (refcount: %d), state: %d", comm, comm->refcount, (int)comm->state); - - if (comm->refcount <= 0) { - xbt_backtrace_display_current(); - xbt_die("This comm has a negative refcount! You must not call test() or wait() more than once on a given communication."); - } - comm->refcount--; - if (comm->refcount > 0) - return; - XBT_DEBUG("Really free communication %p; refcount is now %d", comm, comm->refcount); - - SIMIX_comm_destroy_internal_actions(synchro); - - if (comm->detached && comm->state != SIMIX_DONE) { - /* the communication has failed and was detached: - * we have to free the buffer */ - if (comm->clean_fun) { - comm->clean_fun(comm->src_buff); - } - comm->src_buff = NULL; - } - - if(comm->mbox) - SIMIX_mbox_remove(comm->mbox, comm); - - delete comm; -} - -void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro) -{ - simgrid::simix::Comm *comm = static_cast(synchro); - if (comm->surf_comm){ - comm->surf_comm->unref(); - comm->surf_comm = NULL; - } - - if (comm->src_timeout){ - comm->src_timeout->unref(); - comm->src_timeout = NULL; - } - - if (comm->dst_timeout){ - comm->dst_timeout->unref(); - comm->dst_timeout = NULL; - } -} - void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t src, smx_mailbox_t mbox, double task_size, double rate, void *src_buff, size_t src_buff_size, @@ -249,7 +178,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr XBT_DEBUG("send from %p", mbox); /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */ - smx_synchro_t this_synchro = new simgrid::simix::Comm(SIMIX_COMM_SEND); + simgrid::simix::Comm* this_synchro = new simgrid::simix::Comm(SIMIX_COMM_SEND); /* Look for communication synchro matching our needs. We also provide a description of * ourself so that the other side also gets a chance of choosing if it wants to match with us. @@ -268,7 +197,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr //this mailbox is for small messages, which have to be sent right now other_synchro->state = SIMIX_READY; other_comm->dst_proc=mbox->permanent_receiver; - other_comm->refcount++; + other_comm->ref(); mbox->done_comm_queue->push_back(other_synchro); other_comm->mbox=mbox; XBT_DEBUG("pushing a message into the permanent receive fifo %p, comm %p", mbox, &(other_comm)); @@ -278,8 +207,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr } } else { XBT_DEBUG("Receive already pushed"); - - SIMIX_comm_destroy(this_synchro); + this_synchro->unref(); other_comm->state = SIMIX_READY; other_comm->type = SIMIX_COMM_READY; @@ -290,8 +218,8 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr /* if the communication synchro is detached then decrease the refcount * by one, so it will be eliminated by the receiver's destroy call */ if (detached) { - other_comm->detached = 1; - other_comm->refcount--; + other_comm->detached = true; + other_comm->ref(); other_comm->clean_fun = clean_fun; } else { other_comm->clean_fun = NULL; @@ -344,7 +272,7 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void void *data, double rate) { XBT_DEBUG("recv from %p %p", mbox, mbox->comm_queue); - smx_synchro_t this_synchro = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE); + simgrid::simix::Comm* this_synchro = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE); smx_synchro_t other_synchro; //communication already done, get it inside the fifo of completed comms @@ -367,8 +295,8 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void other_comm->type = SIMIX_COMM_DONE; other_comm->mbox = NULL; } - other_comm->refcount--; - SIMIX_comm_destroy(this_synchro); + other_comm->unref(); + static_cast(this_synchro)->unref(); } } else { /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */ @@ -384,7 +312,7 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void other_synchro = this_synchro; SIMIX_mbox_push(mbox, this_synchro); } else { - SIMIX_comm_destroy(this_synchro); + this_synchro->unref(); simgrid::simix::Comm *other_comm = static_cast(other_synchro); other_comm->state = SIMIX_READY; @@ -426,40 +354,35 @@ smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data) { XBT_DEBUG("iprobe from %p %p", mbox, mbox->comm_queue); - smx_synchro_t this_synchro; + simgrid::simix::Comm* this_comm; int smx_type; if(type == 1){ - this_synchro = new simgrid::simix::Comm(SIMIX_COMM_SEND); + this_comm = new simgrid::simix::Comm(SIMIX_COMM_SEND); smx_type = SIMIX_COMM_RECEIVE; } else{ - this_synchro = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE); + this_comm = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE); smx_type = SIMIX_COMM_SEND; } smx_synchro_t other_synchro=NULL; if(mbox->permanent_receiver && ! mbox->done_comm_queue->empty()){ XBT_DEBUG("first check in the permanent recv mailbox, to see if we already got something"); other_synchro = - _find_matching_comm(mbox->done_comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro,/*remove_matching*/false); + _find_matching_comm(mbox->done_comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_comm,/*remove_matching*/false); } if (!other_synchro){ XBT_DEBUG("check if we have more luck in the normal mailbox"); - other_synchro = _find_matching_comm(mbox->comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_synchro,/*remove_matching*/false); + other_synchro = _find_matching_comm(mbox->comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_comm,/*remove_matching*/false); } - if(other_synchro) { - simgrid::simix::Comm *other_comm = static_cast(other_synchro); - other_comm->refcount--; - } + if(other_synchro) + other_synchro->unref(); - SIMIX_comm_destroy(this_synchro); + this_comm->unref(); return other_synchro; } void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, double timeout) { - /* the simcall may be a wait, a send or a recv */ - surf_action_t sleep; - /* Associate this simcall to the wait synchro */ XBT_DEBUG("simcall_HANDLER_comm_wait, %p", synchro); @@ -492,7 +415,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, dou if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING) { SIMIX_comm_finish(synchro); } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */ - sleep = surf_host_sleep(simcall->issuer->host, timeout); + surf_action_t sleep = surf_host_sleep(simcall->issuer->host, timeout); sleep->setData(synchro); simgrid::simix::Comm *comm = static_cast(synchro); @@ -621,21 +544,18 @@ static inline void SIMIX_comm_start(smx_synchro_t synchro) XBT_DEBUG("Communication from '%s' to '%s' failed to start because of a link failure", sg_host_get_name(sender), sg_host_get_name(receiver)); comm->state = SIMIX_LINK_FAILURE; - SIMIX_comm_destroy_internal_actions(synchro); + comm->cleanupSurf(); } /* If any of the process is suspend, create the synchro but stop its execution, it will be restarted when the sender process resume */ - if (SIMIX_process_is_suspended(comm->src_proc) || - SIMIX_process_is_suspended(comm->dst_proc)) { - /* FIXME: check what should happen with the synchro state */ - + if (SIMIX_process_is_suspended(comm->src_proc) || SIMIX_process_is_suspended(comm->dst_proc)) { if (SIMIX_process_is_suspended(comm->src_proc)) - XBT_DEBUG("The communication is suspended on startup because src (%s:%s) were suspended since it initiated the communication", - sg_host_get_name(comm->src_proc->host), comm->src_proc->name); + XBT_DEBUG("The communication is suspended on startup because src (%s@%s) was suspended since it initiated the communication", + comm->src_proc->name, sg_host_get_name(comm->src_proc->host)); else - XBT_DEBUG("The communication is suspended on startup because dst (%s:%s) were suspended since it initiated the communication", - sg_host_get_name(comm->dst_proc->host), comm->dst_proc->name); + XBT_DEBUG("The communication is suspended on startup because dst (%s@%s) was suspended since it initiated the communication", + comm->dst_proc->name, sg_host_get_name(comm->dst_proc->host)); comm->surf_comm->suspend(); } @@ -770,86 +690,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro) } while (destroy_count-- > 0) - SIMIX_comm_destroy(synchro); -} - -/** - * \brief This function is called when a Surf communication synchro is finished. - * \param synchro the corresponding Simix communication - */ -void SIMIX_post_comm(smx_synchro_t synchro) -{ - simgrid::simix::Comm *comm = static_cast(synchro); - - /* Update synchro state */ - if (comm->src_timeout && - comm->src_timeout->getState() == simgrid::surf::Action::State::done) - synchro->state = SIMIX_SRC_TIMEOUT; - else if (comm->dst_timeout && - comm->dst_timeout->getState() == simgrid::surf::Action::State::done) - synchro->state = SIMIX_DST_TIMEOUT; - else if (comm->src_timeout && - comm->src_timeout->getState() == simgrid::surf::Action::State::failed) - synchro->state = SIMIX_SRC_HOST_FAILURE; - else if (comm->dst_timeout && - comm->dst_timeout->getState() == simgrid::surf::Action::State::failed) - synchro->state = SIMIX_DST_HOST_FAILURE; - else if (comm->surf_comm && - comm->surf_comm->getState() == simgrid::surf::Action::State::failed) { - synchro->state = SIMIX_LINK_FAILURE; - } else - synchro->state = SIMIX_DONE; - - XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", - comm, (int)comm->state, comm->src_proc, comm->dst_proc, comm->detached); - - /* destroy the surf actions associated with the Simix communication */ - SIMIX_comm_destroy_internal_actions(comm); - - /* if there are simcalls associated with the synchro, then answer them */ - if (xbt_fifo_size(synchro->simcalls)) { - SIMIX_comm_finish(comm); - } -} - -/************* synchro Getters **************/ - -/** - * \brief Return the user data associated to the sender of the communication - * \param synchro The communication - * \return the user data - */ -void* SIMIX_comm_get_src_data(smx_synchro_t synchro) -{ - simgrid::simix::Comm *comm = static_cast(synchro); - - return comm->src_data; -} - -/** - * \brief Return the user data associated to the receiver of the communication - * \param synchro The communication - * \return the user data - */ -void* SIMIX_comm_get_dst_data(smx_synchro_t synchro) -{ - simgrid::simix::Comm *comm = static_cast(synchro); - - return comm->dst_data; -} - -smx_process_t SIMIX_comm_get_src_proc(smx_synchro_t synchro) -{ - simgrid::simix::Comm *comm = static_cast(synchro); - - return comm->src_proc; -} - -smx_process_t SIMIX_comm_get_dst_proc(smx_synchro_t synchro) -{ - simgrid::simix::Comm *comm = static_cast(synchro); - - return comm->dst_proc; + static_cast(synchro)->unref(); } /******************************************************************************/ diff --git a/src/simix/smx_network_private.h b/src/simix/smx_network_private.h index 8e54a8a725..55fc6990fa 100644 --- a/src/simix/smx_network_private.h +++ b/src/simix/smx_network_private.h @@ -26,21 +26,15 @@ XBT_PRIVATE void SIMIX_mailbox_exit(void); XBT_PRIVATE smx_mailbox_t SIMIX_mbox_create(const char *name); XBT_PRIVATE smx_mailbox_t SIMIX_mbox_get_by_name(const char *name); XBT_PRIVATE void SIMIX_mbox_remove(smx_mailbox_t mbox, smx_synchro_t comm); -XBT_PRIVATE smx_synchro_t SIMIX_mbox_get_head(smx_mailbox_t mbox); + XBT_PRIVATE void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t proc); -XBT_PRIVATE smx_process_t SIMIX_mbox_get_receiver(smx_mailbox_t mbox); XBT_PRIVATE smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, int (*)(void *, void *, smx_synchro_t), void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data, double rate); -XBT_PRIVATE void SIMIX_comm_destroy(smx_synchro_t synchro); -XBT_PRIVATE void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro); XBT_PRIVATE smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src, int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data); -XBT_PRIVATE void SIMIX_post_comm(smx_synchro_t synchro); -XBT_PRIVATE smx_process_t SIMIX_comm_get_src_proc(smx_synchro_t synchro); -XBT_PRIVATE smx_process_t SIMIX_comm_get_dst_proc(smx_synchro_t synchro); #endif diff --git a/src/simix/smx_process.cpp b/src/simix/smx_process.cpp index 1bd0a3b6a1..ef55883fa2 100644 --- a/src/simix/smx_process.cpp +++ b/src/simix/smx_process.cpp @@ -83,7 +83,7 @@ void SIMIX_process_cleanup(smx_process_t process) if (comm->detached) XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender"); else - SIMIX_comm_destroy(comm); + comm->unref(); } else if (comm->dst_proc == process){ @@ -91,11 +91,11 @@ void SIMIX_process_cleanup(smx_process_t process) comm, (int)comm->state, comm->src_proc, comm->dst_proc); comm->dst_proc = NULL; - if (comm->detached && comm->refcount == 1 && comm->src_proc != NULL) { + if (comm->detached && /* FIXME: This code should be moved within comm->unref() anyway. comm->refcount == 1 &&*/ comm->src_proc != NULL) { /* the comm will be freed right now, remove it from the sender */ xbt_fifo_remove(comm->src_proc->comms, comm); } - SIMIX_comm_destroy(comm); + comm->unref(); } else { xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro); } @@ -502,13 +502,13 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { simgrid::simix::Io *io = dynamic_cast(process->waiting_synchro); if (exec != nullptr) { - SIMIX_execution_destroy(process->waiting_synchro); + exec->unref(); } else if (comm != nullptr) { xbt_fifo_remove(process->comms, process->waiting_synchro); comm->cancel(); xbt_fifo_remove(process->waiting_synchro->simcalls, &process->simcall); - SIMIX_comm_destroy(process->waiting_synchro); + comm->unref(); } else if (sleep != nullptr) { SIMIX_process_sleep_destroy(process->waiting_synchro); @@ -859,46 +859,6 @@ smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration) return synchro; } -void SIMIX_post_process_sleep(smx_synchro_t synchro) -{ - smx_simcall_t simcall; - e_smx_state_t state; - simgrid::simix::Sleep *sleep = static_cast(synchro); - - while ((simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls))) { - - switch (sleep->surf_sleep->getState()){ - case simgrid::surf::Action::State::failed: - simcall->issuer->context->iwannadie = 1; - //SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed"); - state = SIMIX_SRC_HOST_FAILURE; - break; - - case simgrid::surf::Action::State::done: - state = SIMIX_DONE; - break; - - default: - THROW_IMPOSSIBLE; - break; - } - if (simcall->issuer->host->isOff()) { - simcall->issuer->context->iwannadie = 1; - } - simcall_process_sleep__set__result(simcall, state); - simcall->issuer->waiting_synchro = NULL; - if (simcall->issuer->suspended) { - XBT_DEBUG("Wait! This process is suspended and can't wake up now."); - simcall->issuer->suspended = 0; - simcall_HANDLER_process_suspend(simcall, simcall->issuer); - } else { - SIMIX_simcall_answer(simcall); - } - } - - SIMIX_process_sleep_destroy(synchro); -} - void SIMIX_process_sleep_destroy(smx_synchro_t synchro) { XBT_DEBUG("Destroy synchro %p", synchro); diff --git a/src/simix/smx_process_private.h b/src/simix/smx_process_private.h index c721913b38..89a28c3dc0 100644 --- a/src/simix/smx_process_private.h +++ b/src/simix/smx_process_private.h @@ -101,7 +101,6 @@ XBT_PRIVATE int SIMIX_process_is_suspended(smx_process_t process); XBT_PRIVATE xbt_dict_t SIMIX_process_get_properties(smx_process_t process); XBT_PRIVATE smx_synchro_t SIMIX_process_join(smx_process_t issuer, smx_process_t process, double timeout); XBT_PRIVATE smx_synchro_t SIMIX_process_sleep(smx_process_t process, double duration); -XBT_PRIVATE void SIMIX_post_process_sleep(smx_synchro_t synchro); XBT_PRIVATE void SIMIX_process_sleep_destroy(smx_synchro_t synchro); XBT_PRIVATE void SIMIX_process_auto_restart_set(smx_process_t process, int auto_restart); diff --git a/src/simix/smx_synchro.cpp b/src/simix/smx_synchro.cpp index afb57832b8..442695e03c 100644 --- a/src/simix/smx_synchro.cpp +++ b/src/simix/smx_synchro.cpp @@ -14,7 +14,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_synchro, simix, "SIMIX Synchronization (mutex, semaphores and conditions)"); static smx_synchro_t SIMIX_synchro_wait(sg_host_t smx_host, double timeout); -static void SIMIX_synchro_finish(smx_synchro_t synchro); static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout, smx_process_t issuer, smx_simcall_t simcall); static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer, @@ -74,20 +73,7 @@ void SIMIX_synchro_destroy(smx_synchro_t synchro) delete raw; } -void SIMIX_post_synchro(smx_synchro_t synchro) -{ - XBT_IN("(%p)",synchro); - simgrid::simix::Raw *raw = static_cast(synchro); - if (raw->sleep->getState() == simgrid::surf::Action::State::failed) - raw->state = SIMIX_FAILED; - else if(raw->sleep->getState() == simgrid::surf::Action::State::done) - raw->state = SIMIX_SRC_TIMEOUT; - - SIMIX_synchro_finish(raw); - XBT_OUT(); -} - -static void SIMIX_synchro_finish(smx_synchro_t synchro) +void SIMIX_synchro_finish(smx_synchro_t synchro) { XBT_IN("(%p)",synchro); smx_simcall_t simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls); diff --git a/src/simix/smx_synchro_private.h b/src/simix/smx_synchro_private.h index 9cf259203a..c8ea1f64f4 100644 --- a/src/simix/smx_synchro_private.h +++ b/src/simix/smx_synchro_private.h @@ -10,6 +10,7 @@ #include "xbt/base.h" #include "xbt/swag.h" #include "xbt/xbt_os_thread.h" +#include "src/simix/popping_private.h" typedef struct s_smx_mutex { unsigned int locked; @@ -30,6 +31,7 @@ typedef struct s_smx_sem { XBT_PRIVATE void SIMIX_post_synchro(smx_synchro_t synchro); XBT_PRIVATE void SIMIX_synchro_stop_waiting(smx_process_t process, smx_simcall_t simcall); XBT_PRIVATE void SIMIX_synchro_destroy(smx_synchro_t synchro); +XBT_PRIVATE void SIMIX_synchro_finish(smx_synchro_t synchro); XBT_PRIVATE smx_mutex_t SIMIX_mutex_init(void); XBT_PRIVATE int SIMIX_mutex_trylock(smx_mutex_t mutex, smx_process_t issuer); diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index 613e09817e..a8e8409604 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -856,7 +856,8 @@ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* } if (request->action){ - MPI_Request req = (MPI_Request)SIMIX_comm_get_src_data(request->action); + simgrid::simix::Comm *sync_comm = static_cast(request->action); + MPI_Request req = (MPI_Request)sync_comm->src_data; *flag = 1; if(status != MPI_STATUS_IGNORE && !(req->flags & PREPARED)) { status->MPI_SOURCE = smpi_group_rank(smpi_comm_group(comm), req->src);