/* this is a test program for my qcdoc communication routines */ /* Michael Creutz */ #define DEBUG 1 #define BLOCKSIZE 8 #include #include #include "include/qmemcpyoc.C" int main() { int i,sum; double time, dsum, x ,y; #define BUFFERSIZE 50 char buffer1[BUFFERSIZE]; char buffer2[BUFFERSIZE]; mycom.start(); printf("testing stop and start\n"); mycom.stop(); mycom.start(); printf("done with stop start test\n"); /* put something in the buffers */ sprintf(buffer1,"hello world from processor %d\n",processor); sprintf(buffer2,"buffer two\n"); printf(" buffer 1: %s buffer2: %s",buffer1,buffer2); printf("local transfer test\n"); mycom.qmemcpy(processor,buffer2,processor,buffer1,BUFFERSIZE); mycom.finishcopy(); printf(" buffer 1: %s buffer2: %s",buffer1,buffer2); printf("remote fetch test:\n"); mycom.qmemcpy(processor,buffer2, (processor+7)%NumNodes(),buffer1,BUFFERSIZE); mycom.finishcopy(); printf(" buffer 1: %s buffer2: %s",buffer1,buffer2); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; printf("single processor remote fetch test:\n"); if (processor==0) mycom.qmemcpy(processor,buffer2, (processor+2)%NumNodes(),buffer1,BUFFERSIZE); mycom.finishcopy(); printf(" buffer 1: %s buffer2: %s",buffer1,buffer2); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; printf("remote store test:\n"); mycom.qmemcpy((processor+3)%NumNodes(),buffer2, processor ,buffer1,BUFFERSIZE); mycom.finishcopy(); printf(" buffer 1: %s buffer2: %s",buffer1,buffer2); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; printf("remote to same remote test:\n"); mycom.qmemcpy((processor+7)%NumNodes(),buffer2, (processor+7)%NumNodes(),buffer1,BUFFERSIZE); mycom.finishcopy(); printf(" buffer 1: %s buffer2: %s",buffer1,buffer2); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; printf("remote to different remote test:\n"); mycom.qmemcpy((processor+13)%NumNodes(),buffer2, (processor+18)%NumNodes(),buffer1,BUFFERSIZE); mycom.finishcopy(); printf(" buffer 1: %s buffer2: %s",buffer1,buffer2); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; printf("integer global sum test:\n"); time = (1.0 * clock()) / CLOCKS_PER_SEC; for (i=0;i<1000;i++) sum=mycom.igsum(processor); time = (1.0 * clock()) / CLOCKS_PER_SEC - time; printf("sum of processor id's = %d\n",sum); printf(" 1000 integer global sums took %g seconds\n", time); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; printf("double global sum test:\n"); time = (1.0 * clock()) / CLOCKS_PER_SEC; for (i=0;i<1000;i++) dsum=mycom.dgsum(0.7*processor); time = (1.0 * clock()) / CLOCKS_PER_SEC - time; printf("sum of .7* processor id's = %g\n",dsum); printf(" 1000 double global sums took %g seconds\n", time); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; /* broadcast test */ sprintf(buffer1,"processor %d says hello\n",processor); time = (1.0 * clock()) / CLOCKS_PER_SEC; for (i=0;i<1000;i++) mycom.bcast(4%NumNodes(),buffer1,BUFFERSIZE); time = (1.0 * clock()) / CLOCKS_PER_SEC - time; printf("broadcast test from processor %d:\n buffer1: %s", 4%NumNodes(),buffer1); printf(" 1000 broadcasts of char buffer[%d] took %g seconds\n", BUFFERSIZE,time); printf("%d: maxqueue = %d\n",processor, mycom.maxqueue); mycom.maxqueue=0; printf("sync_count=%d\n",mycom.sync_count); x=1.23; y=3.45; printf("addit test x=%g y=%g\n",x,y); if ((processor+3)%NumNodes()==0) mycom.addit(0,&x,y); mycom.finishcopy(); printf("x + remote y = %g\n",x); x=1.0*processor; printf("gmax test: max processor id = %g\n", mycom.dgmax(x)); mycom.stop(); return 0; }