static void send_mrsg_data (msg_task_t msg) { char mailbox[MAILBOX_ALIAS_SIZE]; double data_size; size_t my_id; mrsg_task_info_t ti; my_id = get_mrsg_worker_id (MSG_host_self ()); sprintf (mailbox, TASK_MRSG_MAILBOX, get_mrsg_worker_id (MSG_task_get_source (msg)), MSG_process_get_PID (MSG_task_get_sender (msg))); if (mrsg_message_is (msg, SMS_GET_MRSG_CHUNK)) { MSG_task_dsend (MSG_task_create ("DATA-C", 0.0, config_mrsg.mrsg_chunk_size, NULL), mailbox, NULL); } else if (mrsg_message_is (msg, SMS_GET_INTER_MRSG_PAIRS)) { ti = (mrsg_task_info_t) MSG_task_get_data (msg); data_size = job_mrsg.map_output[my_id][ti->mrsg_tid] - ti->map_output_copied[my_id]; MSG_task_dsend (MSG_task_create ("DATA-IP", 0.0, data_size, NULL), mailbox, NULL); } MSG_task_destroy (msg); }
/** * Tracker main function * @param argc number of arguments * @param argv arguments */ int tracker(int argc, char *argv[]) { int i; RngStream stream = (RngStream) MSG_host_get_property_value(MSG_host_self(), "stream"); //Checking arguments xbt_assert(argc == 2, "Wrong number of arguments for the tracker."); //Retrieving end time double deadline = atof(argv[1]); xbt_assert(deadline > 0, "Wrong deadline supplied"); //Building peers array xbt_dynar_t peers_list = xbt_dynar_new(sizeof(int), NULL); XBT_INFO("Tracker launched."); msg_comm_t comm_received = NULL; msg_task_t task_received = NULL; while (MSG_get_clock() < deadline) { if (comm_received == NULL) { comm_received = MSG_task_irecv(&task_received, TRACKER_MAILBOX); } if (MSG_comm_test(comm_received)) { //Check for correct status if (MSG_comm_get_status(comm_received) == MSG_OK) { //Retrieve the data sent by the peer. tracker_task_data_t data = MSG_task_get_data(task_received); //Add the peer to our peer list. if (!is_in_list(peers_list, data->peer_id)) { xbt_dynar_push_as(peers_list, int, data->peer_id); } //Sending peers to the peer int next_peer; int peers_length = xbt_dynar_length(peers_list); for (i = 0; i < MAXIMUM_PAIRS && i < peers_length; i++) { do { next_peer = xbt_dynar_get_as(peers_list, RngStream_RandInt(stream, 0, peers_length - 1), int); } while (is_in_list(data->peers, next_peer)); xbt_dynar_push_as(data->peers, int, next_peer); } //setting the interval data->interval = TRACKER_QUERY_INTERVAL; //sending the task back to the peer. MSG_task_dsend(task_received, data->mailbox, task_free); //destroy the communication. } MSG_comm_destroy(comm_received); comm_received = NULL; task_received = NULL; } else {
static void broadcast_matrix(xbt_matrix_t M, int num_nodes, int *nodes) { int node; char node_mbox[MAILBOX_NAME_SIZE]; msg_task_t task; xbt_matrix_t sM; for(node=0; node < num_nodes; node++) { snprintf(node_mbox, MAILBOX_NAME_SIZE - 1, "%d", nodes[node]); sM = xbt_matrix_new_sub(M, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, 0, 0, NULL); task = MSG_task_create("sub-matrix", 100, 100, sM); MSG_task_dsend(task, node_mbox, task_cleanup); XBT_DEBUG("sub-matrix sent to %s", node_mbox); } }
/** \ingroup msg_task_usage * \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 * <a href="http://lists.gforge.inria.fr/pipermail/simgrid-user/2011-November/002649.html">this thread</a> * 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 * (if NULL, no function will be called) * \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) { task->simdata->rate = maxrate; MSG_task_dsend(task, alias, cleanup); }