Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill unused field.
[simgrid.git] / src / msg / msg_private.hpp
1 /* Copyright (c) 2004-2018. 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 /**************** datatypes **********************************/
15 /********************************* Task **************************************/
16
17 struct s_simdata_task_t {
18   ~s_simdata_task_t()
19   {
20     /* parallel tasks only */
21     delete[] this->host_list;
22     /* flops_parallel_amount and bytes_parallel_amount are automatically deleted in ~L07Action */
23   }
24   void setUsed();
25   void setNotUsed() { this->isused = false; }
26
27   simgrid::kernel::activity::ExecImplPtr compute = nullptr; /* SIMIX modeling of computation */
28   simgrid::kernel::activity::CommImplPtr comm    = nullptr; /* SIMIX modeling of communication */
29   double bytes_amount                            = 0.0;     /* Data size */
30   double flops_amount                            = 0.0;     /* Computation size */
31   msg_process_t sender                           = nullptr;
32   msg_process_t receiver                         = nullptr;
33   msg_host_t source                              = nullptr;
34
35   double priority = 1.0;
36   double bound    = 0.0; /* Capping for CPU resource, or 0 for no capping */
37   double rate     = -1;  /* Capping for network resource, or -1 for no capping*/
38
39   bool isused = false; /* Indicates whether the task is used in SIMIX currently */
40   int host_nb = 0;     /* ==0 if sequential task; parallel task if not */
41   /*******  Parallel Tasks Only !!!! *******/
42   sg_host_t* host_list          = nullptr;
43   double* flops_parallel_amount = nullptr;
44   double* bytes_parallel_amount = nullptr;
45
46 private:
47   void reportMultipleUse() const;
48 };
49
50 /******************************* Process *************************************/
51
52 namespace simgrid {
53 namespace msg {
54 class ActorExt {
55 public:
56   explicit ActorExt(void* d) : data(d) {}
57   void* data         = nullptr; /* user data */
58 };
59
60 class Comm {
61 public:
62   msg_task_t task_sent;        /* task sent (NULL for the receiver) */
63   msg_task_t* task_received;   /* where the task will be received (NULL for the sender) */
64   smx_activity_t s_comm;       /* SIMIX communication object encapsulated (the same for both processes) */
65   msg_error_t status = MSG_OK; /* status of the communication once finished */
66   Comm(msg_task_t sent, msg_task_t* received, smx_activity_t comm)
67       : task_sent(sent), task_received(received), s_comm(std::move(comm))
68   {
69   }
70 };
71 }
72 }
73
74 /************************** Global variables ********************************/
75 struct s_MSG_Global_t {
76   bool debug_multiple_use;           /* whether we want an error message when reusing the same Task for 2 things */
77   std::atomic_int_fast32_t sent_msg; /* Total amount of messages sent during the simulation */
78   void (*task_copy_callback)(msg_task_t task, msg_process_t src, msg_process_t dst);
79   void_f_pvoid_t process_data_cleanup;
80 };
81 typedef s_MSG_Global_t* MSG_Global_t;
82
83 XBT_PUBLIC_DATA MSG_Global_t msg_global;
84
85 /*************************************************************/
86 XBT_PRIVATE void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_proc);
87 XBT_PRIVATE smx_actor_t MSG_process_create_from_SIMIX(std::string name, simgrid::simix::ActorCode code, void* data,
88                                                       sg_host_t host,
89                                                       std::unordered_map<std::string, std::string>* properties,
90                                                       smx_actor_t parent_process);
91 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(smx_activity_t comm, void* buff, size_t buff_size);
92
93 /********** Tracing **********/
94 /* declaration of instrumentation functions from msg_task_instr.c */
95 XBT_PRIVATE void TRACE_msg_set_task_category(msg_task_t task, const char* category);
96 XBT_PRIVATE void TRACE_msg_task_create(msg_task_t task);
97 XBT_PRIVATE void TRACE_msg_task_execute_start(msg_task_t task);
98 XBT_PRIVATE void TRACE_msg_task_execute_end(msg_task_t task);
99 XBT_PRIVATE void TRACE_msg_task_destroy(msg_task_t task);
100 XBT_PRIVATE void TRACE_msg_task_get_end(msg_task_t task);
101 XBT_PRIVATE void TRACE_msg_task_get_start();
102 XBT_PRIVATE void TRACE_msg_task_put_start(msg_task_t task);
103 XBT_PRIVATE void TRACE_msg_task_put_end();
104
105
106 inline void s_simdata_task_t::setUsed()
107 {
108   if (this->isused)
109     this->reportMultipleUse();
110   this->isused = true;
111 }
112
113 #endif