OpenAtom  Version1.5a
RDMAMessages.h
1 #include "RDMAMessages.decl.h"
2 /// Include cmidirect only if RDMA is enabled
3 #ifdef ENABLE_RDMA_HANDSHAKES
4  #include "cmidirect.h"
5 #endif
6 #include <ostream>
7 
8 #ifndef RDMA_MESSAGES_H
9 #define RDMA_MESSAGES_H
10 
11 /// Based on whether RDMA is enabled, the handle type is either the actual handle or just an empty structure
12 #ifdef ENABLE_RDMA_HANDSHAKES
13  typedef struct infiDirectUserHandle rdmaHandleType;
14  //PUPmarshallBytes(struct infiDirectUserHandle); ///@todo: Determine if something needs to be done to enable PUPing
15 #else
16  typedef struct {} rdmaHandleType;
17 #endif
18 
19 
20 /// A request from a data sender to setup an RDMA link. Initiates the sender-receiver handshake required to setup such a link
21 template <class tokenType>
23 {
24  public:
25  /// Get a copy of the handshake token the sender created
26  inline tokenType token() const { return handshakeToken; }
27  /// Get an integer representation of the sender's ID
28  inline int sender() const { return senderID; }
29  /// Get the PE number of the sender
30  inline int senderPE() const { return senderProc; }
31  /// Get the number of records of data that will be sent by RDMA
32  inline int numDataUnits() const { return (numUnits); }
33  /// Get hold of the callback the sender has configured
34  inline const CkCallback& senderCallback() const { return callbk; }
35 
36  /// Constructors
38  senderID(-1), senderProc(-1), numUnits(0) {}
39  RDMASetupRequestMsg(const tokenType tkn, const int sndr, const int sndrPE, const int dataSize,const CkCallback cb):
40  handshakeToken(tkn),
41  senderID(sndr), senderProc(sndrPE),
42  numUnits(dataSize), callbk(cb) {}
43 
44  private:
45  int senderID, senderProc, numUnits;
46  CkCallback callbk;
47  tokenType handshakeToken;
48 
49  /// Stream inserter. Note: not a member function
50  inline friend std::ostream& operator<< (std::ostream &out, const RDMASetupRequestMsg<tokenType> &obj)
51  {
52  out<<"RDMA setup request from "<<obj.senderID<<" on proc "<<obj.senderProc
53  <<" sending "<<obj.numUnits<<" units. Token data: "<<obj.handshakeToken;
54  return out;
55  }
56 };
57 
58 
59 
60 
61 /// Reply from data receiver to the data sender indicating completion of setup on the receiver side
62 template <class tokenType>
64 {
65  public:
67  RDMASetupConfirmationMsg(const tokenType tkn, const rdmaHandleType hndl): handshakeToken(tkn), ourHandle(hndl) {}
68  inline tokenType token() const { return handshakeToken; }
69  inline rdmaHandleType handle() const { return ourHandle; }
70 
71  private:
72  tokenType handshakeToken;
73  rdmaHandleType ourHandle;
74 
75  /// Stream inserter. Note: not a member function
76  inline friend std::ostream& operator<< (std::ostream &out, const RDMASetupConfirmationMsg<tokenType> &obj)
77  {
78  out<<"RDMA setup confirmation msg. Token data: "<<obj.handshakeToken;
79  return out;
80  }
81 };
82 
83 
84 
85 
86 /** A (hopefully) tiny token that is unique to every data sender-receiver pair,
87  * and is shared by them during the RDMA setup process. This simply encapsulates
88  * information about the sender and the receiver that each other need.
89  *
90  * This can be defined for every unique RDMA pair, and the RDMA setup messages
91  * can be configured with these so that the messages stay somewhat general. This
92  * structure holds information relevant to GSpace and PairCalc communication.
93  */
95 {
96  public:
97  RDMApair_GSP_PC(): shouldSendLeft(true), symmetric(true)
98  {
99  gspIndex.x = gspIndex.y = 0;
100  pcIndex.w = pcIndex.x = pcIndex.y = pcIndex.z = 0;
101  }
102  bool shouldSendLeft, symmetric;
103  CkIndex2D gspIndex;
104  CkIndex4D pcIndex;
105 
106  /// Stream inserter. Note: not a member function
107  inline friend std::ostream& operator<< (std::ostream &out, const RDMApair_GSP_PC &obj)
108  {
109  out<<"GSpace["<<obj.gspIndex.x<<","<<obj.gspIndex.y
110  <<"] - PC["<<obj.pcIndex.w<<","<<obj.pcIndex.x<<","<<obj.pcIndex.y<<","<<obj.pcIndex.z<<","<<obj.symmetric<<"] "
111  <<(obj.shouldSendLeft?"Left ":"Right ");
112  return out;
113  }
114 };
115 
116 
117 
118 /** This include is inside the #define block to avoid redefinition.
119  * def.h files dont have include guards and can cause problems for modules with template chares/messages.
120  */
121 #define CK_TEMPLATES_ONLY
122  #include "RDMAMessages.def.h"
123 #undef CK_TEMPLATES_ONLY
124 #endif // RDMA_MESSAGES_H
const CkCallback & senderCallback() const
Get hold of the callback the sender has configured.
Definition: RDMAMessages.h:34
friend std::ostream & operator<<(std::ostream &out, const RDMApair_GSP_PC &obj)
Stream inserter. Note: not a member function.
Definition: RDMAMessages.h:107
int numDataUnits() const
Get the number of records of data that will be sent by RDMA.
Definition: RDMAMessages.h:32
int senderPE() const
Get the PE number of the sender.
Definition: RDMAMessages.h:30
A request from a data sender to setup an RDMA link. Initiates the sender-receiver handshake required ...
Definition: RDMAMessages.h:22
Based on whether RDMA is enabled, the handle type is either the actual handle or just an empty struct...
Definition: RDMAMessages.h:16
tokenType token() const
Get a copy of the handshake token the sender created.
Definition: RDMAMessages.h:26
RDMASetupRequestMsg()
Constructors.
Definition: RDMAMessages.h:37
int sender() const
Get an integer representation of the sender's ID.
Definition: RDMAMessages.h:28
A (hopefully) tiny token that is unique to every data sender-receiver pair, and is shared by them dur...
Definition: RDMAMessages.h:94
Reply from data receiver to the data sender indicating completion of setup on the receiver side...