int run_timing_tests(void) { time_bench_loop(loops*10, 0, "for_loop", NULL, time_bench_for_loop); time_bench_loop(loops, 0, "kmem fastpath reuse", NULL, benchmark_kmem_cache_fastpath_reuse); bulk_test(1); bulk_test(2); bulk_test(3); bulk_test(4); bulk_test(8); bulk_test(16); bulk_test(30); bulk_test(32); bulk_test(34); bulk_test(48); bulk_test(64); bulk_test(128); bulk_test(128+30); bulk_test(250); 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; }