当前位置: 首页>>代码示例>>C++>>正文


C++ hpx::finalize方法代码示例

本文整理汇总了C++中hpx::finalize方法的典型用法代码示例。如果您正苦于以下问题:C++ hpx::finalize方法的具体用法?C++ hpx::finalize怎么用?C++ hpx::finalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hpx的用法示例。


在下文中一共展示了hpx::finalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hpx_main

int hpx_main(variables_map& vm)
{
    int test;
    std::string inputFile;

    inputFile = vm["input"].as<std::string>();
    {
        id_type prefix = get_applier().get_runtime_support_gid();

        bhcontroller dat;

        dat.create(prefix);
        test = dat.construct(inputFile);
        if(test == 0){
            dat.run_simulation();
        }
        dat.free();

//        std::cout << (boost::format("total error   : %1%\n"
//                                    "average error : %2%\n")
//                     % r % (r / size));  
    }

    finalize();
    std::cout<<"OH YEAH!\n";
    return 0;
}
开发者ID:STEllAR-GROUP,项目名称:hpx_historic,代码行数:27,代码来源:barnes_hut.cpp

示例2: hpx_main

int hpx_main(variables_map& vm)
{
    {
        boost::uint64_t n = vm["n-value"].as<boost::uint64_t>();

        const id_type prefix = get_applier().get_runtime_support_gid();

        high_resolution_timer t;

        jacobsthal_future f(prefix, prefix, n);

        bigint r = f.get();

        double elapsed = t.elapsed();

        std::cout
            << ( boost::format("jacobsthal(%1%) == %2%\n"
                               "elapsed time == %3%\n")
               % n % r % elapsed);
    }

    finalize();

    return 0;
}
开发者ID:STEllAR-GROUP,项目名称:hpx_historic,代码行数:25,代码来源:naive_jacobsthal_bigint.cpp

示例3: hpx_main

int hpx_main(
    variables_map& vm
    )
{
    if (vm.count("no-header"))
        header = false;

    {
        if (0 == tasks)
            throw std::invalid_argument("count of 0 tasks specified\n");

        // Start the clock.
        high_resolution_timer t;

        for (boost::uint64_t i = 0; i < tasks; ++i)
            register_work(HPX_STD_BIND(&invoke_worker, delay));

        // Reschedule hpx_main until all other hpx-threads have finished. We
        // should be resumed after most of the null px-threads have been
        // executed. If we haven't, we just reschedule ourselves again.
        do {
            suspend();
        } while (get_thread_count(hpx::threads::thread_priority_normal) > 1);

        print_results(get_os_thread_count(), t.elapsed());
    }

    return finalize();
}
开发者ID:fpelliccioni,项目名称:hpx,代码行数:29,代码来源:hpx_homogeneous_task_spawn.cpp

示例4: hpx_main

int hpx_main(variables_map& vm)
{
    {
        boost::uint64_t m = vm["m-value"].as<boost::uint64_t>()
                      , n = vm["n-value"].as<boost::uint64_t>();

        const id_type prefix = get_applier().get_runtime_support_gid();

        high_resolution_timer t;

        ackermann_peter_future f(prefix, prefix, m, n);

        boost::uint64_t r = f.get();

        double elapsed = t.elapsed();

        std::cout
            << ( boost::format("ackermann_peter(%1%, %2%) == %3%\n"
                               "elapsed time == %4%\n")
               % m % n % r % elapsed);
    }

    finalize();

    return 0;
}
开发者ID:STEllAR-GROUP,项目名称:hpx_historic,代码行数:26,代码来源:naive_ackermann_peter.cpp

示例5: hpx_main

