From ee63a4fbf0d79259eb0e1e7c5b7053f4b99c7a75 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 26 Feb 2016 19:36:24 +0100 Subject: [PATCH] pedantic freak meets MSG sources --- src/msg/msg_actions.cpp | 15 +-- src/msg/msg_deployment.cpp | 14 +-- src/msg/msg_environment.cpp | 7 +- src/msg/msg_global.cpp | 8 +- src/msg/msg_gos.cpp | 243 ++++++++++++------------------------ src/msg/msg_host.cpp | 51 +++----- src/msg/msg_io.cpp | 64 ++++------ src/msg/msg_mailbox.cpp | 44 ++----- src/msg/msg_private.h | 11 +- src/msg/msg_process.cpp | 196 +++++++++++------------------ src/msg/msg_synchro.cpp | 11 +- src/msg/msg_task.cpp | 190 ++++++++++------------------ 12 files changed, 289 insertions(+), 565 deletions(-) diff --git a/src/msg/msg_actions.cpp b/src/msg/msg_actions.cpp index a1a43da04c..1fd0b4133a 100644 --- a/src/msg/msg_actions.cpp +++ b/src/msg/msg_actions.cpp @@ -5,15 +5,12 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "msg_private.h" -#include "xbt/str.h" #include "xbt/dynar.h" #include "xbt/replay.h" #include -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg, - "MSG actions for trace driven simulation"); - +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_action, msg, "MSG actions for trace driven simulation"); void MSG_action_init() { @@ -26,8 +23,6 @@ void MSG_action_exit() _xbt_replay_action_exit(); } - - /** \ingroup msg_trace_driven * \brief A trace loader * @@ -44,15 +39,13 @@ msg_error_t MSG_action_trace_run(char *path) xbt_action_fp=NULL; if (path) { xbt_action_fp = fopen(path, "r"); - xbt_assert(xbt_action_fp != NULL, "Cannot open %s: %s", - path, strerror(errno)); + xbt_assert(xbt_action_fp != NULL, "Cannot open %s: %s", path, strerror(errno)); } res = MSG_main(); if (!xbt_dict_is_empty(xbt_action_queues)) { - XBT_WARN - ("Not all actions got consumed. If the simulation ended successfully (without deadlock), you may want to add new processes to your deployment file."); - + XBT_WARN("Not all actions got consumed. If the simulation ended successfully (without deadlock)," + " you may want to add new processes to your deployment file."); xbt_dict_foreach(xbt_action_queues, cursor, name, todo) { XBT_WARN("Still %lu actions for %s", xbt_dynar_length(todo), name); diff --git a/src/msg/msg_deployment.cpp b/src/msg/msg_deployment.cpp index 373594265a..af82087e81 100644 --- a/src/msg/msg_deployment.cpp +++ b/src/msg/msg_deployment.cpp @@ -12,8 +12,7 @@ * \brief An application deployer. * * Creates the process described in \a file. - * \param file a filename of a xml description of the application. This file - * follows this DTD : + * \param file a filename of a xml description of the application. This file follows this DTD : * * \include simgrid.dtd * @@ -25,13 +24,8 @@ */ void MSG_launch_application(const char *file) { - - xbt_assert(msg_global, - "MSG_init has to be called before MSG_launch_application."); - + xbt_assert(msg_global, "MSG_init has to be called before MSG_launch_application."); SIMIX_launch_application(file); - - return; } /** \ingroup msg_simulation @@ -45,7 +39,6 @@ void MSG_launch_application(const char *file) void MSG_function_register(const char *name, xbt_main_func_t code) { SIMIX_function_register(name, code); - return; } /** \ingroup msg_simulation @@ -75,8 +68,7 @@ xbt_main_func_t MSG_get_registered_function(const char *name) * \brief register functions bypassing the parser */ -void MSG_set_function(const char *host_id, const char *function_name, - xbt_dynar_t arguments) +void MSG_set_function(const char *host_id, const char *function_name, xbt_dynar_t arguments) { SIMIX_process_set_function(host_id, function_name, arguments, -1, -1); } diff --git a/src/msg/msg_environment.cpp b/src/msg/msg_environment.cpp index b9c604a6d9..d07025343e 100644 --- a/src/msg/msg_environment.cpp +++ b/src/msg/msg_environment.cpp @@ -19,10 +19,8 @@ /** \ingroup msg_simulation * \brief A platform constructor. * - * Creates a new platform, including hosts, links and the - * routing_table. - * \param file a filename of a xml description of a platform. This file - * follows this DTD : + * Creates a new platform, including hosts, links and the routing_table. + * \param file a filename of a xml description of a platform. This file follows this DTD : * * \include simgrid.dtd * @@ -47,7 +45,6 @@ void MSG_post_create_environment(void) { if(data[SIMIX_STORAGE_LEVEL]) __MSG_storage_create(xbt_dict_cursor_get_elm(cursor)); } - } msg_as_t MSG_environment_get_routing_root() { diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index a37a20d33c..ba38cae7ca 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -10,15 +10,11 @@ #include "mc/mc.h" #include "xbt/sysdep.h" #include "xbt/log.h" -#include "xbt/virtu.h" -#include "xbt/ex.h" /* ex_backtrace_display */ -#include "xbt/replay.h" #include "simgrid/sg_config.h" /* Configuration mechanism of SimGrid */ #include "src/surf/xml/platf_private.hpp" // FIXME: KILLME by removing MSG_post_create_environment() XBT_LOG_NEW_CATEGORY(msg, "All MSG categories"); -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, - "Logging specific to MSG (kernel)"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kernel)"); MSG_Global_t msg_global = NULL; static void MSG_exit(void); @@ -110,7 +106,6 @@ void MSG_config(const char *key, const char *value){ xbt_cfg_set_as_string(_sg_cfg_set, key, value); } - /** \ingroup msg_simulation * \brief Kill all running process @@ -139,7 +134,6 @@ static void MSG_exit(void) { msg_global = NULL; } - /** \ingroup msg_simulation * \brief A clock (in second). */ diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index 137787b15f..426f25aa5f 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -15,11 +15,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg, /** \ingroup msg_task_usage * \brief Executes a task and waits for its termination. * - * This function is used for describing the behavior of a process. It - * takes only one parameter. + * This function is used for describing the behavior of a process. It takes only one parameter. * \param task a #msg_task_t to execute on the location on which the process is running. - * \return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED - * or #MSG_HOST_FAILURE otherwise + * \return #MSG_OK if the task was successfully completed, #MSG_TASK_CANCELED or #MSG_HOST_FAILURE otherwise */ msg_error_t MSG_task_execute(msg_task_t task) { @@ -54,8 +52,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) TRACE_msg_task_execute_start(task); xbt_assert((!simdata->compute) && (task->simdata->isused == 0), - "This task is executed somewhere else. Go fix your code! %d", - task->simdata->isused!=NULL); + "This task is executed somewhere else. Go fix your code! %d", task->simdata->isused!=NULL); XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self())); @@ -64,7 +61,6 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) return MSG_OK; } - TRY { if (msg_global->debug_multiple_use) MSG_BT(simdata->isused, "Using Backtrace"); @@ -72,24 +68,19 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) simdata->isused = (void*)1; if (simdata->host_nb > 0) { - simdata->compute = simcall_execution_parallel_start(task->name, - simdata->host_nb, - simdata->host_list, - simdata->flops_parallel_amount, - simdata->bytes_parallel_amount, + simdata->compute = simcall_execution_parallel_start(task->name, simdata->host_nb,simdata->host_list, + simdata->flops_parallel_amount, simdata->bytes_parallel_amount, 1.0, -1.0); XBT_DEBUG("Parallel execution action created: %p", simdata->compute); } else { - unsigned long affinity_mask = (unsigned long)(uintptr_t) xbt_dict_get_or_null_ext(simdata->affinity_mask_db, (char *) p_simdata->m_host, sizeof(msg_host_t)); - XBT_DEBUG("execute %s@%s with affinity(0x%04lx)", MSG_task_get_name(task), MSG_host_get_name(p_simdata->m_host), affinity_mask); - - simdata->compute = simcall_execution_start(task->name, - simdata->flops_amount, - simdata->priority, - simdata->bound, - affinity_mask - ); - + unsigned long affinity_mask = + (unsigned long)(uintptr_t) xbt_dict_get_or_null_ext(simdata->affinity_mask_db, (char *) p_simdata->m_host, + sizeof(msg_host_t)); + XBT_DEBUG("execute %s@%s with affinity(0x%04lx)", + MSG_task_get_name(task), MSG_host_get_name(p_simdata->m_host), affinity_mask); + + simdata->compute = simcall_execution_start(task->name, simdata->flops_amount, simdata->priority, + simdata->bound, affinity_mask); } simcall_set_category(simdata->compute, task->category); p_simdata->waiting_action = simdata->compute; @@ -101,8 +92,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) xbt_ex_free(*(xbt_ex_t*)simdata->isused); simdata->isused = 0; - XBT_DEBUG("Execution task '%s' finished in state %d", - task->name, (int)comp_state); + XBT_DEBUG("Execution task '%s' finished in state %d", task->name, (int)comp_state); } CATCH(e) { switch (e.category) { @@ -117,8 +107,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) } xbt_ex_free(e); } - /* action ended, set comm and compute = NULL, the actions is already destroyed - * in the main function */ + /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */ simdata->flops_amount = 0.0; simdata->comm = NULL; simdata->compute = NULL; @@ -127,7 +116,6 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) MSG_RETURN(status); } - /** \ingroup msg_task_usage * \brief Sleep for the specified number of seconds * @@ -171,8 +159,7 @@ msg_error_t MSG_process_sleep(double nb_sec) /** \ingroup msg_task_usage * \brief Receives a task from a mailbox. * - * This is a blocking function, the execution flow will be blocked - * until the task is received. See #MSG_task_irecv + * This is a blocking function, the execution flow will be blocked until the task is received. See #MSG_task_irecv * for receiving tasks asynchronously. * * \param task a memory location for storing a #msg_task_t. @@ -192,14 +179,13 @@ msg_error_t MSG_task_receive(msg_task_t * task, const char *alias) * * \param task a memory location for storing a #msg_task_t. * \param alias name of the mailbox to receive the task from - * \param rate limit the reception to rate bandwidth + * \param rate limit the reception to rate bandwidth * * \return Returns * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise. */ -msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, - double rate) +msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, double rate) { return MSG_task_receive_with_timeout_bounded(task, alias, -1, rate); } @@ -207,9 +193,8 @@ msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, /** \ingroup msg_task_usage * \brief Receives a task from a mailbox with a given timeout. * - * This is a blocking function with a timeout, the execution flow will be blocked - * until the task is received or the timeout is achieved. See #MSG_task_irecv - * for receiving tasks asynchronously. You can provide a -1 timeout + * This is a blocking function with a timeout, the execution flow will be blocked until the task is received or the + * timeout is achieved. See #MSG_task_irecv for receiving tasks asynchronously. You can provide a -1 timeout * to obtain an infinite timeout. * * \param task a memory location for storing a #msg_task_t. @@ -220,9 +205,7 @@ msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise. */ -msg_error_t -MSG_task_receive_with_timeout(msg_task_t * task, const char *alias, - double timeout) +msg_error_t MSG_task_receive_with_timeout(msg_task_t * task, const char *alias, double timeout) { return MSG_task_receive_ext(task, alias, timeout, NULL); } @@ -239,9 +222,7 @@ MSG_task_receive_with_timeout(msg_task_t * task, const char *alias, * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise. */ -msg_error_t -MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias, - double timeout,double rate) +msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias, double timeout,double rate) { return MSG_task_receive_ext_bounded(task, alias, timeout, NULL, rate); } @@ -249,9 +230,8 @@ MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias, /** \ingroup msg_task_usage * \brief Receives a task from a mailbox from a specific host with a given timeout. * - * This is a blocking function with a timeout, the execution flow will be blocked - * until the task is received or the timeout is achieved. See #MSG_task_irecv - * for receiving tasks asynchronously. You can provide a -1 timeout + * This is a blocking function with a timeout, the execution flow will be blocked until the task is received or the + * timeout is achieved. See #MSG_task_irecv for receiving tasks asynchronously. You can provide a -1 timeout * to obtain an infinite timeout. * * \param task a memory location for storing a #msg_task_t. @@ -263,18 +243,13 @@ MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias, * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise. */ -msg_error_t -MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout, - msg_host_t host) +msg_error_t MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout, msg_host_t host) { xbt_ex_t e; msg_error_t ret = MSG_OK; - XBT_DEBUG - ("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'", - alias); + XBT_DEBUG("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'", alias); TRY { - ret = MSG_mailbox_get_task_ext(MSG_mailbox_get_by_alias(alias), task, - host, timeout); + ret = MSG_mailbox_get_task_ext(MSG_mailbox_get_by_alias(alias), task, host, timeout); } CATCH(e) { switch (e.category) { @@ -290,8 +265,7 @@ MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout, } /** \ingroup msg_task_usage - * \brief Receives a task from a mailbox from a specific host with a given timeout - * and at a given rate. + * \brief Receives a task from a mailbox from a specific host with a given timeout and at a given rate. * * \param task a memory location for storing a #msg_task_t. * \param alias name of the mailbox to receive the task from @@ -303,25 +277,17 @@ MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout, * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise. */ -msg_error_t -MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout, - msg_host_t host, double rate) +msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout, msg_host_t host, + double rate) { - XBT_DEBUG - ("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'", - alias); - return MSG_mailbox_get_task_ext_bounded(MSG_mailbox_get_by_alias(alias), task, - host, timeout, rate); + XBT_DEBUG("MSG_task_receive_ext: Trying to receive a message on mailbox '%s'", alias); + return MSG_mailbox_get_task_ext_bounded(MSG_mailbox_get_by_alias(alias), task, host, timeout, rate); } -/* Internal function used to factorize code between - * MSG_task_isend_with_matching() and MSG_task_dsend(). - */ -static XBT_INLINE -msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias, - int (*match_fun)(void*,void*, smx_synchro_t), - void *match_data, void_f_pvoid_t cleanup, - int detached) +/* Internal function used to factorize code between MSG_task_isend_with_matching() and MSG_task_dsend(). */ +static XBT_INLINE msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias, + int (*match_fun)(void*,void*, smx_synchro_t), + void *match_data, void_f_pvoid_t cleanup, int detached) { simdata_task_t t_simdata = NULL; msg_process_t process = MSG_process_self(); @@ -341,7 +307,8 @@ msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias, xbt_backtrace_display_current(); } else { xbt_assert(t_simdata->isused == 0, - "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)"); + "This task is still being used somewhere else. You cannot send it now. Go fix your code!" + "(use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)"); } } @@ -353,9 +320,8 @@ msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias, msg_global->sent_msg++; /* Send it by calling SIMIX network layer */ - smx_synchro_t act = simcall_comm_isend(SIMIX_process_self(), mailbox, t_simdata->bytes_amount, - t_simdata->rate, task, sizeof(void *), - match_fun, cleanup, NULL, match_data,detached); + smx_synchro_t act = simcall_comm_isend(SIMIX_process_self(), mailbox, t_simdata->bytes_amount, t_simdata->rate, + task, sizeof(void *), match_fun, cleanup, NULL, match_data,detached); t_simdata->comm = act; /* FIXME: is the field t_simdata->comm still useful? */ msg_comm_t comm; @@ -377,12 +343,10 @@ msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias, return comm; } - /** \ingroup msg_task_usage * \brief Sends a task on a mailbox. * - * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() - * to end the communication. + * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() to end the communication. * * \param task a #msg_task_t to send on another location. * \param alias name of the mailbox to sent the task to @@ -396,28 +360,24 @@ msg_comm_t MSG_task_isend(msg_task_t task, const char *alias) /** \ingroup msg_task_usage * \brief Sends a task on a mailbox with a maximum rate * - * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() - * to end the communication. The maxrate parameter allows the application - * to limit the bandwidth utilization of network links when sending the task. + * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() to end the communication. The maxrate + * parameter allows the application to limit the bandwidth utilization of network links when sending the task. * * \param task a #msg_task_t to send on another location. * \param alias name of the mailbox to sent the task to * \param maxrate the maximum communication rate for sending this task . * \return the msg_comm_t communication created */ -msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, - double maxrate) +msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate) { task->simdata->rate = maxrate; return MSG_task_isend_internal(task, alias, NULL, NULL, NULL, 0); } - /** \ingroup msg_task_usage * \brief Sends a task on a mailbox, with support for matching requests * - * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() - * to end the communication. + * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() to end the communication. * * \param task a #msg_task_t to send on another location. * \param alias name of the mailbox to sent the task to @@ -429,9 +389,7 @@ msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, * \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_synchro_t), - void *match_data) + int (*match_fun)(void*, void*, smx_synchro_t), void *match_data) { return MSG_task_isend_internal(task, alias, match_fun, match_data, NULL, 0); } @@ -440,17 +398,15 @@ msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias, * \brief Sends a task on a mailbox. * * This is a non blocking detached send function. - * Think of it as a best effort send. Keep in mind that the third parameter - * is only called if the communication fails. If the communication does work, - * it is responsibility of the receiver code to free anything related to - * the task, as usual. More details on this can be obtained on + * Think of it as a best effort send. Keep in mind that the third parameter is only called if the communication fails. + * If the communication does work, it is responsibility of the receiver code to free anything related to the task, as + * usual. More details on this can be obtained on * this thread * in the SimGrid-user mailing list archive. * * \param task a #msg_task_t to send on another location. * \param alias name of the mailbox to sent the task to - * \param cleanup a function to destroy the task if the - * communication fails, e.g. MSG_task_destroy + * \param cleanup a function to destroy the task if the communication fails, e.g. MSG_task_destroy * (if NULL, no function will be called) */ void MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup) @@ -462,10 +418,9 @@ void MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup) * \brief Sends a task on a mailbox with a maximal rate. * * This is a non blocking detached send function. - * Think of it as a best effort send. Keep in mind that the third parameter - * is only called if the communication fails. If the communication does work, - * it is responsibility of the receiver code to free anything related to - * the task, as usual. More details on this can be obtained on + * Think of it as a best effort send. Keep in mind that the third parameter is only called if the communication fails. + * If the communication does work, it is responsibility of the receiver code to free anything related to the task, as + * usual. More details on this can be obtained on * this thread * in the SimGrid-user mailing list archive. * @@ -477,8 +432,7 @@ void MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup) * \param maxrate the maximum communication rate for sending this task * */ -void MSG_task_dsend_bounded(msg_task_t task, const char *alias, - void_f_pvoid_t cleanup, double maxrate) +void MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate) { task->simdata->rate = maxrate; MSG_task_dsend(task, alias, cleanup); @@ -487,8 +441,7 @@ void MSG_task_dsend_bounded(msg_task_t task, const char *alias, /** \ingroup msg_task_usage * \brief Starts listening for receiving a task from an asynchronous communication. * - * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() - * to end the communication. + * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test() to end the communication. * * \param task a memory location for storing a #msg_task_t. has to be valid until the end of the communication. * \param name of the mailbox to receive the task on @@ -500,27 +453,23 @@ msg_comm_t MSG_task_irecv(msg_task_t *task, const char *name) } /** \ingroup msg_task_usage - * \brief Starts listening for receiving a task from an asynchronous communication - * at a given rate. + * \brief Starts listening for receiving a task from an asynchronous communication at a given rate. * * \param task a memory location for storing a #msg_task_t. has to be valid until the end of the communication. * \param name of the mailbox to receive the task on * \param rate limit the bandwidth to the given rate * \return the msg_comm_t communication created */ -msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, - double rate) +msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rate) { smx_rdv_t rdv = MSG_mailbox_get_by_alias(name); /* FIXME: these functions are not traceable */ - /* Sanity check */ xbt_assert(task, "Null pointer for the task storage"); if (*task) - XBT_CRITICAL - ("MSG_task_irecv() was asked to write in a non empty task struct."); + 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); @@ -561,12 +510,10 @@ int MSG_comm_test(msg_comm_t comm) comm->status = MSG_TRANSFER_FAILURE; finished = 1; break; - case timeout_error: comm->status = MSG_TIMEOUT; finished = 1; break; - default: RETHROW; } @@ -606,12 +553,10 @@ int MSG_comm_testany(xbt_dynar_t comms) finished_index = e.value; status = MSG_TRANSFER_FAILURE; break; - case timeout_error: finished_index = e.value; status = MSG_TIMEOUT; break; - default: RETHROW; } @@ -649,8 +594,8 @@ void MSG_comm_destroy(msg_comm_t comm) * * It takes two parameters. * \param comm the communication to wait. - * \param timeout Wait until the communication terminates or the timeout - * occurs. You can provide a -1 timeout to obtain an infinite timeout. + * \param timeout Wait until the communication terminates or the timeout occurs. + * You can provide a -1 timeout to obtain an infinite timeout. * \return msg_error_t */ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout) @@ -729,12 +674,10 @@ int MSG_comm_waitany(xbt_dynar_t comms) finished_index = e.value; status = MSG_TRANSFER_FAILURE; break; - case timeout_error: finished_index = e.value; status = MSG_TIMEOUT; break; - default: RETHROW; } @@ -790,23 +733,21 @@ msg_task_t MSG_comm_get_task(msg_comm_t comm) * \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 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, simcall_comm_get_src_proc(comm), simcall_comm_get_dst_proc(comm)); } } /** \ingroup msg_task_usage * \brief Sends a task to a mailbox * - * This is a blocking function, the execution flow will be blocked - * until the task is sent (and received in the other side if #MSG_task_receive is used). + * This is a blocking function, the execution flow will be blocked until the task is sent (and received on the other + * side if #MSG_task_receive is used). * See #MSG_task_isend for sending tasks asynchronously. * * \param task the task to be sent @@ -824,9 +765,8 @@ msg_error_t MSG_task_send(msg_task_t task, const char *alias) /** \ingroup msg_task_usage * \brief Sends a task to a mailbox with a maximum rate * - * This is a blocking function, the execution flow will be blocked - * until the task is sent. The maxrate parameter allows the application - * to limit the bandwidth utilization of network links when sending the task. + * This is a blocking function, the execution flow will be blocked until the task is sent. The maxrate parameter allows + * the application to limit the bandwidth utilization of network links when sending the task. * * \param task the task to be sent * \param alias the mailbox name to where the task is sent @@ -835,8 +775,7 @@ msg_error_t MSG_task_send(msg_task_t task, const char *alias) * \return Returns #MSG_OK if the task was successfully sent, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise. */ -msg_error_t -MSG_task_send_bounded(msg_task_t task, const char *alias, double maxrate) +msg_error_t MSG_task_send_bounded(msg_task_t task, const char *alias, double maxrate) { task->simdata->rate = maxrate; return MSG_task_send(task, alias); @@ -845,8 +784,7 @@ MSG_task_send_bounded(msg_task_t task, const char *alias, double maxrate) /** \ingroup msg_task_usage * \brief Sends a task to a mailbox with a timeout * - * This is a blocking function, the execution flow will be blocked - * until the task is sent or the timeout is achieved. + * This is a blocking function, the execution flow will be blocked until the task is sent or the timeout is achieved. * * \param task the task to be sent * \param alias the mailbox name to where the task is sent @@ -855,19 +793,15 @@ MSG_task_send_bounded(msg_task_t task, const char *alias, double maxrate) * \return Returns #MSG_OK if the task was successfully sent, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise. */ -msg_error_t -MSG_task_send_with_timeout(msg_task_t task, const char *alias, - double timeout) +msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout) { - return MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_alias(alias), - task, timeout); + return MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_alias(alias), task, timeout); } /** \ingroup msg_task_usage * \brief Sends a task to a mailbox with a timeout and with a maximum rate * - * This is a blocking function, the execution flow will be blocked - * until the task is sent or the timeout is achieved. + * This is a blocking function, the execution flow will be blocked until the task is sent or the timeout is achieved. * * \param task the task to be sent * \param alias the mailbox name to where the task is sent @@ -877,13 +811,10 @@ MSG_task_send_with_timeout(msg_task_t task, const char *alias, * \return Returns #MSG_OK if the task was successfully sent, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE, or #MSG_TIMEOUT otherwise. */ -msg_error_t -MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, - double timeout, double maxrate) +msg_error_t MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, double timeout, double maxrate) { task->simdata->rate = maxrate; - return MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_alias(alias), - task, timeout); + return MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_alias(alias), task, timeout); } /** \ingroup msg_task_usage @@ -904,20 +835,16 @@ int MSG_task_listen(const char *alias) * \param alias the name of the mailbox to be considered * \param host the host to check for communication * - * \return Returns the number of pending communication actions of the host in the - * given mailbox, 0 if there is no pending communication actions. - * + * \return Returns the number of pending communication actions of the host in the given mailbox, 0 if there is no + * pending communication actions. */ int MSG_task_listen_from_host(const char *alias, msg_host_t host) { - return - MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_alias - (alias), host); + return MSG_mailbox_get_count_host_waiting_tasks(MSG_mailbox_get_by_alias(alias), host); } /** \ingroup msg_task_usage - * \brief Look if there is a communication on a mailbox and return the - * PID of the sender process. + * \brief Look if there is a communication on a mailbox and return the PID of the sender process. * * \param alias the name of the mailbox to be considered * @@ -928,8 +855,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_get_head(MSG_mailbox_get_by_alias(alias)))) return -1; return MSG_process_get_PID(task->simdata->sender); @@ -938,16 +864,12 @@ int MSG_task_listen_from(const char *alias) /** \ingroup msg_task_usage * \brief Sets the tracing category of a task. * - * This function should be called after the creation of - * a MSG task, to define the category of that task. The - * first parameter task must contain a task that was - * created with the function #MSG_task_create. The second - * parameter category must contain a category that was - * previously declared with the function #TRACE_category + * This function should be called after the creation of a MSG task, to define the category of that task. The + * first parameter task must contain a task that was created with the function #MSG_task_create. The second + * parameter category must contain a category that was previously declared with the function #TRACE_category * (or with #TRACE_category_with_color). * - * See \ref tracing for details on how to trace - * the (categorized) resource utilization. + * See \ref tracing for details on how to trace the (categorized) resource utilization. * * \param task the task that is going to be categorized * \param category the name of the category to be associated to the task @@ -983,8 +905,7 @@ const char *MSG_task_get_category (msg_task_t task) */ const char *MSG_as_router_get_property_value(const char* asr, const char *name) { - return (char*) xbt_dict_get_or_null( - MSG_as_router_get_properties(asr), name); + return (char*) xbt_dict_get_or_null(MSG_as_router_get_properties(asr), name); } /** diff --git a/src/msg/msg_host.cpp b/src/msg/msg_host.cpp index b5b4fd1088..feb4f97f62 100644 --- a/src/msg/msg_host.cpp +++ b/src/msg/msg_host.cpp @@ -16,12 +16,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg); * \htmlonly \endhtmlonly * (#msg_host_t) and the functions for managing it. * - * A location (or host) is any possible place where - * a process may run. Thus it may be represented as a - * physical resource with computing capabilities, some - * mailboxes to enable running process to communicate with - * remote ones, and some private data that can be only - * accessed by local process. + * A location (or host) is any possible place where a process may run. Thus it may be represented + * as a physical resource with computing capabilities, some mailboxes to enable running process to + * communicate with remote ones, and some private data that can be only accessed by local process. * \see msg_host_t */ @@ -42,7 +39,7 @@ msg_host_t __MSG_host_create(sg_host_t host) // FIXME: don't return our paramete xbt_dynar_push_as(priv->file_descriptor_table, int, i); sg_host_msg_set(host,priv); - + return host; } @@ -62,8 +59,7 @@ msg_host_t MSG_host_by_name(const char *name) * * \brief Set the user data of a #msg_host_t. * - * This functions checks whether some data has already been associated to \a host - or not and attach \a data to \a host if it is possible. + * This functions attach \a data to \a host if it is possible. */ msg_error_t MSG_host_set_data(msg_host_t host, void *data) { sg_host_user_set(host, data); @@ -74,8 +70,7 @@ msg_error_t MSG_host_set_data(msg_host_t host, void *data) { * * \brief Return the user data of a #msg_host_t. * - * This functions checks whether \a host is a valid pointer or not and return - the user data associated to \a host if it is possible. + * This functions returns the user data associated to \a host if it is possible. */ void *MSG_host_get_data(msg_host_t host) { return sg_host_user(host); @@ -90,12 +85,12 @@ msg_host_t MSG_host_self(void) return MSG_process_get_host(NULL); } - /** \ingroup m_host_management * * \brief Start the host if it is off * - * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy for more info on DVFS. + * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy + * for more info on DVFS. */ void MSG_host_on(msg_host_t host) { @@ -106,7 +101,8 @@ void MSG_host_on(msg_host_t host) * * \brief Stop the host if it is on * - * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy for more info on DVFS. + * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy + * for more info on DVFS. */ void MSG_host_off(msg_host_t host) { @@ -118,7 +114,6 @@ void MSG_host_off(msg_host_t host) */ void __MSG_host_priv_free(msg_host_priv_t priv) { - if (priv == NULL) return; unsigned int size = xbt_dict_size(priv->dp_objs); @@ -141,21 +136,20 @@ int MSG_get_host_number(void) /** \ingroup m_host_management * \brief Return a dynar containing all the hosts declared at a given point of time - * \remark The host order in the returned array is generally different from the host creation/declaration order in the XML platform (we use a hash table internally) + * \remark The host order in the returned array is generally different from the host creation/declaration order in the + * XML platform (we use a hash table internally) */ xbt_dynar_t MSG_hosts_as_dynar(void) { return sg_hosts_as_dynar(); } /** \ingroup m_host_management - * \brief Return the speed of the processor (in flop/s), regardless of - the current load on the machine. + * \brief Return the speed of the processor (in flop/s), regardless of the current load on the machine. */ double MSG_get_host_speed(msg_host_t host) { return host->speed(); } - /** \ingroup m_host_management * \brief Return the number of cores. * @@ -178,7 +172,6 @@ xbt_swag_t MSG_host_get_process_list(msg_host_t host) return host->processes(); } - /** \ingroup m_host_management * \brief Returns the value of a given host property * @@ -212,13 +205,10 @@ xbt_dict_t MSG_host_get_properties(msg_host_t host) * \param free_ctn the freeing function to use to kill the value on need */ void MSG_host_set_property_value(msg_host_t host, const char *name, char *value,void_f_pvoid_t free_ctn) { - xbt_dict_set(MSG_host_get_properties(host), name, value,free_ctn); } - /** @ingroup m_host_management - * * @brief Determine if a host is up and running. * * See also #MSG_host_on() and #MSG_host_off() to switch the host ON and OFF and @ref SURF_plugin_energy for more info on DVFS. @@ -231,8 +221,8 @@ int MSG_host_is_on(msg_host_t host) xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); return sg_host_is_on(host); } + /** @ingroup m_host_management - * * @brief Determine if a host is currently off. * * See also #MSG_host_on() and #MSG_host_off() to switch the host ON and OFF and @ref SURF_plugin_energy for more info on DVFS. @@ -273,8 +263,8 @@ void MSG_host_get_params(msg_host_t host, vm_params_t params) * \return Returns the processor speed associated with pstate_index */ double MSG_host_get_power_peak_at(msg_host_t host, int pstate_index) { - xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); - return host->powerPeakAt(pstate_index); + xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); + return host->powerPeakAt(pstate_index); } /** \ingroup m_host_management @@ -284,8 +274,8 @@ double MSG_host_get_power_peak_at(msg_host_t host, int pstate_index) { * \return Returns the current processor speed */ double MSG_host_get_current_power_peak(msg_host_t host) { - xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); - return host->currentPowerPeak(); + xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); + return host->currentPowerPeak(); } /** \ingroup m_host_management @@ -294,7 +284,7 @@ double MSG_host_get_current_power_peak(msg_host_t host) { * \param host host to test */ int MSG_host_get_nb_pstates(msg_host_t host) { - return sg_host_get_nb_pstates(host); + return sg_host_get_nb_pstates(host); } /** \ingroup m_host_management @@ -346,8 +336,7 @@ xbt_dict_t MSG_host_get_storage_content(msg_host_t host) int __MSG_host_get_file_descriptor_id(msg_host_t host){ msg_host_priv_t priv = sg_host_msg(host); - xbt_assert(!xbt_dynar_is_empty(priv->file_descriptor_table), - "Too much files are opened! Some have to be closed."); + xbt_assert(!xbt_dynar_is_empty(priv->file_descriptor_table), "Too much files are opened! Some have to be closed."); return xbt_dynar_pop_as(priv->file_descriptor_table, int); } diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 7b4c7f4e21..98c1348e8d 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -7,8 +7,7 @@ #include "msg_private.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg, - "Logging specific to MSG (io)"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg, "Logging specific to MSG (io)"); /** @addtogroup msg_file_management * \htmlonly \endhtmlonly @@ -17,7 +16,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_io, msg, * \see #msg_file_t */ - /********************************* File **************************************/ void __MSG_file_get_info(msg_file_t fd){ @@ -39,8 +37,7 @@ void __MSG_file_get_info(msg_file_t fd){ * * \brief Set the user data of a #msg_file_t. * - * This functions checks whether some data has already been associated to \a file - or not and attach \a data to \a file if it is possible. + * This functions attach \a data to \a file. */ msg_error_t MSG_file_set_data(msg_file_t fd, void *data) { @@ -53,8 +50,7 @@ msg_error_t MSG_file_set_data(msg_file_t fd, void *data) * * \brief Return the user data of a #msg_file_t. * - * This functions checks whether \a file is a valid pointer or not and return - the user data associated to \a file if it is possible. + * This functions checks whether \a file is a valid pointer and return the user data associated to \a file if possible. */ void *MSG_file_get_data(msg_file_t fd) { @@ -67,7 +63,6 @@ void *MSG_file_get_data(msg_file_t fd) * * \param fd is a the file descriptor */ - void MSG_file_dump (msg_file_t fd){ /* Update the cached information first */ __MSG_file_get_info(fd); @@ -115,7 +110,8 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size) double flops_amount[] = { 0, 0 }; double bytes_amount[] = { 0, 0, (double)read_size, 0 }; - msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount, NULL); + msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount, + NULL); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -159,7 +155,8 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) double flops_amount[] = { 0, 0 }; double bytes_amount[] = { 0, (double)size, 0, 0 }; - msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL); + msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, + NULL); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -198,8 +195,7 @@ msg_file_t MSG_file_open(const char* fullpath, void* data) priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self()); priv->desc_id = __MSG_host_get_file_descriptor_id(MSG_host_self()); - name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), - priv->desc_id); + name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), priv->desc_id); xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv); msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, name); @@ -223,8 +219,7 @@ int MSG_file_close(msg_file_t fd) xbt_free(priv->data); int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self()); - name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), - priv->desc_id); + name = bprintf("%s:%s:%d", priv->fullpath, MSG_host_get_name(MSG_host_self()), priv->desc_id); __MSG_host_release_file_descriptor_id(MSG_host_self(), priv->desc_id); xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1); xbt_free(name); @@ -242,8 +237,7 @@ msg_error_t MSG_file_unlink(msg_file_t fd) msg_file_priv_t file_priv = MSG_file_priv(fd); /* Find the host where the file is physically located (remote or local)*/ msg_storage_t storage_src = - (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, - file_priv->storageId); + (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, file_priv->storageId); msg_storage_priv_t storage_priv_src = MSG_storage_priv(storage_src); msg_host_t attached_host = MSG_host_by_name(storage_priv_src->hostname); int res = simcall_file_unlink(file_priv->simdata->smx_file, attached_host); @@ -268,14 +262,10 @@ sg_size_t MSG_file_get_size(msg_file_t fd){ * * \param fd : file object that identifies the stream * \param offset : number of bytes to offset from origin - * \param origin : Position used as reference for the offset. It is specified by - * one of the following constants defined in \ exclusively to be used as - * arguments for this function (SEEK_SET = beginning of file, SEEK_CUR = current - * position of the file pointer, SEEK_END = end of file) - * - * \return If successful, the function returns MSG_OK (=0). Otherwise, it returns - * MSG_TASK_CANCELED (=8). - * + * \param origin : Position used as reference for the offset. It is specified by one of the following constants defined + * in \ exclusively to be used as arguments for this function (SEEK_SET = beginning of file, + * SEEK_CUR = current position of the file pointer, SEEK_END = end of file) + * \return If successful, the function returns MSG_OK (=0). Otherwise, it returns MSG_TASK_CANCELED (=8). */ msg_error_t MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin) { @@ -320,8 +310,7 @@ msg_error_t MSG_file_move (msg_file_t fd, const char* fullpath) * \param file : the file to move * \param host : the remote host where the file has to be copied * \param fullpath : the complete path destination on the remote host - * \return If successful, the function returns MSG_OK. Otherwise, it returns - * MSG_TASK_CANCELED. + * \return If successful, the function returns MSG_OK. Otherwise, it returns MSG_TASK_CANCELED. */ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpath) { @@ -368,7 +357,8 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa return MSG_TASK_CANCELED; } - XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname, host_name_dest); + XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname, + host_name_dest); msg_host_t *m_host_list = NULL; m_host_list = (msg_host_t*) calloc(2, sizeof(msg_host_t)); @@ -377,7 +367,8 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa double flops_amount[] = { 0, 0 }; double bytes_amount[] = { 0, (double)read_size, 0, 0 }; - msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL); + msg_task_t task = + MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -395,7 +386,6 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa simcall_file_write(smx_file, read_size, host_dest); simcall_file_close(smx_file, host_dest); return MSG_OK; - } /** @@ -404,8 +394,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa * \param file : the file to move * \param host : the remote host where the file has to be moved * \param fullpath : the complete path destination on the remote host - * \return If successful, the function returns MSG_OK. Otherwise, it returns - * MSG_TASK_CANCELED. + * \return If successful, the function returns MSG_OK. Otherwise, it returns MSG_TASK_CANCELED. */ msg_error_t MSG_file_rmove (msg_file_t file, msg_host_t host, const char* fullpath) { @@ -422,12 +411,11 @@ void __MSG_file_destroy(msg_file_priv_t file) { xbt_free(file->simdata); xbt_free(file); } -/********************************* Storage **************************************/ +/********************************* Storage **************************************/ /** @addtogroup msg_storage_management * \htmlonly \endhtmlonly * (#msg_storage_t) and the functions for managing it. - * */ msg_storage_t __MSG_storage_create(smx_storage_t storage) @@ -447,7 +435,6 @@ void __MSG_storage_destroy(msg_storage_priv_t storage) { free(storage); } - /** \ingroup msg_storage_management * * \brief Returns the name of the #msg_storage_t. @@ -512,7 +499,6 @@ const char *MSG_storage_get_property_value(msg_storage_t storage, const char *na return (char*) xbt_dict_get_or_null(MSG_storage_get_properties(storage), name); } - /** \ingroup msg_storage_management * \brief Finds a msg_storage_t using its name. * \param name the name of a storage @@ -525,10 +511,8 @@ msg_storage_t MSG_storage_get_by_name(const char *name) /** \ingroup msg_storage_management * \brief Returns a dynar containing all the storage elements declared at a given point of time - * */ xbt_dynar_t MSG_storages_as_dynar(void) { - xbt_lib_cursor_t cursor; char *key; void **data; @@ -546,8 +530,7 @@ xbt_dynar_t MSG_storages_as_dynar(void) { /** \ingroup msg_storage_management * * \brief Set the user data of a #msg_storage_t. - * This functions checks whether some data has already been associated to \a storage - or not and attach \a data to \a storage if it is possible. + * This functions attach \a data to \a storage if possible. */ msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data) { @@ -560,8 +543,7 @@ msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data) * * \brief Returns the user data of a #msg_storage_t. * - * This functions checks whether \a storage is a valid pointer or not and returns - the user data associated to \a storage if it is possible. + * This functions checks whether \a storage is a valid pointer and returns its associate user data if possible. */ void *MSG_storage_get_data(msg_storage_t storage) { diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp index 007284d20f..74d330d84e 100644 --- a/src/msg/msg_mailbox.cpp +++ b/src/msg/msg_mailbox.cpp @@ -9,8 +9,7 @@ #include "simgrid/msg.h" #include "msg_private.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_mailbox, msg, - "Logging specific to MSG (mailbox)"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_mailbox, msg, "Logging specific to MSG (mailbox)"); msg_mailbox_t MSG_mailbox_new(const char *alias) { @@ -37,16 +36,13 @@ msg_task_t MSG_mailbox_get_head(msg_mailbox_t mailbox) return (msg_task_t) simcall_comm_get_src_data(comm); } -int -MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, - msg_host_t host) +int MSG_mailbox_get_count_host_waiting_tasks(msg_mailbox_t mailbox, msg_host_t host) { return simcall_rdv_comm_count_by_host(mailbox, host); } msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias) { - msg_mailbox_t mailbox = simcall_rdv_get_by_name(alias); if (!mailbox) @@ -58,11 +54,9 @@ msg_mailbox_t MSG_mailbox_get_by_alias(const char *alias) /** \ingroup msg_mailbox_management * \brief Set the mailbox to receive in asynchronous mode * - * All messages sent to this mailbox will be transferred to - * the receiver without waiting for the receive call. + * All messages sent to this mailbox will be transferred to the receiver without waiting for the receive call. * The receive call will still be necessary to use the received data. - * If there is a need to receive some messages asynchronously, and some not, - * two different mailboxes should be used. + * If there is a need to receive some messages asynchronously, and some not, two different mailboxes should be used. * * \param alias The name of the mailbox */ @@ -71,7 +65,6 @@ void MSG_mailbox_set_async(const char *alias){ simcall_rdv_set_receiver(mailbox, SIMIX_process_self()); XBT_VERB("%s mailbox set to receive eagerly for process %p\n",alias, SIMIX_process_self()); - } /** \ingroup msg_mailbox_management @@ -86,9 +79,7 @@ void MSG_mailbox_set_async(const char *alias){ * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise. */ -msg_error_t -MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t *task, - msg_host_t host, double timeout) +msg_error_t MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t *task, msg_host_t host, double timeout) { return MSG_mailbox_get_task_ext_bounded(mailbox, task, host, timeout, -1.0); } @@ -106,9 +97,8 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t *task, * #MSG_OK if the task was successfully received, * #MSG_HOST_FAILURE, or #MSG_TRANSFER_FAILURE otherwise. */ -msg_error_t -MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task, - msg_host_t host, double timeout, double rate) +msg_error_t MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task, msg_host_t host, double timeout, + double rate) { xbt_ex_t e; msg_error_t ret = MSG_OK; @@ -123,8 +113,7 @@ MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task, xbt_assert(task, "Null pointer for the task storage"); if (*task) - XBT_WARN - ("Asked to write the received task in a non empty struct -- proceeding."); + XBT_WARN("Asked to write the received task in a non empty struct -- proceeding."); /* Try to receive it by calling SIMIX network layer */ TRY { @@ -154,17 +143,13 @@ MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * task, xbt_ex_free(e); } - if (ret != MSG_HOST_FAILURE && - ret != MSG_TRANSFER_FAILURE && - ret != MSG_TIMEOUT) { + if (ret != MSG_HOST_FAILURE && ret != MSG_TRANSFER_FAILURE && ret != MSG_TIMEOUT) { TRACE_msg_task_get_end(start_time, *task); } MSG_RETURN(ret); } -msg_error_t -MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, - double timeout) +msg_error_t MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, double timeout) { msg_error_t ret = MSG_OK; simdata_task_t t_simdata = NULL; @@ -186,7 +171,8 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, xbt_backtrace_display_current(); } else { xbt_assert(t_simdata->isused == 0, - "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)"); + "This task is still being used somewhere else. You cannot send it now. Go fix your code!" + " (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)"); } } @@ -197,7 +183,6 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, t_simdata->comm = NULL; msg_global->sent_msg++; - p_simdata->waiting_task = task; xbt_ex_t e; @@ -205,8 +190,7 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, TRY { smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simix call */ comm = simcall_comm_isend(SIMIX_process_self(), mailbox,t_simdata->bytes_amount, - t_simdata->rate, task, sizeof(void *), - NULL, NULL, NULL, task, 0); + t_simdata->rate, task, sizeof(void *), NULL, NULL, NULL, task, 0); if (TRACE_is_enabled()) simcall_set_category(comm, task->category); t_simdata->comm = comm; @@ -235,10 +219,8 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task, t_simdata->isused = 0; } - p_simdata->waiting_task = NULL; if (call_end) TRACE_msg_task_put_end(); MSG_RETURN(ret); } - diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index ee4720ee1b..b2f710d34c 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -22,8 +22,6 @@ SG_BEGIN_DECL() /**************** datatypes **********************************/ /********************************* Task **************************************/ - - #define MSG_BT(ptr, m) \ do {xbt_ex_t *_xbt_ex_t = xbt_new0(xbt_ex_t, 1); \ /* build the exception */ \ @@ -110,7 +108,6 @@ typedef struct msg_comm { msg_error_t status; /* status of the communication once finished */ } s_msg_comm_t; - /******************************* VM *************************************/ typedef struct dirty_page { double prev_clock; @@ -137,9 +134,7 @@ typedef struct MSG_Global { /*extern MSG_Global_t msg_global;*/ XBT_PUBLIC_DATA(MSG_Global_t) msg_global; - /*************************************************************/ - // FIXME: KILLME # define MSG_RETURN(val) return(val) @@ -183,8 +178,7 @@ XBT_PRIVATE void TRACE_msg_task_put_end(void); /* declaration of instrumentation functions from msg_process_instr.c */ XBT_PRIVATE char *instr_process_id (msg_process_t proc, char *str, int len); XBT_PRIVATE char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len); -XBT_PRIVATE void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host, - msg_host_t new_host); +XBT_PRIVATE void TRACE_msg_process_change_host(msg_process_t process, msg_host_t old_host, msg_host_t new_host); XBT_PRIVATE void TRACE_msg_process_create (const char *process_name, int process_pid, msg_host_t host); XBT_PRIVATE void TRACE_msg_process_destroy (const char *process_name, int process_pid); XBT_PRIVATE void TRACE_msg_process_kill(smx_process_exit_status_t status, msg_process_t process); @@ -196,8 +190,7 @@ XBT_PRIVATE void TRACE_msg_process_sleep_out(msg_process_t process); /* declaration of instrumentation functions from instr_msg_vm.c */ XBT_PRIVATE char *instr_vm_id(msg_vm_t vm, char *str, int len); XBT_PRIVATE char *instr_vm_id_2(const char *vm_name, char *str, int len); -XBT_PRIVATE void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host, - msg_host_t new_host); +XBT_PRIVATE void TRACE_msg_vm_change_host(msg_vm_t vm, msg_host_t old_host, msg_host_t new_host); XBT_PRIVATE void TRACE_msg_vm_start(msg_vm_t vm); XBT_PRIVATE void TRACE_msg_vm_create(const char *vm_name, msg_host_t host); XBT_PRIVATE void TRACE_msg_vm_kill(msg_vm_t process); diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index ab3bc9bbe0..5ce8704be2 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -10,19 +10,19 @@ #include "src/simix/smx_process_private.h" #include "src/simix/smx_private.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, - "Logging specific to MSG (process)"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_process, msg, "Logging specific to MSG (process)"); /** @addtogroup m_process_management * \htmlonly \endhtmlonly * - * Processes (#msg_process_t) are independent agents that can do stuff on their own. They are in charge of executing your code interacting with the simulated world. + * Processes (#msg_process_t) are independent agents that can do stuff on their own. They are in charge of executing + * your code interacting with the simulated world. * A process may be defined as a code with some private data. - * Processes must be located on hosts (#msg_host_t), and they exchange data by sending tasks (#msg_task_t) that are similar to envelops containing data. + * Processes must be located on hosts (#msg_host_t), and they exchange data by sending tasks (#msg_task_t) + * that are similar to envelops containing data. */ /******************************** Process ************************************/ - /** * \brief Cleans the MSG data of a process. * \param smx_proc a SIMIX process @@ -36,8 +36,7 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc) /* avoid a SIMIX request if this function is called by the process itself */ msg_proc = (simdata_process_t) SIMIX_process_self_get_data(smx_proc); SIMIX_process_self_set_data(smx_proc, NULL); - } - else { + } else { msg_proc = (simdata_process_t) simcall_process_get_data(smx_proc); simcall_process_set_data(smx_proc, NULL); } @@ -54,17 +53,12 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc) } /* This function creates a MSG process. It has the prototype enforced by SIMIX_function_register_process_create */ -smx_process_t MSG_process_create_from_SIMIX(const char *name, - xbt_main_func_t code, void *data, - const char *hostname, double kill_time, - int argc, char **argv, - xbt_dict_t properties, int auto_restart, - smx_process_t parent_process) +smx_process_t MSG_process_create_from_SIMIX(const char *name, xbt_main_func_t code, void *data, const char *hostname, + double kill_time, int argc, char **argv, xbt_dict_t properties, + int auto_restart, smx_process_t parent_process) { msg_host_t host = MSG_host_by_name(hostname); - msg_process_t p = MSG_process_create_with_environment(name, code, data, - host, argc, argv, - properties); + msg_process_t p = MSG_process_create_with_environment(name, code, data, host, argc, argv, properties); if (p) { MSG_process_set_kill_time(p,kill_time); MSG_process_auto_restart_set(p,auto_restart); @@ -75,36 +69,28 @@ smx_process_t MSG_process_create_from_SIMIX(const char *name, /** \ingroup m_process_management * \brief Creates and runs a new #msg_process_t. * - * Does exactly the same as #MSG_process_create_with_arguments but without - providing standard arguments (\a argc, \a argv, \a start_time, \a kill_time). + * Does exactly the same as #MSG_process_create_with_arguments but without providing standard arguments + * (\a argc, \a argv, \a start_time, \a kill_time). * \sa MSG_process_create_with_arguments */ -msg_process_t MSG_process_create(const char *name, - xbt_main_func_t code, void *data, - msg_host_t host) +msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host) { - return MSG_process_create_with_environment(name, code, data, host, 0, - NULL, NULL); + return MSG_process_create_with_environment(name, code, data, host, 0, NULL, NULL); } /** \ingroup m_process_management * \brief Creates and runs a new #msg_process_t. - * A constructor for #msg_process_t taking four arguments and returning the - * corresponding object. The structure (and the corresponding thread) is - * created, and put in the list of ready process. - * \param name a name for the object. It is for user-level information - and can be NULL. - * \param code is a function describing the behavior of the process. It - should then only use functions described in \ref - m_process_management (to create a new #msg_process_t for example), - in \ref m_host_management (only the read-only functions i.e. whose - name contains the word get), in \ref m_task_management (to create - or destroy some #msg_task_t for example) and in \ref - msg_task_usage (to handle file transfers and task processing). - * \param data a pointer to any data one may want to attach to the new - object. It is for user-level information and can be NULL. It can - be retrieved with the function \ref MSG_process_get_data. + * A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and + * the corresponding thread) is created, and put in the list of ready process. + * \param name a name for the object. It is for user-level information and can be NULL. + * \param code is a function describing the behavior of the process. It should then only use functions described + * in \ref m_process_management (to create a new #msg_process_t for example), + in \ref m_host_management (only the read-only functions i.e. whose name contains the word get), + in \ref m_task_management (to create or destroy some #msg_task_t for example) and + in \ref msg_task_usage (to handle file transfers and task processing). + * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and + * can be NULL. It can be retrieved with the function \ref MSG_process_get_data. * \param host the location where the new process is executed. * \param argc first argument passed to \a code * \param argv second argument passed to \a code @@ -112,45 +98,35 @@ msg_process_t MSG_process_create(const char *name, * \return The new corresponding object. */ -msg_process_t MSG_process_create_with_arguments(const char *name, - xbt_main_func_t code, - void *data, msg_host_t host, +msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv) { - return MSG_process_create_with_environment(name, code, data, host, - argc, argv, NULL); + return MSG_process_create_with_environment(name, code, data, host, argc, argv, NULL); } /** \ingroup m_process_management * \brief Creates and runs a new #msg_process_t. - * A constructor for #msg_process_t taking four arguments and returning the - * corresponding object. The structure (and the corresponding thread) is - * created, and put in the list of ready process. - * \param name a name for the object. It is for user-level information - and can be NULL. - * \param code is a function describing the behavior of the process. It - should then only use functions described in \ref - m_process_management (to create a new #msg_process_t for example), - in \ref m_host_management (only the read-only functions i.e. whose - name contains the word get), in \ref m_task_management (to create - or destroy some #msg_task_t for example) and in \ref - msg_task_usage (to handle file transfers and task processing). - * \param data a pointer to any data one may want to attach to the new - object. It is for user-level information and can be NULL. It can - be retrieved with the function \ref MSG_process_get_data. + * A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and + * the corresponding thread) is created, and put in the list of ready process. + * \param name a name for the object. It is for user-level information and can be NULL. + * \param code is a function describing the behavior of the process. It should then only use functions described + * in \ref m_process_management (to create a new #msg_process_t for example), + in \ref m_host_management (only the read-only functions i.e. whose name contains the word get), + in \ref m_task_management (to create or destroy some #msg_task_t for example) and + in \ref msg_task_usage (to handle file transfers and task processing). + * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and + * can be NULL. It can be retrieved with the function \ref MSG_process_get_data. * \param host the location where the new process is executed. * \param argc first argument passed to \a code - * \param argv second argument passed to \a code. WARNING, these strings are freed by the SimGrid kernel when the process exits, so they cannot be static nor shared between several processes. + * \param argv second argument passed to \a code. WARNING, these strings are freed by the SimGrid kernel when the + * process exits, so they cannot be static nor shared between several processes. * \param properties list a properties defined for this process * \see msg_process_t * \return The new corresponding object. */ -msg_process_t MSG_process_create_with_environment(const char *name, - xbt_main_func_t code, - void *data, msg_host_t host, - int argc, char **argv, - xbt_dict_t properties) +msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_func_t code, void *data, msg_host_t host, + int argc, char **argv, xbt_dict_t properties) { xbt_assert(code != NULL && host != NULL, "Invalid parameters: host and code params must not be NULL"); simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1); @@ -167,8 +143,7 @@ msg_process_t MSG_process_create_with_environment(const char *name, /* Let's create the process: SIMIX may decide to start it right now, * even before returning the flow control to us */ - process = simcall_process_create(name, code, simdata, sg_host_get_name(host), -1, - argc, argv, properties,0); + process = simcall_process_create(name, code, simdata, sg_host_get_name(host), -1, argc, argv, properties,0); if (!process) { /* Undo everything we have just changed */ @@ -181,8 +156,7 @@ msg_process_t MSG_process_create_with_environment(const char *name, return process; } -static -int MSG_maestro(int argc, char** argv) +static int MSG_maestro(int argc, char** argv) { int res = MSG_main(); return res; @@ -190,15 +164,12 @@ int MSG_maestro(int argc, char** argv) /* Become a process in the simulation * - * Currently this can only be called by the main thread (once) and only work - * with some thread factories (currently ThreadContextFactory). + * Currently this can only be called by the main thread (once) and only work with some thread factories + * (currently ThreadContextFactory). * - * In the future, it might be extended in order to attach other threads created - * by a third party library. + * In the future, it might be extended in order to attach other threads created by a third party library. */ -msg_process_t MSG_process_attach( - const char *name, void *data, - msg_host_t host, xbt_dict_t properties) +msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties) { xbt_assert(host != NULL, "Invalid parameters: host and code params must not be NULL"); simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1); @@ -213,8 +184,7 @@ msg_process_t MSG_process_attach( simdata->data = data; simdata->last_errno = MSG_OK; - /* Let's create the process: SIMIX may decide to start it right now, - * even before returning the flow control to us */ + /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */ process = SIMIX_process_attach(name, simdata, sg_host_get_name(host), properties, NULL); if (!process) xbt_die("Could not attach"); @@ -225,9 +195,8 @@ msg_process_t MSG_process_attach( /** Detach a process attached with `MSG_process_attach()` * * This is called when the current process has finished its job. - * Used in the main thread, it waits for the simulation to finish before - * returning. When it returns, the other simulated processes and the maestro - * are destroyed. + * Used in the main thread, it waits for the simulation to finish before returning. When it returns, the other + * simulated processes and the maestro are destroyed. */ void MSG_process_detach(void) { @@ -246,10 +215,7 @@ void MSG_process_kill(msg_process_t process) // if (p_simdata->waiting_task && p_simdata->waiting_task->simdata->comm) { // simcall_comm_cancel(p_simdata->waiting_task->simdata->comm); // } - simcall_process_kill(process); - - return; } /** @@ -266,8 +232,8 @@ msg_error_t MSG_process_join(msg_process_t process, double timeout){ /** \ingroup m_process_management * \brief Migrates a process to another location. * - * This function checks whether \a process and \a host are valid pointers - and change the value of the #msg_host_t on which \a process is running. + * This function checks whether \a process and \a host are valid pointers and change the value of the #msg_host_t on + * which \a process is running. */ msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host) { @@ -282,8 +248,7 @@ msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host) /** \ingroup m_process_management * \brief Returns the user data of a process. * - * This function checks whether \a process is a valid pointer or not - and returns the user data associated to this process. + * This function checks whether \a process is a valid pointer and returns the user data associated to this process. */ void* MSG_process_get_data(msg_process_t process) { @@ -300,36 +265,30 @@ void* MSG_process_get_data(msg_process_t process) /** \ingroup m_process_management * \brief Sets the user data of a process. * - * This function checks whether \a process is a valid pointer or not - and sets the user data associated to this process. + * This function checks whether \a process is a valid pointer and sets the user data associated to this process. */ msg_error_t MSG_process_set_data(msg_process_t process, void *data) { xbt_assert(process != NULL, "Invalid parameter: first parameter must not be NULL!"); - simdata_process_t simdata = - (simdata_process_t) simcall_process_get_data(process); + simdata_process_t simdata = (simdata_process_t) simcall_process_get_data(process); simdata->data = data; return MSG_OK; } /** \ingroup m_process_management - * \brief Sets a cleanup function to be called to free the userdata of a - * process when a process is destroyed. - * \param data_cleanup a cleanup function for the userdata of a process, - * or NULL to call no function + * \brief Sets a cleanup function to be called to free the userdata of a process when a process is destroyed. + * \param data_cleanup a cleanup function for the userdata of a process, or NULL to call no function */ XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) { - msg_global->process_data_cleanup = data_cleanup; } /** \ingroup m_process_management * \brief Return the location on which a process is running. * \param process a process (NULL means the current one) - * \return the msg_host_t corresponding to the location on which \a - * process is running. + * \return the msg_host_t corresponding to the location on which \a process is running. */ msg_host_t MSG_process_get_host(msg_process_t process) { @@ -347,8 +306,8 @@ msg_host_t MSG_process_get_host(msg_process_t process) * * \brief Return a #msg_process_t given its PID. * - * This function search in the list of all the created msg_process_t for a msg_process_t - whose PID is equal to \a PID. If no host is found, \c NULL is returned. + * This function search in the list of all the created msg_process_t for a msg_process_t whose PID is equal to \a PID. + * If no host is found, \c NULL is returned. Note that the PID are uniq in the whole simulation, not only on a given host. */ msg_process_t MSG_process_from_PID(int PID) @@ -360,8 +319,8 @@ msg_process_t MSG_process_from_PID(int PID) xbt_dynar_t MSG_processes_as_dynar(void) { return SIMIX_processes_as_dynar(); } -/** @brief Return the current number MSG processes. - */ + +/** @brief Return the current number MSG processes. */ int MSG_process_get_number(void) { return SIMIX_process_count(); @@ -382,8 +341,7 @@ msg_error_t MSG_process_set_kill_time(msg_process_t process, double kill_time) /** \ingroup m_process_management * \brief Returns the process ID of \a process. * - * This function checks whether \a process is a valid pointer or not - and return its PID (or 0 in case of problem). + * This function checks whether \a process is a valid pointer and return its PID (or 0 in case of problem). */ int MSG_process_get_PID(msg_process_t process) { @@ -398,27 +356,23 @@ int MSG_process_get_PID(msg_process_t process) /** \ingroup m_process_management * \brief Returns the process ID of the parent of \a process. * - * This function checks whether \a process is a valid pointer or not - and return its PID. Returns -1 if the process has not been created by - any other process. + * This function checks whether \a process is a valid pointer and return its PID. + * Returns -1 if the process has not been created by any other process. */ int MSG_process_get_PPID(msg_process_t process) { xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); - return simcall_process_get_PPID(process); } /** \ingroup m_process_management * \brief Return the name of a process. * - * This function checks whether \a process is a valid pointer or not - and return its name. + * This function checks whether \a process is a valid pointer and return its name. */ const char *MSG_process_get_name(msg_process_t process) { xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); - return simcall_process_get_name(process); } @@ -429,8 +383,7 @@ const char *MSG_process_get_name(msg_process_t process) * \param name a property name * \return value of a property (or NULL if the property is not set) */ -const char *MSG_process_get_property_value(msg_process_t process, - const char *name) +const char *MSG_process_get_property_value(msg_process_t process, const char *name) { return (char*) xbt_dict_get_or_null(MSG_process_get_properties(process), name); } @@ -443,9 +396,7 @@ const char *MSG_process_get_property_value(msg_process_t process, xbt_dict_t MSG_process_get_properties(msg_process_t process) { xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); - return simcall_process_get_properties(process); - } /** \ingroup m_process_management @@ -461,8 +412,7 @@ int MSG_process_self_PID(void) /** \ingroup m_process_management * \brief Return the PPID of the current process. * - * This function returns the PID of the parent of the currently - * running #msg_process_t. + * This function returns the PID of the parent of the currently running #msg_process_t. */ int MSG_process_self_PPID(void) { @@ -482,8 +432,7 @@ msg_process_t MSG_process_self(void) /** \ingroup m_process_management * \brief Suspend the process. * - * This function suspends the process by suspending the task on which - * it was waiting for the completion. + * This function suspends the process by suspending the task on which it was waiting for the completion. */ msg_error_t MSG_process_suspend(msg_process_t process) { @@ -497,8 +446,7 @@ msg_error_t MSG_process_suspend(msg_process_t process) /** \ingroup m_process_management * \brief Resume a suspended process. * - * This function resumes a suspended process by resuming the task on - * which it was waiting for the completion. + * This function resumes a suspended process by resuming the task on which it was waiting for the completion. */ msg_error_t MSG_process_resume(msg_process_t process) { @@ -512,8 +460,7 @@ msg_error_t MSG_process_resume(msg_process_t process) /** \ingroup m_process_management * \brief Returns true if the process is suspended . * - * This checks whether a process is suspended or not by inspecting the - * task on which it was waiting for the completion. + * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion. */ int MSG_process_is_suspended(msg_process_t process) { @@ -536,8 +483,7 @@ void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data) { /** * \ingroup m_process_management * \brief Sets the "auto-restart" flag of the process. - * If the flag is set to 1, the process will be automatically restarted when - * its host comes back up. + * If the flag is set to 1, the process will be automatically restarted when its host comes back up. */ XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_restart) { simcall_process_auto_restart_set(process,auto_restart); diff --git a/src/msg/msg_synchro.cpp b/src/msg/msg_synchro.cpp index 6547de0507..d88e01f655 100644 --- a/src/msg/msg_synchro.cpp +++ b/src/msg/msg_synchro.cpp @@ -9,17 +9,13 @@ #include "xbt/synchro_core.h" #include "xbt/log.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_synchro, msg, - "Logging specific to MSG (synchro)"); - +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_synchro, msg, "Logging specific to MSG (synchro)"); /** @addtogroup msg_synchro * * @{ */ -/********************************* Host **************************************/ - /** @brief creates a semaphore object of the given initial capacity */ msg_sem_t MSG_sem_init(int initial_value) { return simcall_sem_init(initial_value); @@ -29,6 +25,7 @@ msg_sem_t MSG_sem_init(int initial_value) { void MSG_sem_acquire(msg_sem_t sem) { simcall_sem_acquire(sem); } + /** @brief locks on a semaphore object up until the provided timeout expires */ msg_error_t MSG_sem_acquire_timeout(msg_sem_t sem, double timeout) { xbt_ex_t e; @@ -45,10 +42,12 @@ msg_error_t MSG_sem_acquire_timeout(msg_sem_t sem, double timeout) { } return res; } + /** @brief releases the semaphore object */ void MSG_sem_release(msg_sem_t sem) { simcall_sem_release(sem); } + void MSG_sem_get_capacity(msg_sem_t sem) { simcall_sem_get_capacity(sem); } @@ -56,6 +55,7 @@ void MSG_sem_get_capacity(msg_sem_t sem) { void MSG_sem_destroy(msg_sem_t sem) { SIMIX_sem_destroy(sem); } + /** @brief returns a boolean indicating if this semaphore would block at this very specific time * * Note that the returned value may be wrong right after the function call, when you try to use it... @@ -82,5 +82,4 @@ int MSG_barrier_wait(msg_bar_t bar) { else return 0; } - /**@}*/ diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 245564538c..8c3a95f0c3 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -11,40 +11,30 @@ /** @addtogroup m_task_management * - * - * Since most scheduling algorithms rely on a concept of task - * that can be either computed locally or - * transferred on another processor, it seems to be the - * right level of abstraction for our purposes. A task - * may then be defined by a computing amount, a - * message size and some private data. + * Since most scheduling algorithms rely on a concept of task that can be either computed locally or + * transferred on another processor, it seems to be the right level of abstraction for our purposes. + * A task may then be defined by a computing amount, a message size and + * some private data. */ -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, - "Logging specific to MSG (task)"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)"); /********************************* Task **************************************/ /** \ingroup m_task_management * \brief Creates a new #msg_task_t. * - * A constructor for #msg_task_t taking four arguments and returning the - corresponding object. - * \param name a name for the object. It is for user-level information - and can be NULL. - * \param flop_amount a value of the processing amount (in flop) - needed to process this new task. If 0, then it cannot be executed with - MSG_task_execute(). This value has to be >=0. - * \param message_size a value of the amount of data (in bytes) needed to - transfer this new task. If 0, then it cannot be transfered with - MSG_task_send() and MSG_task_recv(). This value has to be >=0. - * \param data a pointer to any data may want to attach to the new - object. It is for user-level information and can be NULL. It can - be retrieved with the function \ref MSG_task_get_data. + * A constructor for #msg_task_t taking four arguments and returning the corresponding object. + * \param name a name for the object. It is for user-level information and can be NULL. + * \param flop_amount a value of the processing amount (in flop) needed to process this new task. + * If 0, then it cannot be executed with MSG_task_execute(). This value has to be >=0. + * \param message_size a value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot + * be transfered with MSG_task_send() and MSG_task_recv(). This value has to be >=0. + * \param data a pointer to any data may want to attach to the new object. It is for user-level information and can + * be NULL. It can be retrieved with the function \ref MSG_task_get_data. * \see msg_task_t * \return The new corresponding object. */ -msg_task_t MSG_task_create(const char *name, double flop_amount, - double message_size, void *data) +msg_task_t MSG_task_create(const char *name, double flop_amount, double message_size, void *data) { msg_task_t task = xbt_new(s_msg_task_t, 1); simdata_task_t simdata = xbt_new(s_simdata_task_t, 1); @@ -80,14 +70,12 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, /** \ingroup m_task_management * \brief Creates a new #msg_task_t (a parallel one....). * - * A constructor for #msg_task_t taking six arguments and returning the - corresponding object. - * \param name a name for the object. It is for user-level information - and can be NULL. + * A constructor for #msg_task_t taking six arguments and returning the corresponding object. + * \param name a name for the object. It is for user-level information and can be NULL. * \param host_nb the number of hosts implied in the parallel task. * \param host_list an array of \p host_nb msg_host_t. * \param flops_amount an array of \p host_nb doubles. - * flops_amount[i] is the total number of operations that have to be performed on host_list[i]. + * flops_amount[i] is the total number of operations that have to be performed on host_list[i]. * \param bytes_amount an array of \p host_nb* \p host_nb doubles. * \param data a pointer to any data may want to attach to the new object. * It is for user-level information and can be NULL. @@ -95,11 +83,8 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, * \see msg_task_t * \return The new corresponding object. */ -msg_task_t -MSG_parallel_task_create(const char *name, int host_nb, - const msg_host_t * host_list, - double *flops_amount, - double *bytes_amount, void *data) +msg_task_t MSG_parallel_task_create(const char *name, int host_nb, const msg_host_t * host_list, + double *flops_amount, double *bytes_amount, void *data) { msg_task_t task = MSG_task_create(name, 0, 0, data); simdata_task_t simdata = task->simdata; @@ -121,26 +106,19 @@ MSG_parallel_task_create(const char *name, int host_nb, /** \ingroup m_task_management * \brief Creates a new #msg_gpu_task_t. - * A constructor for #msg_gpu_task_t taking four arguments and returning - a pointer to the new created GPU task. - - * \param name a name for the object. It is for user-level information - and can be NULL. - - * \param flops_amount a value of the processing amount (in flop) - needed to process this new task. If 0, then it cannot be executed with - MSG_gpu_task_execute(). This value has to be >=0. + * A constructor for #msg_gpu_task_t taking four arguments and returning a pointer to the new created GPU task. + * \param name a name for the object. It is for user-level information and can be NULL. + * \param flops_amount a value of the processing amount (in flop)needed to process this new task. If 0, then it cannot + * be executed with MSG_gpu_task_execute(). This value has to be >=0. * \param dispatch_latency time in seconds to load this task on the GPU - - * \param collect_latency time in seconds to transfer result from the GPU - back to the CPU (host) when done + * \param collect_latency time in seconds to transfer result from the GPU back to the CPU (host) when done * \see msg_gpu_task_t * \return The new corresponding object. */ -msg_gpu_task_t MSG_gpu_task_create(const char *name, double flops_amount, - double dispatch_latency, double collect_latency) +msg_gpu_task_t MSG_gpu_task_create(const char *name, double flops_amount, double dispatch_latency, + double collect_latency) { msg_gpu_task_t task = xbt_new(s_msg_gpu_task_t, 1); simdata_gpu_task_t simdata = xbt_new(s_simdata_gpu_task_t, 1); @@ -154,7 +132,6 @@ msg_gpu_task_t MSG_gpu_task_create(const char *name, double flops_amount, simdata->collect_latency = collect_latency; /* TRACE_msg_gpu_task_create(task); FIXME*/ - return task; } /*************** End GPU ***************/ @@ -162,26 +139,22 @@ msg_gpu_task_t MSG_gpu_task_create(const char *name, double flops_amount, /** \ingroup m_task_management * \brief Return the user data of a #msg_task_t. * - * This function checks whether \a task is a valid pointer or not and return - the user data associated to \a task if it is possible. + * This function checks whether \a task is a valid pointer and return the user data associated to \a task if possible. */ void *MSG_task_get_data(msg_task_t task) { xbt_assert((task != NULL), "Invalid parameter"); - return (task->data); } /** \ingroup m_task_management * \brief Sets the user data of a #msg_task_t. * - * This function allows to associate a new pointer to - the user data associated of \a task. + * This function allows to associate a new pointer to the user data associated of \a task. */ void MSG_task_set_data(msg_task_t task, void *data) { xbt_assert((task != NULL), "Invalid parameter"); - task->data = data; } @@ -189,15 +162,13 @@ void MSG_task_set_data(msg_task_t task, void *data) * \brief Sets a function to be called when a task has just been copied. * \param callback a callback function */ -void MSG_task_set_copy_callback(void (*callback) - (msg_task_t task, msg_process_t sender, msg_process_t receiver)) { +void MSG_task_set_copy_callback(void (*callback) (msg_task_t task, msg_process_t sender, msg_process_t receiver)) { msg_global->task_copy_callback = callback; if (callback) { SIMIX_comm_set_copy_data_callback(MSG_comm_copy_data_from_SIMIX); - } - else { + } else { SIMIX_comm_set_copy_data_callback(SIMIX_comm_copy_pointer_callback); } } @@ -249,13 +220,12 @@ void MSG_task_set_name(msg_task_t task, const char *name) /** \ingroup m_task_management * \brief Destroy a #msg_task_t. * - * Destructor for #msg_task_t. Note that you should free user data, if any, \b - * before calling this function. + * Destructor for #msg_task_t. Note that you should free user data, if any, \b before calling this function. * * Only the process that owns the task can destroy it. * The owner changes after a successful send. - * If a task is successfully sent, the receiver becomes the owner and is - * supposed to destroy it. The sender should not use it anymore. + * If a task is successfully sent, the receiver becomes the owner and is supposed to destroy it. The sender should not + * use it anymore. * If the task failed to be sent, the sender remains the owner of the task. */ msg_error_t MSG_task_destroy(msg_task_t task) @@ -287,11 +257,9 @@ msg_error_t MSG_task_destroy(msg_task_t task) return MSG_OK; } - /** \ingroup m_task_usage * \brief Cancel a #msg_task_t. - * \param task the task to cancel. If it was executed or transfered, it - stops the process that were working on it. + * \param task the task to cancel. If it was executed or transfered, it stops the process that were working on it. */ msg_error_t MSG_task_cancel(msg_task_t task) { @@ -313,11 +281,10 @@ msg_error_t MSG_task_cancel(msg_task_t task) /** \ingroup m_task_management * \brief Returns the remaining amount of flops needed to execute a task #msg_task_t. * - * Once a task has been processed, this amount is set to 0. If you want, you - * can reset this value with #MSG_task_set_flops_amount before restarting the task. + * Once a task has been processed, this amount is set to 0. If you want, you can reset this value with + * #MSG_task_set_flops_amount before restarting the task. */ double MSG_task_get_flops_amount(msg_task_t task) { - if (task->simdata->compute) { return simcall_execution_get_remains(task->simdata->compute); } else { @@ -325,16 +292,13 @@ double MSG_task_get_flops_amount(msg_task_t task) { } } - /** \ingroup m_task_management * \brief set the computation amount needed to process a task #msg_task_t. * * \warning If the computation is ongoing (already started and not finished), - * it is not modified by this call. Moreover, after its completion, the ongoing - * execution with set the flops_amount to zero, overriding any value set during - * the execution. + * it is not modified by this call. Moreover, after its completion, the ongoing execution with set the flops_amount to + * zero, overriding any value set during the execution. */ - void MSG_task_set_flops_amount(msg_task_t task, double flops_amount) { task->simdata->flops_amount = flops_amount; @@ -343,78 +307,59 @@ void MSG_task_set_flops_amount(msg_task_t task, double flops_amount) /** \ingroup m_task_management * \brief set the amount data attached with a task #msg_task_t. * - * \warning If the transfer is ongoing (already started and not finished), - * it is not modified by this call. + * \warning If the transfer is ongoing (already started and not finished), it is not modified by this call. */ - void MSG_task_set_bytes_amount(msg_task_t task, double data_size) { task->simdata->bytes_amount = data_size; } - /** \ingroup m_task_management * \brief Returns the total amount received by a task #msg_task_t. * If the communication does not exist it will return 0. - * So, if the communication has FINISHED or FAILED it returns - * zero. + * So, if the communication has FINISHED or FAILED it returns zero. */ double MSG_task_get_remaining_communication(msg_task_t task) { - xbt_assert((task != NULL) - && (task->simdata != NULL), "Invalid parameter"); - XBT_DEBUG("calling simcall_communication_get_remains(%p)", - task->simdata->comm); + xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter"); + XBT_DEBUG("calling simcall_communication_get_remains(%p)", task->simdata->comm); return simcall_comm_get_remains(task->simdata->comm); } #ifdef HAVE_LATENCY_BOUND_TRACKING /** \ingroup m_task_management * \brief Return 1 if communication task is limited by latency, 0 otherwise - * */ int MSG_task_is_latency_bounded(msg_task_t task) { - xbt_assert((task != NULL) - && (task->simdata != NULL), "Invalid parameter"); - XBT_DEBUG("calling simcall_communication_is_latency_bounded(%p)", - task->simdata->comm); + xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter"); + XBT_DEBUG("calling simcall_communication_is_latency_bounded(%p)", task->simdata->comm); return simcall_comm_is_latency_bounded(task->simdata->comm); } #endif /** \ingroup m_task_management * \brief Returns the size of the data attached to a task #msg_task_t. - * */ double MSG_task_get_bytes_amount(msg_task_t task) { - xbt_assert((task != NULL) - && (task->simdata != NULL), "Invalid parameter"); - + xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter"); return task->simdata->bytes_amount; } - - /** \ingroup m_task_management - * \brief Changes the priority of a computation task. This priority doesn't affect - * the transfer rate. A priority of 2 will make a task receive two times more - * cpu power than the other ones. - * + * \brief Changes the priority of a computation task. This priority doesn't affect the transfer rate. A priority of 2 + * will make a task receive two times more cpu power than the other ones. */ void MSG_task_set_priority(msg_task_t task, double priority) { - xbt_assert((task != NULL) - && (task->simdata != NULL), "Invalid parameter"); - + xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter"); task->simdata->priority = 1 / priority; if (task->simdata->compute) simcall_execution_set_priority(task->simdata->compute, task->simdata->priority); } - /** \ingroup m_task_management * \brief Changes the maximum CPU utilization of a computation task. * Unit is flops/s. @@ -431,23 +376,19 @@ void MSG_task_set_bound(msg_task_t task, double bound) task->simdata->bound = bound; if (task->simdata->compute) - simcall_execution_set_bound(task->simdata->compute, - task->simdata->bound); + simcall_execution_set_bound(task->simdata->compute, task->simdata->bound); } - /** \ingroup m_task_management * \brief Changes the CPU affinity of a computation task. * - * When pinning the given task to the first CPU core of the given host, use - * 0x01 for the mask value. Each bit of the mask value corresponds to each CPU - * core. See taskset(1) on Linux. + * When pinning the given task to the first CPU core of the given host, use 0x01 for the mask value. Each bit of the + * mask value corresponds to each CPU core. See taskset(1) on Linux. * * \param task a target task * \param host the host having a multi-core CPU * \param mask the bit mask of a new CPU affinity setting for the task * - * * Usage: * 0. Define a host with multiple cores. * \ @@ -463,17 +404,13 @@ void MSG_task_set_bound(msg_task_t task, double bound) * * See examples/msg/cloud/multicore.c for more information. * - * * Note: * 1. The current code does not allow an affinity of a task to multiple cores. - * The mask value 0x03 (i.e., a given task will be executed on the first core - * or the second core) is not allowed. The mask value 0x01 or 0x02 works. See - * cpu_cas01.c for details. - * - * 2. It is recommended to first compare simulation results in both the Lazy - * and Full calculation modes (using --cfg=cpu/optim:Full or not). Fix - * cpu_cas01.c if you find wrong results in the Lazy mode. + * The mask value 0x03 (i.e., a given task will be executed on the first core or the second core) is not allowed. + * The mask value 0x01 or 0x02 works. See cpu_cas01.c for details. * + * 2. It is recommended to first compare simulation results in both the Lazy and Full calculation modes + * (using --cfg=cpu/optim:Full or not). Fix cpu_cas01.c if you find wrong results in the Lazy mode. */ void MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask) { @@ -482,22 +419,19 @@ void MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask) if (mask == 0) { /* 0 means clear */ - { /* We need remove_ext() not throwing exception. */ void *ret = xbt_dict_get_or_null_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(msg_host_t)); if (ret != NULL) xbt_dict_remove_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(host)); - } } else xbt_dict_set_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(host), (void *)(uintptr_t) mask, NULL); - /* We set affinity data of this task. If the task is being executed, we - * actually change the affinity setting of the task. Otherwise, this change - * will be applied when the task is executed. */ - + /* We set affinity data of this task. If the task is being executed, we actually change the affinity setting of the + * task. Otherwise, this change will be applied when the task is executed. */ if (!task->simdata->compute) { /* task is not yet executed */ - XBT_INFO("set affinity(0x%04lx@%s) for %s (not active now)", mask, MSG_host_get_name(host), MSG_task_get_name(task)); + XBT_INFO("set affinity(0x%04lx@%s) for %s (not active now)", mask, MSG_host_get_name(host), + MSG_task_get_name(task)); return; } @@ -506,14 +440,16 @@ void MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask) msg_host_t host_now = compute->execution.host; // simix_private.h is necessary if (host_now != host) { /* task is not yet executed on this host */ - XBT_INFO("set affinity(0x%04lx@%s) for %s (not active now)", mask, MSG_host_get_name(host), MSG_task_get_name(task)); + XBT_INFO("set affinity(0x%04lx@%s) for %s (not active now)", mask, MSG_host_get_name(host), + MSG_task_get_name(task)); return; } /* task is being executed on this host. so change the affinity now */ { /* check it works. remove me if it works. */ - xbt_assert((unsigned long)(uintptr_t) xbt_dict_get_or_null_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(msg_host_t)) == mask); + xbt_assert((unsigned long)(uintptr_t) xbt_dict_get_or_null_ext(task->simdata->affinity_mask_db, + (char *) host, sizeof(msg_host_t)) == mask); } XBT_INFO("set affinity(0x%04lx@%s) for %s", mask, MSG_host_get_name(host), MSG_task_get_name(task)); -- 2.20.1