Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a doc error about actors (Tutorial_algorithms)
[simgrid.git] / src / smpi / include / smpi_comm.hpp
1 /* Copyright (c) 2010-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_COMM_HPP_INCLUDED
7 #define SMPI_COMM_HPP_INCLUDED
8
9 #include <list>
10 #include <string>
11 #include "smpi_errhandler.hpp"
12 #include "smpi_keyvals.hpp"
13 #include "smpi_group.hpp"
14 #include "smpi_topo.hpp"
15
16 namespace simgrid{
17 namespace smpi{
18
19 class Comm : public F2C, public Keyval{
20   MPI_Group group_;
21   SMPI_Topo_type topoType_;
22   MPI_Topology topo_; // to be replaced by an union
23   int refcount_;
24   MPI_Comm leaders_comm_; // inter-node communicator
25   MPI_Comm intra_comm_;   // intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
26   // use an intracomm stored in the process data instead
27   int* leaders_map_; // who is the leader of each process
28   int is_uniform_;
29   int* non_uniform_map_;        // set if smp nodes have a different number of processes allocated
30   int is_blocked_;              // are ranks allocated on the same smp node contiguous ?
31   int is_smp_comm_;             // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursivity
32   std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
33   std::string name_;
34   MPI_Info info_;
35   int id_;
36   MPI_Errhandler errhandler_;
37
38 public:
39   static std::unordered_map<int, smpi_key_elem> keyvals_;
40   static int keyval_id_;
41
42   Comm() = default;
43   Comm(MPI_Group group, MPI_Topology topo, int smp = 0, int id=MPI_UNDEFINED);
44   int dup(MPI_Comm* newcomm);
45   int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
46   MPI_Group group();
47   MPI_Topology topo() { return topo_; }
48   int size();
49   int rank();
50   int id();
51   void get_name(char* name, int* len);
52   void set_name(const char* name);
53   MPI_Info info();
54   void set_info( MPI_Info info);
55   MPI_Errhandler errhandler();
56   void set_errhandler( MPI_Errhandler errhandler);
57   void set_leaders_comm(MPI_Comm leaders);
58   void set_intra_comm(MPI_Comm leaders) { intra_comm_ = leaders; };
59   int* get_non_uniform_map();
60   int* get_leaders_map();
61   MPI_Comm get_leaders_comm();
62   MPI_Comm get_intra_comm();
63   MPI_Comm find_intra_comm(int* leader);
64   int is_uniform();
65   int is_blocked();
66   int is_smp_comm();
67   MPI_Comm split(int color, int key);
68   void cleanup_smp();
69   void ref();
70   static void unref(MPI_Comm comm);
71   static void destroy(MPI_Comm comm);
72   void init_smp();
73
74   static void free_f(int id);
75   static Comm* f2c(int);
76
77   static int keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval,
78                            void* extra_state);
79   static int keyval_free(int* keyval);
80   static void keyval_cleanup();
81
82   void add_rma_win(MPI_Win win);
83   void remove_rma_win(MPI_Win win);
84   void finish_rma_calls();
85   MPI_Comm split_type(int type, int key, MPI_Info info);
86 };
87
88 } // namespace smpi
89 } // namespace simgrid
90
91 #endif