int hpx_main(variables_map& vm)
{
    boost::uint64_t const futures = vm["futures"].as<boost::uint64_t>();
    boost::uint64_t const grain_size = vm["grain-size"].as<boost::uint64_t>();

    {
        thread_id_type thread_id = register_thread_nullary(
            boost::bind(&test_dummy_thread, futures));
        HPX_TEST(thread_id != hpx::threads::invalid_thread_id);

        // Flood the queues with suspension operations before the rescheduling
        // attempt.
        unique_future<void> before = async(&tree_boot, futures, grain_size, thread_id);

        set_thread_state(thread_id, pending, wait_signaled);

        // Flood the queues with suspension operations after the rescheduling
        // attempt.
        unique_future<void> after = async(&tree_boot, futures, grain_size, thread_id);

        before.get();
        after.get();

        set_thread_state(thread_id, pending, wait_terminate);
    }

    finalize();

    return 0;
}
开发者ID:41i,项目名称:hpx,代码行数:30,代码来源:thread_rescheduling.cpp

示例6: hpx_main

int hpx_main(variables_map& vm)
{
    unsigned int size(0), allocblock(0), blocksize(0);

    size = vm["size"].as<unsigned int>();
    allocblock = vm["allocblock"].as<unsigned int>();
    blocksize = vm["blocksize"].as<unsigned int>();
    {
        id_type prefix = get_applier().get_runtime_support_gid();

        smphplmatrex dat;

        dat.create(prefix);
        dat.construct(size, allocblock, blocksize);

        double r = dat.LUsolve();

        dat.free();

        std::cout << (boost::format("total error   : %1%\n"
                                    "average error : %2%\n")
                     % r % (r / size));
    }

    finalize();
    return 0;
}
开发者ID:STEllAR-GROUP,项目名称:hpx_historic,代码行数:27,代码来源:smphplpx.cpp

示例7: hpx_main

int hpx_main(variables_map& vm)
{
    std::size_t pxthreads = 0;

    if (vm.count("pxthreads"))
        pxthreads = vm["pxthreads"].as<std::size_t>();
    
    std::size_t iterations = 0;

    if (vm.count("iterations"))
        iterations = vm["iterations"].as<std::size_t>();

    std::size_t suspend_duration = 0;

    if (vm.count("suspend-duration"))
        suspend_duration = vm["suspend-duration"].as<std::size_t>();

    {
        barrier b(pxthreads + 1);

        // Create the hpx-threads.
        for (std::size_t i = 0; i < pxthreads; ++i)
            register_work(boost::bind
                (&suspend_test, boost::ref(b), iterations, suspend_duration));

        b.wait(); // Wait for all hpx-threads to enter the barrier.
    }

    // Initiate shutdown of the runtime system.
    return finalize();
}
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:31,代码来源:thread_suspend_duration.cpp

示例8: hpx_main

int hpx_main(variables_map& vm)
{
    boost::uint64_t const futures = vm["futures"].as<boost::uint64_t>();
    boost::uint64_t const grain_size = vm["grain-size"].as<boost::uint64_t>();

    {
        id_type const prefix = find_here();

        thread_id_type thread_id = register_thread_nullary
            (boost::bind(&test_dummy_thread, futures));
        boost::uint64_t thread = boost::uint64_t(thread_id);

        // Flood the queues with suspension operations before the rescheduling
        // attempt.
        future<void> before =
            async<tree_boot_action>(prefix, futures, grain_size, prefix, thread);

        set_thread_state(thread_id, pending, wait_signaled);

        // Flood the queues with suspension operations after the rescheduling
        // attempt.
        future<void> after =
            async<tree_boot_action>(prefix, futures, grain_size, prefix, thread);

        before.get();
        after.get();

        set_thread_state(thread_id, pending, wait_terminate);
    }

    finalize();

    return 0;
}
开发者ID:NOMORECOFFEE,项目名称:hpx,代码行数:34,代码来源:thread_rescheduling.cpp

示例9: hpx_main

