1 #include "pcCommManager.h"
3 #include "paircalc/pcMessages.h"
4 #include "ckPairCalculator.decl.h"
5 #include "paircalc/InputDataHandler.h"
6 #include "utility/matrix2file.h"
8 #include "ckmulticast.h"
14 #define _PC_COMMLIB_MULTI_ 0
22 gspaceIndex(gspaceIdx), pcCfg(_cfg), pcHandle(_pcHandle),
23 sectionGettingLeft(0), sectionGettingRight(0),
24 existsLproxy(false), existsRproxy(false)
32 #ifdef DEBUG_CP_PAIRCALC_CREATION
40 s1 = (s1>maxpcstateindex) ? maxpcstateindex :s1;
44 #ifdef DEBUG_CP_PAIRCALC_COMM
45 CkPrintf(
"GSpace[%d,%d] will send left matrix data to symm(%d) PC chares on: Row %d, Cols %d to %d\n",
53 for(
int s2 = sColMin; s2 <= maxpcstateindex; s2 +=
pcCfg.
grainSize)
70 #ifndef _PAIRCALC_DO_NOT_DELEGATE_
72 if(_PC_COMMLIB_MULTI_ )
92 #ifdef DEBUG_CP_PAIRCALC_CREATION
99 s2 = (s2>maxpcstateindex) ? maxpcstateindex :s2;
102 #ifdef DEBUG_CP_PAIRCALC_COMM
103 CkPrintf(
"GSpace[%d,%d] will send left matrix data to symm(%d) PC chares on: Col %d, Rows %d to %d\n",
131 #ifndef _PAIRCALC_DO_NOT_DELEGATE_
133 if(_PC_COMMLIB_MULTI_)
161 #ifdef DEBUG_CP_PAIRCALC_RDMA
162 CkPrintf(
"GSpace[%d,%d] Using traditional channels (not RDMA) for psiV left data.\n",
gspaceIndex.x,
gspaceIndex.y);
176 int outsize = chunksize;
183 #ifdef _PAIRCALC_DEBUG_PARANOID_FW_
186 CkPrintf(
"L [%d,%d,%d,%d,%d] chunk %d chunksize %d outsize %d for numpoint %d offset will be %d %.12g\n",
gspaceIndex.y,
gspaceIndex.x,
gspaceIndex.x, chunk,
pcCfg.
isSymmetric, chunk,chunksize, outsize, numPoints, chunk*chunksize, ptr[chunk*chunksize].re);
196 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
198 reinterpret_cast<short*
> (idx.data() )[3]=chunk;
200 for(
int i=0;i<outsize ;i++)
202 CkAssert(finite(msg->
points[i].re));
203 CkAssert(finite(msg->
points[i].im));
207 handlerProxy(idx).acceptLeftData(msg);
215 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
216 #ifdef _PAIRCALC_DEBUG_PARANOID_FW_
221 for(
int i=0;i<outsize ;i++)
223 CkAssert(finite(msg->
points[i].re));
224 CkAssert(finite(msg->
points[i].im));
248 #ifdef DEBUG_CP_PAIRCALC_RDMA
249 CkPrintf(
"GSpace[%d,%d] Using traditional channels (not RDMA) for psiV right data.\n",
gspaceIndex.x,
gspaceIndex.y);
260 #ifdef _DEBUG_PAIRCALC_PARANOID_
263 for(
int i=0;i<numPoints;i++)
268 CkAssert(fabs(re)>1.0e-300);
270 CkAssert(fabs(im)>1.0e-300);
276 int outsize = chunksize;
286 reinterpret_cast<short*
> (idx.data() )[3]=chunk;
288 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
291 for(
int i=0;i<outsize ;i++)
293 CkAssert(finite(msg->
points[i].re));
294 CkAssert(finite(msg->
points[i].im));
298 handlerProxy(idx).acceptRightData(msg);
304 CkSetQueueing(msg, CK_QUEUEING_IFIFO);
307 for(
int i=0;i<outsize ;i++)
309 CkAssert(finite(msg->
points[i].re));
310 CkAssert(finite(msg->
points[i].im));
328 CkAbort(
"GSpace[,] Trying to send data to paircalcs via RDMA when RDMA is not enabled\n");
336 #ifdef DEBUG_CP_PAIRCALC_RDMA
345 #endif // PC_USE_RDMA
354 CkAbort(
"GSpace[,] Trying to send data to paircalcs via RDMA when RDMA is not enabled\n");
359 for (
int i=0; i< rightDestinationHandles.size();i++)
360 if (rightDestinationHandles[i].handle >=0)
362 #ifdef DEBUG_CP_PAIRCALC_RDMA
365 CmiDirect_put( &(rightDestinationHandles[i]) );
371 #endif // PC_USE_RDMA
380 CkAbort(
"GSpace[,] Trying to setup RDMA when RDMA is not enabled\n");
382 #ifdef DEBUG_CP_PAIRCALC_RDMA
383 CkPrintf(
"GSpace[%d,%d] Sending out RDMA setup requests to PCs getting left matrix data from me.\n",idTkn.gspIndex.x,idTkn.gspIndex.y);
409 reinterpret_cast<short*
> (idx.data() )[3]=chunk;
412 handlerProxy(idx).setupRDMALeft(msg);
423 #endif // PC_USE_RDMA
432 CkAbort(
"GSpace[,] Trying to setup RDMA when RDMA is not enabled\n");
434 #ifdef DEBUG_CP_PAIRCALC_RDMA
435 CkPrintf(
"GSpace[%d,%d] Sending out RDMA setup requests to PCs getting right matrix data from me.\n",idTkn.gspIndex.x,idTkn.gspIndex.y);
461 reinterpret_cast<short*
> (idx.data() )[3]=chunk;
464 handlerProxy(idx).setupRDMARight(msg);
475 #endif // PC_USE_RDMA
491 redMsg->offset=offset;
492 redMsg->lbsync=lbsync;
493 redMsg->synccb=synccb;
494 sectProxy->initResultSection(redMsg);
519 s2 = (s2>maxpcstateindex) ? maxpcstateindex :s2;
521 CProxySection_PairCalculator sectProxy = CProxySection_PairCalculator::ckNew(
pcHandle.
pcAID,
526 CkSectionID sid=sectProxy.ckGetSectionID();
527 std::random_shuffle(sid._elems, sid._elems + sid._nElems);
528 sectProxy.ckSectionDelegate(mcastGrp);
530 setResultProxy(§Proxy,
false, CkCallback(CkCallback::ignore));
542 s1 = (s1>maxpcstateindex) ? maxpcstateindex :s1;
554 elems[ecount++]=idx4d;
557 std::random_shuffle(elems, elems + ecount);
558 CProxySection_PairCalculator sectProxy = CProxySection_PairCalculator::ckNew(
pcHandle.
pcAID, elems, ecount);
560 sectProxy.ckSectionDelegate(mcastGrp);
561 setResultProxy(§Proxy,
false, CkCallback(CkCallback::ignore));
575 s2 = (s2>maxpcstateindex) ? maxpcstateindex :s2;
578 CProxySection_PairCalculator sectProxy = CProxySection_PairCalculator::ckNew(
pcHandle.
pcAID,
583 CkSectionID sid=sectProxy.ckGetSectionID();
584 std::random_shuffle(sid._elems, sid._elems + sid._nElems);
585 sectProxy.ckSectionDelegate(mcastGrp);
586 setResultProxy(§Proxy,
false, CkCallback(CkCallback::ignore));
599 s1 = (s1>maxpcstateindex) ? maxpcstateindex :s1;
602 s2start= (s2start>maxpcstateindex) ? maxpcstateindex : s2start;
605 CProxySection_PairCalculator sectProxy =
609 s2start, maxpcstateindex, s2range,
612 CkSectionID sid=sectProxy.ckGetSectionID();
613 std::random_shuffle(sid._elems, sid._elems + sid._nElems);
614 sectProxy.ckSectionDelegate(mcastGrp);
615 setResultProxy(§Proxy,
false, CkCallback(CkCallback::ignore));
622 #include "RDMAMessages.def.h"
bool isSymmetric
Is this a symmetric or asymmetric paircalc instance.
void makeRightTree()
Creates a multicast tree that includes the PC chare arrays used in the asymmetric loop...
CProxySection_InputDataHandler< CollatorType, CollatorType > * sectionGettingRight
Array section which receives right matrix block data.
CkVec< CkArrayIndex4D > listGettingLeft
A list of PC array elements which expect left matrix data from owning GSpace chare.
bool existsLproxy
True if a proxy for the destination PC array section including a (portion of a) row exists...
int inputMsgPriority
The priority (set by GSpace) of the input messages.
bool isDoublePackOn
Is double-packing on?
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...
bool isInputMulticast
Will the input data be multicast to PC sections or sent directly (p2p)
CkGroupID mCastMgrGID
The CkMulticast group that will handle gspace <–> pc comm.
int numStates
The total number of states in the system.
CkIndex2D gspaceIndex
The array index of the owner GSpace chare.
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...
int grainSize
The grain size along the states dimensions (plural) (number of states per PC chare) ...
void sendRightDataRDMA(int numPoints, complex *ptr, bool psiV)
Sends right matrix data via RDMA.
cp::paircalc::pcConfig pcCfg
Input configurations for the paircalcs.
int numChunks
The number of chunks (4th dimension of decomposition)
CProxySection_InputDataHandler< CollatorType, CollatorType > * sectionGettingLeft
Array section which receives left matrix block data.
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...
A request from a data sender to setup an RDMA link. Initiates the sender-receiver handshake required ...
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...
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...
CProxySection_PairCalculator makeOneResultSection_asym_column(int chunk)
initialize plane and column wise section reduction for lambda->gspace
A (hopefully) tiny token that is unique to every data sender-receiver pair, and is shared by them dur...
CkVec< CkArrayIndex4D > listGettingRight
A list of PC array elements which expect right matrix data from owning GSpace chare.
Dumb structure that holds all the configuration inputs required for paircalc instantiation, functioning and interaction.
CkArrayID pcAID
The array IDs of the paircalc and its servant input handler arrays.
A tiny structure to hold the relevant IDs/ proxies required to interact with a paircalc instance...
cp::paircalc::InstanceIDs pcHandle
Handles to the paircalc array and related entities that I will be managing comm with.
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.