int main(int argc, char **argv) { gasnet_node_t rank, size; size_t segsz = GASNET_PAGESIZE; size_t heapsz = GASNET_PAGESIZE; int argi; GASNET_SAFE(gasnet_init(&argc, &argv)); rank = gasnet_mynode(); size = gasnet_nodes(); argi = 1; if ((argi < argc) && !strcmp(argv[argi], "-m")) { segsz = gasnet_getMaxLocalSegmentSize(); ++argi; } GASNET_SAFE(gasnet_attach(NULL, 0, segsz, heapsz)); /* Only first and last print here, to keep managable I/O volume at scale */ if (!rank || (rank == size-1)) printf("Hello from node %d of %d\n", (int)rank, (int)size); /* Spec says client should include a barrier before gasnet_exit() */ gasnet_barrier_notify(0,GASNET_BARRIERFLAG_ANONYMOUS); gasnet_barrier_wait(0,GASNET_BARRIERFLAG_ANONYMOUS); gasnet_exit(0); /* Not reached in most implementations */ return 0; }
void grt_init(int argc, char **argv) { pthread_t thread; /* Set up handler table */ if (!entry_table) { entry_table = grt_entry_table; table_size = GRT_TABLE_SIZE; } /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); /* get SPMD info */ grt_id = gasnet_mynode(); grt_num_procs = gasnet_nodes(); gethostname(grt_proc_name, MAX_PROCESSOR_NAME); /* Attach to network */ GASNET_Safe(gasnet_attach(entry_table, table_size, GASNET_HEAP_SIZE, MINHEAPOFFSET)); if (grt_id == 0) { printf("%s\n", argv[0]); #ifdef GRT_WORD_32 printf("We are on a 32-bit machine.\n"); #else printf("We are on a 64-bit machine.\n"); #endif printf("gasnet_AMMaxMedium()=%lu\n", gasnet_AMMaxMedium()); printf("gasnet_AMMaxLongRequest()=%lu\n", gasnet_AMMaxLongRequest()); printf("gasnet_AMMaxLongReply()=%lu\n", gasnet_AMMaxLongReply()); } fflush(stdout); BARRIER(); fflush(stdout); BARRIER(); /* Get segment info */ grt_seginfo = (gasnet_seginfo_t*) malloc(sizeof(gasnet_seginfo_t) * grt_num_procs); GASNET_Safe(gasnet_getSegmentInfo(grt_seginfo, grt_num_procs)); /* Initialize the heap for memory allocation */ grt_heap_base = grt_addr(grt_id, 0); grt_heap = umalloc_makeheap(grt_heap_base, grt_heap_size, UMALLOC_HEAP_GROWS_UP); /* Spawn off a thread to handle remote handler requests */ pthread_create(&thread, NULL, poll, NULL); /* Set up thread list */ linkedlist_init(&thread_list, 0, 0); BARRIER(); }
int main(int argc, char **argv) { int iters = 0; gasnet_handlerentry_t htable[] = { { 201, chksum_reqh }, { 202, chksum_reph } }; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(htable, sizeof(htable)/sizeof(gasnet_handlerentry_t), TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testcore1",0,"(iters)"); assert(CHKSUM_TOTAL <= gasnet_AMMaxMedium()); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 1000; if (argc > 2) test_usage(); /* get SPMD info */ chksum_iters = iters; myproc = gasnet_mynode(); numprocs = gasnet_nodes(); /* Only allow even number for numprocs */ if (numprocs % 2 != 0) { MSG("WARNING: This test requires an even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } peerproc = (myproc % 2) ? myproc-1 : myproc+1; seginfo_table = (gasnet_seginfo_t *) test_malloc(sizeof(gasnet_seginfo_t) * numprocs); printf("%d> starting monoseed_init(%d)\n", myproc, iters); monoseed_init(iters); printf("%d> starting chksums_test(%d)\n", myproc, iters); chksum_test(iters); gasnet_exit(0); return(0); }
/* This tester measures the performance of a number of miscellaneous GASNet functions that don't involve actual communication, to assist in evaluating the overhead of the GASNet layer itself */ int main(int argc, char **argv) { gasnet_handlerentry_t htable[] = { { hidx_null_shorthandler, null_shorthandler }, { hidx_justreply_shorthandler, justreply_shorthandler }, { hidx_null_medhandler, null_medhandler }, { hidx_justreply_medhandler, justreply_medhandler }, { hidx_null_longhandler, null_longhandler }, { hidx_justreply_longhandler, justreply_longhandler } }; GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(htable, sizeof(htable)/sizeof(gasnet_handlerentry_t), TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testmisc",1,"(iters) (accuracy_digits) (test_sections)"); mynode = gasnet_mynode(); myseg = TEST_MYSEG(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 100000; if (argc > 2) accuracy = atoi(argv[2]); if (!accuracy) accuracy = 3; if (argc > 3) TEST_SECTION_PARSE(argv[3]); if (argc > 4) test_usage(); if (mynode == 0) { printf("Running misc performance test with %i iterations...\n",iters); printf("%-50s Total time Avg. time\n" "%-50s ---------- ---------\n", "", ""); fflush(stdout); } doit1(); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); /* parse arguments */ arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-in")) { insegment = 1; ++arg; } else if (!strcmp(argv[arg], "-out")) { insegment = 0; ++arg; } else if (!strcmp(argv[arg], "-f")) { firstlastmode = 1; ++arg; } else if (!strcmp(argv[arg], "-a")) { fullduplexmode = 1; ++arg; } else if (!strcmp(argv[arg], "-p")) { do_puts = 1; numflavors++; ++arg; } else if (!strcmp(argv[arg], "-g")) { do_gets = 1; numflavors++; ++arg; } else if (!strcmp(argv[arg], "-s")) { do_amshort = 1; numflavors++; ++arg; } else if (!strcmp(argv[arg], "-m")) { do_ammedium = 1; numflavors++; ++arg; } else if (!strcmp(argv[arg], "-l")) { do_amlong = 1; numflavors++; ++arg; } else if (!strcmp(argv[arg], "-b")) { do_bulk = 1; ++arg; } else if (!strcmp(argv[arg], "-n")) { do_nonbulk = 1; ++arg; } else if (!strcmp(argv[arg], "-v")) { do_value = 1; ++arg; } else if (!strcmp(argv[arg], "-i")) { do_implicit = 1; numsync++; ++arg; } else if (!strcmp(argv[arg], "-e")) { do_explicit = 1; numsync++; ++arg; } else if (!strcmp(argv[arg], "-k")) { do_blocking = 1; numsync++; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (fullduplexmode && firstlastmode) help = 1; if (argc > arg+3) help = 1; if (argc > arg) { iters = atoi(argv[arg]); arg++; } if (!iters) iters = 10; if (argc > arg) { maxdepth = atoi(argv[arg]); arg++; } if (!maxdepth) maxdepth = 1024; /* 1024 default */ if (argc > arg) { maxsz = atoi(argv[arg]); arg++; } if (!maxsz) maxsz = 2*1024*1024; /* 2 MB default */ #ifdef GASNET_SEGMENT_EVERYTHING if (maxsz > TEST_SEGSZ) { MSG("maxsz must be <= %lu on GASNET_SEGMENT_EVERYTHING",(unsigned long)TEST_SEGSZ); gasnet_exit(1); } #endif GASNET_Safe(gasnet_attach(htable, sizeof(htable)/sizeof(gasnet_handlerentry_t), TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testqueue",1,"[-in|-out|-a|-f] (iters) (maxdepth) (maxsz)\n" " The 'in' or 'out' option selects whether the initiator-side\n" " memory is in the GASNet segment or not (default is not).\n" " The -a option enables full-duplex mode, where all nodes send.\n" " The -f option enables 'first/last' mode, where the first node\n" " sends to the last, while all other nodes sit idle.\n" " Test types to run: (defaults to everything)\n" " -p : puts\n" " -g : gets\n" " -s : AMShort\n" " -m : AMMedium\n" " -l : AMLong\n" " -n : Test non-bulk put/gets\n" " -b : Test bulk put/gets\n" " -v : Test value-based put/gets\n" " -i : Test implicit-handle put/gets\n" " -e : Test explicit-handle put/gets\n" " -k : Test blocking put/gets\n"); if (help) test_usage(); min_payload = 1; max_payload = maxsz; if (numflavors == 0) { /* default to all */ do_puts = 1; do_gets = 1; do_amshort = 1; do_ammedium = 1; do_amlong = 1; } if (numsync == 0) { /* default to all */ do_implicit = 1; do_explicit = 1; do_blocking = 1; } if (!do_bulk && !do_nonbulk && !do_value) { do_bulk = 1; do_nonbulk = 1; do_value = 1; } if (!do_implicit && !do_explicit && !do_blocking) { do_implicit = 1; do_explicit = 1; do_blocking = 1; } if (max_payload < min_payload) { printf("ERROR: maxsz must be >= %i\n",min_payload); gasnet_exit(1); } /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); if (!firstlastmode) { /* Only allow 1 or even number for numprocs */ if (numprocs > 1 && numprocs % 2 != 0) { MSG0("WARNING: This test requires a unary or even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } } /* Setting peer thread rank */ if (firstlastmode) { peerproc = numprocs-1; iamsender = (myproc == 0); iamrecver = (myproc == numprocs-1); multisender = 0; } else if (numprocs == 1) { peerproc = 0; iamsender = 1; iamrecver = 1; multisender = 0; } else { peerproc = (myproc % 2) ? (myproc - 1) : (myproc + 1); iamsender = (fullduplexmode || myproc % 2 == 0); iamrecver = (fullduplexmode || !iamsender); multisender = (fullduplexmode || numprocs >= 4); } multisender = 1; /* messes up output on some systems */ myseg = TEST_SEG(myproc); tgtmem = TEST_SEG(peerproc); if (insegment) { msgbuf = (void *) myseg; } else { alloc = (void *) test_calloc(maxsz+PAGESZ,1); /* use calloc to prevent valgrind warnings */ msgbuf = (void *) alignup(((uintptr_t)alloc), PAGESZ); /* ensure page alignment of base */ } assert(((uintptr_t)msgbuf) % PAGESZ == 0); MSG0("Running %squeue test with local addr %sside segment, iters=%i, maxdepth=%i, sz: %i...%i", firstlastmode ? "first/last " : (fullduplexmode ? "full-duplex ": ""), insegment ? "in" : "out", iters, maxdepth, min_payload, max_payload); MSG0("x-axis: queue depth, y-axis: message size, injection time in microseconds\n"); BARRIER(); handles = (gasnet_handle_t *) test_malloc(sizeof(gasnet_handle_t) * maxdepth); vghandles = (gasnet_valget_handle_t *) test_malloc(sizeof(gasnet_valget_handle_t) * maxdepth); do_bulkputgets(); do_nonbulkputgets(); do_valueputgets(); do_blockingputgets(); do_amtests(); BARRIER(); test_free(handles); if (!insegment) { test_free(alloc); } gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int arg = 1, help = 0; gasnet_handlerentry_t htable[] = { { hidx_ping_medhandler, ping_medhandler }, { hidx_pong_medhandler, pong_medhandler }, { hidx_ping_longhandler, ping_longhandler }, { hidx_pong_longhandler, pong_longhandler }, { hidx_ping_alonghandler, ping_alonghandler }, }; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); #define AMOPT() if (!amopt) { amopt = 1; domed = 0; dolong = 0; dolongasync = 0; } while (argc > arg) { if (!strcmp(argv[arg], "-p")) { doprime = 1; ++arg; } else if (!strcmp(argv[arg], "-u")) { dosizesync = 0; ++arg; } else if (!strcmp(argv[arg], "-s")) { domultith = 0; ++arg; } else if (!strcmp(argv[arg], "-n")) { allowretry = 0; ++arg; } else if (!strcmp(argv[arg], "-in")) { doinseg = 1; dooutseg = 0; ++arg; } else if (!strcmp(argv[arg], "-out")) { doinseg = 0; dooutseg = 1; ++arg; } else if (!strcmp(argv[arg], "-m")) { AMOPT(); domed = 1; ++arg; } else if (!strcmp(argv[arg], "-l")) { AMOPT(); dolong = 1; ++arg; } else if (!strcmp(argv[arg], "-a")) { AMOPT(); dolongasync = 1; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); arg++; } if (!iters) iters = 10; if (argc > arg) { max_payload = atoi(argv[arg]); arg++; } if (!max_payload) max_payload = 1024*1024; if (argc > arg) { depth = atoi(argv[arg]); arg++; } if (!depth) depth = 16; /* round down to largest payload AM allows */ maxlong = MIN(gasnet_AMMaxLongRequest(),gasnet_AMMaxLongReply()); max_payload = MIN(max_payload,MAX(gasnet_AMMaxMedium(),maxlong)); GASNET_Safe(gasnet_attach(htable, sizeof(htable)/sizeof(gasnet_handlerentry_t), TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testcore2",0,"[options] (iters) (max_payload) (depth)\n" " -m test AMMedium (defaults to all types)\n" " -l test AMLong (defaults to all types)\n" " -a test AMLongAsync (defaults to all types)\n" " -p prime the AMLong transfer areas with puts, to encourage pinning\n" " -u loosen sychronization to allow diff payload sizes to be in flight at once\n" " -s single-threaded PAR mode (default is to start a polling thread in PAR mode)\n" " -n no retry on failure\n" " -in/-out use only in- or out-of-segment sources for AMLong(Async) (default is both)\n" ); if (help || argc > arg) test_usage(); TEST_PRINT_CONDUITINFO(); /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); peerproc = myproc ^ 1; if (peerproc == gasnet_nodes()) { /* w/ odd # of nodes, last one talks to self */ peerproc = myproc; } myseg = TEST_MYSEG(); peerreqseg = TEST_SEG(peerproc); peerrepseg = peerreqseg+max_payload*depth*2; localseg = myseg + max_payload*depth*4; assert_always(TEST_SEGSZ >= max_payload*depth*5); privateseg = test_malloc(max_payload*depth*3); /* out-of-seg request src, long reply src, along reply src */ longreplysrc = privateseg+max_payload*depth; alongreplysrc = privateseg+max_payload*depth*2; #ifdef GASNET_PAR if (domultith) test_createandjoin_pthreads(2,doit,NULL,0); else #endif doit(0); BARRIER(); test_free(privateseg); MSG("done. (detected %i errs)", test_errs); gasnet_exit(test_errs > 0 ? 1 : 0); return 0; }
int main(int argc, char **argv) { int iters = 0; int arg; void *myseg; int firstlastmode = 0; int fullduplexmode = 0; int crossmachinemode = 0; int skipwarmup = 0; int help = 0; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); /* parse arguments */ arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-f")) { firstlastmode = 1; ++arg; } else if (!strcmp(argv[arg], "-c")) { crossmachinemode = 1; ++arg; } else if (!strcmp(argv[arg], "-a")) { fullduplexmode = 1; ++arg; } else if (!strcmp(argv[arg], "-m")) { unitsMB = 1; ++arg; } else if (!strcmp(argv[arg], "-s")) { skipwarmup = 1; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); arg++; } if (!iters) iters = 1000; if (argc > arg) { maxsz = atoi(argv[arg]); arg++; } if (!maxsz) maxsz = 1024*1024; /* 1 MB default */ if (argc > arg) { TEST_SECTION_PARSE(argv[arg]); arg++; } #ifdef GASNET_SEGMENT_EVERYTHING if (maxsz > TEST_SEGSZ) { ERR("maxsz must be <= %lu on GASNET_SEGMENT_EVERYTHING",(unsigned long)TEST_SEGSZ); gasnet_exit(1); } #endif GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testmemset",1, "[options] (iters) (maxsz) (test_sections)\n" " The -s option skips warm-up iterations\n" " The -m option enables MB/sec units for bandwidth output (MB=2^20 bytes).\n" " The -a option enables full-duplex mode, where all nodes send.\n" " The -c option enables cross-machine pairing, default is nearest neighbor.\n" " The -f option enables 'first/last' mode, where the first/last\n" " nodes communicate with each other, while all other nodes sit idle."); if (help || argc > arg) test_usage(); min_payload = 1; max_payload = maxsz; if (max_payload < min_payload) { ERR("maxsz must be >= %i\n",min_payload); test_usage(); } /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); if (!firstlastmode) { /* Only allow 1 or even number for numprocs */ if (numprocs > 1 && numprocs % 2 != 0) { MSG("WARNING: This test requires a unary or even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } } /* Setting peer thread rank */ if (firstlastmode) { peerproc = (myproc == 0 ? numprocs-1 : 0); iamsender = (fullduplexmode ? myproc == 0 || myproc == numprocs-1 : myproc == 0); } else if (numprocs == 1) { peerproc = 0; iamsender = 1; } else if (crossmachinemode) { if (myproc < numprocs / 2) { peerproc = myproc + numprocs/2; iamsender = 1; } else { peerproc = myproc - numprocs/2; iamsender = fullduplexmode; } } else { peerproc = (myproc % 2) ? (myproc - 1) : (myproc + 1); iamsender = (fullduplexmode || myproc % 2 == 0); } myseg = TEST_SEG(myproc); tgtmem = TEST_SEG(peerproc); if (myproc == 0) MSG("Running %i iterations of %s%s%smemset for sizes: %i...%i\n", iters, (firstlastmode ? "first/last " : ""), (fullduplexmode ? "full-duplex ": ""), (crossmachinemode ? "cross-machine ": ""), min_payload, max_payload); BARRIER(); if (iamsender && !skipwarmup) { /* pay some warm-up costs */ int i; int warm_iters = MIN(iters, 32767); /* avoid hitting 65535-handle limit */ gasnet_handle_t *h = test_malloc(sizeof(gasnet_handle_t)*warm_iters); for (i = 0; i < warm_iters; i++) { gasnet_memset(peerproc, tgtmem, 0xff, 8); gasnet_memset_nbi(peerproc, tgtmem, 0xff, 8); h[i] = gasnet_memset_nb(peerproc, tgtmem, 0xff, 8); } gasnet_memset(peerproc, tgtmem, 0xff, max_payload); gasnet_wait_syncnb_all(h, warm_iters); gasnet_wait_syncnbi_puts(); test_free(h); } BARRIER(); if (TEST_SECTION_BEGIN_ENABLED()) bulk_test(iters); if (TEST_SECTION_BEGIN_ENABLED()) bulk_test_nbi(iters); if (TEST_SECTION_BEGIN_ENABLED()) bulk_test_nb(iters); BARRIER(); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int arg; int iters = 0; int size = 0; int j; int help = 0; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testalign", 1, "[-in|-out] (iters) (size)\n" " The 'in' or 'out' option selects whether the initiator-side\n" " memory is in the GASNet segment or not (default is not).\n" " The -m option enables MB/sec units for bandwidth output (MB=2^20 bytes)."); /* parse arguments */ arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-in")) { insegment = 1; ++arg; } else if (!strcmp(argv[arg], "-out")) { insegment = 0; ++arg; } else if (!strcmp(argv[arg], "-m")) { unitsMB = 1; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (help || argc > arg+2) test_usage(); if (argc > arg) iters = atoi(argv[arg++]); if (!iters) iters = 1000; if (argc > arg) size = atoi(argv[arg++]); if (!size) size = DEFAULT_SZ; /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); /* Only allow even number for numprocs */ if (numprocs % 2 != 0) { MSG("WARNING: This test requires an even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } /* Setting peer thread rank */ peerproc = (myproc % 2) ? (myproc - 1) : (myproc + 1); iamsender = (myproc % 2 == 0); rembuf = (void *) TEST_SEG(peerproc); /* initialize global data in my thread */ if (insegment) { locbuf = (void *)TEST_MYSEG(); } else { /* size + 1 page of alignment + initial alignment padding of PAGESZ-1 */ uintptr_t tmp = (uintptr_t) test_malloc(size + 2 * PAGESZ - 1); locbuf = (void *)((tmp + PAGESZ - 1) & ~(PAGESZ - 1)); } for (j = 1; j <= PAGESZ; j *= 2) oneway_test(iters, size, j); for (j = 1; j <= PAGESZ; j *= 2) oneway_nbi_test(iters, size, j); for (j = 1; j <= PAGESZ; j *= 2) oneway_nb_test(iters, size, j); BARRIER(); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { static int *A, *B, *C, *D, *E, *F, *G; gasnet_node_t myproc, i; int j; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); if (argc > 1) { iters = atoi(argv[1]); } if (iters < 1) { iters = 1000; } #if GASNET_PAR if (argc > 2) { threads = atoi(argv[2]); } threads = test_thread_limit(threads); if (threads < 1) { printf("ERROR: Threads must be between 1 and %d\n", TEST_MAXTHREADS); exit(EXIT_FAILURE); } #endif /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); images = numprocs * threads; datasize = iters * (3 + 4 * images); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testcoll",0,"(iters) (threadcnt)"); TEST_SET_WAITMODE(threads); if (argc > 3) test_usage(); MSG0("Running coll test(s) with %d iterations.", iters); R = test_malloc(iters*sizeof(int)); TEST_SRAND(1); /* Number if ints to store */ /* Carve some variables out of the (aligned) segment: */ Aw = test_malloc(iters * sizeof(int *)); Bw = test_malloc(iters * sizeof(int *)); Cw = test_malloc(iters * sizeof(int *)); Dw = test_malloc(iters * sizeof(int *)); Ew = test_malloc(iters * sizeof(int *)); Fw = test_malloc(iters * sizeof(int *)); Gw = test_malloc(iters * sizeof(int *)); A = (int *)TEST_MYSEG(); /* int [1*iters] */ B = A + 1*iters; /* int [1*iters] */ C = B + 1*iters; /* int [N*iters] */ D = C + images*iters; /* int [N*iters] */ E = D + images*iters; /* int [1*iters] */ F = E + 1*iters; /* int [N*iters] */ G = F + images*iters; /* int [N*iters] */ for (j = 0; j < iters; ++j) { Aw[j] = A + j; Bw[j] = B + j; Cw[j] = C + j*images; Dw[j] = D + j*images; Ew[j] = E + j; Fw[j] = F + j*images; Gw[j] = G + j*images; } /* The unaligned equivalents */ Av = test_malloc_2D(iters, images * sizeof(int *)); Bv = test_malloc_2D(iters, images * sizeof(int *)); Cv = test_malloc_2D(iters, images * sizeof(int *)); Dv = test_malloc_2D(iters, images * sizeof(int *)); Ev = test_malloc_2D(iters, images * sizeof(int *)); Fv = test_malloc_2D(iters, images * sizeof(int *)); Gv = test_malloc_2D(iters, images * sizeof(int *)); for (i = 0; i < images; ++i) { /* Using (TEST_SEG(n) + n) yields unaligned even when the segments are aligned. This is to help catch any case where addresses might have been misused that might go undetected if the addresses were aligned */ A = (int *)TEST_SEG(i/threads) + (i/threads) + datasize*(i%threads); B = A + 1*iters; C = B + 1*iters; D = C + images*iters; E = D + images*iters; F = E + 1*iters; G = F + images*iters; for (j = 0; j < iters; ++j) { Av[j][i] = A + j; Bv[j][i] = B + j; Cv[j][i] = C + j*images; Dv[j][i] = D + j*images; Ev[j][i] = E + j; Fv[j][i] = F + j*images; Gv[j][i] = G + j*images; } } BARRIER(); #if GASNET_PAR MSG("Forking %d gasnet threads", threads); { int i; thread_data_t* tt_thread_data = test_malloc(threads*sizeof(thread_data_t)); for (i = 0; i < threads; i++) { tt_thread_data[i].myproc = myproc; tt_thread_data[i].local_id = i; tt_thread_data[i].mythread = i + threads * myproc; tt_thread_data[i].peerthread = i + threads * (((myproc ^ 1) == numprocs) ? myproc : (myproc ^ 1)); } test_createandjoin_pthreads(threads, &thread_main, tt_thread_data, sizeof(tt_thread_data[0])); test_free(tt_thread_data); } #else { thread_data_t td; td.myproc = myproc; td.local_id = 0; td.mythread = myproc; td.peerthread = ((myproc ^ 1) == numprocs) ? myproc : (myproc ^ 1); thread_main(&td); } #endif BARRIER(); test_free(Aw); test_free(Bw); test_free(Cw); test_free(Dw); test_free_2D(Av); test_free_2D(Bv); test_free_2D(Cv); test_free_2D(Dv); test_free(R); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { static int *A, *B, *C, *D, *E, *F, *G; gasnet_node_t myproc, i; int pollers = 0; int j; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); int arg = 1; int help = 0; while (argc > arg) { if (!strcmp(argv[arg], "-p")) { #if GASNET_PAR ++arg; if (argc > arg) { pollers = atoi(argv[arg]); arg++; } else help = 1; #else if (0 == gasnet_mynode()) { fprintf(stderr, "testcoll %s\n", GASNET_CONFIG_STRING); fprintf(stderr, "ERROR: The -p option is only available in the PAR configuration.\n"); fflush(NULL); } sleep(1); gasnet_exit(1); #endif } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); ++arg; } if (iters < 1) { iters = 1000; } #if GASNET_PAR if (argc > arg) { threads = atoi(argv[arg]); ++arg; } threads = test_thread_limit(threads); if (threads < 1) { printf("ERROR: Threads must be between 1 and %d\n", TEST_MAXTHREADS); exit(EXIT_FAILURE); } #endif /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); images = numprocs * threads; datasize = iters * (3 + 4 * images); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); #if GASNET_PAR #define USAGE "[options] (iters) (threadcnt)\n" \ " The -p option gives the number of polling threads, specified as\n" \ " a non-negative integer argument (default is no polling threads).\n" #else #define USAGE "(iters)\n" #endif test_init("testcoll",0,USAGE); TEST_SET_WAITMODE(threads + pollers); if (argc > arg || help) test_usage(); MSG0("Running coll test(s) with %d iterations.", iters); R = test_malloc(iters*sizeof(int)); /* Number if ints to store */ /* Carve some variables out of the (aligned) segment: */ Aw = test_malloc(iters * sizeof(int *)); Bw = test_malloc(iters * sizeof(int *)); Cw = test_malloc(iters * sizeof(int *)); Dw = test_malloc(iters * sizeof(int *)); Ew = test_malloc(iters * sizeof(int *)); Fw = test_malloc(iters * sizeof(int *)); Gw = test_malloc(iters * sizeof(int *)); A = (int *)TEST_MYSEG(); /* int [1*iters] */ B = A + 1*iters; /* int [1*iters] */ C = B + 1*iters; /* int [N*iters] */ D = C + images*iters; /* int [N*iters] */ E = D + images*iters; /* int [1*iters] */ F = E + 1*iters; /* int [N*iters] */ G = F + images*iters; /* int [N*iters] */ for (j = 0; j < iters; ++j) { Aw[j] = A + j; Bw[j] = B + j; Cw[j] = C + j*images; Dw[j] = D + j*images; Ew[j] = E + j; Fw[j] = F + j*images; Gw[j] = G + j*images; } /* The unaligned equivalents */ Av = test_malloc_2D(iters, images * sizeof(int *)); Bv = test_malloc_2D(iters, images * sizeof(int *)); Cv = test_malloc_2D(iters, images * sizeof(int *)); Dv = test_malloc_2D(iters, images * sizeof(int *)); Ev = test_malloc_2D(iters, images * sizeof(int *)); Fv = test_malloc_2D(iters, images * sizeof(int *)); Gv = test_malloc_2D(iters, images * sizeof(int *)); for (i = 0; i < images; ++i) { /* Using (TEST_SEG(n) + n) yields unaligned even when the segments are aligned. This is to help catch any case where addresses might have been misused that might go undetected if the addresses were aligned */ A = (int *)TEST_SEG(i/threads) + (i/threads) + datasize*(i%threads); B = A + 1*iters; C = B + 1*iters; D = C + images*iters; E = D + images*iters; F = E + 1*iters; G = F + images*iters; for (j = 0; j < iters; ++j) { Av[j][i] = A + j; Bv[j][i] = B + j; Cv[j][i] = C + j*images; Dv[j][i] = D + j*images; Ev[j][i] = E + j; Fv[j][i] = F + j*images; Gv[j][i] = G + j*images; } } BARRIER(); #if GASNET_PAR MSG("Forking %d gasnet threads (%d active, %d polling)", threads+pollers, threads, pollers); { int i; thread_data_t* tt_thread_data = test_malloc(threads*sizeof(thread_data_t)); for (i = 0; i < threads; i++) { tt_thread_data[i].myproc = myproc; tt_thread_data[i].local_id = i; tt_thread_data[i].mythread = i + threads * myproc; tt_thread_data[i].peerthread = i + threads * (((myproc ^ 1) == numprocs) ? myproc : (myproc ^ 1)); } test_createandjoin_pthreads(threads, &thread_main, tt_thread_data, sizeof(tt_thread_data[0])); test_free(tt_thread_data); } #else { thread_data_t td; td.myproc = myproc; td.local_id = 0; td.mythread = myproc; td.peerthread = ((myproc ^ 1) == numprocs) ? myproc : (myproc ^ 1); thread_main(&td); } #endif BARRIER(); test_free(Aw); test_free(Bw); test_free(Cw); test_free(Dw); test_free_2D(Av); test_free_2D(Bv); test_free_2D(Cv); test_free_2D(Dv); test_free(R); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int i,j; static uint8_t *A, *B; thread_data_t *td_arr; GASNET_Safe(gasnet_init(&argc, &argv)); performance_iters = DEFAULT_PERFORMANCE_ITERS; for(i=1; i<argc; i++) { if(strcmp("-i", argv[i])==0 || strcmp("-iters", argv[i])==0) { performance_iters = atoi(argv[i+1]); i++; } else if(strcmp("-f", argv[i])==0 || strcmp("-tune-file", argv[i])==0) { outputfile = test_malloc(strlen(argv[i+1])+1); strcpy(outputfile, argv[i+1]); i++; } else if(strcmp("-p", argv[i])==0 || strcmp("-profile", argv[i])==0) { profile_file = test_malloc(strlen(argv[i+1])+1); strcpy(profile_file, argv[i+1]); i++; } else if(strcmp("-h", argv[i])==0 || strcmp("-help", argv[i])==0) { MSG0("usage: %s (-i iters) (-f output file)\n", argv[0]); gasnet_exit(0); } } max_data_size = 0; threads_per_node = 0; profile_info = load_file(profile_file); fill_meta_data(profile_info); printf("data loaded: %d %d\n", (int)max_data_size, threads_per_node); if(max_data_size <=0) { fprintf(stderr, "max data size(%d) should be >=0\n", (int) max_data_size); gasnet_exit(1); } if(threads_per_node<1) { fprintf(stderr, "threads_per_node (%d) should be > 0\n", threads_per_node); gasnet_exit(1); } if(performance_iters <=0) { gasnet_exit(0); } mynode = gasnet_mynode(); nodes = gasnet_nodes(); THREADS = nodes * threads_per_node; GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); /* ?? test_init("testcolltuner",0,"(-i iters) (-f output_file)"); */ A = TEST_MYSEG(); B = A+(SEG_PER_THREAD*threads_per_node); my_srcs = (uint8_t**) test_malloc(sizeof(uint8_t*)*threads_per_node); my_dsts = (uint8_t**) test_malloc(sizeof(uint8_t*)*threads_per_node); all_srcs = (uint8_t**) test_malloc(sizeof(uint8_t*)*THREADS); all_dsts = (uint8_t**) test_malloc(sizeof(uint8_t*)*THREADS); td_arr = (thread_data_t*) test_malloc(sizeof(thread_data_t)*threads_per_node); TEST_SET_WAITMODE(threads_per_node); for(i=0; i<threads_per_node; i++) { my_srcs[i] = A + i*SEG_PER_THREAD; my_dsts[i] = B + i*SEG_PER_THREAD; td_arr[i].my_local_thread = i; td_arr[i].mythread = mynode*threads_per_node+i; td_arr[i].mysrc = my_srcs[i]; td_arr[i].mydest = my_dsts[i]; } for(i=0; i<nodes; i++) { /* assert_always(TEST_SEG(i).size >= SEG_PER_THREAD*threads_per_node); */ for(j=0; j<threads_per_node; j++) { all_srcs[i*threads_per_node+j] = (uint8_t*) TEST_SEG(i) + j*SEG_PER_THREAD; all_dsts[i*threads_per_node+j] = (uint8_t*) TEST_SEG(i) + SEG_PER_THREAD*threads_per_node + j*SEG_PER_THREAD; } } #if GASNET_PAR test_createandjoin_pthreads(threads_per_node, &thread_main, td_arr, sizeof(thread_data_t)); #else thread_main(&td_arr[0]); #endif test_free(td_arr); BARRIER(); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int iters = 0; int arg; void *alloc = NULL; int firstlastmode = 0; int fullduplexmode = 0; int crossmachinemode = 0; int singlesender = 0; int help = 0; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); /* parse arguments */ arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-in")) { insegment = 1; ++arg; } else if (!strcmp(argv[arg], "-out")) { insegment = 0; ++arg; } else if (!strcmp(argv[arg], "-sl")) { ++arg; if (argc > arg) { stridelevels = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-mincontig")) { ++arg; if (argc > arg) { min_contig = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-maxcontig")) { ++arg; if (argc > arg) { max_contig = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-contigfactor")) { ++arg; if (argc > arg) { contigfactor = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-mindata")) { ++arg; if (argc > arg) { min_payload = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-maxdata")) { ++arg; if (argc > arg) { max_payload = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-datafactor")) { ++arg; if (argc > arg) { datafactor = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-densitysteps")) { ++arg; if (argc > arg) { densitysteps = atoi(argv[arg]); arg++; } else help = 1; } else if (!strcmp(argv[arg], "-f")) { firstlastmode = 1; ++arg; } else if (!strcmp(argv[arg], "-c")) { crossmachinemode = 1; ++arg; } else if (!strcmp(argv[arg], "-a")) { fullduplexmode = 1; ++arg; } else if (!strcmp(argv[arg], "-p")) { dogets = 0; doputs = 1; ++arg; } else if (!strcmp(argv[arg], "-g")) { dogets = 1; doputs = 0; ++arg; } else if (!strcmp(argv[arg], "-r")) { remotecontig = 1; ++arg; } else if (!strcmp(argv[arg], "-l")) { localcontig = 1; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); arg++; } if (!iters) iters = 1000; if (argc > arg) { TEST_SECTION_PARSE(argv[arg]); arg++; } if (min_contig && max_contig && min_contig > max_contig) { ERR("min_contig > max_contig"); help = 1; } if (min_payload && max_payload && min_payload > max_payload) { ERR("min_payload > max_payload"); help = 1; } if (min_payload && min_contig && min_payload < min_contig) { ERR("min_payload < min_contig"); help = 1; } if (max_contig && max_payload && max_contig > max_payload) { ERR("max_contig > max_payload"); help = 1; } if (contigfactor < 2) { ERR("contigfactor < 2"); help = 1; } if (datafactor < 2) { ERR("datafactor < 2"); help = 1; } if (!max_payload) max_payload = 2*1024*1024; /* 2 MB default */ #ifdef GASNET_SEGMENT_EVERYTHING maxsz = gasnet_getMaxGlobalSegmentSize(); #else maxsz = 16*1024*1024; #endif max_payload = (int)MIN(maxsz, max_payload); maxsz = MIN(((uint64_t)max_payload) * densitysteps,maxsz); if (!min_contig) min_contig = 8; if (!max_contig) max_contig = MIN(256*1024,max_payload); if (!min_payload) min_payload = min_contig; GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testvisperf",1, "[options] (iters) (test_sections)\n" " -p/-g selects puts only or gets only (default is both).\n" " -r/-l selects remotely contiguous or locally contiguous (default is neither).\n" " -mindata/-maxdata <sz> \n" " selects sz as min/max data payload per operation.\n" " -mincontig/-maxcontig <sz> \n" " selects sz as min/max contig size.\n" " -datafactor/-contigfactor <f> \n" " selects f as growth factor for data/contig sizes.\n" " -densitysteps <d> \n" " selects d density steps, inclusive from 100%..100/d%\n" " -sl <n> selects n striding levels (default is 2).\n" " -in/-out selects whether the initiator-side\n" " memory is in the GASNet segment or not (default is not).\n" " -a enables full-duplex mode, where all nodes send.\n" " -c enables cross-machine pairing, default is nearest neighbor.\n" " -f enables 'first/last' mode, where the first/last\n" " nodes communicate with each other, while all other nodes sit idle."); if (help || argc > arg) test_usage(); /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); if (!firstlastmode) { /* Only allow 1 or even number for numprocs */ if (numprocs > 1 && numprocs % 2 != 0) { MSG0("WARNING: This test requires a unary or even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } } /* Setting peer thread rank */ if (firstlastmode) { peerproc = (myproc == 0 ? numprocs-1 : 0); iamsender = (fullduplexmode ? myproc == 0 || myproc == numprocs-1 : myproc == 0); } else if (numprocs == 1) { peerproc = 0; iamsender = 1; } else if (crossmachinemode) { if (myproc < numprocs / 2) { peerproc = myproc + numprocs/2; iamsender = 1; } else { peerproc = myproc - numprocs/2; iamsender = fullduplexmode; } } else { peerproc = (myproc % 2) ? (myproc - 1) : (myproc + 1); iamsender = (fullduplexmode || myproc % 2 == 0); } singlesender = (numprocs == 1) || ((numprocs == 2 || firstlastmode) && !fullduplexmode); Rbase = TEST_SEG(peerproc); if (insegment) { Lbase = TEST_SEG(myproc); } else { alloc = test_calloc(maxsz+PAGESZ,1); /* use calloc to prevent valgrind warnings */ Lbase = alignup_ptr(alloc, PAGESZ); /* ensure page alignment of base */ } assert(((uintptr_t)Lbase) % PAGESZ == 0); if (myproc == 0) { MSG0("Running %i iterations of %s%s%snon-contiguous put/get%s%s\n local data %s-segment for sizes: %i...%i\n", iters, (firstlastmode ? "first/last " : ""), (fullduplexmode ? "full-duplex ": ""), (crossmachinemode ? "cross-machine ": ""), (remotecontig?"(remotely-contiguous)":""), (localcontig?"(locally-contiguous)":""), insegment ? "in" : "out", min_payload, max_payload); printf("rows are databytes/op : bandwidth values in MB/s\n"); } BARRIER(); { int contigsz; int rawdatasz; int isget; test_vis_t viscat; for (viscat = TEST_V; viscat <= TEST_S; viscat++) { for (isget = 0; isget < 2; isget++) { if (TEST_SECTION_BEGIN_ENABLED()) { if (isget && !dogets) continue; if (!isget && !doputs) continue; if (!dovis[viscat]) continue; for (contigsz = min_contig; contigsz <= max_contig; contigsz *= contigfactor) { int di; size_t lastdatasz = 0; if (contigsz > max_payload) continue; if (!myproc) { printf("\n%c: %s %s CONTIGSZ = %i\n", TEST_SECTION_NAME(), visdesc[(int)viscat], (isget?"GET":"PUT"), contigsz); printf(" density:"); for (di = 0; di < densitysteps; di++) { printf("%8i%%", (int)((densitysteps-di)*100.0/densitysteps)); } printf("\n"); } for (rawdatasz = min_payload; rawdatasz <= max_payload; rawdatasz *= datafactor) { char mystr[255]; size_t datasz = aligndown(rawdatasz,contigsz); if (datasz == lastdatasz) continue; lastdatasz = datasz; if (singlesender) snprintf(mystr, sizeof(mystr), "%8i: ", (int)datasz); else snprintf(mystr, sizeof(mystr), "P%i: %6i: ", myproc, (int)datasz); for (di = 0; di < densitysteps; di++) { gasnett_tick_t begin=0, end=0; size_t Lcnt = (localcontig ? 1 : datasz/contigsz); size_t Rcnt = (remotecontig? 1 : datasz/contigsz); size_t Lsz = datasz/Lcnt; size_t Rsz = datasz/Rcnt; void **Lilist = NULL; void **Rilist = NULL; gasnet_memvec_t *Lvlist = NULL; gasnet_memvec_t *Rvlist = NULL; size_t *Lstrides = NULL; size_t *Rstrides = NULL; size_t *LRcount = NULL; size_t stride = contigsz*(((double)densitysteps)/(densitysteps-di)); if (stride * MAX(Lcnt,Rcnt) > maxsz) { strcat(mystr," - "); continue; } if (iamsender) { /* setup metadata */ switch (viscat) { case TEST_V: Lvlist = make_vlist(Lbase, stride, Lcnt, Lsz); Rvlist = make_vlist(Rbase, stride, Rcnt, Rsz); break; case TEST_I: Lilist = make_ilist(Lbase, stride, Lcnt, Lsz); Rilist = make_ilist(Rbase, stride, Rcnt, Rsz); break; case TEST_S: { size_t chunkcnt = datasz/contigsz; int dim; Lstrides = test_malloc(sizeof(size_t)*stridelevels); Rstrides = test_malloc(sizeof(size_t)*stridelevels); LRcount = test_malloc(sizeof(size_t)*(stridelevels+1)); LRcount[0] = contigsz; Lstrides[0] = (localcontig ? contigsz : stride); Rstrides[0] = (remotecontig ? contigsz : stride); for (dim = 1; dim < stridelevels; dim++) { size_t factor = 1, fi; for (fi = 1; fi <= chunkcnt/(2*(stridelevels-dim)); fi++) /* choose a reasonable factor */ if (chunkcnt/fi*fi == chunkcnt) factor = fi; LRcount[dim] = factor; chunkcnt /= factor; Lstrides[dim] = LRcount[dim]*Lstrides[dim-1]; Rstrides[dim] = LRcount[dim]*Rstrides[dim-1]; } LRcount[stridelevels] = chunkcnt; { size_t tmp = 1; for (dim = 0; dim <= stridelevels; dim++) tmp *= LRcount[dim]; assert(tmp == datasz); } break; } } } #define DOIT(iters) do { \ int i; \ switch (viscat) { \ case TEST_V: \ for (i = 0; i < iters; i++) { \ if (isget) gasnet_getv_nbi_bulk(Lcnt,Lvlist,peerproc,Rcnt,Rvlist); \ else gasnet_putv_nbi_bulk(peerproc,Rcnt,Rvlist,Lcnt,Lvlist); \ } \ break; \ case TEST_I: \ for (i = 0; i < iters; i++) { \ if (isget) gasnet_geti_nbi_bulk(Lcnt,Lilist,Lsz,peerproc,Rcnt,Rilist,Rsz); \ else gasnet_puti_nbi_bulk(peerproc,Rcnt,Rilist,Rsz,Lcnt,Lilist,Lsz); \ } \ break; \ case TEST_S: \ for (i = 0; i < iters; i++) { \ if (isget) gasnet_gets_nbi_bulk(Lbase,Lstrides,peerproc,Rbase,Rstrides, \ LRcount,stridelevels); \ else gasnet_puts_nbi_bulk(peerproc,Rbase,Rstrides,Lbase,Lstrides, \ LRcount,stridelevels); \ } \ break; \ } \ gasnet_wait_syncnbi_all(); \ } while (0) if (iamsender) DOIT(1); /* pay some warm-up costs */ BARRIER(); if (iamsender) { begin = gasnett_ticks_now(); DOIT(iters); end = gasnett_ticks_now(); } BARRIER(); if (iamsender) { char tmp[80]; double secs = gasnett_ticks_to_ns(end - begin)/1.0E9; double dataMB = ((double)datasz) * iters / (1024*1024); snprintf(tmp, sizeof(tmp), " %8.3f", dataMB / secs); strcat(mystr, tmp); } if (Lilist) test_free(Lilist); if (Rilist) test_free(Rilist); if (Lvlist) test_free(Lvlist); if (Rvlist) test_free(Rvlist); if (Lstrides) test_free(Lstrides); if (Rstrides) test_free(Rstrides); if (LRcount) test_free(LRcount); } if (iamsender) { printf("%s\n", mystr); fflush(stdout); } BARRIER(); } } } } } } BARRIER(); if (alloc) test_free(alloc); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int i = 0; thread_data_t *td_arr; GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); mynode = gasnet_mynode(); nodes = gasnet_nodes(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 10000; #if GASNET_PAR test_init("testteambarrier", 2, "(iters) (threadcount) (test sections)"); if (argc > 2) { threads_per_node = atoi(argv[2]); } else { if (gasnett_getenv_yesno_withdefault("GASNET_TEST_POLITE_SYNC",0)) { /* May overcommit only if somebody already expected it */ threads_per_node = gasnett_cpu_count(); } else { threads_per_node = gasnett_cpu_count() / TEST_LOCALPROCS(); } threads_per_node = MIN(threads_per_node, 8); threads_per_node = test_thread_limit(threads_per_node); threads_per_node = MAX(threads_per_node, 1); } if (threads_per_node > TEST_MAXTHREADS || threads_per_node < 1) { printf("ERROR: Threads must be between 1 and %d\n", TEST_MAXTHREADS); exit(EXIT_FAILURE); } if (argc > 3) TEST_SECTION_PARSE(argv[3]); if (argc > 4) test_usage(); #else test_init("testteambarrier", 1, "(iters) (test sections)"); threads_per_node = 1; if (argc > 3) test_usage(); if (argc > 2) TEST_SECTION_PARSE(argv[2]); #endif TEST_SET_WAITMODE(threads_per_node); td_arr = (thread_data_t*) test_malloc(sizeof(thread_data_t)*threads_per_node); for(i=0; i<threads_per_node; i++) { td_arr[i].my_local_thread = i; td_arr[i].mythread = mynode*threads_per_node+i; } #if GASNET_PAR test_createandjoin_pthreads(threads_per_node, &thread_main, td_arr, sizeof(thread_data_t)); #else thread_main(&td_arr[0]); #endif test_free(td_arr); gasnet_coll_barrier_notify(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS); GASNET_Safe(gasnet_coll_barrier_wait(GASNET_TEAM_ALL, 0, GASNET_BARRIERFLAG_ANONYMOUS)); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int help=0; int arg=1; gasnet_handlerentry_t htable[] = { { hidx_ping_shorthandler, ping_shorthandler }, { hidx_pong_shorthandler, pong_shorthandler }, { hidx_ping_medhandler, ping_medhandler }, { hidx_pong_medhandler, pong_medhandler }, { hidx_ping_longhandler, ping_longhandler }, { hidx_pong_longhandler, pong_longhandler }, { hidx_ping_shorthandler_flood, ping_shorthandler_flood }, { hidx_pong_shorthandler_flood, pong_shorthandler_flood }, { hidx_ping_medhandler_flood, ping_medhandler_flood }, { hidx_pong_medhandler_flood, pong_medhandler_flood }, { hidx_ping_longhandler_flood, ping_longhandler_flood }, { hidx_pong_longhandler_flood, pong_longhandler_flood }, { hidx_done_shorthandler, done_shorthandler } }; GASNET_Safe(gasnet_init(&argc, &argv)); mynode = gasnet_mynode(); numnode = gasnet_nodes(); arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-p")) { #if GASNET_PAR pollers = atoi(argv[arg+1]); arg += 2; #else if (0 == mynode) { fprintf(stderr, "testam %s\n", GASNET_CONFIG_STRING); fprintf(stderr, "ERROR: The -p option is only available in the PAR configuration.\n"); fflush(NULL); } sleep(1); gasnet_exit(1); #endif } else if (!strcmp(argv[arg], "-in")) { insegment = 1; ++arg; } else if (!strcmp(argv[arg], "-out")) { insegment = 0; ++arg; } else if (!strcmp(argv[arg], "-c")) { crossmachinemode = 1; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); ++arg; } if (!iters) iters = 1000; if (argc > arg) { maxsz = atoi(argv[arg]); ++arg; } if (!maxsz) maxsz = 2*1024*1024; if (argc > arg) { TEST_SECTION_PARSE(argv[arg]); ++arg; } GASNET_Safe(gasnet_attach(htable, sizeof(htable)/sizeof(gasnet_handlerentry_t), TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); #if GASNET_PAR test_init("testam", 1, "[options] (iters) (maxsz) (test_sections)\n" " The '-in' or '-out' option selects whether the requestor's\n" " buffer is in the GASNet segment or not (default is 'in').\n" " The -p option gives the number of polling threads, specified as\n" " a non-negative integer argument (default is no polling threads).\n" " The -c option enables cross-machine pairing (default is nearest neighbor).\n"); #else test_init("testam", 1, "[options] (iters) (maxsz) (test_sections)\n" " The '-in' or '-out' option selects whether the requestor's\n" " buffer is in the GASNet segment or not (default is 'in').\n" " The -c option enables cross-machine pairing (default is nearest neighbor).\n"); #endif if (help || argc > arg) test_usage(); TEST_PRINT_CONDUITINFO(); if (insegment) { myseg = TEST_MYSEG(); } else { char *space = test_malloc(alignup(maxsz,PAGESZ) + PAGESZ); myseg = alignup_ptr(space, PAGESZ); } maxmed = MIN(maxsz, gasnet_AMMaxMedium()); maxlongreq = MIN(maxsz, gasnet_AMMaxLongRequest()); maxlongrep = MIN(maxsz, gasnet_AMMaxLongReply()); if (crossmachinemode) { if ((numnode%2) && (mynode == numnode-1)) { sender = 1; peer = mynode; } else { gasnet_node_t half = numnode / 2; sender = (mynode < half); peer = sender ? (mynode + half) : (mynode - half); } } else { peer = mynode ^ 1; sender = mynode % 2 == 0; if (peer == numnode) { peer = mynode; } } recvr = !sender || (peer == mynode); peerseg = TEST_SEG(peer); BARRIER(); if (mynode == 0) { printf("Running %sAM performance test with %i iterations" #if GASNET_PAR " and %i extra recvr polling threads" #endif "...\n", (crossmachinemode ? "cross-machine ": ""), iters #if GASNET_PAR ,pollers #endif ); printf(" Msg Sz Description Total time Avg. time Bandwidth\n" " ------ ----------- ---------- --------- ---------\n"); fflush(stdout); } #if GASNET_PAR if (pollers) test_createandjoin_pthreads(pollers+1,doAll,NULL,0); else #endif doAll(NULL); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { struct delay_s { int64_t delay_us; int64_t delay_loops; } delay_params; int mynode, nodes, iters=0; int64_t start,total,delay_us,baseline_us; int64_t min_time, max_time, avg_time; int64_t delay_loops = 0; int j, i = 0; int pause_len; int pollcnt = 0; GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testbarrierlate",1,"(iters) (pollcnt)"); mynode = gasnet_mynode(); nodes = gasnet_nodes(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 10000; if (argc > 2) pollcnt = atoi(argv[2]); if (argc > 3) test_usage(); if (mynode == 0) { printf("Running barrier late arrival test with %i iterations, pollcnt=%i...\n",iters, pollcnt); fflush(stdout); } BARRIER(); /* warmup */ for (i=0; i < MIN(100,iters/100); i++) { gasnet_barrier_notify(0, GASNET_BARRIERFLAG_ANONYMOUS); GASNET_Safe(gasnet_barrier_wait(0, GASNET_BARRIERFLAG_ANONYMOUS)); } BARRIER(); start = TIME(); for (i=0; i < iters; i++) { gasnet_barrier_notify(0, GASNET_BARRIERFLAG_ANONYMOUS); GASNET_Safe(gasnet_barrier_wait(0, GASNET_BARRIERFLAG_ANONYMOUS)); } baseline_us = TIME() - start; BARRIER(); if (mynode == 0) { printf("Total time: %8.3f sec Avg Anon. Barrier latency: %8.3f us\n", ((float)baseline_us)/1000000, ((float)baseline_us)/iters); fflush(stdout); } /* Calibrate a delay loop. Given "iters" and "delay_us", we determine the argument * we need when calling test_delay() iters times, to get a _total_ delay no less than * delay_us. The value of delay_us is overwritten with the achieved delay. * We calibrate the delay on exactly one node to avoid spoiling timings on * overcommitted CPUs. Nodes not performing the calibration sleep for at least twice * the time we are calibrating for. (No way to be sure this is enough, since * calibration is iterative.) */ BARRIER(); pause_len = 1 + 4 * (baseline_us + 999999)/1000000; if (mynode == 0) { struct delay_s *p = (struct delay_s *)TEST_MYSEG(); start = TIME(); printf("Calibrating delay loop (expect at least a %d sec pause)...\n", pause_len); fflush(stdout); p->delay_us = 2*baseline_us; /* delay at least two full barrier times */ p->delay_loops = test_calibrate_delay(iters, pollcnt, &(p->delay_us)); } else { sleep(pause_len); } BARRIER(); gasnet_get(&delay_params, 0, TEST_SEG(0), sizeof(struct delay_s)); delay_us = delay_params.delay_us; delay_loops = delay_params.delay_loops; if (mynode == 0) { printf("Calibration complete (actual pause = %5.3f sec).\n", (float)((TIME()-start)/1000000.0)); printf("Ideal loop time = %8.3f sec.\n", (float)(delay_us)/1000000.0); fflush(stdout); } /* Take turns being late to notify * We insert a delay before the _notify() on one node. * This simulates a load imbalance between barriers. * The time reported is how much the barrier costs excluding the delay. * This reported time will often be less than the full barrier because * some progress was made by the other nodes. */ avg_time = 0; max_time = 0; min_time = (int64_t)1 << 62; /* good enough */ for (j=0; j < nodes; j++) { BARRIER(); start = TIME(); for (i=0; i < iters; i++) { if (j == mynode) { test_delay(delay_loops, pollcnt); } gasnet_barrier_notify(0, GASNET_BARRIERFLAG_ANONYMOUS); GASNET_Safe(gasnet_barrier_wait(0, GASNET_BARRIERFLAG_ANONYMOUS)); } total = TIME() - start; if (mynode == 0) { printf("Total time: %8.3f sec Late-notify test on node %d\n", ((float)total)/1000000, j); fflush(stdout); } total -= delay_us; avg_time += total; min_time = MIN(min_time, total); max_time = MAX(max_time, total); } avg_time /= nodes; if (mynode == 0) { printf("Total difference: %8.3f sec Late notify() Anon. Barrier net latency, minimum: %8.3f us (%6.2f%%)\n", ((float)min_time)/1000000, ((float)min_time)/iters, ((float)min_time * 100.)/baseline_us); printf("Total difference: %8.3f sec Late notify() Anon. Barrier net latency, maximum: %8.3f us (%6.2f%%)\n", ((float)max_time)/1000000, ((float)max_time)/iters, ((float)max_time * 100.)/baseline_us); printf("Total difference: %8.3f sec Late notify() Anon. Barrier net latency, average: %8.3f us (%6.2f%%)\n", ((float)avg_time)/1000000, ((float)avg_time)/iters, ((float)avg_time * 100.)/baseline_us); fflush(stdout); } /* Take turns being late to wait * We insert a delay between the _notify() and _wait() on one node. * This simulates a load imbalance between barrier notify and wait. * The time reported is how much the barrier costs excluding the delay. * This reported time will often be less than the full barrier because * some progress was made by the other nodes. */ avg_time = 0; max_time = 0; min_time = (int64_t)1 << 62; /* good enough */ for (j=0; j < nodes; j++) { BARRIER(); start = TIME(); for (i=0; i < iters; i++) { gasnet_barrier_notify(0, GASNET_BARRIERFLAG_ANONYMOUS); if (j == mynode) { test_delay(delay_loops, pollcnt); } GASNET_Safe(gasnet_barrier_wait(0, GASNET_BARRIERFLAG_ANONYMOUS)); } total = TIME() - start; if (mynode == 0) { printf("Total time: %8.3f sec Late-wait test on node %d\n", ((float)total)/1000000, j); fflush(stdout); } total -= delay_us; avg_time += total; min_time = MIN(min_time, total); max_time = MAX(max_time, total); } avg_time /= nodes; if (mynode == 0) { printf("Total difference: %8.3f sec Late wait() Anon. Barrier net latency, minimum: %8.3f us (%6.2f%%)\n", ((float)min_time)/1000000, ((float)min_time)/iters, ((float)min_time * 100.)/baseline_us); printf("Total difference: %8.3f sec Late wait() Anon. Barrier net latency, maximum: %8.3f us (%6.2f%%)\n", ((float)max_time)/1000000, ((float)max_time)/iters, ((float)max_time * 100.)/baseline_us); printf("Total difference: %8.3f sec Late wait() Anon. Barrier net latency, average: %8.3f us (%6.2f%%)\n", ((float)avg_time)/1000000, ((float)avg_time)/iters, ((float)avg_time * 100.)/baseline_us); fflush(stdout); } BARRIER(); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int mynode, nodes, iters=0; int64_t start,total; int i = 0; gasnet_node_t nrows, ncols, my_row, my_col; void *clientdata = NULL; gasnet_team_handle_t my_row_team, my_col_team; static uint8_t *A, *B, *C; static int *B_int, *C_int; int num_iters; size_t sz; gasnet_seginfo_t teamA_scratch; gasnet_seginfo_t teamB_scratch; gasnet_seginfo_t const * test_segs; GASNET_Safe(gasnet_init(&argc, &argv)); #if !GASNET_SEQ MSG0("WARNING: This test does not work for NON-SEQ builds yet.. skipping test\n"); gasnet_exit(0); #endif GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); A = TEST_MYSEG(); B = A + SCRATCH_SIZE; C = B + SCRATCH_SIZE; B_int = (int*) B; C_int = (int*) C; gasnet_coll_init(NULL, 0, NULL, 0, 0); test_init("testteambcast", 1, "(nrows) (ncols) (iters)"); mynode = gasnet_mynode(); nodes = gasnet_nodes(); test_segs = TEST_SEGINFO(); teamA_scratch.addr = test_segs[mynode].addr; teamA_scratch.size = SCRATCH_SIZE/2; teamB_scratch.addr = (uint8_t*)teamA_scratch.addr + SCRATCH_SIZE/2; teamB_scratch.size = teamA_scratch.size; if (argc > 4) test_usage(); if (argc > 1) { nrows = atoi(argv[1]); } else { nrows = 1 + !(nodes & 1); /* 1 if odd, 2 if even */ } if (argc > 2) { ncols = atoi(argv[2]); } else { ncols = nodes / nrows; } assert_always(nrows*ncols == nodes); if (argc > 3) iters = atoi(argv[3]); if (!iters) iters = 20; if (mynode == 0) { printf("Running team test with a %u-by-%u grid and %i iterations...\n", nrows, ncols, iters); fflush(stdout); } BARRIER(); my_row = mynode / ncols; my_col = mynode % ncols; my_row_team = gasnet_coll_team_split(GASNET_TEAM_ALL, my_row, my_col, &teamA_scratch); my_col_team = gasnet_coll_team_split(GASNET_TEAM_ALL, my_col, my_row, &teamB_scratch); if (my_col == 0) { printf("row team %u: Running team barrier test with row teams...\n", my_row); fflush(stdout); } BARRIER(); start = TIME(); for (i=0; i < iters*10; i++) { gasnet_coll_barrier_notify(my_row_team, 0, GASNET_BARRIERFLAG_UNNAMED); gasnet_coll_barrier_wait(my_row_team, 0, GASNET_BARRIERFLAG_UNNAMED); } total = TIME() - start; if (my_col == 0) { printf("row team %u: total time: %8.3f sec, avg row team Barrier latency: %8.3f us\n", my_row, ((float)total)/1000000, ((float)total)/(iters*10)); fflush(stdout); } if (my_row == 0) { printf("col team %u: Running team barrier test with column teams...\n", my_col); fflush(stdout); } BARRIER(); start = TIME(); for (i=0; i < iters*10; i++) { gasnet_coll_barrier_notify(my_col_team, 0, GASNET_BARRIERFLAG_UNNAMED); gasnet_coll_barrier_wait(my_col_team, 0, GASNET_BARRIERFLAG_UNNAMED); } total = TIME() - start; if (my_row == 0) { printf("col team %u: total time: %8.3f sec Avg column team Barrier latency: %8.3f us\n", my_col, ((float)total)/1000000, ((float)total)/(iters*10)); fflush(stdout); } BARRIER(); /*first do team all broadcast*/ for (sz = 1; sz<MAX_SIZE; sz=sz*2) { int root = 0; for(i=0; i<sz; i++) { B_int[i] = mynode*sz+42+i; C_int[i] = -1; } BARRIER(); gasnet_coll_broadcast(GASNET_TEAM_ALL, C_int, root, B_int, sz*sizeof(int), GASNET_COLL_IN_ALLSYNC|GASNET_COLL_OUT_NOSYNC|GASNET_COLL_LOCAL); BARRIER(); for(i=0; i<sz; i++) { int expected = root*sz+42+i; if(expected != C_int[i]) { fprintf(stderr, "%d> %d %d (expecting %d)\n", mynode, i, C_int[i], expected); gasnet_exit(1); } } BARRIER(); /*time this*/ start = TIME(); for(i=0; i<iters; i++) { gasnet_coll_broadcast(GASNET_TEAM_ALL, C_int, root, B_int, sz*sizeof(int), GASNET_COLL_IN_ALLSYNC|GASNET_COLL_OUT_NOSYNC|GASNET_COLL_LOCAL); } total = TIME() - start; if(mynode == 0){ printf("%d> %ld byte broadcast team all time: %8.3f usec\n",mynode,(long)sz*sizeof(int), ((float)total)/(iters)); fflush(stdout); } } BARRIER(); /*next do row broadcasts*/ for (sz = 1; sz<MAX_SIZE; sz=sz*2) { for(i=0; i<sz; i++) { B_int[i] = mynode*sz+42+i; C_int[i] = -1; } BARRIER(); gasnet_coll_broadcast(my_row_team, C_int, 0, B_int, sz*sizeof(int), GASNET_COLL_IN_ALLSYNC|GASNET_COLL_OUT_NOSYNC|GASNET_COLL_LOCAL); BARRIER(); for(i=0; i<sz; i++) { int expected = my_row*ncols*sz+42+i; if(expected != C_int[i]) { fprintf(stderr, "%d> %d %d (expecting %d)\n", mynode, i, C_int[i], expected); gasnet_exit(1); } } BARRIER(); /*time this*/ start = TIME(); for(i=0; i<iters; i++) { gasnet_coll_broadcast(my_row_team, C_int, 0, B_int, sz*sizeof(int), GASNET_COLL_IN_ALLSYNC|GASNET_COLL_OUT_NOSYNC|GASNET_COLL_LOCAL); } total = TIME() - start; if(my_col == 0){ printf("%d> %ld byte broadcast row team %u time: %8.3f usec\n",mynode,(long)sz*sizeof(int), my_row, ((float)total)/(iters)); fflush(stdout); } } BARRIER(); /*next do col broadcasts*/ for (sz = 1; sz<MAX_SIZE; sz=sz*2) { for(i=0; i<sz; i++) { B_int[i] = mynode*sz+42+i; C_int[i] = -1; } BARRIER(); gasnet_coll_broadcast(my_col_team, C_int, 0, B_int, sz*sizeof(int), GASNET_COLL_IN_ALLSYNC|GASNET_COLL_OUT_NOSYNC|GASNET_COLL_LOCAL); BARRIER(); for(i=0; i<sz; i++) { int expected = my_col*sz+42+i; if(expected != C_int[i]) { fprintf(stderr, "%d> %d %d (expecting %d)\n", mynode, i, C_int[i], expected); gasnet_exit(1); } } BARRIER(); /*time this*/ start = TIME(); for(i=0; i<iters; i++) { gasnet_coll_broadcast(my_col_team, C_int, 0, B_int, sz*sizeof(int), GASNET_COLL_IN_ALLSYNC|GASNET_COLL_OUT_NOSYNC|GASNET_COLL_LOCAL); } total = TIME() - start; if(my_row == 0){ printf("%d> %ld byte broadcast col team %u time: %8.3f usec\n",mynode,(long)sz*sizeof(int), my_col, ((float)total)/(iters)); fflush(stdout); } } BARRIER(); MSG("done."); gasnet_exit(0); /* for faster exit */ return 0; }
int main(int argc, char **argv) { int outer_iterations = 0; int inner_iterations = 0; int seedoffset = 0; int numprocs, myproc, peerproc; int sender_p; char *shadow_region_1, *shadow_region_2; int i,j; char *local_base, *target_base; /* call startup */ GASNET_Safe(gasnet_init(&argc, &argv)); /* get SPMD info */ myproc = gasnet_mynode(); numprocs = gasnet_nodes(); if (argc > 1) segsize = atoi(argv[1]); if (!segsize) segsize = 1024*1000; if (argc > 2) outer_iterations = atoi(argv[2]); if (!outer_iterations) outer_iterations = 10; if (argc > 3) inner_iterations = atoi(argv[3]); if (!inner_iterations) inner_iterations = 10; if (argc > 4) seedoffset = atoi(argv[4]); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ, TEST_MINHEAPOFFSET)); test_init("testslice",0, "(segsize) (iterations) (# of sizes per iteration) (seed)"); /* parse arguments */ if (argc > 5) test_usage(); if(numprocs & 1) { MSG0("WARNING: This test requires an even number of nodes. Test skipped.\n"); gasnet_exit(0); /* exit 0 to prevent false negatives in test harnesses for smp-conduit */ } sender_p = !(myproc & 1); peerproc = myproc ^ 1; if (seedoffset == 0) { seedoffset = (((unsigned int)TIME()) & 0xFFFF); TEST_BCAST(&seedoffset, 0, &seedoffset, sizeof(&seedoffset)); } TEST_SRAND(myproc+seedoffset); MSG0("Running with segment size = %d outer iterations=%d inner iterations=%d seed=%d", segsize,outer_iterations, inner_iterations, seedoffset); BARRIER(); /* Allocate two shadow regions the same size as the segment */ shadow_region_1 = (char *) test_malloc(segsize); shadow_region_2 = (char *) test_malloc(segsize); /* Fill up the shadow region with random data */ for(i=0; i < segsize; i++) { shadow_region_1[i] = (char) TEST_RAND(0,255); } memset(shadow_region_2,0,segsize); /* Big loop performing the following */ for(i=0; i < outer_iterations; i++) { if(sender_p) { /* Pick a starting point anywhere in the segment */ int starting_point = TEST_RAND(0,(segsize-1)); local_base = TEST_SEG(myproc); target_base = TEST_SEG(peerproc); for(j=0; j < inner_iterations; j++) { /* Pick a length */ int len = TEST_RAND(1,segsize-starting_point); int remote_starting_point = TEST_RAND(0,segsize-len); int local_starting_point_1 = TEST_RAND(0,segsize-len); int local_starting_point_2 = TEST_RAND(0,segsize-len); /* Perform operations */ /* Out of segment put from shadow_region 1 to remote */ gasnet_put(peerproc,target_base+remote_starting_point,shadow_region_1 + starting_point,len); /* In segment get from remote to local segment */ gasnet_get(local_base+local_starting_point_1,peerproc,target_base+remote_starting_point,len); /* Verify */ assert_eq(shadow_region_1 + starting_point, local_base + local_starting_point_1, len,starting_point,i,j,"Out of segment put + in segment get"); /* Out of segment get from remote to shadow_region_2 (starting from 0) */ gasnet_get(shadow_region_2+local_starting_point_2,peerproc,target_base+remote_starting_point,len); /* Verify */ assert_eq(shadow_region_2+local_starting_point_2, shadow_region_1 + starting_point, len,starting_point,i,j,"Out of segment get"); } TEST_PROGRESS_BAR(i,outer_iterations); } BARRIER(); } if(sender_p && !failures) { MSG("testslice PASSED"); } gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int help=0; int arg=1; gasnet_handlerentry_t htable[] = { { hidx_ping_shorthandler, ping_shorthandler }, { hidx_pong_shorthandler, pong_shorthandler }, { hidx_ping_medhandler, ping_medhandler }, { hidx_pong_medhandler, pong_medhandler }, { hidx_ping_longhandler, ping_longhandler }, { hidx_pong_longhandler, pong_longhandler }, { hidx_ping_shorthandler_flood, ping_shorthandler_flood }, { hidx_pong_shorthandler_flood, pong_shorthandler_flood }, { hidx_ping_medhandler_flood, ping_medhandler_flood }, { hidx_pong_medhandler_flood, pong_medhandler_flood }, { hidx_ping_longhandler_flood, ping_longhandler_flood }, { hidx_pong_longhandler_flood, pong_longhandler_flood }, { hidx_done_shorthandler, done_shorthandler } }; GASNET_Safe(gasnet_init(&argc, &argv)); mynode = gasnet_mynode(); numnode = gasnet_nodes(); arg = 1; while (argc > arg) { if (!strcmp(argv[arg], "-p")) { #if GASNET_PAR pollers = test_thread_limit(atoi(argv[arg+1])+1)-1; arg += 2; #else if (0 == mynode) { fprintf(stderr, "testam %s\n", GASNET_CONFIG_STRING); fprintf(stderr, "ERROR: The -p option is only available in the PAR configuration.\n"); fflush(NULL); } sleep(1); gasnet_exit(1); #endif } else if (!strcmp(argv[arg], "-in")) { insegment = 1; ++arg; } else if (!strcmp(argv[arg], "-out")) { insegment = 0; ++arg; } else if (!strcmp(argv[arg], "-c")) { crossmachinemode = 1; ++arg; } else if (!strcmp(argv[arg], "-src-noop")) { src_mode = SRC_NOOP; ++arg; } else if (!strcmp(argv[arg], "-src-generate")) { src_mode = SRC_GENERATE; ++arg; } else if (!strcmp(argv[arg], "-src-memcpy")) { src_mode = SRC_MEMCPY; ++arg; } else if (argv[arg][0] == '-') { help = 1; ++arg; } else break; } if (argc > arg) { iters = atoi(argv[arg]); ++arg; } if (!iters) iters = 1000; if (argc > arg) { maxsz = atoi(argv[arg]); ++arg; } if (!maxsz) maxsz = 2*1024*1024; if (argc > arg) { TEST_SECTION_PARSE(argv[arg]); ++arg; } GASNET_Safe(gasnet_attach(htable, sizeof(htable)/sizeof(gasnet_handlerentry_t), TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); #if GASNET_PAR #define PAR_USAGE \ " The -p option gives the number of polling threads, specified as\n" \ " a non-negative integer argument (default is no polling threads).\n" #else #define PAR_USAGE "" #endif test_init("testam", 1, "[options] (iters) (maxsz) (test_sections)\n" " The '-in' or '-out' option selects whether the requestor's\n" " buffer is in the GASNet segment or not (default is 'in').\n" PAR_USAGE " The '-src-*' options select treatment of the payload buffer used for\n" " Medium and Long AMs, as follows:\n" " -src-noop: no per-operation initialization (default)\n" " -src-generate: initialized (w/o memory reads) on each AM injection\n" " -src-memcpy: initialized using memcpy() on each AM injection\n" " The -c option enables cross-machine pairing (default is nearest neighbor).\n"); if (help || argc > arg) test_usage(); TEST_PRINT_CONDUITINFO(); if (insegment) { myseg = TEST_MYSEG(); } else { char *space = test_malloc(alignup(maxsz,PAGESZ) + PAGESZ); myseg = alignup_ptr(space, PAGESZ); } maxmed = MIN(maxsz, gasnet_AMMaxMedium()); maxlongreq = MIN(maxsz, gasnet_AMMaxLongRequest()); maxlongrep = MIN(maxsz, gasnet_AMMaxLongReply()); if (src_mode == SRC_MEMCPY) { zero_buffer = test_calloc(maxsz, 1); } if (crossmachinemode) { if ((numnode%2) && (mynode == numnode-1)) { sender = 1; peer = mynode; } else { gasnet_node_t half = numnode / 2; sender = (mynode < half); peer = sender ? (mynode + half) : (mynode - half); } } else { peer = mynode ^ 1; sender = mynode % 2 == 0; if (peer == numnode) { peer = mynode; } } recvr = !sender || (peer == mynode); // Long Request and Reply (distinct for loopback) reply_addr = TEST_SEG(peer); request_addr = (peer == mynode) ? (void*)((uintptr_t)reply_addr + alignup(maxsz,SIZEOF_GASNET_REGISTER_VALUE_T)) : reply_addr; BARRIER(); #if GASNET_PAR #define PAR_FMT " %i extra recvr polling threads\n" #define PAR_ARG ,pollers #else #define PAR_FMT /*empty*/ #define PAR_ARG /*empty*/ #endif if (mynode == 0) { printf("Running %i iterations of %s AM performance with:\n" " local addresses %sside the segment%s\n" " %s\n" PAR_FMT " ...\n", iters, (crossmachinemode ? "cross-machine ": ""), (insegment ? "in" : "out"), (insegment ? " (default)" : ""), ((src_mode == SRC_NOOP) ? "no payload initialization (default)" :(src_mode == SRC_GENERATE) ? "payload initialized by computation" : "payload initialized using memcpy()") PAR_ARG ); printf(" Msg Sz Description Total time Avg. time Bandwidth\n" " ------ ----------- ---------- --------- ---------\n"); fflush(stdout); } #if GASNET_PAR TEST_SET_WAITMODE(pollers+1); if (pollers) test_createandjoin_pthreads(pollers+1,doAll,NULL,0); else #endif doAll(NULL); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int mynode, nodes, iters=0; int64_t start,total; int i = 0; gasnet_node_t nrows, ncols, my_row, my_col; void *clientdata = NULL; gasnet_team_handle_t my_row_team, my_col_team; static uint8_t *A, *B; gasnet_seginfo_t teamA_scratch; gasnet_seginfo_t teamB_scratch; gasnet_seginfo_t const * test_segs; GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); #if !GASNET_SEQ MSG0("WARNING: This test does not work for NON-SEQ builds yet.. skipping test\n"); gasnet_exit(0); #endif A = TEST_MYSEG(); gasnet_coll_init(NULL, 0, NULL, 0, 0); test_init("testteam", 1, "(iters) (nrows) (ncols)"); mynode = gasnet_mynode(); nodes = gasnet_nodes(); test_segs = TEST_SEGINFO(); teamA_scratch.addr = test_segs[mynode].addr; teamA_scratch.size = test_segs[mynode].size/2; teamB_scratch.addr = (uint8_t*)teamA_scratch.addr + teamA_scratch.size; teamB_scratch.size = teamA_scratch.size; if (argc > 4) test_usage(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 10000; if (argc > 2) { nrows = atoi(argv[2]); } else { /* search for as near to square as possible */ nrows = sqrt(nodes); while (nodes % nrows) --nrows; } if (argc > 3) { ncols = atoi(argv[3]); } else { ncols = nodes / nrows; } assert_always(nrows*ncols == nodes); MSG0("Running team test with a %u-by-%u grid and %i iterations...\n", (int)nrows, (int)ncols, iters); BARRIER(); my_row = mynode / ncols; my_col = mynode % ncols; my_row_team = gasnet_coll_team_split(GASNET_TEAM_ALL, my_row, my_col, &teamA_scratch); my_col_team = gasnet_coll_team_split(GASNET_TEAM_ALL, my_col, my_row, &teamB_scratch); if (my_col == 0) { printf("row team %u: Running team barrier test with row teams...\n", (int)my_row); fflush(stdout); } BARRIER(); start = TIME(); for (i=0; i < iters; i++) { gasnete_coll_teambarrier_notify(my_row_team); gasnete_coll_teambarrier_wait(my_row_team); } total = TIME() - start; if (my_col == 0) { printf("row team %u: total time: %8.3f sec, avg row team Barrier latency: %8.3f us\n", (int)my_row, ((float)total)/1000000, ((float)total)/iters); fflush(stdout); } if (my_row == 0) { printf("col team %u: Running team barrier test with column teams...\n", (int)my_col); fflush(stdout); } BARRIER(); start = TIME(); for (i=0; i < iters; i++) { gasnete_coll_teambarrier_notify(my_col_team); gasnete_coll_teambarrier_wait(my_col_team); } total = TIME() - start; if (my_row == 0) { printf("col team %u: total time: %8.3f sec Avg column team Barrier latency: %8.3f us\n", (int)my_col, ((float)total)/1000000, ((float)total)/iters); fflush(stdout); } BARRIER(); MSG("done."); gasnet_exit(0); /* for faster exit */ return 0; }
int main(int argc, char **argv) { const char *kind = ""; int pollers = 0; int arg = 1; GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(htable, 1, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); TEST_COLL_INIT(); #if GASNET_PAR test_init("testbarrier", 1, "[-t] [-p polling_threads] (iters)\n" " The -p option gives a number of polling threads to spawn (default is 0).\n" " The -b option replaces barrier_notify calls with blocking barrier calls\n" " The -t option replaces barrier_wait calls with looping on barrier_try"); #else test_init("testbarrier", 1, "[-t] (iters)\n" " The -b option replaces barrier_notify calls with blocking barrier calls\n" " The -t option replaces barrier_wait calls with looping on barrier_try"); #endif mynode = gasnet_mynode(); nodes = gasnet_nodes(); while (argc-arg >= 2) { if (!strcmp(argv[arg], "-p")) { #if GASNET_PAR pollers = test_thread_limit(atoi(argv[arg+1])+1)-1; arg += 2; #else if (gasnet_mynode() == 0) { fprintf(stderr, "testbarrier %s\n", GASNET_CONFIG_STRING); fprintf(stderr, "ERROR: The -p option is only available in the PAR configuration.\n"); fflush(NULL); } sleep(1); gasnet_exit(1); #endif } else if (!strcmp(argv[arg], "-t")) { do_try = 1; kind = " polling"; arg += 1; } else if (!strcmp(argv[arg], "-b")) { do_block = 1; kind = " blocking"; arg += 1; } } if (argc-arg >= 1) iters = atoi(argv[arg]); if (!iters) iters = 10000; if (argc-arg >= 2) test_usage(); if (do_try && do_block) { if (!mynode) fprintf(stderr, "ERROR: The -b and -t options are mutually exclusive.\n"); gasnet_exit(1); } #if !defined(GASNET_PAR) MSG0("Running%s barrier test with %i iterations...\n",kind,iters); #else MSG0("Running%s barrier test with %i iterations and %i extra polling threads...\n",kind,iters,pollers); TEST_SET_WAITMODE(pollers+1); if (pollers) test_createandjoin_pthreads(pollers+1,doTest,NULL,0); else #endif doTest(NULL); BARRIER(); MSG("done."); gasnet_exit(0); return 0; }
int main(int argc, char **argv) { int i; const char *getopt_str; int opt_p=0, opt_g=0, opt_a=0, opt_m=0; #if TEST_MPI init_test_mpi(&argc, &argv); getopt_str = "pgamlvtdi:"; #else getopt_str = "pgalvtdi:"; #endif GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(htable, HANDLER_TABLE_SIZE, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); #if TEST_MPI #define TEST_MPI_USAGE " -m use MPI calls \n" #else #define TEST_MPI_USAGE "" #endif #if GASNET_PAR #define TEST_THREAD_USAGE " [<threads_per_node>]\n\n" \ "<threads_per_node> must be between 1 and "_STRINGIFY(TEST_MAXTHREADS)" \n" #else #define TEST_THREAD_USAGE "\n\n" #endif test_init("testthreads",0, "[ -pgalvtd ] [ -i <iters> ]" TEST_THREAD_USAGE "no options means run all tests with "_STRINGIFY(DEFAULT_ITERS)" iterations\n" "options: \n" " -p use puts \n" " -g use gets \n" " -a use Active Messages \n" " -l use local Active Messages \n" TEST_MPI_USAGE " -v output information about actions taken \n" " -t include AM handler actions with -v \n" " -d dynamic thread creation stress test \n" " -i <iters> use <iters> iterations per thread \n"); while ((i = getopt (argc, argv, getopt_str)) != EOF) { switch (i) { case 'p': opt_p = 1; break; case 'g': opt_g = 1; break; case 'a': opt_a = 1; break; case 'm': opt_m = 1; break; case 'l': AM_loopback = 1; break; case 'i': iters = atoi(optarg); break; case 'v': verbose = 1; break; case 't': amtrace = 1; break; case 'd': threadstress = 1; break; default: test_usage(); } } if (opt_p) test_functions[functions_num++] = test_put; if (opt_g) test_functions[functions_num++] = test_get; if (opt_a) { test_functions[functions_num++] = test_amshort; test_functions[functions_num++] = test_ammedium; test_functions[functions_num++] = test_amlong; } #if TEST_MPI if (opt_m) test_functions[functions_num++] = test_mpi; #endif if (amtrace) verbose = 1; /* Assume all test functions if no option is passed */ if (functions_num == 0) { MSG("running all functions!"); memcpy(test_functions, test_functions_all, sizeof(test_functions_all)); functions_num = NUM_FUNCTIONS; } argc -= optind; if (argc > 1) test_usage(); else if (argc == 1) { argv += optind; threads_num = atoi(argv[0]); } if (threads_num > TEST_MAXTHREADS || threads_num < 1) { printf("ERROR: Threads must be between 1 and %i\n",TEST_MAXTHREADS); exit(EXIT_FAILURE); } /* limit sizes to a reasonable size */ #define LIMIT(sz) MIN(sz,4194304) { int sz = 0; sizes[sz++] = LIMIT(gasnet_AMMaxMedium()-1); sizes[sz++] = LIMIT(gasnet_AMMaxMedium()); sizes[sz++] = LIMIT(gasnet_AMMaxMedium()+1); sizes[sz++] = LIMIT(gasnet_AMMaxLongRequest()-1); sizes[sz++] = LIMIT(gasnet_AMMaxLongRequest()); sizes[sz++] = LIMIT(gasnet_AMMaxLongRequest()+1); sizes[sz++] = LIMIT(gasnet_AMMaxLongReply()-1); sizes[sz++] = LIMIT(gasnet_AMMaxLongReply()); sizes[sz++] = LIMIT(gasnet_AMMaxLongReply()+1); assert(sizes[sz] == 0); } alloc_thread_data(threads_num); #if TEST_MPI attach_test_mpi(); #endif #ifdef GASNET_PAR if (threadstress) { int spawniters = MAX(1,iters/threads_num); int i; MSG("Dynamic thread creation stress test, %d gasnet threads, (%d at a time)", spawniters*threads_num, threads_num); iters = 10; /* enough iters to ensure we get thread registration */ for (i = 0; i < spawniters; i++) { test_createandjoin_pthreads(threads_num, &threadmain, tt_thread_data, sizeof(threaddata_t)); TEST_PROGRESS_BAR(i, spawniters); } } else { MSG("Forking %d gasnet threads and running %d iterations", threads_num, iters); test_createandjoin_pthreads(threads_num, &threadmain, tt_thread_data, sizeof(threaddata_t)); } #else /* for testmpi-seq and -parsync */ #ifdef GASNET_SEQ MSG("Running with 1 thread/node for GASNET_SEQ mode"); #else MSG("Running with 1 thread/node for GASNET_PARSYNC mode"); #endif threadmain(tt_thread_data); #endif BARRIER(); free_thread_data(); MSG("Tests complete"); BARRIER(); gasnet_exit(0); return 0; }