1 /* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef MSG_PRIVATE_HPP
7 #define MSG_PRIVATE_HPP
9 #include "simgrid/msg.h"
11 #include "src/kernel/activity/CommImpl.hpp"
12 #include "src/kernel/activity/ExecImpl.hpp"
14 /**************** datatypes **********************************/
15 /********************************* Task **************************************/
17 struct s_simdata_task_t {
20 /* parallel tasks only */
22 delete[] flops_parallel_amount;
23 delete[] bytes_parallel_amount;
26 void setNotUsed() { this->isused = false; }
28 simgrid::kernel::activity::ExecImplPtr compute = nullptr; /* SIMIX modeling of computation */
29 simgrid::kernel::activity::CommImplPtr comm = nullptr; /* SIMIX modeling of communication */
30 double bytes_amount = 0.0; /* Data size */
31 double flops_amount = 0.0; /* Computation size */
32 msg_process_t sender = nullptr;
33 msg_process_t receiver = nullptr;
34 msg_host_t source = nullptr;
36 double priority = 1.0;
37 double bound = 0.0; /* Capping for CPU resource, or 0 for no capping */
38 double rate = -1; /* Capping for network resource, or -1 for no capping*/
40 bool isused = false; /* Indicates whether the task is used in SIMIX currently */
41 int host_nb = 0; /* ==0 if sequential task; parallel task if not */
42 /******* Parallel Tasks Only !!!! *******/
43 sg_host_t* host_list = nullptr;
44 double* flops_parallel_amount = nullptr;
45 double* bytes_parallel_amount = nullptr;
48 void reportMultipleUse() const;
51 /******************************* Process *************************************/
58 msg_task_t task_sent; /* task sent (NULL for the receiver) */
59 msg_task_t* task_received; /* where the task will be received (NULL for the sender) */
60 smx_activity_t s_comm; /* SIMIX communication object encapsulated (the same for both processes) */
61 msg_error_t status = MSG_OK; /* status of the communication once finished */
62 Comm(msg_task_t sent, msg_task_t* received, smx_activity_t comm)
63 : task_sent(sent), task_received(received), s_comm(std::move(comm))
70 /************************** Global variables ********************************/
71 struct s_MSG_Global_t {
72 bool debug_multiple_use; /* whether we want an error message when reusing the same Task for 2 things */
73 std::atomic_int_fast32_t sent_msg; /* Total amount of messages sent during the simulation */
74 void (*task_copy_callback)(msg_task_t task, msg_process_t src, msg_process_t dst);
75 void_f_pvoid_t process_data_cleanup;
77 typedef s_MSG_Global_t* MSG_Global_t;
79 XBT_PUBLIC_DATA MSG_Global_t msg_global;
81 /*************************************************************/
82 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
84 /********** Tracing **********/
85 /* declaration of instrumentation functions from msg_task_instr.c */
86 XBT_PRIVATE void TRACE_msg_set_task_category(msg_task_t task, const char* category);
87 XBT_PRIVATE void TRACE_msg_task_create(msg_task_t task);
88 XBT_PRIVATE void TRACE_msg_task_execute_start(msg_task_t task);
89 XBT_PRIVATE void TRACE_msg_task_execute_end(msg_task_t task);
90 XBT_PRIVATE void TRACE_msg_task_destroy(msg_task_t task);
91 XBT_PRIVATE void TRACE_msg_task_get_end(msg_task_t task);
92 XBT_PRIVATE void TRACE_msg_task_get_start();
93 XBT_PRIVATE void TRACE_msg_task_put_start(msg_task_t task);
94 XBT_PRIVATE void TRACE_msg_task_put_end();
97 inline void s_simdata_task_t::setUsed()
100 this->reportMultipleUse();