void do_nonbulkputgets(void) { if (do_puts && do_nonbulk && do_explicit) { QUEUE_TEST("gasnet_put_nb", handles[i] = gasnet_put_nb(peerproc, tgtmem, msgbuf, payload), gasnet_wait_syncnb_all(handles, depth), (void)0, 0); } if (do_gets && do_nonbulk && do_explicit) { QUEUE_TEST("gasnet_get_nb", handles[i] = gasnet_get_nb(msgbuf, peerproc, tgtmem, payload), gasnet_wait_syncnb_all(handles, depth), (void)0, 0); } if (do_puts && do_nonbulk && do_implicit) { QUEUE_TEST("gasnet_put_nbi", gasnet_put_nbi(peerproc, tgtmem, msgbuf, payload), gasnet_wait_syncnbi_all(), (void)0, 0); } if (do_gets && do_nonbulk && do_implicit) { QUEUE_TEST("gasnet_get_nbi", gasnet_get_nbi(msgbuf, peerproc, tgtmem, payload), gasnet_wait_syncnbi_all(), (void)0, 0); } }
void oneway_nb_test(int iters, int nbytes, int alignment) {GASNET_BEGIN_FUNCTION(); int i; int64_t begin, end; stat_struct_t st; gasnet_handle_t *handles; int pad = (alignment % PAGESZ); /* initialize statistics */ init_stat(&st, nbytes, alignment); handles = (gasnet_handle_t*) test_malloc(sizeof(gasnet_handle_t) * iters); memset(locbuf+pad, 1, nbytes); BARRIER(); if (iamsender) { /* measure the throughput of sending a message */ begin = TIME(); for (i = 0; i < iters; i++) { handles[i] = gasnet_put_nb_bulk(peerproc, rembuf, locbuf+pad, nbytes); } gasnet_wait_syncnb_all(handles, iters); end = TIME(); update_stat(&st, (end - begin), iters); } BARRIER(); if (iamsender) { print_stat(myproc, &st, "put_nb_bulk throughput", PRINT_THROUGHPUT); } /* initialize statistics */ init_stat(&st, nbytes, alignment); if (iamsender) { /* measure the throughput of receiving a message */ begin = TIME(); for (i = 0; i < iters; i++) { handles[i] = gasnet_get_nb_bulk(locbuf, peerproc, rembuf+pad, nbytes); } gasnet_wait_syncnb_all(handles, iters); end = TIME(); update_stat(&st, (end - begin), iters); } BARRIER(); if (iamsender) { print_stat(myproc, &st, "get_nb_bulk throughput", PRINT_THROUGHPUT); } test_free(handles); }
void bulk_test_nb(int iters) {GASNET_BEGIN_FUNCTION(); int i; int64_t begin, end; stat_struct_t stput; gasnet_handle_t *handles; int payload; handles = (gasnet_handle_t *) test_malloc(sizeof(gasnet_handle_t) * iters); for (payload = min_payload; payload <= max_payload && payload > 0; payload *= 2) { init_stat(&stput, payload); BARRIER(); if (iamsender) { /* measure the throughput of sending a message */ begin = TIME(); for (i = 0; i < iters; i++) { handles[i] = gasnet_memset_nb(peerproc, tgtmem, 0x5a, payload); } gasnet_wait_syncnb_all(handles, iters); end = TIME(); update_stat(&stput, (end - begin), iters); } BARRIER(); if (iamsender) { print_stat(myproc, &stput, "memset_nb throughput", PRINT_THROUGHPUT); } } test_free(handles); }
void do_valueputgets(void) { if (do_puts && do_value && do_explicit) { QUEUE_TEST("gasnet_put_nb_val", handles[i] = gasnet_put_nb_val(peerproc, tgtmem, regval, payload), gasnet_wait_syncnb_all(handles, depth), (void)0, SIZEOF_GASNET_REGISTER_VALUE_T); } if (do_gets && do_value && do_explicit) { QUEUE_TEST("gasnet_get_nb_val", vghandles[i] = gasnet_get_nb_val(peerproc, tgtmem, payload), { for (i=0;i<depth;++i) regval ^= gasnet_wait_syncnb_valget(vghandles[i]); },
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; }