00001 #ifndef _MACHINE_RDMA_H_
00002 #define _MACHINE_RDMA_H_
00003
00004
00005 typedef void (*RdmaAckHandlerFn)(void *token);
00006
00007
00008 typedef struct _cmi_common_rdma_info {
00009 #if CMK_USE_CMA
00010 pid_t pid;
00011 #elif defined _MSC_VER
00012 char empty;
00013 #endif
00014 } CmiCommonRdmaInfo_t;
00015
00016
00017 void CmiSetRdmaCommonInfo(void *info, const void *ptr, int size) {
00018 #if CMK_USE_CMA
00019 CmiCommonRdmaInfo_t *cmmInfo = (CmiCommonRdmaInfo_t *)info;
00020 cmmInfo->pid = getpid();
00021 #endif
00022 }
00023
00024 int CmiGetRdmaCommonInfoSize() {
00025 return sizeof(CmiCommonRdmaInfo_t);
00026 }
00027
00028 #if CMK_USE_CMA
00029 #include <sys/uio.h>
00030 extern int cma_works;
00031 int readShmCma(pid_t, struct iovec *, struct iovec *, int, size_t);
00032 int writeShmCma(pid_t, struct iovec *, struct iovec *, int, size_t);
00033
00034
00035 void CmiIssueRgetUsingCMA(
00036 const void* srcAddr,
00037 void *srcInfo,
00038 int srcPe,
00039 const void* destAddr,
00040 void *destInfo,
00041 int destPe,
00042 int size) {
00043
00044
00045 struct iovec local, remote;
00046
00047 local.iov_base = (void *)destAddr;
00048 local.iov_len = size;
00049
00050
00051 remote.iov_base = (void *)srcAddr;
00052 remote.iov_len = size;
00053
00054
00055 CmiCommonRdmaInfo_t *remoteCommInfo = (CmiCommonRdmaInfo_t *)srcInfo;
00056 pid_t pid = remoteCommInfo->pid;
00057 readShmCma(pid, &local, &remote, 1, size);
00058 }
00059
00060 void CmiIssueRputUsingCMA(
00061 const void* destAddr,
00062 void *destInfo,
00063 int destPe,
00064 const void* srcAddr,
00065 void *srcInfo,
00066 int srcPe,
00067 int size) {
00068
00069
00070 struct iovec local, remote;
00071
00072 local.iov_base = (void *)srcAddr;
00073 local.iov_len = size;
00074
00075
00076 remote.iov_base = (void *)destAddr;
00077 remote.iov_len = size;
00078
00079
00080 CmiCommonRdmaInfo_t *remoteCommInfo = (CmiCommonRdmaInfo_t *)destInfo;
00081 pid_t pid = remoteCommInfo->pid;
00082 writeShmCma(pid, &local, &remote, 1, size);
00083 }
00084 #endif
00085
00086 #if CMK_ONESIDED_IMPL
00087
00088
00089 RdmaAckHandlerFn ncpyDirectAckHandlerFn;
00090
00091 typedef struct _cmi_rdma_direct_ack {
00092 const void *srcAddr;
00093 int srcPe;
00094 const void *destAddr;
00095 int destPe;
00096 int ackSize;
00097 } CmiRdmaDirectAck;
00098
00099
00100 void LrtsSetRdmaBufferInfo(void *info, const void *ptr, int size, unsigned short int mode);
00101 void LrtsSetRdmaNcpyAck(RdmaAckHandlerFn fn);
00102 void LrtsIssueRget(NcpyOperationInfo *ncpyOpInfo);
00103
00104 void LrtsIssueRput(NcpyOperationInfo *ncpyOpInfo);
00105
00106 void LrtsDeregisterMem(const void *ptr, void *info, int pe, unsigned short int mode);
00107
00108 #if CMK_REG_REQUIRED
00109 void LrtsInvokeRemoteDeregAckHandler(int pe, NcpyOperationInfo *ncpyOpInfo);
00110 #endif
00111
00112
00113 void CmiSetRdmaBufferInfo(void *info, const void *ptr, int size, unsigned short int mode){
00114 LrtsSetRdmaBufferInfo(info, ptr, size, mode);
00115 }
00116
00117 void CmiInvokeNcpyAck(void *ack) {
00118 ncpyDirectAckHandlerFn(ack);
00119 }
00120
00121
00122 void CmiSetDirectNcpyAckHandler(RdmaAckHandlerFn fn){
00123 ncpyDirectAckHandlerFn = fn;
00124 }
00125
00126
00127 void CmiIssueRget(NcpyOperationInfo *ncpyOpInfo) {
00128
00129 LrtsIssueRget(ncpyOpInfo);
00130 }
00131
00132
00133 void CmiIssueRput(NcpyOperationInfo *ncpyOpInfo) {
00134
00135 LrtsIssueRput(ncpyOpInfo);
00136 }
00137
00138
00139 void CmiDeregisterMem(const void *ptr, void *info, int pe, unsigned short int mode){
00140 LrtsDeregisterMem(ptr, info, pe, mode);
00141 }
00142
00143 #if CMK_REG_REQUIRED
00144 void CmiInvokeRemoteDeregAckHandler(int pe, NcpyOperationInfo *ncpyOpInfo) {
00145 LrtsInvokeRemoteDeregAckHandler(pe, ncpyOpInfo);
00146 }
00147 #endif
00148
00149 #endif
00150 #endif