Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
847d59525c4eb6760e1b042c219dfde04eb122a9
[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 /**************** datatypes **********************************/
15 namespace simgrid {
16 namespace msg {
17 class Task {
18 public:
19   ~Task();
20   explicit Task(double flops_amount, double bytes_amount) : flops_amount(flops_amount), bytes_amount(bytes_amount) {}
21   void set_used();
22   void set_not_used() { this->is_used = false; }
23
24   kernel::activity::ExecImplPtr compute          = nullptr; /* SIMIX modeling of computation */
25   s4u::CommPtr comm                              = nullptr; /* S4U modeling of communication */
26   double flops_amount                            = 0.0;     /* Computation size */
27   double bytes_amount                            = 0.0;     /* Data size */
28   msg_process_t sender                           = nullptr;
29   msg_process_t receiver                         = nullptr;
30
31   double priority = 1.0;
32   double bound    = 0.0; /* Capping for CPU resource, or 0 for no capping */
33   double rate     = -1;  /* Capping for network resource, or -1 for no capping*/
34
35   bool is_used = false; /* Indicates whether the task is used in SIMIX currently */
36   int host_nb = 0;     /* ==0 if sequential task; parallel task if not */
37   /*******  Parallel Tasks Only !!!! *******/
38   sg_host_t* host_list          = nullptr;
39   double* flops_parallel_amount = nullptr;
40   double* bytes_parallel_amount = nullptr;
41
42 private:
43   void report_multiple_use() const;
44 };
45
46 class Comm {
47 public:
48   msg_task_t task_sent;        /* task sent (NULL for the receiver) */
49   msg_task_t* task_received;   /* where the task will be received (NULL for the sender) */
50   s4u::CommPtr s_comm;         /* SIMIX communication object encapsulated (the same for both processes) */
51   msg_error_t status = MSG_OK; /* status of the communication once finished */
52   Comm(msg_task_t sent, msg_task_t* received, s4u::CommPtr comm)
53       : task_sent(sent), task_received(received), s_comm(std::move(comm))
54   {
55   }
56 };
57
58 } // namespace msg
59 } // namespace simgrid
60
61 /************************** Global variables ********************************/
62 struct s_MSG_Global_t {
63   bool debug_multiple_use;           /* whether we want an error message when reusing the same Task for 2 things */
64   std::atomic_int_fast32_t sent_msg; /* Total amount of messages sent during the simulation */
65   void (*task_copy_callback)(msg_task_t task, msg_process_t src, msg_process_t dst);
66   void_f_pvoid_t process_data_cleanup;
67 };
68 typedef s_MSG_Global_t* MSG_Global_t;
69
70 XBT_PUBLIC_DATA MSG_Global_t msg_global;
71
72 /*************************************************************/
73 XBT_PRIVATE void MSG_comm_copy_data_from_SIMIX(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
74
75 /********** Tracing **********/
76 /* declaration of instrumentation functions from msg_task_instr.c */
77 XBT_PRIVATE void TRACE_msg_task_put_start(msg_task_t task);
78
79
80 #endif