Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Anonymize unused parameters.
[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 #include "src/kernel/activity/CommImpl.hpp"
11 #include "src/kernel/activity/ExecImpl.hpp"
12 #include <simgrid/modelchecker.h>
13
14 /**************** datatypes **********************************/
15 namespace simgrid {
16 namespace msg {
17 class Task {
18   std::string name_             = "";
19   std::string tracing_category_ = "";
20   void* userdata_               = nullptr;
21   long long int id_;
22
23 public:
24   explicit Task(std::string name, double flops_amount, double bytes_amount, void* data)
25       : name_(std::move(name)), userdata_(data), flops_amount(flops_amount), bytes_amount(bytes_amount)
26   {
27     static std::atomic_ullong counter{0};
28     id_ = counter++;
29     if (MC_is_active())
30       MC_ignore_heap(&(id_), sizeof(id_));
31   }
32   Task(const Task&) = delete;
33   Task& operator=(const Task&) = delete;
34   ~Task();
35   void set_used();
36   void set_not_used() { this->is_used = false; }
37
38   const std::string& get_name() const { return name_; }
39   const char* get_cname() { return name_.c_str(); }
40   void set_name(const char* new_name) { name_ = std::string(new_name); }
41   void set_tracing_category(const char* category) { tracing_category_ = category ? std::string(category) : ""; }
42   const std::string& get_tracing_category() { return tracing_category_; }
43   bool has_tracing_category() { return not tracing_category_.empty(); }
44   void* get_user_data() { return userdata_; }
45   void set_user_data(void* data) { userdata_ = data; }
46   long long int get_id() { return id_; }
47
48   kernel::activity::ExecImplPtr compute          = nullptr; /* SIMIX modeling of computation */
49   s4u::CommPtr comm                              = nullptr; /* S4U modeling of communication */
50   double flops_amount                            = 0.0;     /* Computation size */
51   double bytes_amount                            = 0.0;     /* Data size */
52   msg_process_t sender                           = nullptr;
53   msg_process_t receiver                         = nullptr;
54
55   double priority = 1.0;
56   double bound    = 0.0; /* Capping for CPU resource, or 0 for no capping */
57   double rate     = -1;  /* Capping for network resource, or -1 for no capping*/
58
59   bool is_used = false; /* Indicates whether the task is used in SIMIX currently */
60   int host_nb = 0;     /* ==0 if sequential task; parallel task if not */
61   /*******  Parallel Tasks Only !!!! *******/
62   sg_host_t* host_list          = nullptr;
63   double* flops_parallel_amount = nullptr;
64   double* bytes_parallel_amount = nullptr;
65
66 private:
67   void report_multiple_use() const;
68 };
69
70 class Comm {
71 public:
72   msg_task_t task_sent;        /* task sent (NULL for the receiver) */
73   msg_task_t* task_received;   /* where the task will be received (NULL for the sender) */
74   s4u::CommPtr s_comm;         /* SIMIX communication object encapsulated (the same for both processes) */
75   msg_error_t status = MSG_OK; /* status of the communication once finished */
76   Comm(msg_task_t sent, msg_task_t* received, s4u::CommPtr comm)
77       : task_sent(sent), task_received(received), s_comm(std::move(comm))
78   {
79   }
80 };
81
82 } // namespace msg
83 } // namespace simgrid
84
85 /************************** Global variables ********************************/
86 struct s_MSG_Global_t {
87   bool debug_multiple_use;           /* whether we want an error message when reusing the same Task for 2 things */
88   std::atomic_int_fast32_t sent_msg; /* Total amount of messages sent during the simulation */
89   void (*task_copy_callback)(msg_task_t task, msg_process_t src, msg_process_t dst);
90   void_f_pvoid_t process_data_cleanup;
91 };
92 typedef s_MSG_Global_t* MSG_Global_t;
93
94 XBT_PUBLIC_DATA MSG_Global_t msg_global;
95
96 /*************************************************************/
97 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
98
99 /********** Tracing **********/
100 /* declaration of instrumentation functions from msg_task_instr.c */
101 XBT_PRIVATE void TRACE_msg_task_put_start(msg_task_t task);
102
103
104 #endif