00001
00002
00003
00004 #include "converse.h"
00005
00006
00007 #if !CMK_USE_LRTS
00008 void CmiSetRdmaCommonInfo(void *info, const void *ptr, int size) {
00009 }
00010
00011 int CmiGetRdmaCommonInfoSize() {
00012 return 0;
00013 }
00014 #endif
00015
00016 #if !CMK_ONESIDED_IMPL
00017
00018
00019
00020 RdmaAckCallerFn ncpyDirectAckHandlerFn;
00021
00022
00023 typedef struct _converseRdmaMsg {
00024 char cmicore[CmiMsgHeaderSizeBytes];
00025 } ConverseRdmaMsg;
00026
00027 static int get_request_handler_idx;
00028 static int put_data_handler_idx;
00029
00030
00031 static void getRequestHandler(ConverseRdmaMsg *getReqMsg){
00032
00033 NcpyOperationInfo *ncpyOpInfo = (NcpyOperationInfo *)((char *)(getReqMsg) + sizeof(ConverseRdmaMsg));
00034
00035 resetNcpyOpInfoPointers(ncpyOpInfo);
00036
00037 ncpyOpInfo->freeMe = CMK_DONT_FREE_NCPYOPINFO;
00038
00039
00040 CmiIssueRput(ncpyOpInfo);
00041 }
00042
00043
00044 static void putDataHandler(ConverseRdmaMsg *payloadMsg) {
00045
00046 NcpyOperationInfo *ncpyOpInfo = (NcpyOperationInfo *)((char *)payloadMsg + sizeof(ConverseRdmaMsg));
00047
00048 resetNcpyOpInfoPointers(ncpyOpInfo);
00049
00050
00051 memcpy((char *)ncpyOpInfo->destPtr,
00052 (char *)payloadMsg + sizeof(ConverseRdmaMsg) + ncpyOpInfo->ncpyOpInfoSize,
00053 ncpyOpInfo->srcSize);
00054
00055
00056 ncpyOpInfo->ackMode = CMK_DEST_ACK;
00057 ncpyOpInfo->freeMe = CMK_DONT_FREE_NCPYOPINFO;
00058 ncpyDirectAckHandlerFn(ncpyOpInfo);
00059 }
00060
00061
00062
00063 void CmiOnesidedDirectInit(void) {
00064 get_request_handler_idx = CmiRegisterHandler((CmiHandler)getRequestHandler);
00065 put_data_handler_idx = CmiRegisterHandler((CmiHandler)putDataHandler);
00066 }
00067
00068 void CmiSetDirectNcpyAckHandler(RdmaAckCallerFn fn) {
00069 ncpyDirectAckHandlerFn = fn;
00070 }
00071
00072 void CmiIssueRget(NcpyOperationInfo *ncpyOpInfo) {
00073
00074 int ncpyOpInfoSize = ncpyOpInfo->ncpyOpInfoSize;
00075
00076
00077 ConverseRdmaMsg *getReqMsg = (ConverseRdmaMsg *)CmiAlloc(sizeof(ConverseRdmaMsg) + ncpyOpInfoSize);
00078
00079
00080 memcpy((char *)getReqMsg + sizeof(ConverseRdmaMsg),
00081 (char *)ncpyOpInfo,
00082 ncpyOpInfoSize);
00083
00084 CmiSetHandler(getReqMsg, get_request_handler_idx);
00085 CmiSyncSendAndFree(ncpyOpInfo->srcPe, sizeof(ConverseRdmaMsg) + ncpyOpInfoSize, getReqMsg);
00086
00087
00088 CmiFree(ncpyOpInfo);
00089 }
00090
00091 void CmiIssueRput(NcpyOperationInfo *ncpyOpInfo) {
00092
00093 int ncpyOpInfoSize = ncpyOpInfo->ncpyOpInfoSize;
00094 int size = ncpyOpInfo->srcSize;
00095
00096
00097 ConverseRdmaMsg *payloadMsg = (ConverseRdmaMsg *)CmiAlloc(sizeof(ConverseRdmaMsg) + ncpyOpInfoSize + size);
00098
00099
00100 memcpy((char *)payloadMsg + sizeof(ConverseRdmaMsg),
00101 (char *)ncpyOpInfo,
00102 ncpyOpInfoSize);
00103
00104
00105 memcpy((char *)payloadMsg + sizeof(ConverseRdmaMsg) + ncpyOpInfoSize,
00106 ncpyOpInfo->srcPtr,
00107 size);
00108
00109
00110 ncpyOpInfo->ackMode = CMK_SRC_ACK;
00111
00112 ncpyDirectAckHandlerFn(ncpyOpInfo);
00113
00114 CmiSetHandler(payloadMsg, put_data_handler_idx);
00115 CmiSyncSendAndFree(ncpyOpInfo->destPe,
00116 sizeof(ConverseRdmaMsg) + ncpyOpInfoSize + size,
00117 payloadMsg);
00118 }
00119
00120 void CmiSetRdmaBufferInfo(void *info, const void *ptr, int size, unsigned short int mode) {}
00121
00122 void CmiDeregisterMem(const void *ptr, void *info, int pe, unsigned short int mode) {}
00123
00124 #else
00125
00126
00127
00128 RdmaEMAckCallerFn ncpyEMAckHandlerFn;
00129
00130 RdmaAckCallerFn ncpyEMBcastAckHandlerFn;
00131
00132 RdmaAckCallerFn ncpyEMBcastPostAckHandlerFn;
00133
00134 static int invoke_entry_method_ack_handler_idx, ncpy_bcast_ack_handler_idx;
00135 static int ncpy_bcast_post_handler_idx;
00136
00137
00138 typedef struct _ackEntryMethodMsg{
00139 char cmicore[CmiMsgHeaderSizeBytes];
00140 void *ref;
00141 } ackEntryMethodMsg;
00142
00143
00144
00145 static void ackEntryMethodHandler(ackEntryMethodMsg *msg) {
00146
00147 ncpyEMAckHandlerFn(CmiMyPe(), msg->ref);
00148 }
00149
00150
00151 static void bcastAckHandler(ackEntryMethodMsg *msg) {
00152 ncpyEMBcastAckHandlerFn(msg->ref);
00153 }
00154
00155 static void bcastPostAckArrayHandler(ackEntryMethodMsg *msg) {
00156 ncpyEMBcastPostAckHandlerFn(msg->ref);
00157 }
00158
00159
00160 void CmiInvokeRemoteAckHandler(int pe, void *ref) {
00161 ackEntryMethodMsg *msg = (ackEntryMethodMsg *)CmiAlloc(sizeof(ackEntryMethodMsg));
00162 msg->ref = ref;
00163
00164 CmiSetHandler(msg, invoke_entry_method_ack_handler_idx);
00165 CmiSyncSendAndFree(pe, sizeof(ackEntryMethodMsg), msg);
00166 }
00167
00168
00169 void CmiOnesidedDirectInit(void) {
00170 invoke_entry_method_ack_handler_idx = CmiRegisterHandler((CmiHandler)ackEntryMethodHandler);
00171 ncpy_bcast_ack_handler_idx = CmiRegisterHandler((CmiHandler)bcastAckHandler);
00172
00173 ncpy_bcast_post_handler_idx = CmiRegisterHandler((CmiHandler)bcastPostAckArrayHandler);
00174 }
00175
00176 void CmiSetEMNcpyAckHandler(RdmaEMAckCallerFn fn, RdmaAckCallerFn bcastFn, RdmaAckCallerFn bcastArrayFn) {
00177
00178 ncpyEMAckHandlerFn = fn;
00179
00180
00181 ncpyEMBcastAckHandlerFn = bcastFn;
00182
00183
00184 ncpyEMBcastPostAckHandlerFn = bcastArrayFn;
00185 }
00186
00187 void CmiInvokeBcastAckHandler(int pe, void *ref) {
00188
00189 ackEntryMethodMsg *msg = (ackEntryMethodMsg *)CmiAlloc(sizeof(ackEntryMethodMsg));
00190 msg->ref = ref;
00191
00192 CmiSetHandler(msg, ncpy_bcast_ack_handler_idx);
00193 CmiSyncSendAndFree(pe, sizeof(ackEntryMethodMsg), msg);
00194 }
00195
00196 void CmiInvokeBcastPostAckHandler(int pe, void *ref) {
00197 ackEntryMethodMsg *msg = (ackEntryMethodMsg *)CmiAlloc(sizeof(ackEntryMethodMsg));
00198 msg->ref = ref;
00199
00200 CmiSetHandler(msg, ncpy_bcast_post_handler_idx);
00201 CmiSyncSendAndFree(pe, sizeof(ackEntryMethodMsg), msg);
00202 }
00203 #endif