/* $Source: runtime/gasnet/tests/testbarrier.c $ * $Date: Mon, 30 May 2005 23:46:52 -0700 $ * $Revision: 1.5.1.5 $ * Description: GASNet barrier performance test * Copyright 2002, Dan Bonachea * Terms of use are as specified in license.txt */ #include #include int main(int argc, char **argv) { int mynode, nodes, iters=0; int64_t start,total; int i = 0; GASNET_Safe(gasnet_init(&argc, &argv)); GASNET_Safe(gasnet_attach(NULL, 0, TEST_SEGSZ_REQUEST, TEST_MINHEAPOFFSET)); test_init("testbarrier", 1); mynode = gasnet_mynode(); nodes = gasnet_nodes(); if (argc > 1) iters = atoi(argv[1]); if (!iters) iters = 10000; if (mynode == 0) { printf("Running barrier test with %i iterations...\n",iters); fflush(stdout); } BARRIER(); start = TIME(); for (i=0; i < iters; i++) { gasnet_barrier_notify(i, 0); GASNET_Safe(gasnet_barrier_wait(i, 0)); } total = TIME() - start; BARRIER(); if (mynode == 0) { printf("Total time: %8.3f sec Avg Named Barrier latency: %8.3f us\n", ((float)total)/1000000, ((float)total)/iters); fflush(stdout); } 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)); } total = TIME() - start; BARRIER(); if (mynode == 0) { printf("Total time: %8.3f sec Avg Anon. Barrier latency: %8.3f us\n", ((float)total)/1000000, ((float)total)/iters); fflush(stdout); } BARRIER(); MSG("done."); gasnet_exit(0); return 0; }