Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / src / smpi / include / smpi_actor.hpp
1 /* Copyright (c) 2009-2022. 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
13 namespace simgrid {
14 namespace smpi {
15
16 class ActorExt {
17   double simulated_ = 0 /* Used to time with simulated_start/elapsed */;
18   s4u::Mailbox* mailbox_;
19   s4u::Mailbox* mailbox_small_;
20   s4u::MutexPtr mailboxes_mutex_;
21   xbt_os_timer_t timer_;
22   MPI_Comm comm_self_   = MPI_COMM_NULL;
23   MPI_Comm comm_intra_  = MPI_COMM_NULL;
24   MPI_Comm* comm_world_ = nullptr;
25   SmpiProcessState state_;
26   int sampling_ = 0; /* inside an SMPI_SAMPLE_ block? */
27   std::string instance_id_;
28   bool replaying_ = false; /* is the process replaying a trace */
29   smpi_trace_call_location_t trace_call_loc_;
30   s4u::Actor* actor_                             = nullptr;
31   smpi_privatization_region_t privatized_region_ = nullptr;
32 #ifdef __linux__
33   int optind_                                     = 0; /*for getopt replacement */
34 #else
35   int optind_                                     = 1; /*for getopt replacement */
36 #endif
37   std::string tracing_category_                  = "";
38   MPI_Info info_env_;
39   void* bsend_buffer_    = nullptr;
40   int bsend_buffer_size_ = 0;
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
48 public:
49   static simgrid::xbt::Extension<simgrid::s4u::Actor, ActorExt> EXTENSION_ID;
50
51   explicit ActorExt(s4u::Actor* actor);
52   ActorExt(const ActorExt&) = delete;
53   ActorExt& operator=(const ActorExt&) = delete;
54   ~ActorExt();
55   void finalize();
56   int finalized() const;
57   int initializing() const;
58   int initialized() const;
59   void mark_as_initialized();
60   void set_replaying(bool value);
61   bool replaying() const;
62   std::string get_instance_id() const { return instance_id_;}
63   void set_tracing_category(const std::string& category) { tracing_category_ = category; }
64   const std::string& get_tracing_category() const { return tracing_category_; }
65   smpi_trace_call_location_t* call_location();
66   void set_privatized_region(smpi_privatization_region_t region);
67   smpi_privatization_region_t privatized_region() const;
68   s4u::Mailbox* mailbox() const { return mailbox_; }
69   s4u::Mailbox* mailbox_small() const { return mailbox_small_; }
70   s4u::MutexPtr mailboxes_mutex() const;
71 #if HAVE_PAPI
72   int papi_event_set() const;
73   papi_counter_t& papi_counters();
74 #endif
75   xbt_os_timer_t timer();
76   void simulated_start();
77   double simulated_elapsed() const;
78   MPI_Comm comm_world() const;
79   bool comm_self_is_set() const { return (comm_self_ != MPI_COMM_NULL); };
80   MPI_Comm comm_self();
81   MPI_Comm comm_intra();
82   void set_comm_intra(MPI_Comm comm);
83   void set_sampling(int s);
84   int sampling() const;
85   static void init();
86   s4u::ActorPtr get_actor();
87   int get_optind() const;
88   void set_optind(int optind);
89   MPI_Info info_env();
90   void bsend_buffer(void** buf, int* size);
91   int set_bsend_buffer(void* buf, int size);
92 };
93
94 } // namespace smpi
95 } // namespace simgrid
96
97 #endif