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 **********************************/
18 std::string name_ = ""; /**< @brief task name if any */
21 explicit Task(std::string name, double flops_amount, double bytes_amount)
22 : name_(std::move(name)), flops_amount(flops_amount), bytes_amount(bytes_amount)
26 void set_not_used() { this->is_used = false; }
28 const std::string& get_name() const { return name_; }
29 const char* get_cname() { return name_.c_str(); }
30 void set_name(const char* new_name) { name_ = std::string(new_name); }
32 kernel::activity::ExecImplPtr compute = nullptr; /* SIMIX modeling of computation */
33 s4u::CommPtr comm = nullptr; /* S4U modeling of communication */
34 double flops_amount = 0.0; /* Computation size */
35 double bytes_amount = 0.0; /* Data size */
36 msg_process_t sender = nullptr;
37 msg_process_t receiver = nullptr;
39 double priority = 1.0;
40 double bound = 0.0; /* Capping for CPU resource, or 0 for no capping */
41 double rate = -1; /* Capping for network resource, or -1 for no capping*/
43 bool is_used = false; /* Indicates whether the task is used in SIMIX currently */
44 int host_nb = 0; /* ==0 if sequential task; parallel task if not */
45 /******* Parallel Tasks Only !!!! *******/
46 sg_host_t* host_list = nullptr;
47 double* flops_parallel_amount = nullptr;
48 double* bytes_parallel_amount = nullptr;
51 void report_multiple_use() const;
56 msg_task_t task_sent; /* task sent (NULL for the receiver) */
57 msg_task_t* task_received; /* where the task will be received (NULL for the sender) */
58 s4u::CommPtr s_comm; /* SIMIX communication object encapsulated (the same for both processes) */
59 msg_error_t status = MSG_OK; /* status of the communication once finished */
60 Comm(msg_task_t sent, msg_task_t* received, s4u::CommPtr comm)
61 : task_sent(sent), task_received(received), s_comm(std::move(comm))
67 } // namespace simgrid
69 /************************** Global variables ********************************/
70 struct s_MSG_Global_t {
71 bool debug_multiple_use; /* whether we want an error message when reusing the same Task for 2 things */
72 std::atomic_int_fast32_t sent_msg; /* Total amount of messages sent during the simulation */
73 void (*task_copy_callback)(msg_task_t task, msg_process_t src, msg_process_t dst);
74 void_f_pvoid_t process_data_cleanup;
76 typedef s_MSG_Global_t* MSG_Global_t;
78 XBT_PUBLIC_DATA MSG_Global_t msg_global;
80 /*************************************************************/
81 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
83 /********** Tracing **********/
84 /* declaration of instrumentation functions from msg_task_instr.c */
85 XBT_PRIVATE void TRACE_msg_task_put_start(msg_task_t task);