Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mv counter from msg_task_t to simgrid::msg::Task
[simgrid.git] / src / msg / msg_private.hpp
1 /* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #ifndef MSG_PRIVATE_HPP
7 #define MSG_PRIVATE_HPP
8
9 #include "simgrid/msg.h"
10
11 #include "src/kernel/activity/CommImpl.hpp"
12 #include "src/kernel/activity/ExecImpl.hpp"
13
14 static long long int msg_task_max_counter = 0;
15
16 /**************** datatypes **********************************/
17 namespace simgrid {
18 namespace msg {
19 class Task {
20   std::string name_             = "";
21   std::string tracing_category_ = "";
22   void* userdata_               = nullptr;
23   long long int counter_;
24
25 public:
26   ~Task();
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)
29   {
30     counter_ = msg_task_max_counter++;
31   }
32   void set_used();
33   void set_not_used() { this->is_used = false; }
34
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_; }
44
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;
51
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*/
55
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;
62
63 private:
64   void report_multiple_use() const;
65 };
66
67 class Comm {
68 public:
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))
75   {
76   }
77 };
78
79 } // namespace msg
80 } // namespace simgrid
81
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;
88 };
89 typedef s_MSG_Global_t* MSG_Global_t;
90
91 XBT_PUBLIC_DATA MSG_Global_t msg_global;
92
93 /*************************************************************/
94 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
95
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);
99
100
101 #endif