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 static long long int msg_task_max_counter = 0;
16 /**************** datatypes **********************************/
20 std::string name_ = "";
21 std::string tracing_category_ = "";
22 void* userdata_ = nullptr;
23 long long int counter_;
27 explicit Task(std::string name, double flops_amount, double bytes_amount, void* data)
28 : name_(std::move(name)), userdata_(data), flops_amount(flops_amount), bytes_amount(bytes_amount)
30 counter_ = msg_task_max_counter++;
33 void set_not_used() { this->is_used = false; }
35 const std::string& get_name() const { return name_; }
36 const char* get_cname() { return name_.c_str(); }
37 void set_name(const char* new_name) { name_ = std::string(new_name); }
38 void set_tracing_category(const char* category) { tracing_category_ = category ? std::string(category) : ""; }
39 const std::string& get_tracing_category() { return tracing_category_; }
40 bool has_tracing_category() { return not tracing_category_.empty(); }
41 void* get_user_data() { return userdata_; }
42 void set_user_data(void* data) { userdata_ = data; }
43 long long int get_counter() { return counter_; }
45 kernel::activity::ExecImplPtr compute = nullptr; /* SIMIX modeling of computation */
46 s4u::CommPtr comm = nullptr; /* S4U modeling of communication */
47 double flops_amount = 0.0; /* Computation size */
48 double bytes_amount = 0.0; /* Data size */
49 msg_process_t sender = nullptr;
50 msg_process_t receiver = nullptr;
52 double priority = 1.0;
53 double bound = 0.0; /* Capping for CPU resource, or 0 for no capping */
54 double rate = -1; /* Capping for network resource, or -1 for no capping*/
56 bool is_used = false; /* Indicates whether the task is used in SIMIX currently */
57 int host_nb = 0; /* ==0 if sequential task; parallel task if not */
58 /******* Parallel Tasks Only !!!! *******/
59 sg_host_t* host_list = nullptr;
60 double* flops_parallel_amount = nullptr;
61 double* bytes_parallel_amount = nullptr;
64 void report_multiple_use() const;
69 msg_task_t task_sent; /* task sent (NULL for the receiver) */
70 msg_task_t* task_received; /* where the task will be received (NULL for the sender) */
71 s4u::CommPtr s_comm; /* SIMIX communication object encapsulated (the same for both processes) */
72 msg_error_t status = MSG_OK; /* status of the communication once finished */
73 Comm(msg_task_t sent, msg_task_t* received, s4u::CommPtr comm)
74 : task_sent(sent), task_received(received), s_comm(std::move(comm))
80 } // namespace simgrid
82 /************************** Global variables ********************************/
83 struct s_MSG_Global_t {
84 bool debug_multiple_use; /* whether we want an error message when reusing the same Task for 2 things */
85 std::atomic_int_fast32_t sent_msg; /* Total amount of messages sent during the simulation */
86 void (*task_copy_callback)(msg_task_t task, msg_process_t src, msg_process_t dst);
87 void_f_pvoid_t process_data_cleanup;
89 typedef s_MSG_Global_t* MSG_Global_t;
91 XBT_PUBLIC_DATA MSG_Global_t msg_global;
93 /*************************************************************/
94 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
96 /********** Tracing **********/
97 /* declaration of instrumentation functions from msg_task_instr.c */
98 XBT_PRIVATE void TRACE_msg_task_put_start(msg_task_t task);