1 /* Copyright (c) 2010-2020. 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. */
6 #ifndef SMPI_COMM_HPP_INCLUDED
7 #define SMPI_COMM_HPP_INCLUDED
11 #include "smpi_errhandler.hpp"
12 #include "smpi_keyvals.hpp"
13 #include "smpi_group.hpp"
14 #include "smpi_topo.hpp"
19 class Comm : public F2C, public Keyval{
22 SMPI_Topo_type topoType_ = MPI_INVALID_TOPO;
23 MPI_Topology topo_; // to be replaced by an union
25 MPI_Comm leaders_comm_ = MPI_COMM_NULL; // inter-node communicator
26 MPI_Comm intra_comm_ = MPI_COMM_NULL; // intra-node communicator. For MPI_COMM_WORLD this can't be used, as var is
27 // global. Use an intracomm stored in the process data instead
28 int* leaders_map_ = nullptr; // who is the leader of each process
30 int* non_uniform_map_ = nullptr; // set if smp nodes have a different number of processes allocated
31 int is_blocked_ = 0; // are ranks allocated on the same smp node contiguous ?
32 bool is_smp_comm_ = false; // set to false in case this is already an intra-comm or a leader-comm to avoid
34 std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
36 MPI_Info info_ = MPI_INFO_NULL;
38 MPI_Errhandler errhandler_ = MPI_ERRORS_ARE_FATAL;
41 static std::unordered_map<int, smpi_key_elem> keyvals_;
42 static int keyval_id_;
45 Comm(MPI_Group group, MPI_Topology topo, bool smp = false, int id = MPI_UNDEFINED);
46 int dup(MPI_Comm* newcomm);
47 int dup_with_info(MPI_Info info, MPI_Comm* newcomm);
49 MPI_Topology topo() { return topo_; }
53 void get_name(char* name, int* len);
54 void set_name(const char* name);
56 void set_info( MPI_Info info);
57 MPI_Errhandler errhandler();
58 void set_errhandler( MPI_Errhandler errhandler);
59 void set_leaders_comm(MPI_Comm leaders);
60 void set_intra_comm(MPI_Comm leaders) { intra_comm_ = leaders; };
61 int* get_non_uniform_map();
62 int* get_leaders_map();
63 MPI_Comm get_leaders_comm();
64 MPI_Comm get_intra_comm();
65 MPI_Comm find_intra_comm(int* leader);
69 MPI_Comm split(int color, int key);
72 static void unref(MPI_Comm comm);
73 static void destroy(MPI_Comm comm);
76 static void free_f(int id);
77 static Comm* f2c(int);
79 static int keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval,
81 static int keyval_free(int* keyval);
82 static void keyval_cleanup();
84 void add_rma_win(MPI_Win win);
85 void remove_rma_win(MPI_Win win);
86 void finish_rma_calls();
87 MPI_Comm split_type(int type, int key, const Info* info);
91 } // namespace simgrid