Logo AND Algorithmique Numérique Distribuée

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