int hpx_main(variables_map& vm)
{
    std::size_t pxthreads = 0;

    if (vm.count("pxthreads"))
        pxthreads = vm["pxthreads"].as<std::size_t>();

    std::size_t iterations = 0;

    if (vm.count("iterations"))
        iterations = vm["iterations"].as<std::size_t>();

    for (std::size_t i = 0; i < iterations; ++i)
    {
        // create a barrier waiting on 'count' threads
        barrier b(pxthreads + 1);

        boost::atomic<std::size_t> c(0);

        // create the threads which will wait on the barrier
        for (std::size_t i = 0; i < pxthreads; ++i)
            register_work(hpx::util::bind
                (&local_barrier_test, std::ref(b), std::ref(c)));

        b.wait(); // wait for all threads to enter the barrier
        HPX_TEST_EQ(pxthreads, c);
    }

    // initiate shutdown of the runtime system
    finalize();
    return 0;
}
开发者ID:atrantan,项目名称:hpx,代码行数:32,代码来源:local_barrier.cpp

示例10: hpx_main

int hpx_main(
    variables_map& vm
    )
{
    if (vm.count("no-header"))
        header = false;

    std::size_t num_os_threads = hpx::get_os_thread_count();

    int num_executors = vm["executors"].as<int>();
    if (num_executors <= 0)
        throw std::invalid_argument("number of executors to use must be larger than 0");

    if (std::size_t(num_executors) > num_os_threads)
        throw std::invalid_argument("number of executors to use must be \
                                        smaller than number of OS threads");

    std::size_t num_cores_per_executor = vm["cores"].as<int>();

    if ((num_executors - 1) * num_cores_per_executor > num_os_threads)
        throw std::invalid_argument("number of cores per executor should not \
                                     cause oversubscription");

    if (0 == tasks)
        throw std::invalid_argument("count of 0 tasks specified\n");

    // Start the clock.
    high_resolution_timer t;

    // create the executor instances
    using hpx::threads::executors::local_priority_queue_executor;

    {
        std::vector<local_priority_queue_executor> executors;
        for (std::size_t i = 0; i != std::size_t(num_executors); ++i)
        {
            // make sure we don't oversubscribe the cores, the last executor will
            // be bound to the remaining number of cores
            if ((i + 1) * num_cores_per_executor > num_os_threads)
            {
                HPX_ASSERT(i == std::size_t(num_executors) - 1);
                num_cores_per_executor = num_os_threads - i * num_cores_per_executor;
            }
            executors.push_back(local_priority_queue_executor(num_cores_per_executor));
        }

        t.restart();

        // schedule normal threads
        for (boost::uint64_t i = 0; i < tasks; ++i)
            executors[i % num_executors].add(
                hpx::util::bind(&worker_timed, delay * 1000));
    // destructors of executors will wait for all tasks to finish executing
    }

    print_results(num_os_threads, t.elapsed());

    return finalize();
}
开发者ID:HadrienG2,项目名称:hpx,代码行数:59,代码来源:hpx_homogeneous_timed_task_spawn_executors.cpp

示例11: hpx_main

int hpx_main(variables_map& vm)
{
  here = find_here();
  pi = boost::math::constants::pi<double>();

  //    dt = vm["dt-value"].as<double>();
  //    dx = vm["dx-value"].as<double>();
  //    c = vm["c-value"].as<double>();
  nx = vm["nx-value"].as<boost::uint64_t>();
  nt = vm["nt-value"].as<boost::uint64_t>();

  c = 1.0;

  dt = 1.0/(nt-1);
  dx = 1.0/(nx-1);
  alpha_squared = (c*dt/dx)*(c*dt/dx);

  // check that alpha_squared satisfies the stability condition
  if (0.25 < alpha_squared)
    {
      cout << (("alpha^2 = (c*dt/dx)^2 should be less than 0.25 for stability!\n"))
          << flush;
    }

  u = std::vector<std::vector<data> >(nt, std::vector<data>(nx));

  cout << (boost::format("dt = %1%\n") % dt) << flush;
  cout << (boost::format("dx = %1%\n") % dx) << flush;
  cout << (boost::format("alpha^2 = %1%\n") % alpha_squared) << flush;

  {
    // Keep track of the time required to execute.
    high_resolution_timer t;

    std::vector<future<double> > futures;
    for (boost::uint64_t i=0;i<nx;i++)
      futures.push_back(async<wave_action>(here,nt-1,i));

    // open file for output
    std::ofstream outfile;
    outfile.open ("output.dat");

    wait(futures, [&](std::size_t i, double n)
         { double x_here = i*dx;
           outfile << (boost::format("%1% %2%\n") % x_here % n) << flush; });

    outfile.close();

    char const* fmt = "elapsed time: %1% [s]\n";
    std::cout << (boost::format(fmt) % t.elapsed());

  }

  finalize();
  return 0;
}
开发者ID:HadrienG2,项目名称:hpx,代码行数:56,代码来源:1d_wave_equation.cpp

