int main(int argc, char *argv[]) { int e = hpx_init(&argc, &argv); if (e) { fprintf(stderr, "HPX: failed to initialize.\n"); return e; } int iters = 100; size_t size = 8; int opt = 0; while ((opt = getopt(argc, argv, "i:s:h?")) != -1) { switch (opt) { case 'i': iters = atoi(optarg); break; case 's': size = atoi(optarg); break; case 'h': _usage(stdout, EXIT_SUCCESS); default: _usage(stderr, EXIT_FAILURE); } } argc -= optind; argv += optind; e = hpx_run(&_main, &iters, &size); assert(e == HPX_SUCCESS); hpx_finalize(); }
int main(int argc, char *argv[]) { // Register the main action HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _main, _main_action, HPX_POINTER, HPX_SIZE_T); if (hpx_init(&argc, &argv)) { fprintf(stderr, "HPX: failed to initialize.\n"); return 1; } int opt = 0; while ((opt = getopt(argc, argv, "h?")) != -1) { switch (opt) { case 'h': usage(stdout); return 0; case '?': default: usage(stderr); return -1; } } fprintf(stdout, "Starting the cost of GAS Allocation benchmark\n"); // run the main action int e = hpx_run(&_main, NULL, 0); hpx_finalize(); return e; }
int main(int argc, char *argv[]) { // register the actions HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _main, _main_action, HPX_POINTER, HPX_SIZE_T); HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _set_value, action_set_value, HPX_POINTER, HPX_SIZE_T); HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _get_value, action_get_value, HPX_POINTER, HPX_SIZE_T); if (hpx_init(&argc, &argv)) { fprintf(stderr, "HPX: failed to initialize.\n"); return 1; } int opt = 0; while ((opt = getopt(argc, argv, "h?")) != -1) { switch (opt) { case 'h': _usage(stdout); return 0; case '?': default: _usage(stderr); return -1; } } // run the main action int e = hpx_run(&_main, NULL, 0); hpx_finalize(); return e; }
int main(int argc, char *argv[]) { int e = hpx_init(&argc, &argv); if (e) { fprintf(stderr, "HPX: failed to initialize.\n"); return e; } // run the main action e = hpx_run(&thread_create, &e, sizeof(e)); hpx_finalize(); return e; }
int main(int argc, char *argv[]) { long bots_t_start; long bots_t_end; Node root; char bots_arg_file[255]; int e = hpx_init(&argc, &argv); if (e) { fprintf(stderr, "HPX: failed to initialize.\n"); return e; } int opt = 0; while ((opt = getopt(argc, argv, "h?")) != -1) { switch (opt) { case 'h': printf("./hpx-5 [file]"); case '?': default: printf("./hpx-5 [file]"); } } argc -= optind; argv += optind; switch (argc) { case 0: fprintf(stderr, "Missing uts file.\n"); // fall through default: printf("./hpx-5 [file]"); case 1: strcpy(bots_arg_file, argv[0]); break; } uts_read_file(bots_arg_file); HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _uts, _uts_action, HPX_POINTER, HPX_SIZE_T); HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _uts_main, _uts_main_action, HPX_POINTER, HPX_SIZE_T); int t = hpx_run(&_uts_main, &root, sizeof(root)); hpx_finalize(); return t; }
int main(int argc, char *argv[]) { HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _nqueens_main, _nqueens_main_action, HPX_POINTER, HPX_SIZE_T); HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _nqueens, _nqueens_action, HPX_POINTER, HPX_SIZE_T); if (hpx_init(&argc, &argv) != 0) { fprintf(stderr, "HPX: failed to initialize.\n"); return -1; } // parse the command line int opt = 0; while ((opt = getopt(argc, argv, "h?")) != -1) { switch (opt) { case 'h': _usage(stdout, EXIT_SUCCESS); case '?': default: _usage(stderr, EXIT_FAILURE); } } argc -= optind; argv += optind; int n = 0; switch (argc) { case 0: fprintf(stderr, "\nMissing nqueens number.\n"); // fall through default: _usage(stderr, EXIT_FAILURE); case 1: n = atoi(argv[0]); break; } if( n > MAX_SIZE) { printf("Max size is %d.\n", MAX_SIZE); n = MAX_SIZE; } // run the main action int e = hpx_run(&_nqueens_main, &n, sizeof(n)); hpx_finalize(); return e; }
int main(int argc, char *argv[]) { char bots_arg_file[255]="./input/small.input"; if (hpx_init(&argc, &argv) != 0) { fprintf(stderr, "HPX: failed to initialize.\n"); return -1; } // parse the command line int opt = 0; while ((opt = getopt(argc, argv, "h?")) != -1) { switch (opt) { case 'h': _usage(stdout, EXIT_SUCCESS); case '?': default: _usage(stderr, EXIT_FAILURE); } } argc -= optind; argv += optind; int n = 0; switch (argc) { case 0: fprintf(stderr, "\nMissing health input.\n"); // fall through default: _usage(stderr, EXIT_FAILURE); case 1: strcpy(bots_arg_file, argv[0] ); break; } HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _health, _health_action, HPX_POINTER, HPX_SIZE_T); HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _health_main, _health_main_action, HPX_POINTER, HPX_SIZE_T); int t = hpx_run(&_health_main, &bots_arg_file, sizeof(bots_arg_file)); hpx_finalize(); return t; }
int main(int argc, char *argv[]) { // register the cswitch action HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _cswitch_main, _cswitch_main_action, HPX_POINTER, HPX_SIZE_T); int e = hpx_init(&argc, &argv); if (e) { fprintf(stderr, "HPX: failed to initialize.\n"); return e; } // parse the command line int opt = 0; while ((opt = getopt(argc, argv, "h?")) != -1) { switch (opt) { case 'h': _usage(stdout, EXIT_SUCCESS); case '?': default: _usage(stderr, EXIT_FAILURE); } } argc -= optind; argv += optind; int n = 100000; switch (argc) { case 0: break; default: _usage(stderr, EXIT_FAILURE); case 1: n = atoi(argv[0]); break; } // run the main action e = hpx_run(&_cswitch_main, &n, sizeof(n)); hpx_finalize(); return e; }
/// The main function parses the command line, sets up the HPX runtime system, /// and initiates the first HPX thread to perform seqspawn(n). int main(int argc, char *argv[]) { // register the actions HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _nop, _nop_action, HPX_POINTER, HPX_SIZE_T); HPX_REGISTER_ACTION(HPX_DEFAULT, HPX_MARSHALLED, _main, _main_action, HPX_POINTER, HPX_SIZE_T); if (hpx_init(&argc, &argv)) { fprintf(stderr, "HPX: failed to initialize.\n"); return -1; } int opt = 0; while ((opt = getopt(argc, argv, "h?")) != -1) { switch (opt) { case 'h': _usage(stdout, EXIT_SUCCESS); case '?': default: _usage(stderr, EXIT_FAILURE); } } argc -= optind; argv += optind; int n = 0; switch (argc) { case 0: fprintf(stderr, "\nMissing spawn count.\n"); default: _usage(stderr, EXIT_FAILURE); case 1: n = atoi(argv[0]); break; } // run the main action int e = hpx_run(&_main, &n, sizeof(n)); hpx_finalize(); return e; }
int main(int argc, char **argv) { int e = hpx_init(&argc, &argv); if (e) { fprintf(stderr, "failed to initialize HPX.\n"); return e; } int n = 100; int nsteps = 100; // parse the command line int opt = 0; while ((opt = getopt(argc, argv, "n:s:f:h?")) != -1) { switch (opt) { case 'n': n = atoi(optarg); break; case 's': nsteps = atoi(optarg); break; case 'f': fname = optarg; break; case 'h': _usage(stdout, EXIT_SUCCESS); break; case '?': default: _usage(stderr, EXIT_FAILURE); } } argc -= optind; argv += optind; // run the main action e = hpx_run(&_jacobi_main, &n, &nsteps); hpx_finalize(); return e; }
int hpx_init(int *argc, char ***argv) { int status = HPX_SUCCESS; // Start the internal clock libhpx_time_start(); here = malloc(sizeof(*here)); if (!here) { status = log_error("failed to allocate a locality.\n"); goto unwind0; } here->rank = -1; here->ranks = 0; here->epoch = 0; sigset_t set; sigemptyset(&set); dbg_check(pthread_sigmask(SIG_BLOCK, &set, &here->mask)); here->config = config_new(argc, argv); if (!here->config) { status = log_error("failed to create a configuration.\n"); goto unwind1; } // check to see if everyone is waiting if (config_dbg_waitat_isset(here->config, HPX_LOCALITY_ALL)) { dbg_wait(); } // bootstrap here->boot = boot_new(here->config->boot); if (!here->boot) { status = log_error("failed to bootstrap.\n"); goto unwind1; } here->rank = boot_rank(here->boot); here->ranks = boot_n_ranks(here->boot); // initialize the debugging system // @todo We would like to do this earlier but MPI_init() for the bootstrap // network overwrites our segv handler. if (LIBHPX_OK != dbg_init(here->config)) { goto unwind1; } // Now that we know our rank, we can be more specific about waiting. if (config_dbg_waitat_isset(here->config, here->rank)) { // Don't wait twice. if (!config_dbg_waitat_isset(here->config, HPX_LOCALITY_ALL)) { dbg_wait(); } } // see if we're supposed to output the configuration, only do this at rank 0 if (config_log_level_isset(here->config, HPX_LOG_CONFIG)) { if (here->rank == 0) { config_print(here->config, stdout); } } // topology discovery and initialization here->topology = topology_new(here->config); if (!here->topology) { status = log_error("failed to discover topology.\n"); goto unwind1; } // Initialize our instrumentation. if (inst_init(here->config)) { log_dflt("error detected while initializing instrumentation\n"); } // Allocate the global heap. here->gas = gas_new(here->config, here->boot); if (!here->gas) { status = log_error("failed to create the global address space.\n"); goto unwind1; } HPX_HERE = HPX_THERE(here->rank); here->percolation = percolation_new(); if (!here->percolation) { status = log_error("failed to activate percolation.\n"); goto unwind1; } int cores = system_get_available_cores(); dbg_assert(cores > 0); if (!here->config->threads) { here->config->threads = cores; } log_dflt("HPX running %d worker threads on %d cores\n", here->config->threads, cores); here->net = network_new(here->config, here->boot, here->gas); if (!here->net) { status = log_error("failed to create network.\n"); goto unwind1; } // thread scheduler here->sched = scheduler_new(here->config); if (!here->sched) { status = log_error("failed to create scheduler.\n"); goto unwind1; } #ifdef HAVE_APEX // initialize APEX, give this main thread a name apex_init("HPX WORKER THREAD"); apex_set_node_id(here->rank); #endif action_registration_finalize(); inst_start(); // start the scheduler, this will return after scheduler_shutdown() if (scheduler_startup(here->sched, here->config) != LIBHPX_OK) { log_error("scheduler shut down with error.\n"); goto unwind1; } if ((here->ranks > 1 && here->config->gas != HPX_GAS_AGAS) || !here->config->opt_smp) { status = hpx_run(&_hpx_143_fix); } return status; unwind1: _stop(here); _cleanup(here); unwind0: return status; }