Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Pane_communicator.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: Pane_communicator.h,v 1.20 2009/08/27 14:04:49 mtcampbe Exp $
24 
31 #ifndef _PANE_COMMUNICATOR_H
32 #define _PANE_COMMUNICATOR_H
33 
34 #include "mapbasic.h"
35 #include "roccom_devel.h"
36 #include "commpi.h"
37 #include "roccom_assertion.h"
38 
40 
47 protected:
55  // Default constructor
56  Pane_comm_buffers() : rank(-1), tag(-1), index(-1) {}
57 
58  int rank; // rank for communicating process
59  int tag; // tag for MPI message
60  int index; // starting index of information
61  // between the two panes in the
62  // pconn of the local pane
63  std::vector< char> outbuf; // buffer for outgoing messages
64  std::vector< char> inbuf; // buffer for incoming messages
65  };
66 public:
67  // Note: One can use the RNS and GNR for sending and receiving data for
68  // boundary edges with a custmized pconn.
69  enum Buff_type {
70  RNS, // Real nodes to send
71  RCS, // Real cells to send.
72  SHARED_NODE, // Shared nodes to send and receive.
73  GNR, // Ghost nodes to receive.
74  GCR // Ghost cells to receive.
75  };
76 
80  explicit Pane_communicator( COM::Window *w, MPI_Comm c=MPI_COMM_WORLD);
81 
88  void init( void** ptrs, COM_Type type, int ncomp,
89  const int *sizes=NULL, const int *strds=NULL);
90 
94  void init( COM::Attribute *att, const COM::Attribute *my_pconn = NULL);
95 
97  MPI_Comm mpi_comm() const { return _comm; }
98 
100  std::vector<COM::Pane*> &panes() { return _panes; }
101 
104  int owner_rank( const int pane_id) const
105  { return _appl_window->owner_rank( pane_id); }
106 
108  int total_npanes() const { return _total_npanes; }
109 
112  int lpaneid( const int pane_id) const {
114  return _lpaneid_map.find(pane_id)->second;
115  }
116 
124  void begin_update_shared_nodes(std::vector<std::vector<bool> > *involved=NULL){
125  begin_update(SHARED_NODE,involved);
126  }
127 
130  begin_update(RNS);
131  begin_update(GNR);
132  }
133 
136  begin_update(RCS);
137  begin_update(GCR);
138  }
139 
142  end_update();
143  }
144 
148  end_update();
149  }
150 
154  end_update();
155  }
156 
159  void reduce_on_shared_nodes( MPI_Op);
160 
164 
168 
172 
173  void update_ghost_values();
174 
178 
179 protected:
181  void init_pane_comm_buffers(std::vector< Pane_comm_buffers>& pcb,
182  const int* ptr, int& index, const int n_items, const int lpid);
183 
185  void end_update();
186 
189  void begin_update(const Buff_type btype,
190  std::vector<std::vector<bool> > *involved=NULL);
191 
194 
196  COM::Window *_appl_window;
198  const MPI_Comm _comm;
200  std::vector<COM::Pane*> _panes;
206  std::map<int,int> _lpaneid_map;
211  std::vector< void*> _ptrs;
213  std::vector< int> _sizes;
215  std::vector< int> _strds;
218  // communicating panes for each local pane.
219  std::vector< std::vector< Pane_comm_buffers> > _shr_buffs;
221  std::vector< std::vector< Pane_comm_buffers> > _rns_buffs;
223  std::vector< std::vector< Pane_comm_buffers> > _gnr_buffs;
225  std::vector< std::vector< Pane_comm_buffers> > _rcs_buffs;
227  std::vector< std::vector< Pane_comm_buffers> > _gcr_buffs;
229  std::vector<MPI_Request> _reqs_send, _reqs_recv;
231  std::vector<std::pair<int,int> > _reqs_indices;
232 
233 private:
234  // Disable the following operators
237 };
238 
240 
241 #endif /* _PANE_COMMUNICATOR_H */
242 
243 
244 
245 
246 
247 
void begin_update_shared_nodes(std::vector< std::vector< bool > > *involved=NULL)
Initiates updating shared nodes by calling MPI_Isend and MPI_Irecv.
std::vector< void * > _ptrs
An array of pointers to the data for all local panes.
#define MAP_END_NAMESPACE
Definition: mapbasic.h:29
int COM_Type
Indices for derived data types.
Definition: roccom_basic.h:122
std::vector< int > _sizes
The sizes of the arrays for all local panes.
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
void end_update_ghost_nodes()
Finalizes ghost node updating by calling MPI_Waitall on all send requests.
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
std::map< int, int > _lpaneid_map
Mapping from user-defined pane ids to internal IDs, which are unique and contiguous across all proces...
std::vector< std::vector< Pane_comm_buffers > > _gnr_buffs
Buffer for ghost nodes to receive.
void reduce_on_shared_nodes(MPI_Op)
Perform a reduction operation using locally cached values of the shared nodes, assuming begin_update_...
Buffers for outgoing and incoming messages of a specific pane to be communicated with another pane (e...
void reduce_average_on_shared_nodes()
Reduce to the average of values using locally cached values of the shared nodes, assuming begin_updat...
Pane_communicator(COM::Window *w, MPI_Comm c=MPI_COMM_WORLD)
Constructor from a communicator.
void reduce_diff_on_shared_nodes()
Compute difference of non-zero values of each shared node, assuming there are at most two non-zero va...
std::vector< int > _strds
The strides of the arrays for all local panes.
int owner_rank(const int pane_id) const
Obtain the process rank of a given pane.
void end_update()
Finalizes updating by calling MPI_Waitall on all send requests.
std::vector< std::vector< Pane_comm_buffers > > _rns_buffs
Buffer for real nodes to send.
void init_pane_comm_buffers(std::vector< Pane_comm_buffers > &pcb, const int *ptr, int &index, const int n_items, const int lpid)
Initialize a Pane_comm_buffers for ghost information.
Pane_communicator & operator=(const Pane_communicator &)
MPI_Comm mpi_comm() const
Obtain the MPI communicator for the object.
int total_npanes() const
Obtain the total number of panes on all processes.
std::vector< std::vector< Pane_comm_buffers > > _rcs_buffs
Buffer for real cells to send.
std::vector< std::vector< Pane_comm_buffers > > _shr_buffs
Shared node pane communication buffers.
std::vector< MPI_Request > _reqs_recv
std::vector< std::pair< int, int > > _reqs_indices
The indices in buffs for each pending nonblocking receive request.
void end_update_shared_nodes()
Finalizes shared node updating by calling MPI_Waitall on all send requests.
Contains declarations of MPI subroutines used in Roccom.
This file contains a set of routines for error assertion.
std::vector< COM::Pane * > & panes()
Obtains all the local panes.
std::vector< std::vector< Pane_comm_buffers > > _gcr_buffs
Buffer for ghost cells to receive.
std::vector< MPI_Request > _reqs_send
Arrays of pending nonblocking MPI requests. Same format as _shr_buffs.
Encapsulates information about distribution of panes on all processes and handles across pane communi...
int lpaneid(const int pane_id) const
For a given pane, obtain an internal pane ID which is unique and contiguous across processes...
int _type
The base data type, number of components, and the number of bytes of all components for the data to b...
void begin_update_ghost_nodes()
Initiates updating ghost nodes by calling MPI_Isend and MPI_Irecv.
void reduce_maxabs_on_shared_nodes()
Reduce to the value with the maximum absolute value using locally cached values of shared nodes...
void init(void **ptrs, COM_Type type, int ncomp, const int *sizes=NULL, const int *strds=NULL)
Initialize the communication buffers.
int _my_pconn_id
The id of the pconn being used.
#define MAP_BEGIN_NAMESPACE
Definition: mapbasic.h:28
const MPI_Comm _comm
MPI Communicator.
void begin_update(const Buff_type btype, std::vector< std::vector< bool > > *involved=NULL)
Initiates updating by calling MPI_Isend and MPI_Irecv.
void reduce_minabs_on_shared_nodes()
Reduce to the value with the maximum absolute value using locally cached values of shared nodes...
void begin_update_ghost_cells()
Initiates updating ghost nodes by calling MPI_Isend and MPI_Irecv.
void end_update_ghost_cells()
Finalizes ghost cell updating by calling MPI_Waitall on all send requests.
int _total_npanes
The total number of panes on all processes.
std::vector< COM::Pane * > _panes
Vector of all local panes.
COM::Window * _appl_window
Reference to the application window.