1 /* Copyright (c) 2009-2023. The SimGrid Team. All rights reserved. */
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. */
10 #include "simgrid/s4u/Mailbox.hpp"
11 #include "src/instr/instr_smpi.hpp"
12 #include "xbt/xbt_os_time.h"
13 #include <string_view>
15 namespace simgrid::smpi {
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 smpi_trace_call_location_t trace_call_loc_;
31 s4u::Actor* actor_ = nullptr;
32 smpi_privatization_region_t privatized_region_ = nullptr;
34 int optind_ = 0; /*for getopt replacement */
36 int optind_ = 1; /*for getopt replacement */
38 std::string tracing_category_ = "";
40 void* bsend_buffer_ = nullptr;
41 int bsend_buffer_size_ = 0;
44 /** Contains hardware data as read by PAPI **/
46 papi_counter_t papi_counter_data_;
50 static simgrid::xbt::Extension<simgrid::s4u::Actor, ActorExt> EXTENSION_ID;
52 explicit ActorExt(s4u::Actor* actor);
53 ActorExt(const ActorExt&) = delete;
54 ActorExt& operator=(const ActorExt&) = delete;
57 int finalized() const;
58 int initializing() const;
59 int initialized() const;
60 int finalizing() const;
61 void mark_as_initialized();
62 void mark_as_finalizing();
63 void set_replaying(bool value);
64 bool replaying() const;
65 std::string get_instance_id() const { return instance_id_;}
66 void set_tracing_category(std::string_view category) { tracing_category_ = category; }
67 const std::string& get_tracing_category() const { return tracing_category_; }
68 smpi_trace_call_location_t* call_location();
69 void set_privatized_region(smpi_privatization_region_t region);
70 smpi_privatization_region_t privatized_region() const;
71 s4u::Mailbox* mailbox();
72 s4u::Mailbox* mailbox_small();
73 s4u::MutexPtr mailboxes_mutex() const;
75 int papi_event_set() const;
76 papi_counter_t& papi_counters();
78 xbt_os_timer_t timer();
79 void simulated_start();
80 double simulated_elapsed() const;
81 MPI_Comm comm_world() const;
82 bool comm_self_is_set() const { return (comm_self_ != MPI_COMM_NULL); };
84 MPI_Comm comm_intra();
85 void set_comm_intra(MPI_Comm comm);
86 void set_sampling(int s);
89 s4u::ActorPtr get_actor();
90 int get_optind() const;
91 void set_optind(int optind);
93 void bsend_buffer(void** buf, int* size);
94 int set_bsend_buffer(void* buf, int size);
97 } // namespace simgrid::smpi