int main(int argc, char **argv) { eb_t eb; ep_t ep; uint64_t networkpid; int64_t begin, end, total; int polling = 1; int iters = 0; TEST_STARTUP(argc, argv, networkpid, eb, ep, 1, 2, "iters (Poll/Block)"); /* setup handlers */ AM_Safe(AM_SetHandler(ep, LARGE_REQ_HANDLER, large_request_handler)); AM_Safe(AM_SetHandler(ep, LARGE_REP_HANDLER, large_reply_handler)); setupUtilHandlers(ep, eb); /* get SPMD info */ myproc = AMX_SPMDMyProc(); numprocs = AMX_SPMDNumProcs(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 1; if (argc > 2) { switch(argv[2][0]) { case 'p': case 'P': polling = 1; break; case 'b': case 'B': polling = 0; break; default: printf("polling must be 'P' or 'B'..\n"); AMX_SPMDExit(1); } } if (numprocs % 2 != 0 && numprocs > 1) { printf("requires an even or unary number of processors\n"); AMX_SPMDExit(1); } VMseg = (uint32_t *)malloc(AM_MaxLong()+100); memset(VMseg, 0, AM_MaxLong()+100); AM_Safe(AM_SetSeg(ep, VMseg, AM_MaxLong()+100)); if (myproc % 2 == 0) partner = (myproc + 1) % numprocs; else partner = (myproc - 1); AM_Safe(AMX_SPMDBarrier()); if (myproc == 0) printf("Running %i iterations of bulk bounce test...\n", iters); begin = getCurrentTimeMicrosec(); if (myproc % 2 == 1 || numprocs == 1) { int q; for (q=0; q<iters; q++) { /* init my source mem */ int i; uint32_t *srcmem = (uint32_t *)(((uint8_t*)VMseg)+100); for (i = 0; i < AM_MaxLong()/4; i++) { srcmem[i] = (uint32_t)((count << 16) + i); } #if VERBOSE printf("%i: sending request...", myproc); fflush(stdout); #endif done = 0; AM_Safe(AM_RequestXfer1(ep, partner, 100, LARGE_REQ_HANDLER, srcmem, AM_MaxLong(), 666)); if (polling) { /* poll until everyone done */ while (!done) { AM_Safe(AM_Poll(eb)); } } else { while (!done) { AM_Safe(AM_SetEventMask(eb, AM_NOTEMPTY)); AM_Safe(AM_WaitSema(eb)); AM_Safe(AM_Poll(eb)); } } } } else { if (polling) { /* poll until everyone done */ while (count<iters*2) { AM_Safe(AM_Poll(eb)); } } else { while (count<iters*2) { AM_Safe(AM_SetEventMask(eb, AM_NOTEMPTY)); AM_Safe(AM_WaitSema(eb)); AM_Safe(AM_Poll(eb)); } } } end = getCurrentTimeMicrosec(); total = end - begin; printf("Slave %i: %i microseconds total, throughput: %8.3f KB/sec\n", myproc, (int)total, (float)(((float)1000000)*AM_MaxLong()*iters/((int)total))/1024.0); fflush(stdout); /* dump stats */ AM_Safe(AMX_SPMDBarrier()); printGlobalStats(); AM_Safe(AMX_SPMDBarrier()); /* exit */ AM_Safe(AMX_SPMDExit(0)); return 0; }
int main(int argc, char **argv) { eb_t eb; ep_t ep; uint64_t networkpid; int myproc; int numprocs; int k; int iters = 0; int errs = 0; TEST_STARTUP(argc, argv, networkpid, eb, ep, 1, 1, "iters"); /* setup handlers */ setupUtilHandlers(ep, eb); /* get SPMD info */ myproc = AMX_SPMDMyProc(); numprocs = AMX_SPMDNumProcs(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 1; if (myproc == 0) { printf("Running %i iterations of read/write test...\n", iters); fflush(stdout); } /* gather pointers to static data, to handle non-uniform address spaces */ AM_Safe(AMX_SPMDAllGather(&myvals, pvals, sizeof(myvals))); for (k=0;k < iters; k++) { /* set left neighbor's array */ int i; int leftP = myproc-1; if (leftP == -1) leftP = numprocs-1; for (i=0;i<MAX_PROCS;i++) writeWord(leftP, pvals[leftP]+i, k); writeSync(); AM_Safe(AMX_SPMDBarrier()); /* barrier */ { /* read right neighbor's array */ int i; int rightP = myproc+1; if (rightP == numprocs) rightP = 0; for (i=0;i<MAX_PROCS;i++) readWord(&readarray[i], rightP, pvals[rightP]+i); readSync(); /* verify */ for (i=0;i<MAX_PROCS;i++) { if (((int)readarray[i]) != k) { printf("ERROR: Proc %i READ/WRITE TEST FAILED : readarray[%i] = %i k = %i\n", myproc, i, (int)readarray[i], k); fflush(stdout); errs++; break; } } } AM_Safe(AMX_SPMDBarrier()); /* barrier */ } if (!errs) { printf("Proc %i verified.\n", myproc); fflush(stdout); } /* dump stats */ AM_Safe(AMX_SPMDBarrier()); printGlobalStats(); AM_Safe(AMX_SPMDBarrier()); /* exit */ AM_Safe(AMX_SPMDExit(0)); return 0; }
int main(int argc, char **argv) { eb_t eb; ep_t ep; uint64_t networkpid; int64_t begin, end, total; int polling = 1; int fullduplex = 0; int rightguy; uint32_t *srcmem; int iters = 0; TEST_STARTUP(argc, argv, networkpid, eb, ep, 1, 4, "iters (bulkmsgsize) (Poll/Block) (Half/Full)"); /* setup handlers */ AM_Safe(AM_SetHandler(ep, BULK_REQ_HANDLER, bulk_request_handler)); AM_Safe(AM_SetHandler(ep, BULK_REP_HANDLER, bulk_reply_handler)); setupUtilHandlers(ep, eb); /* get SPMD info */ myproc = AMX_SPMDMyProc(); numprocs = AMX_SPMDNumProcs(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 1; if (argc > 2) size = atoi(argv[2]); if (size == -1) size = 512; if (argc > 3) { switch(argv[3][0]) { case 'p': case 'P': polling = 1; break; case 'b': case 'B': polling = 0; break; default: printf("polling must be 'P' or 'B'..\n"); AMX_SPMDExit(1); } } if (argc > 4) { switch(argv[4][0]) { case 'h': case 'H': fullduplex = 0; break; case 'f': case 'F': fullduplex = 1; break; default: printf("duplex must be H or F..\n"); AMX_SPMDExit(1); } } if (!fullduplex && numprocs > 1 && numprocs % 2 != 0) { printf("half duplex requires an even number of processors\n"); AMX_SPMDExit(1); } msg_size = (size > AM_MaxLong() ? AM_MaxLong() : size); nummsgs = (size % AM_MaxLong() == 0 ? size / AM_MaxLong() : (size / AM_MaxLong())+1); srcmem = (uint32_t *)malloc(msg_size); memset(srcmem, 0, msg_size); VMseg = (uint32_t *)malloc(msg_size+100); memset(VMseg, 0, msg_size+100); AM_Safe(AM_SetSeg(ep, VMseg, msg_size+100)); rightguy = (myproc + 1) % numprocs; { /* init my source mem */ int i; int numints = msg_size/4; for (i=0; i < numints; i++) srcmem[i] = i; } AM_Safe(AMX_SPMDBarrier()); if (myproc == 0) printf("Running %s bulk test sz=%i...\n", (fullduplex?"full-duplex":"half-duplex"), size); begin = getCurrentTimeMicrosec(); if (fullduplex || myproc % 2 == 1 || numprocs == 1) { int q; for (q=0; q<iters; q++) { int j; msg_size = AM_MaxLong(); for (j = 0; j < nummsgs; j++) { if (j == nummsgs-1 && size % AM_MaxLong() != 0) msg_size = size % AM_MaxLong(); /* last one */ #if VERBOSE_PING printf("%i: sending request...", myproc); fflush(stdout); #endif AM_Safe(AM_RequestXfer1(ep, rightguy, 100, BULK_REQ_HANDLER, srcmem, msg_size, 666)); } } } { int expectedmsgs = nummsgs*iters; if (numprocs == 1 || fullduplex) expectedmsgs *= 2; if (polling) { /* poll until everyone done */ while (done<expectedmsgs) { AM_Safe(AM_Poll(eb)); } } else { while (done<expectedmsgs) { AM_Safe(AM_SetEventMask(eb, AM_NOTEMPTY)); AM_Safe(AM_WaitSema(eb)); AM_Safe(AM_Poll(eb)); } } } end = getCurrentTimeMicrosec(); total = end - begin; if (fullduplex || myproc % 2 == 1 || numprocs == 1) printf("Slave %i: %i microseconds total, throughput: %8.3f KB/sec\n", myproc, (int)total, (float)(((float)1000000)*size*iters/((int)total))/1024.0); fflush(stdout); /* dump stats */ AM_Safe(AMX_SPMDBarrier()); printGlobalStats(); AM_Safe(AMX_SPMDBarrier()); /* exit */ AM_Safe(AMX_SPMDExit(0)); return 0; }
/* usage: testlatency numprocs spawnfn iters P/B */ int main(int argc, char **argv) { uint64_t networkpid; int64_t begin, end, total; int polling = 1; int k; int iters = 0; TEST_STARTUP(argc, argv, networkpid, eb, ep, 1, 2, "iters (Poll/Block)"); /* setup handlers */ AM_Safe(AM_SetHandler(ep, PING_REQ_HANDLER, ping_request_handler)); AM_Safe(AM_SetHandler(ep, PING_REP_HANDLER, ping_reply_handler)); setupUtilHandlers(ep, eb); /* get SPMD info */ myproc = AMX_SPMDMyProc(); numprocs = AMX_SPMDNumProcs(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 1; if (argc > 2) { switch(argv[2][0]) { case 'p': case 'P': polling = 1; break; case 'b': case 'B': polling = 0; break; default: printf("polling must be 'P' or 'B'..\n"); AMX_SPMDExit(1); } } outputTimerStats(); AM_Safe(AMX_SPMDBarrier()); if (myproc == 0) printf("Running %i iterations of latency test...\n", iters); if (myproc == 0 && numprocs > 1) numleft = (numprocs-1)*iters; AM_Safe(AMX_SPMDBarrier()); begin = getCurrentTimeMicrosec(); if (myproc == 0 && numprocs > 1) { mywait(polling); } else { /* everybody sends packets to 0 */ int expect = (numprocs > 1 ? 1 : 2); for (k=0;k < iters; k++) { numleft = expect; #if VERBOSE printf("%i: sending request...", myproc); fflush(stdout); #endif AM_Safe(AM_Request0(ep, 0, PING_REQ_HANDLER)); mywait(polling); } } end = getCurrentTimeMicrosec(); total = end - begin; if (myproc != 0 || numprocs == 1) printf("Slave %i: %i microseconds total, throughput: %i requests/sec (%.3f us / request)\n", myproc, (int)total, (int)(((float)1000000)*iters/((int)total)), ((double)total)/iters); else printf("Slave 0 done.\n"); fflush(stdout); /* dump stats */ AM_Safe(AMX_SPMDBarrier()); printGlobalStats(); AM_Safe(AMX_SPMDBarrier()); /* exit */ AM_Safe(AMX_SPMDExit(0)); return 0; }