Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a0ee3b2307c7c5d6c6082dbddd6c1b787d5413b9
[simgrid.git] / src / smpi / include / smpi_actor.hpp
1 /* Copyright (c) 2009-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 SMPI_ACTOR_HPP
7 #define SMPI_ACTOR_HPP
8
9 #include "private.hpp"
10 #include "simgrid/s4u/Mailbox.hpp"
11 #include "src/instr/instr_smpi.hpp"
12 #include "xbt/synchro.h"
13
14 namespace simgrid {
15 namespace smpi {
16
17 class ActorExt {
18   double simulated_ = 0 /* Used to time with simulated_start/elapsed */;
19   s4u::Mailbox* mailbox_;
20   s4u::Mailbox* mailbox_small_;
21   s4u::MutexPtr mailboxes_mutex_;
22   xbt_os_timer_t timer_;
23   MPI_Comm comm_self_   = MPI_COMM_NULL;
24   MPI_Comm comm_intra_  = MPI_COMM_NULL;
25   MPI_Comm* comm_world_ = nullptr;
26   SmpiProcessState state_;
27   int sampling_ = 0; /* inside an SMPI_SAMPLE_ block? */
28   std::string instance_id_;
29   bool replaying_ = false; /* is the process replaying a trace */
30   s4u::Barrier* finalization_barrier_;
31   smpi_trace_call_location_t trace_call_loc_;
32   s4u::ActorPtr actor_                           = nullptr;
33   smpi_privatization_region_t privatized_region_ = nullptr;
34 #ifdef __linux__
35   int optind_                                     = 0; /*for getopt replacement */
36 #else
37   int optind_                                     = 1; /*for getopt replacement */
38 #endif
39   std::string tracing_category_                  = "";
40   MPI_Info info_env_;
41
42 #if HAVE_PAPI
43   /** Contains hardware data as read by PAPI **/
44   int papi_event_set_;
45   papi_counter_t papi_counter_data_;
46 #endif
47 public:
48   explicit ActorExt(s4u::ActorPtr actor, s4u::Barrier* barrier);
49   ActorExt(const ActorExt&) = delete;
50   ActorExt& operator=(const ActorExt&) = delete;
51   ~ActorExt();
52   void set_data(const std::string& instance_id);
53   void finalize();
54   int finalized();
55   int initializing();
56   int initialized();
57   void mark_as_initialized();
58   void set_replaying(bool value);
59   bool replaying();
60   void set_tracing_category(const std::string& category) { tracing_category_ = category; }
61   const std::string& get_tracing_category() { return tracing_category_; }
62   smpi_trace_call_location_t* call_location();
63   void set_privatized_region(smpi_privatization_region_t region);
64   smpi_privatization_region_t privatized_region();
65   s4u::Mailbox* mailbox() { return mailbox_; }
66   s4u::Mailbox* mailbox_small() { return mailbox_small_; }
67   s4u::MutexPtr mailboxes_mutex();
68 #if HAVE_PAPI
69   int papi_event_set();
70   papi_counter_t& papi_counters();
71 #endif
72   xbt_os_timer_t timer();
73   void simulated_start();
74   double simulated_elapsed();
75   MPI_Comm comm_world();
76   MPI_Comm comm_self();
77   MPI_Comm comm_intra();
78   void set_comm_intra(MPI_Comm comm);
79   void set_sampling(int s);
80   int sampling();
81   static void init();
82   s4u::ActorPtr get_actor();
83   int get_optind();
84   void set_optind(int optind);
85   MPI_Info info_env();
86 };
87
88 } // namespace smpi
89 } // namespace simgrid
90
91 #endif