Logo AND Algorithmique Numérique Distribuée

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