OpenAtom  Version1.5a
pcCommManager.h
1 #include "debug_flags.h"
2 #include "paircalc/pcConfig.h"
3 #include "paircalc/pcInstanceIDs.h"
4 #include "paircalc/pcFwdDeclarations.h"
5 
6 #ifndef PC_COMM_MANAGER_H
7 #define PC_COMM_MANAGER_H
8 
9 /// Forward declarations
11 struct ckcomplex;
12 typedef ckcomplex complex;
13 /** @addtogroup GSpaceState
14  @{
15 */
16 
17 namespace cp {
18  namespace gspace {
19 
20 /**
21  * Manages communication with a single paircalc array
22  *
23  * It needs a handle to an already created paircalc instance and the config settings for that instance
24  * Given this info, and the index of its owner (GSpace) chare, it creates appropriate mcast/redn sections
25  * and manages these communications. GSpace simply delegates the data sends to the appropriate comm manager
26  * instances in every iteration.
27  *
28  * @todo: This class also manages the RDMA setup requests, although it could also assume the responsibility
29  * for processing the ack msg that arrives in GSpace to complete an RDMA handshake.
30  */
32 {
33  friend class ::CP_State_GSpacePlane; ///< @note: Temporary until paircalc startup moves completely to GSpace
34 
35  public:
36  /// Constructor
37  PCCommManager(const CkIndex2D gspaceIdx, const pc::pcConfig &_cfg, const pc::InstanceIDs _pcHandle);
38  PCCommManager() {} ///< @warning: Just to appease charm migration constructors. pffouggh...
39  /// Starts the forward path work (Psi, Lambda and PsiV cases) by multicasting an entry method call to the appropriate PC chare array section
40  void sendLeftData (int numPoints, complex* ptr, bool psiV);
41  /// Starts the forward path work (along with startPairCalcLeft()) in the asymmetric (Lambda) case
42  void sendRightData(int numPoints, complex* ptr, bool psiV);
43 
44  //@{
45  /// Initialize an array section that is used to reduce the results from the PCs back to the GSP chares
46  CProxySection_PairCalculator makeOneResultSection_asym(int chunk);
47  CProxySection_PairCalculator makeOneResultSection_asym_column(int chunk);
48  CProxySection_PairCalculator makeOneResultSection_sym1(int chunk);
49  CProxySection_PairCalculator makeOneResultSection_sym2(int chunk);
50  //@}
51 
52 
53  private:
54  /// Creates multicast trees to the appropriate PC chare array sections used in the symmetric / asymmetric loops
55  void makeLeftTree();
56  /// Creates a multicast tree that includes the PC chare arrays used in the asymmetric loop
57  void makeRightTree();
58  /// Multicasts the left matrix data to the PC section
59  void sendLeftDataMcast (int numPoints, complex* ptr, bool psiV);
60  /// Multicasts the right matrix data to the PC section
61  void sendRightDataMcast(int numPoints, complex* ptr, bool psiV);
62  /// Sends left matrix data via RDMA
63  void sendLeftDataRDMA (int numPoints, complex* ptr, bool psiV);
64  /// Sends right matrix data via RDMA
65  void sendRightDataRDMA (int numPoints, complex* ptr, bool psiV);
66  /// Send RDMA setup requests to all the destination PC chares that will be getting left data
67  void sendLeftRDMARequest (RDMApair_GSP_PC idTkn, int totalsize, CkCallback cb);
68  /// Send RDMA setup requests to all the destination PC chares that will be getting right data
69  void sendRightRDMARequest(RDMApair_GSP_PC idTkn, int totalsize, CkCallback cb);
70  /// Send out a dummy mcast to prod CkMulticast into setting up the result reduction trees etc
71  void setResultProxy(CProxySection_PairCalculator *sectProxy, bool lbsync, CkCallback synccb);
72 
73 
74  /// The array index of the owner GSpace chare
75  CkIndex2D gspaceIndex;
76  /// Input configurations for the paircalcs
78  /// Handles to the paircalc array and related entities that I will be managing comm with
80 
81  /** Array section which receives left matrix block data
82  *
83  * symm instance: post-diagonal chares on row 's' that get data from this GSpace[s,p] chare
84  * asymm instance: all chares on row 's' that get data from this GSpace[s,p] chare
85  */
87 
88  /** Array section which receives right matrix block data
89  *
90  * symm instance: pre-diagonal chares on column 's' that get data from this GSpace[s,p] chare
91  * asymm instance: all chares on column 's' that get data from this GSpace[s,p] chare
92  */
94 
95  /// A list of PC array elements which expect left matrix data from owning GSpace chare
96  CkVec <CkArrayIndex4D> listGettingLeft;
97  /// A list of PC array elements which expect right matrix data from owning GSpace chare
98  CkVec <CkArrayIndex4D> listGettingRight;
99  /// RDMA handles for each PC chare's input data handler that will receive data from the owner of this object (a GSpace[s,p] chare)
100  CkVec<rdmaHandleType> leftDestinationHandles, rightDestinationHandles;
101  /// True if a proxy for the destination PC array section including a (portion of a) row exists
103  /// True if a proxy for the destination PC array section including a (portion of a) column exists
105 };
106 
107 
108 
109 
110 inline void PCCommManager::sendLeftData(int n, complex* ptr, bool psiV)
111 {
112  #ifdef PC_USE_RDMA
113  sendLeftDataRDMA(n,ptr,psiV);
114  #else
115  sendLeftDataMcast(n,ptr,psiV);
116  #endif
117 }
118 
119 
120 
121 
122 inline void PCCommManager::sendRightData(int n, complex* ptr, bool psiV)
123 {
124  #ifdef PC_USE_RDMA
125  sendRightDataRDMA(n,ptr,psiV);
126  #else
127  sendRightDataMcast(n,ptr,psiV);
128  #endif
129 }
130 
131  } // end namespace gspace
132 } // end namespace cp
133 /*@}*/
134 #endif // PC_COMM_MANAGER_H
135 
void makeRightTree()
Creates a multicast tree that includes the PC chare arrays used in the asymmetric loop...
Definition: pcCommManager.C:90
CProxySection_InputDataHandler< CollatorType, CollatorType > * sectionGettingRight
Array section which receives right matrix block data.
Definition: pcCommManager.h:93
CkVec< CkArrayIndex4D > listGettingLeft
A list of PC array elements which expect left matrix data from owning GSpace chare.
Definition: pcCommManager.h:96
bool existsLproxy
True if a proxy for the destination PC array section including a (portion of a) row exists...
void sendLeftDataMcast(int numPoints, complex *ptr, bool psiV)
Multicasts the left matrix data to the PC section.
void sendRightDataMcast(int numPoints, complex *ptr, bool psiV)
Multicasts the right matrix data to the PC section.
CProxySection_PairCalculator makeOneResultSection_asym(int chunk)
Initialize an array section that is used to reduce the results from the PCs back to the GSP chares...
void sendLeftRDMARequest(RDMApair_GSP_PC idTkn, int totalsize, CkCallback cb)
Send RDMA setup requests to all the destination PC chares that will be getting left data...
2D chare array [nchareG][nstates] Handles the electronic structure in Fourier space (referred to as G...
CkIndex2D gspaceIndex
The array index of the owner GSpace chare.
Definition: pcCommManager.h:75
CProxySection_PairCalculator makeOneResultSection_sym1(int chunk)
initialize plane and row wise section reduction for psi->gspace
bool existsRproxy
True if a proxy for the destination PC array section including a (portion of a) column exists...
void sendRightDataRDMA(int numPoints, complex *ptr, bool psiV)
Sends right matrix data via RDMA.
cp::paircalc::pcConfig pcCfg
Input configurations for the paircalcs.
Definition: pcCommManager.h:77
CProxySection_InputDataHandler< CollatorType, CollatorType > * sectionGettingLeft
Array section which receives left matrix block data.
Definition: pcCommManager.h:86
void setResultProxy(CProxySection_PairCalculator *sectProxy, bool lbsync, CkCallback synccb)
Send out a dummy mcast to prod CkMulticast into setting up the result reduction trees etc...
CProxySection_PairCalculator makeOneResultSection_sym2(int chunk)
initialize plane and column wise section reduction for psi->gspace
void makeLeftTree()
Creates multicast trees to the appropriate PC chare array sections used in the symmetric / asymmetric...
Definition: pcCommManager.C:30
void sendRightRDMARequest(RDMApair_GSP_PC idTkn, int totalsize, CkCallback cb)
Send RDMA setup requests to all the destination PC chares that will be getting right data...
void sendLeftData(int numPoints, complex *ptr, bool psiV)
Starts the forward path work (Psi, Lambda and PsiV cases) by multicasting an entry method call to the...
CProxySection_PairCalculator makeOneResultSection_asym_column(int chunk)
initialize plane and column wise section reduction for lambda->gspace
Manages communication with a single paircalc array.
Definition: pcCommManager.h:31
A (hopefully) tiny token that is unique to every data sender-receiver pair, and is shared by them dur...
Definition: RDMAMessages.h:94
CkVec< CkArrayIndex4D > listGettingRight
A list of PC array elements which expect right matrix data from owning GSpace chare.
Definition: pcCommManager.h:98
Dumb structure that holds all the configuration inputs required for paircalc instantiation, functioning and interaction.
Definition: pcConfig.h:23
Useful debugging flags.
A tiny structure to hold the relevant IDs/ proxies required to interact with a paircalc instance...
Definition: pcInstanceIDs.h:11
cp::paircalc::InstanceIDs pcHandle
Handles to the paircalc array and related entities that I will be managing comm with.
Definition: pcCommManager.h:79
void sendRightData(int numPoints, complex *ptr, bool psiV)
Starts the forward path work (along with startPairCalcLeft()) in the asymmetric (Lambda) case...
CkVec< rdmaHandleType > leftDestinationHandles
RDMA handles for each PC chare's input data handler that will receive data from the owner of this obj...
void sendLeftDataRDMA(int numPoints, complex *ptr, bool psiV)
Sends left matrix data via RDMA.