6
void Init(ArgStruct *p, int* pargc, char*** pargv)
8
gpshmem_init(pargc, pargv);
11
void Setup(ArgStruct *p)
15
if((npes=gpnumpes())!=2) {
17
printf("Error Message: npes = %d - You must run on 2 nodes\n", gpnumpes());
21
p->prot.flag=(int *) gpshmalloc(sizeof(int));
22
pTime = (double *) gpshmalloc(sizeof(double));
23
pNrepeat = (int *) gpshmalloc(sizeof(int));
26
if((p->prot.ipe=gpmype()) == 0) {
39
void Sync(ArgStruct *p)
41
gpshmem_barrier_all();
44
void PrepareToReceive(ArgStruct *p) { }
46
void SendData(ArgStruct *p)
49
gpshmem_put32((short*)p->buff,(short*)p->buff,p->bufflen/4,p->prot.nbor);
51
gpshmem_putmem(p->buff,p->buff,p->bufflen,p->prot.nbor);
54
void RecvData(ArgStruct *p)
58
while( p->buff[p->bufflen-1] != 'b'+p->prot.ipe ) {
60
if( ++i%10000000==0 ) printf("");
64
p->buff[p->bufflen-1] = 'b' + p->prot.nbor;
67
void SendTime(ArgStruct *p, double *t)
71
gpshmem_putmem(pTime,pTime,sizeof(double),p->prot.nbor);
72
gpshmem_putmem(p->prot.flag,p->prot.flag,sizeof(int),p->prot.nbor);
75
void RecvTime(ArgStruct *p, double *t)
79
while(*p->prot.flag!=p->prot.ipe)
81
if(++i%10000000==0) printf("");
84
*p->prot.flag=p->prot.nbor;
87
void SendRepeat(ArgStruct *p, int rpt)
91
gpshmem_putmem(pNrepeat,pNrepeat,sizeof(int),p->prot.nbor);
93
gpshmem_putmem(p->prot.flag,p->prot.flag,sizeof(int),p->prot.nbor);
97
void RecvRepeat(ArgStruct *p, int *rpt)
101
while( *p->prot.flag != p->prot.ipe ) {
103
if( ++i%2 == 3 ) printf("%d", *p->prot.flag); /* invalidate cache */
107
*p->prot.flag=p->prot.nbor;
111
void CleanUp(ArgStruct *p)
117
void Reset(ArgStruct *p)
122
void MyMalloc(ArgStruct *p, int bufflen, int soffset, int roffset)
124
if((p->buff=(char *)gpshmalloc(bufflen+MAX(soffset,roffset)))==(char *)NULL)
126
fprintf(stderr,"couldn't allocate memory\n");
129
p->buff[bufflen-1]='b'+p->tr;
130
if((p->buff1=(char *)gpshmalloc(bufflen+soffset))==(char *)NULL)
132
fprintf(stderr,"Couldn't allocate memory\n");
137
void FreeBuff(char *buff1, char* buff2)