00001 #include "cmirdmautils.h"
00002 #include "converse.h"
00003
00004 #include <stdio.h>
00005 #include <string.h>
00006
00007 int getNcpyOpInfoTotalSize(
00008 int srcLayerSize,
00009 int srcAckSize,
00010 int destLayerSize,
00011 int destAckSize) {
00012 return sizeof(NcpyOperationInfo) + srcLayerSize + destLayerSize + srcAckSize + destAckSize;
00013 }
00014
00015 void setNcpyOpInfo(
00016 const void *srcPtr,
00017 char *srcLayerInfo,
00018 int srcLayerSize,
00019 char *srcAck,
00020 int srcAckSize,
00021 int srcSize,
00022 unsigned short int srcRegMode,
00023 unsigned short int srcDeregMode,
00024 unsigned short int isSrcRegistered,
00025 int srcPe,
00026 const void *srcRef,
00027 const void *destPtr,
00028 char *destLayerInfo,
00029 int destLayerSize,
00030 char *destAck,
00031 int destAckSize,
00032 int destSize,
00033 unsigned short int destRegMode,
00034 unsigned short int destDeregMode,
00035 unsigned short int isDestRegistered,
00036 int destPe,
00037 const void *destRef,
00038 NcpyOperationInfo *ncpyOpInfo) {
00039
00040 char *base = (char *)ncpyOpInfo + sizeof(NcpyOperationInfo);
00041
00042 ncpyOpInfo->srcLayerInfo = NULL;
00043 ncpyOpInfo->destLayerInfo = NULL;
00044 ncpyOpInfo->srcAck = NULL;
00045 ncpyOpInfo->destAck = NULL;
00046
00047
00048 if(srcLayerInfo != NULL && srcLayerSize != 0) {
00049 memcpy(base, srcLayerInfo, srcLayerSize);
00050 ncpyOpInfo->srcLayerInfo = base;
00051 base = base + srcLayerSize;
00052 }
00053
00054
00055 if(srcAck != NULL && srcAckSize != 0) {
00056 memcpy(base, srcAck, srcAckSize);
00057 ncpyOpInfo->srcAck = base;
00058 base = base + srcAckSize;
00059 }
00060
00061
00062 if(srcLayerInfo != NULL && destLayerSize != 0) {
00063 memcpy(base, destLayerInfo, destLayerSize);
00064 ncpyOpInfo->destLayerInfo = base;
00065 base = base + destLayerSize;
00066 }
00067
00068
00069 if(destAck != NULL && destAckSize != 0) {
00070 memcpy(base, destAck, destAckSize);
00071 ncpyOpInfo->destAck = base;
00072 }
00073
00074 ncpyOpInfo->srcPtr = srcPtr;
00075 ncpyOpInfo->srcPe = srcPe;
00076 ncpyOpInfo->srcRef = srcRef;
00077 ncpyOpInfo->srcLayerSize = srcLayerSize;
00078 ncpyOpInfo->srcAckSize = srcAckSize;
00079 ncpyOpInfo->srcSize = srcSize;
00080 ncpyOpInfo->srcRegMode = srcRegMode;
00081 ncpyOpInfo->srcDeregMode = srcDeregMode;
00082 ncpyOpInfo->isSrcRegistered = isSrcRegistered;
00083
00084 ncpyOpInfo->destPtr = destPtr;
00085 ncpyOpInfo->destPe = destPe;
00086 ncpyOpInfo->destRef = destRef;
00087 ncpyOpInfo->destLayerSize = destLayerSize;
00088 ncpyOpInfo->destAckSize = destAckSize;
00089 ncpyOpInfo->destSize = destSize;
00090 ncpyOpInfo->destRegMode = destRegMode;
00091 ncpyOpInfo->destDeregMode = destDeregMode;
00092 ncpyOpInfo->isDestRegistered = isDestRegistered;
00093
00094 ncpyOpInfo->opMode = CMK_DIRECT_API;
00095 ncpyOpInfo->ackMode = CMK_SRC_DEST_ACK;
00096 ncpyOpInfo->freeMe = CMK_FREE_NCPYOPINFO;
00097
00098 ncpyOpInfo->ncpyOpInfoSize = sizeof(NcpyOperationInfo) + srcLayerSize + destLayerSize + srcAckSize + destAckSize;
00099 }
00100
00101
00102 void resetNcpyOpInfoPointers(NcpyOperationInfo *ncpyOpInfo) {
00103
00104 char *base = (char *)ncpyOpInfo + sizeof(NcpyOperationInfo);
00105
00106 if(ncpyOpInfo->srcLayerInfo) {
00107 ncpyOpInfo->srcLayerInfo = base;
00108 base = base + ncpyOpInfo->srcLayerSize;
00109 }
00110
00111 if(ncpyOpInfo->srcAck) {
00112 ncpyOpInfo->srcAck = base;
00113 base = base + ncpyOpInfo->srcAckSize;
00114 }
00115
00116 if(ncpyOpInfo->destLayerInfo) {
00117 ncpyOpInfo->destLayerInfo = base;
00118 base = base + ncpyOpInfo->destLayerSize;
00119 }
00120
00121 if(ncpyOpInfo->destAck) {
00122 ncpyOpInfo->destAck = base;
00123 }
00124
00125 }
00126
00127 void setReverseModeForNcpyOpInfo(NcpyOperationInfo *ncpyOpInfo) {
00128 switch(ncpyOpInfo->opMode) {
00129 case CMK_EM_API : ncpyOpInfo->opMode = CMK_EM_API_REVERSE;
00130 break;
00131 case CMK_DIRECT_API :
00132 break;
00133 case CMK_BCAST_EM_API : ncpyOpInfo->opMode = CMK_BCAST_EM_API_REVERSE;
00134 break;
00135 default : CmiAbort("Unknown opcode");
00136 break;
00137 }
00138 }