示例12: hpx_main

int hpx_main(variables_map&)
{
    test_void_actions();
    test_void_direct_actions();
    test_object_actions();
    test_object_direct_actions();

    finalize();

    return hpx::util::report_errors();
}
开发者ID:khuck,项目名称:hpx,代码行数:11,代码来源:plain_action_move_semantics.cpp

示例13: hpx_main

int hpx_main(
    variables_map& vm
    )
{
    {
        simple_mobile_object a(hpx::find_here());
        simple_mobile_object b(hpx::find_here());

        id_type a_id = a.get_id();
        gid_type a_gid = get_stripped_gid(a_id.get_gid());
        boost::uint64_t b_lva = b.get_lva();

        // Resolve a_gid.
        address addr = hpx::agas::resolve(a_id).get();

        ///////////////////////////////////////////////////////////////////////
        HPX_TEST_EQ(addr.address_, a.get_lva());
        HPX_SANITY_EQ(hpx::agas::resolve(a_id).get().address_, a.get_lva());

        ///////////////////////////////////////////////////////////////////////
        // Change a's GID to point to b.

        // Rebind the GID.
        boost::uint64_t a_lva = addr.address_;
        addr.address_ = b_lva;
        HPX_TEST(get_agas_client().bind_local(a_gid, addr));

        // Update our AGAS cache.
        get_agas_client().update_cache_entry(a_gid, addr);

        ///////////////////////////////////////////////////////////////////////
        HPX_TEST_EQ(b_lva, a.get_lva());
        HPX_SANITY_EQ(hpx::agas::resolve(a_id).get().address_, a.get_lva());

        ///////////////////////////////////////////////////////////////////////
        // Now we restore the original bindings to prevent a double free.

        // Rebind the GID.
        addr.address_ = a_lva;
        HPX_TEST(get_agas_client().bind_local(a_gid, addr));

        // Update our AGAS cache.
        get_agas_client().update_cache_entry(a_gid, addr);

        ///////////////////////////////////////////////////////////////////////
        HPX_TEST_EQ(hpx::agas::resolve(a_id).get().address_, a_lva);
        HPX_SANITY_EQ(hpx::agas::resolve(a_id).get().address_, a.get_lva());
    }

    finalize();
    return report_errors();
}
开发者ID:Bcorde5,项目名称:hpx,代码行数:52,代码来源:local_address_rebind.cpp

示例14: hpx_main

int hpx_main(
    variables_map&
    )
{
    {
        const boost::format fmter("%1% %|40t|%2%\n");

        cout << HPX_SIZEOF(hpx::naming::gid_type)
             << HPX_SIZEOF(hpx::naming::id_type)
             << HPX_SIZEOF(hpx::naming::address)
             << flush;
    }

    finalize();
    return 0;
}
开发者ID:41i,项目名称:hpx,代码行数:16,代码来源:sizeof.cpp

示例15: hpx_main

int hpx_main(variables_map & vm)
{
    {
        std::size_t nx = vm["nx"].as<std::size_t>();
        std::size_t ny = vm["ny"].as<std::size_t>();
        std::size_t max_iterations = vm["max_iterations"].as<std::size_t>();
        std::size_t line_block = vm["line_block"].as<std::size_t>();

        jacobi::grid u(nx, ny, 1.0);

        jacobi::solver solver(u, nx, line_block);

        solver.run(max_iterations);
    }

    return finalize();
}
开发者ID:Stevejohntest,项目名称:hpx,代码行数:17,代码来源:jacobi.cpp


注:本文中的hpx::finalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。