Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4c2ead02c760739b42c048111b2ab0daa8f89317
[simgrid.git] / src / smpi / smpi_comm.hpp
1 /* Copyright (c) 2010-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SMPI_COMM_HPP_INCLUDED
8 #define SMPI_COMM_HPP_INCLUDED
9
10 #include "private.h"
11
12
13 typedef struct s_smpi_mpi_comm_key_elem {
14   MPI_Comm_copy_attr_function* copy_fn;
15   MPI_Comm_delete_attr_function* delete_fn;
16 } s_smpi_mpi_comm_key_elem_t; 
17 typedef struct s_smpi_mpi_comm_key_elem *smpi_comm_key_elem;
18
19 namespace simgrid{
20 namespace smpi{
21
22 class Comm : public F2C{
23
24   private:
25     MPI_Group group_;
26     MPIR_Topo_type topoType_; 
27     MPI_Topology topo_; // to be replaced by an union
28     int refcount_;
29     MPI_Comm leaders_comm_;//inter-node communicator
30     MPI_Comm intra_comm_;//intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
31     //use an intracomm stored in the process data instead
32     int* leaders_map_; //who is the leader of each process
33     int is_uniform_;
34     int* non_uniform_map_; //set if smp nodes have a different number of processes allocated
35     int is_blocked_;// are ranks allocated on the same smp node contiguous ?
36     xbt_dict_t attributes_;
37
38     static xbt_dict_t keyvals_;
39     static int keyval_id_;
40
41   public:
42     Comm() = default;
43     Comm(MPI_Group group, MPI_Topology topo);
44
45
46     int dup(MPI_Comm* newcomm);
47     MPI_Group group();
48     MPI_Topology topo();
49     int size();
50     int rank();
51     void get_name (char* name, int* len);
52     void set_leaders_comm(MPI_Comm leaders);
53     void set_intra_comm(MPI_Comm leaders);
54     int* get_non_uniform_map();
55     int* get_leaders_map();
56     MPI_Comm get_leaders_comm();
57     MPI_Comm get_intra_comm();
58     int is_uniform();
59     int is_blocked();
60     MPI_Comm split(int color, int key);
61     void cleanup_attributes();
62     void cleanup_smp();
63     void ref();
64     static void unref(MPI_Comm comm);
65     static void destroy(MPI_Comm comm);
66     void init_smp();
67     int attr_delete(int keyval);
68     int attr_get(int keyval, void* attr_value, int* flag);
69     int attr_put(int keyval, void* attr_value);
70
71     int add_f();
72     static void free_f(int id);
73     static Comm* f2c(int);
74
75     static int keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state);
76     static int keyval_free(int* keyval);
77     static void keyval_cleanup();
78
79 };
80
81 }
82 }
83
84
85 #endif