/* This tester measures the performance of contended HSLs and pthread mutexes. */ int main(int argc, char **argv) { GASNET_Safe(gex_Client_Init(&myclient, &myep, &myteam, "testlockcontend", &argc, &argv, 0)); GASNET_Safe(gex_Segment_Attach(&mysegment, myteam, TEST_SEGSZ_REQUEST)); test_init("testlockcontend",1,"(maxthreads) (iters) (accuracy) (test sections)"); if (argc > 1) maxthreads = atoi(argv[1]); maxthreads = test_thread_limit(maxthreads); if (maxthreads < 1) { printf("Threads must be between 1 and %i\n", TEST_MAXTHREADS); gasnet_exit(-1); } if (argc > 2) iters = atoi(argv[2]); if (!iters) iters = 1000000; if (argc > 3) accuracy = atoi(argv[3]); if (!accuracy) accuracy = 3; if (argc > 4) TEST_SECTION_PARSE(argv[4]); if (argc > 5) test_usage(); mynode = gex_TM_QueryRank(myteam); myseg = TEST_MYSEG(); if (mynode == 0) { printf("Running locks performance test with 1..%i threads and %i iterations...\n",maxthreads,iters); fflush(stdout); MSG0("Spawning pthreads..."); if (TEST_SECTION_BEGIN_ENABLED()) { header("lock/unlock contended pthread mutex (others in thread barrier)"); test_createandjoin_pthreads(threads = maxthreads, &thread_fn1, NULL, 0); } if (TEST_SECTION_BEGIN_ENABLED()) { header("lock/unlock contended HSL (others in thread barrier)"); test_createandjoin_pthreads(threads = maxthreads, &thread_fn2, NULL, 0); } if (TEST_SECTION_BEGIN_ENABLED()) { header("lock/unlock contended pthread mutex (no other threads)"); for (threads=1; threads<=maxthreads; ++threads) { test_createandjoin_pthreads(threads, &thread_fn3, NULL, 0); } } if (TEST_SECTION_BEGIN_ENABLED()) { header("lock/unlock contended HSL (no other threads)"); for (threads=1; threads<=maxthreads; ++threads) { test_createandjoin_pthreads(threads, &thread_fn4, NULL, 0); } } } BARRIER(); 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 = 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 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 help=0; int arg=1; GASNET_Safe(gex_Client_Init(&myclient, &myep, &myteam, "testam", &argc, &argv, 0)); mynode = gex_TM_QueryRank(myteam); numnode = gex_TM_QuerySize(myteam); 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], "-sync-req")) { asynclc = 0; lc_opt = GEX_EVENT_NOW; ++arg; } else if (!strcmp(argv[arg], "-async-req")) { asynclc = 1; lc_opt = GEX_EVENT_GROUP; ++arg; } else if (!strcmp(argv[arg], "-fp")) { use_np = 0; ++arg; } else if (!strcmp(argv[arg], "-np-cb")) { use_np = 1; np_cbuf = 1; ++arg; } else if (!strcmp(argv[arg], "-np-gb")) { use_np = 1; np_cbuf = 0; ++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(gex_Segment_Attach(&mysegment, myteam, TEST_SEGSZ_REQUEST)); GASNET_Safe(gex_EP_RegisterHandlers(myep, htable, sizeof(htable)/sizeof(gex_AM_Entry_t))); #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 '-sync-req' or '-async-req' option selects synchronous or asynchronous\n" " local completion of Medium and Long Requests (default is synchronous).\n" " The '-fp', '-np-gb' or '-np-cb' option selects Fixed- or Negotiated-Payload\n" " for Medium and Long AMs, as follows:\n" " -fp: Fixed-Payload (default)\n" " -np-gb: Negotiated-Payload with GASNet-provided buffer\n" " -np-cb: Negotiated-Payload with client-provided buffer\n" " 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); } if (src_mode == SRC_MEMCPY) { zero_buffer = test_calloc(maxsz, 1); } np_lc_opt = np_cbuf ? lc_opt : NULL; if (crossmachinemode) { if ((numnode%2) && (mynode == numnode-1)) { sender = 1; peer = mynode; } else { gex_Rank_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; } } gex_Event_t *tmp_lc_opt = use_np ? np_lc_opt : lc_opt; gex_Flags_t flags = use_np ? ( np_cbuf ? GEX_FLAG_AM_PREPARE_LEAST_CLIENT : GEX_FLAG_AM_PREPARE_LEAST_ALLOC) : 0; maxmedreq = MIN(maxsz, gex_AM_MaxRequestMedium(myteam,peer,tmp_lc_opt,flags,0)); maxmedrep = MIN(maxsz, gex_AM_MaxReplyMedium (myteam,peer,GEX_EVENT_NOW,flags,0)); maxlongreq = MIN(maxsz, gex_AM_MaxRequestLong (myteam,peer,tmp_lc_opt,flags,0)); maxlongrep = MIN(maxsz, gex_AM_MaxReplyLong (myteam,peer,GEX_EVENT_NOW,flags,0)); 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_GEX_RMA_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" " %ssynchronous LC for Requests%s\n" " %s\n" " %s\n" PAR_FMT " ...\n", iters, (crossmachinemode ? "cross-machine ": ""), (insegment ? "in" : "out"), (insegment ? " (default)" : ""), (asynclc ? "a": ""), (asynclc ? "": " (default)"), (!use_np ? "fixed-Payload (default)" :(np_cbuf ? "negotiated-Payload with client-provided buffer" : "negotiated-Payload with GASNet-provided buffer")), ((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) { 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) { 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) { 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) { 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; }
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; }