00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "pup.h"
00013 #include "pup_c.h"
00014 #include "pup_toNetwork.h"
00015 #include "charm-api.h"
00016
00017
00018
00019
00020
00021
00022 #define mp (*(PUP::er *)p)
00023
00024
00025 CLINKAGE pup_er pup_new_sizer(void)
00026 { return new PUP::sizer; }
00027 CLINKAGE pup_er pup_new_toMem(void *Nbuf)
00028 { return new PUP::toMem(Nbuf); }
00029 CLINKAGE pup_er pup_new_fromMem(const void *Nbuf)
00030 { return new PUP::fromMem(Nbuf); }
00031 CLINKAGE pup_er pup_new_network_sizer(void)
00032 { return new PUP_toNetwork_sizer; }
00033 CLINKAGE pup_er pup_new_network_pack(void *Nbuf)
00034 { return new PUP_toNetwork_pack(Nbuf); }
00035 CLINKAGE pup_er pup_new_network_unpack(const void *Nbuf)
00036 { return new PUP_toNetwork_unpack(Nbuf); }
00037 #if CMK_CCS_AVAILABLE
00038 #include "ccs-builtins.h"
00039 CLINKAGE pup_er pup_new_fmt(pup_er p)
00040 { return new PUP_fmt(mp); }
00041 CLINKAGE void pup_fmt_sync_begin_object(pup_er p)
00042 { mp.synchronize(PUP::sync_begin_object); }
00043 CLINKAGE void pup_fmt_sync_end_object(pup_er p)
00044 { mp.synchronize(PUP::sync_end_object); }
00045 CLINKAGE void pup_fmt_sync_begin_array(pup_er p)
00046 { mp.synchronize(PUP::sync_begin_array); }
00047 CLINKAGE void pup_fmt_sync_end_array(pup_er p)
00048 { mp.synchronize(PUP::sync_end_array); }
00049 CLINKAGE void pup_fmt_sync_item(pup_er p)
00050 { mp.syncComment(PUP::sync_item); }
00051 #endif
00052 CLINKAGE void pup_destroy(pup_er p)
00053 { delete ((PUP::er *)p); }
00054
00055
00056
00057 CLINKAGE int pup_isPacking(const pup_er p)
00058 { return (mp.isPacking())?1:0;}
00059 CLINKAGE int pup_isUnpacking(const pup_er p)
00060 { return (mp.isUnpacking())?1:0;}
00061 CLINKAGE int pup_isSizing(const pup_er p)
00062 { return (mp.isSizing())?1:0;}
00063 CLINKAGE int pup_isDeleting(const pup_er p)
00064 { return (mp.isDeleting())?1:0;}
00065 CLINKAGE int pup_isUserlevel(const pup_er p)
00066 { return (mp.isUserlevel())?1:0;}
00067 CLINKAGE int pup_isRestarting(const pup_er p)
00068 { return (mp.isRestarting())?1:0;}
00069 CLINKAGE char* pup_typeString(const pup_er p)
00070 { return (char *)mp.typeString(); }
00071
00072 FLINKAGE int FTN_NAME(FPUP_ISPACKING,fpup_ispacking)(const pup_er p)
00073 { return (mp.isPacking())?1:0;}
00074 FLINKAGE int FTN_NAME(FPUP_ISUNPACKING,fpup_isunpacking)(const pup_er p)
00075 { return (mp.isUnpacking())?1:0;}
00076 FLINKAGE int FTN_NAME(FPUP_ISSIZING,fpup_issizing)(const pup_er p)
00077 { return (mp.isSizing())?1:0;}
00078 FLINKAGE int FTN_NAME(FPUP_ISDELETING,fpup_isdeleting)(const pup_er p)
00079 { return (mp.isDeleting())?1:0;}
00080 FLINKAGE int FTN_NAME(FPUP_ISUSERLEVEL,fpup_isuserlevel)(const pup_er p)
00081 { return (mp.isUserlevel())?1:0;}
00082
00083
00084 CLINKAGE size_t pup_size(const pup_er p)
00085 { return mp.size(); }
00086
00087 #define SIZE_APPROX_BITS 13
00088
00089
00090 CLINKAGE CMK_TYPEDEF_UINT2 pup_encodeSize(size_t s)
00091 {
00092
00093
00094
00095 CmiUInt2 power = 0;
00096
00097 while (s > (1UL << SIZE_APPROX_BITS) - 1) {
00098 power++;
00099 if (s & (1UL << 6))
00100 s += (1UL << 7);
00101 s >>= 8;
00102 }
00103
00104 return (power << SIZE_APPROX_BITS) | s;
00105 }
00106
00107 CLINKAGE size_t pup_decodeSize(CMK_TYPEDEF_UINT2 a)
00108 {
00109 CmiUInt2 power = a >> SIZE_APPROX_BITS;
00110 size_t factor = 1UL << (8 * power);
00111
00112 size_t base = a & ((1UL << SIZE_APPROX_BITS) - 1);
00113
00114 return base * factor;
00115 }
00116
00117
00118 CLINKAGE void pup_syncComment(const pup_er p, unsigned int sync, const char *message)
00119 { mp.syncComment(sync, message); }
00120
00121
00122 CLINKAGE void pup_comment(const pup_er p, const char *message)
00123 { mp.comment(message); }
00124
00125 #undef PUP_BASIC_DATATYPE
00126 #undef PUP_BASIC_DATATYPEF
00127
00128
00129
00130
00131
00132
00133
00134
00135 #define PUP_BASIC_DATATYPE(typeName,type) \
00136 CLINKAGE void pup_##typeName(pup_er p,type *v) \
00137 {mp(*v);} \
00138 CLINKAGE void pup_##typeName##s(pup_er p,type *arr,size_t nItems) \
00139 {mp(arr,nItems);}
00140
00141 PUP_BASIC_DATATYPE(char,char)
00142 PUP_BASIC_DATATYPE(short,short)
00143 PUP_BASIC_DATATYPE(int,int)
00144 PUP_BASIC_DATATYPE(long,long)
00145 PUP_BASIC_DATATYPE(uchar,unsigned char)
00146 PUP_BASIC_DATATYPE(ushort,unsigned short)
00147 PUP_BASIC_DATATYPE(uint,unsigned int)
00148 PUP_BASIC_DATATYPE(ulong,unsigned long)
00149 PUP_BASIC_DATATYPE(float,float)
00150 PUP_BASIC_DATATYPE(double,double)
00151 PUP_BASIC_DATATYPE(int8,CMK_TYPEDEF_INT8)
00152 PUP_BASIC_DATATYPE(size_t,size_t)
00153
00154
00155 CLINKAGE void pup_pointer(pup_er p,void **v) {mp(*v,(void*)NULL);}
00156 CLINKAGE void pup_pointers(pup_er p,void **arr,size_t nItems) {mp(arr,nItems,(void*)NULL);}
00157
00158 #define PUP_BASIC_DATATYPEF(typeUP,typelo,type) \
00159 FLINKAGE void FTN_NAME(FPUP_##typeUP,fpup_##typelo)(pup_er p,type *v) \
00160 {mp(*v);} \
00161 FLINKAGE void FTN_NAME(FPUP_##typeUP##SG,fpup_##typelo##sg)(pup_er p,type *arr,int *nItems) \
00162 {mp(arr,*nItems);} \
00163 FLINKAGE void FTN_NAME(FPUP_##typeUP##S,fpup_##typelo##s)(pup_er p,type *arr,int *nItems) \
00164 {mp(arr,*nItems);}
00165
00166 PUP_BASIC_DATATYPEF(CHAR,char,char)
00167 PUP_BASIC_DATATYPEF(SHORT,short,short)
00168 PUP_BASIC_DATATYPEF(INT,int,int)
00169 PUP_BASIC_DATATYPEF(LONG,long,long)
00170 PUP_BASIC_DATATYPEF(REAL,real,float)
00171 PUP_BASIC_DATATYPEF(DOUBLE,double,double)
00172 PUP_BASIC_DATATYPEF(LOGICAL,logical,int)
00173
00174
00175 FLINKAGE void FTN_NAME(FPUP_COMPLEX,fpup_complex)(pup_er p, float *v)
00176 {mp(v,2);}
00177
00178 FLINKAGE void FTN_NAME(FPUP_COMPLEXESG,fpup_complexesg)(pup_er p, float *arr, int *nItems)
00179 {mp(arr,2*(*nItems));}
00180
00181 FLINKAGE void FTN_NAME(FPUP_COMPLEXES,fpup_complexes)(pup_er p, float *arr, int *nItems)
00182 {mp(arr,2*(*nItems));}
00183
00184 FLINKAGE void FTN_NAME(FPUP_DOUBLECOMPLEX,fpup_doublecomplex)(pup_er p, double *v)
00185 {mp(v,2);}
00186
00187 FLINKAGE void FTN_NAME(FPUP_DOUBLECOMPLEXESG,fpup_doublecomplexesg)(pup_er p, double *arr, int *nItems)
00188 {mp(arr,2*(*nItems));}
00189
00190 FLINKAGE void FTN_NAME(FPUP_DOUBLECOMPLEXES,fpup_doublecomplexes)(pup_er p, double *arr, int *nItems)
00191 {mp(arr,2*(*nItems));}
00192
00193
00194 CLINKAGE void pup_bytes(pup_er p,void *ptr,size_t nBytes)
00195 {
00196 mp((char *)ptr,nBytes);
00197 }
00198
00199 FLINKAGE void FTN_NAME(FPUP_BYTES,fpup_bytes)(pup_er p,void *ptr,int *nBytes)
00200 {
00201 mp((char *)ptr,*nBytes);
00202 }