X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/652e6c763d01ad7924087d541928bd44c795d72d..6e6af9ba860e3f607fddcdfbda94c44f8f1becbb:/src/msg/msg_gos.cpp diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index f3880e3de9..8b72d65f69 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -6,12 +6,12 @@ #include #include "src/kernel/activity/ExecImpl.hpp" -#include "src/msg/msg_private.h" -#include "src/simix/smx_private.h" /* MSG_task_listen looks inside the rdv directly. Not clean. */ +#include "src/msg/msg_private.hpp" +#include "src/simix/smx_private.hpp" /* MSG_task_listen looks inside the rdv directly. Not clean. */ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg, "Logging specific to MSG (gos)"); -SG_BEGIN_DECL() +extern "C" { /** \ingroup msg_task_usage * \brief Executes a task and waits for its termination. @@ -70,8 +70,8 @@ msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeo simdata->compute = boost::static_pointer_cast(simcall_execution_parallel_start( task->name, simdata->host_nb, simdata->host_list, simdata->flops_parallel_amount, - simdata->bytes_parallel_amount, 1.0, -1.0, timeout)); - XBT_DEBUG("Parallel execution action created: %p", simdata->compute); + simdata->bytes_parallel_amount, -1.0, timeout)); + XBT_DEBUG("Parallel execution action created: %p", simdata->compute.get()); } else { simdata->compute = boost::static_pointer_cast( simcall_execution_start(task->name, simdata->flops_amount, simdata->priority, simdata->bound)); @@ -259,7 +259,6 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d THROW_UNIMPLEMENTED; TRACE_msg_task_get_start(); - double start_time = MSG_get_clock(); /* Sanity check */ xbt_assert(task, "Null pointer for the task storage"); @@ -270,7 +269,7 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d /* Try to receive it by calling SIMIX network layer */ try { simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate); - XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name()); + XBT_DEBUG("Got task %s from %s", (*task)->name, mailbox->getCname()); (*task)->simdata->setNotUsed(); } catch (xbt_ex& e) { @@ -291,15 +290,15 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d } if (ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) { - TRACE_msg_task_get_end(start_time, *task); + TRACE_msg_task_get_end(*task); } return ret; } /* Internal function used to factorize code between MSG_task_isend_with_matching() and MSG_task_dsend(). */ -static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias, - int (*match_fun)(void*,void*, smx_activity_t), - void *match_data, void_f_pvoid_t cleanup, int detached) +static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char* alias, + int (*match_fun)(void*, void*, void*), void* match_data, + void_f_pvoid_t cleanup, int detached) { simdata_task_t t_simdata = nullptr; msg_process_t myself = MSG_process_self(); @@ -315,17 +314,14 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al msg_global->sent_msg++; /* Send it by calling SIMIX network layer */ - smx_activity_t act = simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate, - task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached); + smx_activity_t act = + simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate, task, + sizeof(void*), (simix_match_func_t)match_fun, cleanup, nullptr, match_data, detached); t_simdata->comm = boost::static_pointer_cast(act); msg_comm_t comm = nullptr; if (not detached) { - comm = xbt_new0(s_msg_comm_t, 1); - comm->task_sent = task; - comm->task_received = nullptr; - comm->status = MSG_OK; - comm->s_comm = act; + comm = new simgrid::msg::Comm(task, nullptr, act); } if (TRACE_is_enabled()) @@ -381,8 +377,8 @@ msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, double max * \param match_data user provided data passed to match_fun * \return the msg_comm_t communication created */ -msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias, - int (*match_fun)(void*, void*, smx_activity_t), void *match_data) +msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char* alias, int (*match_fun)(void*, void*, void*), + void* match_data) { return MSG_task_isend_internal(task, alias, match_fun, match_data, nullptr, 0); } @@ -465,11 +461,9 @@ msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rat XBT_CRITICAL("MSG_task_irecv() was asked to write in a non empty task struct."); /* Try to receive it by calling SIMIX network layer */ - msg_comm_t comm = xbt_new0(s_msg_comm_t, 1); - comm->task_sent = nullptr; - comm->task_received = task; - comm->status = MSG_OK; - comm->s_comm = simcall_comm_irecv(SIMIX_process_self(), mbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, rate); + msg_comm_t comm = + new simgrid::msg::Comm(nullptr, task, simcall_comm_irecv(SIMIX_process_self(), mbox->getImpl(), task, nullptr, + nullptr, nullptr, nullptr, rate)); return comm; } @@ -570,7 +564,7 @@ int MSG_comm_testany(xbt_dynar_t comms) */ void MSG_comm_destroy(msg_comm_t comm) { - xbt_free(comm); + delete comm; } /** \ingroup msg_task_usage @@ -634,11 +628,14 @@ int MSG_comm_waitany(xbt_dynar_t comms) int finished_index = -1; /* create the equivalent dynar with SIMIX objects */ - xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_activity_t), nullptr); + xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_activity_t), [](void*ptr){ + intrusive_ptr_release(*(simgrid::kernel::activity::ActivityImpl**)ptr); + }); msg_comm_t comm; unsigned int cursor; xbt_dynar_foreach(comms, cursor, comm) { - xbt_dynar_push(s_comms, &comm->s_comm); + intrusive_ptr_add_ref(comm->s_comm.get()); + xbt_dynar_push_as(s_comms, simgrid::kernel::activity::ActivityImpl*, comm->s_comm.get()); } msg_error_t status = MSG_OK; @@ -909,5 +906,4 @@ const char *MSG_task_get_category (msg_task_t task) { return task->category; } - -SG_END_DECL() +}