• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ hpx类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: hpx_main

int hpx_main(variables_map& vm)
{
    int r = master(vm);
    finalize();
    return r;
}
开发者ID:STEllAR-GROUP,项目名称:hpx_historic,代码行数:6,代码来源:solver_rational64.cpp


示例2: hpx_main

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

        if (vm.count("csv-header"))
            csv_header = true;

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

        if (suspended_tasks > tasks)
            throw std::invalid_argument(
                "suspended tasks must be smaller than tasks\n");

        std::uint64_t const os_thread_count = get_os_thread_count();

        ///////////////////////////////////////////////////////////////////////
        stage_worker_function stage_worker;

        if ("static-balanced-stackbased" == distribution)
            stage_worker = &stage_worker_static_balanced_stackbased;
        else if ("static-imbalanced" == distribution)
            stage_worker = &stage_worker_static_imbalanced;
        else if ("round-robin" == distribution)
            stage_worker = &stage_worker_round_robin;
        else
            throw std::invalid_argument(
                "invalid distribution type specified (valid options are "
                "\"static-balanced\", \"static-imbalanced\" or \"round-robin\")"
                );

        ///////////////////////////////////////////////////////////////////////
        std::uint64_t tasks_per_feeder = 0;
        //std::uint64_t total_tasks = 0;
        std::uint64_t suspended_tasks_per_feeder = 0;
        std::uint64_t total_suspended_tasks = 0;

        if ("strong" == scaling)
        {
            if (tasks % os_thread_count)
                throw std::invalid_argument(
                    "tasks must be cleanly divisable by OS-thread count\n");

            if (suspended_tasks % os_thread_count)
                throw std::invalid_argument(
                    "suspended tasks must be cleanly divisable by OS-thread "
                    "count\n");

            tasks_per_feeder = tasks / os_thread_count;
            //total_tasks      = tasks;
            suspended_tasks_per_feeder = suspended_tasks / os_thread_count;
            total_suspended_tasks      = suspended_tasks;
        }
        else if ("weak" == scaling)
        {
            tasks_per_feeder = tasks;
            //total_tasks      = tasks * os_thread_count;
            suspended_tasks_per_feeder = suspended_tasks;
            total_suspended_tasks      = suspended_tasks * os_thread_count;
        }
        else
            throw std::invalid_argument(
                "invalid scaling type specified (valid options are \"strong\" "
                "or \"weak\")");

        ///////////////////////////////////////////////////////////////////////
        if (suspended_tasks != 0)
        {
            std::uint64_t gcd = boost::math::gcd(tasks_per_feeder
                                                 , suspended_tasks_per_feeder);

            suspend_step = suspended_tasks_per_feeder / gcd;
            // We check earlier to make sure that there are never more
            // suspended tasks than tasks requested.
            no_suspend_step = (tasks_per_feeder / gcd) - suspend_step;
        }

        ///////////////////////////////////////////////////////////////////////
        std::vector<std::string> counter_shortnames;
        std::vector<std::string> counters;
        if (vm.count("counter"))
        {
            std::vector<std::string> raw_counters =
                vm["counter"].as<std::vector<std::string> >();

            for (std::uint64_t i = 0; i < raw_counters.size(); ++i)
            {
                std::vector<std::string> entry;
                boost::algorithm::split(entry, raw_counters[i],
                    boost::algorithm::is_any_of(","),
                    boost::algorithm::token_compress_on);

                HPX_ASSERT(entry.size() == 2);

                counter_shortnames.push_back(entry[0]);
                counters.push_back(entry[1]);
//.........这里部分代码省略.........
开发者ID:ShmuelLevine,项目名称:hpx,代码行数:101,代码来源:timed_task_spawn.cpp


示例3: get_task_data

// The input on the Intel call is a pair of pointers to arrays of dep structs,
// and the length of these arrays.
// The structs contain a pointer and a flag for in or out dep
void hpx_runtime::create_df_task( int gtid, kmp_task_t *thunk, 
                           int ndeps, kmp_depend_info_t *dep_list,
                           int ndeps_noalias, kmp_depend_info_t *noalias_dep_list )
{
    auto task = get_task_data();
    auto team = task->team;
    if(team->num_threads == 1 ) {
        create_task(thunk->routine, gtid, thunk);
    }
    vector<shared_future<void>> dep_futures;
    dep_futures.reserve( ndeps + ndeps_noalias);

    //Populating a vector of futures that the task depends on
    for(int i = 0; i < ndeps;i++) {
        if(task->df_map.count( dep_list[i].base_addr) > 0) {
            dep_futures.push_back(task->df_map[dep_list[i].base_addr]);
        }
    }
    for(int i = 0; i < ndeps_noalias;i++) {
        if(task->df_map.count( noalias_dep_list[i].base_addr) > 0) {
            dep_futures.push_back(task->df_map[noalias_dep_list[i].base_addr]);
        }
    }

    shared_future<void> new_task;

    if(task->in_taskgroup) {
    } else {
        *(task->num_child_tasks) += 1;
    }
#ifndef OMP_COMPLIANT
    team->num_tasks++;
#endif
    if(dep_futures.size() == 0) {
#ifdef OMP_COMPLIANT
        if(task->in_taskgroup) {
            new_task = hpx::async( *(task->tg_exec), tg_task_setup, gtid, thunk, task->icv,
                                    task->tg_exec, team);
        } else {
            new_task = hpx::async( *(team->exec), task_setup, gtid, thunk, task->icv,
                                    task->num_child_tasks, team);
        }
#else
        new_task = hpx::async( task_setup, gtid, thunk, task->icv,
                                task->num_child_tasks, team);
#endif
    } else {


#ifdef OMP_COMPLIANT
        //shared_future<shared_ptr<local_priority_queue_executor>> tg_exec = hpx::make_ready_future(task->tg_exec);

        if(task->in_taskgroup) {
            new_task = dataflow( *(task->tg_exec),
                                 unwrapping(df_tg_task_wrapper), gtid, thunk, task->icv, 
                                 task->tg_exec, 
                                 team, hpx::when_all(dep_futures) );
        } else {
            new_task = dataflow( *(team->exec),
                                 unwrapping(df_task_wrapper), gtid, thunk, task->icv, 
                                 task->num_child_tasks, 
                                 team, hpx::when_all(dep_futures) );
        }
#else
        new_task = dataflow( unwrapping(df_task_wrapper), gtid, thunk, task->icv, 
                             task->num_child_tasks, 
                             team, hpx::when_all(dep_futures) );
#endif
    }
    for(int i = 0 ; i < ndeps; i++) {
        if(dep_list[i].flags.out) {
            task->df_map[dep_list[i].base_addr] = new_task;
        }
    }
    for(int i = 0 ; i < ndeps_noalias; i++) {
        if(noalias_dep_list[i].flags.out) {
            task->df_map[noalias_dep_list[i].base_addr] = new_task;
        }
    }
    //task->last_df_task = new_task;
}
开发者ID:kempj,项目名称:hpxMP,代码行数:84,代码来源:hpx_runtime.cpp


示例4: test_object_actions

void test_object_actions()
{
    std::vector<id_type> localities = hpx::find_all_localities();

    BOOST_FOREACH(id_type id, localities)
    {
        bool is_local = id == find_here();

        // test size_t(movable_object const&)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_action, movable_object>(id)
            ), 1u); // bind

            HPX_TEST_EQ((
                move_object<pass_movable_object_action, movable_object>(id)
            ), 0U);
        } else {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_action, movable_object>(id)
            ), 2u); // transfer_action + bind
            //! should be: transfer_action

            HPX_TEST_EQ((
                move_object<pass_movable_object_action, movable_object>(id)
            ), 1u); // bind
            //! should be: -
        }

        // test size_t(non_movable_object const&)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_non_movable_object_action, non_movable_object>(id)
            ), 2u); // bind + function

            HPX_TEST_EQ((
                move_object<pass_non_movable_object_action, non_movable_object>(id)
            ), 2u); // bind + function
        } else {
            HPX_TEST_EQ((
                pass_object<pass_non_movable_object_action, non_movable_object>(id)
            ), 3u); // transfer_action + bind + function

            HPX_TEST_EQ((
                move_object<pass_non_movable_object_action, non_movable_object>(id)
            ), 3u); // transfer_action + bind + function
        }

        // test size_t(movable_object)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_value_action, movable_object>(id)
            ), 1u); // call

            HPX_TEST_EQ((
                move_object<pass_movable_object_value_action, movable_object>(id)
            ), 0u);
        } else {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_value_action, movable_object>(id)
            ), 2u); // transfer_action + bind
            //! should be: transfer_action

            HPX_TEST_EQ((
                move_object<pass_movable_object_value_action, movable_object>(id)
            ), 1u); // bind
            //! should be: -
        }

        // test size_t(non_movable_object)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_non_movable_object_value_action, non_movable_object>(id)
            ), 3u); // bind + function + call

            HPX_TEST_EQ((
                move_object<pass_non_movable_object_value_action, non_movable_object>(id)
            ), 3u); // bind + function + call
        } else {
            HPX_TEST_EQ((
                pass_object<pass_non_movable_object_value_action, non_movable_object>(id)
            ), 4u); // transfer_action + bind + function + call

            HPX_TEST_EQ((
                move_object<pass_non_movable_object_value_action, non_movable_object>(id)
            ), 4u); // transfer_action + bind + function + call
        }

        // test movable_object()
        if (is_local)
        {
            HPX_TEST_EQ((
                return_object<
                    return_movable_object_action, movable_object
                >(id)
            ), 1u); // value_or_error(r)
//.........这里部分代码省略.........
开发者ID:johnforce,项目名称:hpx,代码行数:101,代码来源:plain_action_move_semantics.cpp


示例5: hpx_main

int hpx_main()
{
    using hpx::make_continuation;

    increment_action inc;
    increment_with_future_action inc_f;
    mult2_action mult;

    // test locally, fully equivalent to plain hpx::async
    {
        hpx::future<int> f1 = hpx::async_continue(
            inc, make_continuation(), hpx::find_here(), 42);
        HPX_TEST_EQ(f1.get(), 43);

        hpx::promise<std::int32_t> p;
        hpx::shared_future<std::int32_t> f = p.get_future();

        hpx::future<int> f2 = hpx::async_continue(
            inc_f, make_continuation(), hpx::find_here(), f);

        p.set_value(42);
        HPX_TEST_EQ(f2.get(), 43);
    }

    // test remotely, if possible, fully equivalent to plain hpx::async
    std::vector<hpx::id_type> localities = hpx::find_remote_localities();
    if (!localities.empty())
    {
        hpx::future<int> f1 = hpx::async_continue(
            inc, make_continuation(), localities[0], 42);
        HPX_TEST_EQ(f1.get(), 43);

        hpx::promise<std::int32_t> p;
        hpx::shared_future<std::int32_t> f = p.get_future();

        hpx::future<int> f2 = hpx::async_continue(
            inc_f, make_continuation(), localities[0], f);

        p.set_value(42);
        HPX_TEST_EQ(f2.get(), 43);
    }

    // test chaining locally
    {
        hpx::future<int> f = hpx::async_continue(
            inc, make_continuation(mult), hpx::find_here(), 42);
        HPX_TEST_EQ(f.get(), 86);

        f = hpx::async_continue(inc,
            make_continuation(mult, make_continuation()), hpx::find_here(), 42);
        HPX_TEST_EQ(f.get(), 86);

        f = hpx::async_continue(inc,
            make_continuation(mult, make_continuation(inc)), hpx::find_here() ,42);
        HPX_TEST_EQ(f.get(), 87);

        f = hpx::async_continue(inc,
            make_continuation(mult, make_continuation(inc, make_continuation())),
            hpx::find_here(), 42);
        HPX_TEST_EQ(f.get(), 87);
    }

    // test chaining remotely, if possible
    if (!localities.empty())
    {
        hpx::future<int> f = hpx::async_continue(inc,
            make_continuation(mult, localities[0]), localities[0], 42);
        HPX_TEST_EQ(f.get(), 86);

        f = hpx::async_continue(inc,
            make_continuation(mult, localities[0], make_continuation()),
            localities[0], 42);
        HPX_TEST_EQ(f.get(), 86);

        f = hpx::async_continue(inc,
            make_continuation(mult, localities[0],
                make_continuation(inc)), localities[0], 42);
        HPX_TEST_EQ(f.get(), 87);

        f = hpx::async_continue(inc,
            make_continuation(mult, localities[0],
                make_continuation(inc, make_continuation())), localities[0], 42);
        HPX_TEST_EQ(f.get(), 87);

        f = hpx::async_continue(inc,
            make_continuation(mult, localities[0],
                make_continuation(inc, localities[0])), localities[0], 42);
        HPX_TEST_EQ(f.get(), 87);

        f = hpx::async_continue(inc,
            make_continuation(mult, localities[0],
                make_continuation(inc, localities[0], make_continuation())),
            localities[0], 42);
        HPX_TEST_EQ(f.get(), 87);

        f = hpx::async_continue(inc,
            make_continuation(mult), localities[0], 42);
        HPX_TEST_EQ(f.get(), 86);

        f = hpx::async_continue(inc,
//.........这里部分代码省略.........
开发者ID:K-ballo,项目名称:hpx,代码行数:101,代码来源:async_continue.cpp


示例6: 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)
            {
                BOOST_ASSERT(i == 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();

        if (0 == vm.count("no-stack")) {
            // schedule normal threads
            for (boost::uint64_t i = 0; i < tasks; ++i)
                executors[i % num_executors].add(HPX_STD_BIND(&invoke_worker, delay));
        }
        else {
            // schedule stackless threads
            for (boost::uint64_t i = 0; i < tasks; ++i)
                executors[i % num_executors].add(HPX_STD_BIND(&invoke_worker, delay),
                    "", hpx::threads::pending, true, hpx::threads::thread_stacksize_nostack);
        }

    // destructors of executors will wait for all tasks to finish executing
    }

    print_results(num_os_threads, t.elapsed());

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


示例7: plain_arguments

void plain_arguments()
{
    void_f4_count.store(0);
    int_f4_count.store(0);

    {
        future<void> f1 = dataflow(&void_f4, 42);
        future<int> f2 = dataflow(&int_f4, 42);

        f1.wait();
        HPX_TEST_EQ(void_f4_count, 1u);

        HPX_TEST_EQ(f2.get(), 84);
        HPX_TEST_EQ(int_f4_count, 1u);
    }

    {
        future<void> f1 = dataflow(hpx::launch::async, &void_f4, 42);
        future<int> f2 = dataflow(hpx::launch::async, &int_f4, 42);

        f1.wait();
        HPX_TEST_EQ(void_f4_count, 2u);

        HPX_TEST_EQ(f2.get(), 84);
        HPX_TEST_EQ(int_f4_count, 2u);
    }

    void_f5_count.store(0);
    int_f5_count.store(0);

    {
        future<void> f1 = dataflow(&void_f5, 42, async(&int_f));
        future<int> f2 = dataflow(&int_f5, 42, async(&int_f));

        f1.wait();
        HPX_TEST_EQ(void_f5_count, 1u);

        HPX_TEST_EQ(f2.get(), 126);
        HPX_TEST_EQ(int_f5_count, 1u);
    }

    {
        future<void> f1 = dataflow(hpx::launch::async, &void_f5, 42, async(&int_f));
        future<int> f2 = dataflow(hpx::launch::async, &int_f5, 42, async(&int_f));

        f1.wait();
        HPX_TEST_EQ(void_f5_count, 2u);

        HPX_TEST_EQ(f2.get(), 126);
        HPX_TEST_EQ(int_f5_count, 2u);
    }
}
开发者ID:pra85,项目名称:hpx,代码行数:52,代码来源:local_dataflow.cpp


示例8: hpx_main

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

        const boost::uint64_t count = vm["futures"].as<boost::uint64_t>();

        k1 = vm["k1"].as<std::size_t>();
        k2 = vm["k2"].as<std::size_t>();
        k3 = vm["k3"].as<std::size_t>();

        const id_type here = find_here();

        if (HPX_UNLIKELY(0 == count))
            throw std::logic_error("error: count of 0 futures specified\n");

        std::vector<unique_future<double> > futures;

        futures.reserve(count);

        // start the clock

        /*
        k1 = 1;
        k2 = 2;
        for(; k1 < 256; k1 = k1 * 2)*/
        {
            //for(; k2 < 2056; k2 = k2 * 2)
            {
                high_resolution_timer walltime;
                for (boost::uint64_t i = 0; i < count; ++i)
                    futures.push_back(async<null_action>(here, i));

                wait(futures, [&] (std::size_t, double r) {
                    global_scratch += r;
                });

                // stop the clock
                const double duration = walltime.elapsed();

                if (vm.count("csv"))
                    cout << ( boost::format("%3%,%4%,%5%,%2%\n")
                              % count
                              % duration
                              % k1
                              % k2
                              % k3
                            )
                         << flush;
                else
                    cout << ( boost::format("invoked %1% futures in %2% seconds (k1 = %3%, k2 = %4%, k3 = %5%)\n")
                              % count
                              % duration
                              % k1
                              % k2
                              % k3
                            )
                         << flush;
            }
        }
    }

    finalize();
    return 0;
}
开发者ID:adk9,项目名称:hpx,代码行数:67,代码来源:spinlock_overhead2.cpp


示例9: hpx_main

int hpx_main(variables_map& vm)
{
    {
        {
            any any1(big_object(30, 40));
            std::stringstream buffer;

            buffer << any1;

            HPX_TEST_EQ(buffer.str(), "3040");
        }

        {
            typedef uint64_t index_type;
            typedef hpx::util::any elem_type;
            typedef hpx::util::hash_any hash_elem_functor;

            typedef boost::unordered_multimap<elem_type, index_type, hash_elem_functor> field_index_map_type;
            typedef field_index_map_type::iterator field_index_map_iterator_type;

            field_index_map_type field_index_map_;
            field_index_map_iterator_type it;
            elem_type elem(std::string("first string"));
            index_type id = 1;

            std::pair<elem_type, index_type> pp=std::make_pair(elem,id);
            it = field_index_map_.insert(pp);
        }

        // test equality
        {
            any any1(7), any2(7), any3(10), any4(std::string("seven"));

            HPX_TEST_EQ(any1, 7);
            HPX_TEST_NEQ(any1, 10);
            HPX_TEST_NEQ(any1, 10.0f);
            HPX_TEST_EQ(any1, any1);
            HPX_TEST_EQ(any1, any2);
            HPX_TEST_NEQ(any1, any3);
            HPX_TEST_NEQ(any1, any4);

            std::string long_str =
                std::string("This is a looooooooooooooooooooooooooong string");
            std::string other_str = std::string("a different string");
            any1 = long_str;
            any2 = any1;
            any3 = other_str;
            any4 = 10.0f;

            HPX_TEST_EQ(any1, long_str);
            HPX_TEST_NEQ(any1, other_str);
            HPX_TEST_NEQ(any1, 10.0f);
            HPX_TEST_EQ(any1, any1);
            HPX_TEST_EQ(any1, any2);
            HPX_TEST_NEQ(any1, any3);
            HPX_TEST_NEQ(any1, any4);
        }

        {
            if (sizeof(small_object) <= sizeof(void*))
                std::cout << "object is small\n";
            else
                std::cout << "object is large\n";

            small_object const f(17);

            any any1(f);
            any any2(any1);
            any any3;
            any3 = any1;

            HPX_TEST_EQ((any_cast<small_object>(any1)) (7), uint64_t(17+7));
            HPX_TEST_EQ((any_cast<small_object>(any2)) (9), uint64_t(17+9));
            HPX_TEST_EQ((any_cast<small_object>(any3)) (11), uint64_t(17+11));
        }

        {
            if (sizeof(big_object) <= sizeof(void*))
                std::cout << "object is small\n";
            else
                std::cout << "object is large\n";

            big_object const f(5, 12);

            any any1(f);
            any any2(any1);
            any any3 = any1;

            HPX_TEST_EQ((any_cast<big_object>(any1)) (0, 1), uint64_t(5+12+0+1));
            HPX_TEST_EQ((any_cast<big_object>(any2)) (1, 0), uint64_t(5+12+1+0));
            HPX_TEST_EQ((any_cast<big_object>(any3)) (1, 1), uint64_t(5+12+1+1));
        }

        // move semantics
        {
            any any1(5);
            HPX_TEST(!any1.empty());
            any any2(std::move(any1));
            HPX_TEST(!any2.empty());
            HPX_TEST(any1.empty());
//.........这里部分代码省略.........
开发者ID:Bcorde5,项目名称:hpx,代码行数:101,代码来源:any.cpp


示例10: hpx_main

int hpx_main(variables_map& vm)
{

    parameter par;

    // default pars
    par->loglevel       = 2;

    par->nt0            = 100;
    par->nx0            = 101;
    par->grain_size     = 10;
    par->allowedl       = 0;
    par->num_neighbors  = 2;
    par->out_every      = 5.0;
    par->refine_every   = 100;
    par->ethreshold     = 1.e-4;
    par->ghostwidth     = 9;

    // application specific parameters
    par->cfl    = 0.01;
    par->disip  = 0.005;
    par->Rmin   = -5.0;
    par->Rout   = 15.0;
    par->tau    = 1.0;
    par->lambda = 1.0;
    par->v      = 0.1;
    par->amp    = 0.0001;
    par->x0     = 10.0;
    par->id_sigma = 0.9;
    par->outdir = "./";

    id_type rt_id = get_applier().get_runtime_support_gid();

    section root;
    hpx::components::stubs::runtime_support::get_config(rt_id, root);

    if (root.has_section("adaptive1d"))
    {
        section pars = *(root.get_section("adaptive1d"));

        appconfig_option<std::size_t>("loglevel", pars, par->loglevel);
        appconfig_option<std::size_t>("nx0", pars, par->nx0);
        appconfig_option<std::size_t>("nt0", pars, par->nt0);
        appconfig_option<std::size_t>("allowedl", pars, par->allowedl);
        appconfig_option<std::size_t>("grain_size", pars, par->grain_size);
        appconfig_option<std::size_t>("num_neighbors", pars, par->num_neighbors);
        appconfig_option<double>("out_every", pars, par->out_every);
        appconfig_option<std::string>("output_directory", pars, par->outdir);
        appconfig_option<std::size_t>("refine_every", pars, par->refine_every);
        appconfig_option<double>("ethreshold", pars, par->ethreshold);
        appconfig_option<std::size_t>("ghostwidth", pars, par->ghostwidth);

        // Application parameters
        appconfig_option<double>("cfl", pars, par->cfl);
        appconfig_option<double>("disip", pars, par->disip);
        appconfig_option<double>("Rmin", pars, par->Rmin);
        appconfig_option<double>("Rout", pars, par->Rout);
        appconfig_option<double>("tau", pars, par->tau);
        appconfig_option<double>("lambda", pars, par->lambda);
        appconfig_option<double>("v", pars, par->v);
        appconfig_option<double>("amp", pars, par->amp);
        appconfig_option<double>("x0", pars, par->x0);
        appconfig_option<double>("id_sigma", pars, par->id_sigma);
    }

    // derived parameters
    if ( (par->nx0 % 2) == 0 )
    {
        std::string msg = boost::str(boost::format(
            "mesh dimensions (%1%) must be odd "
            ) % par->nx0 );
        HPX_THROW_IN_CURRENT_FUNC(bad_parameter, msg);
    }
    if ( (par->nt0 % 2) != 0 )
    {
        std::string msg = boost::str(boost::format(
            "nt0 needs to be even: (%1%) "
            ) % par->nt0);
        HPX_THROW_IN_CURRENT_FUNC(bad_parameter, msg);
    }
    if ( par->grain_size <= 3*par->num_neighbors ) {
        std::string msg = boost::str(boost::format(
            "Increase grain size (%1%) or decrease the num_neighbors (%2%) "
            ) % par->grain_size % par->num_neighbors);
        HPX_THROW_IN_CURRENT_FUNC(bad_parameter, msg);
    }
    if ( par->refine_every < 1 ) {
      // no adaptivity
      par->refine_every = par->nt0;
    }

    if ( (par->refine_every % 2) != 0 )
    {
        std::string msg = boost::str(boost::format(
            "refine_every needs to be even: (%1%) "
            ) % par->refine_every);
        HPX_THROW_IN_CURRENT_FUNC(bad_parameter, msg);
    }

    if ( (par->nt0 % par->refine_every ) != 0 )
//.........这里部分代码省略.........
开发者ID:Stevejohntest,项目名称:hpx,代码行数:101,代码来源:adaptive1d.cpp


示例11: hpx_main

int hpx_main(variables_map&)
{
    std::vector<id_type> localities = hpx::find_all_localities();

    BOOST_FOREACH(id_type id, localities)
    {
        bool is_local = id == find_here();

        if (is_local) {
            // test the void actions locally only (there is no way to get the
            // overall copy count back)

            HPX_TEST_EQ((
                pass_object_void<
                    pass_movable_object_void_action, movable_object
                >()
            ), 1u);

            HPX_TEST_EQ((
                pass_object_void<
                    pass_movable_object_void_direct_action, movable_object
                >()
            ), 1u);

            HPX_TEST_EQ((
                pass_object_void<
                    pass_non_movable_object_void_action, non_movable_object
                >()
            ), 3u);

            HPX_TEST_EQ((
                pass_object_void<
                    pass_non_movable_object_void_direct_action, non_movable_object
                >()
            ), 1u);

            HPX_TEST_EQ((
                move_object_void<
                    pass_movable_object_void_action, movable_object
                >()
            ), 1u);

            HPX_TEST_EQ((
                move_object_void<
                    pass_movable_object_void_direct_action, movable_object
                >()
            ), 1u);

            HPX_TEST_EQ((
                move_object_void<
                    pass_non_movable_object_void_action, non_movable_object
                >()
            ), 3u);

            HPX_TEST_EQ((
                move_object_void<
                    pass_non_movable_object_void_direct_action, non_movable_object
                >()
            ), 1u);
        }

        // test for movable object ('normal' actions)
        HPX_TEST_EQ((
            pass_object<pass_movable_object_action, movable_object>(id)
        ), is_local ? 1u : 1u);

        // test for movable object (direct actions)
        HPX_TEST_EQ((
            pass_object<pass_movable_object_direct_action, movable_object>(id)
        ), is_local ? 1u : 1u);

        // test for a non-movable object ('normal' actions)
        HPX_TEST_EQ((
            pass_object<pass_non_movable_object_action, non_movable_object>(id)
        ), is_local ? 3u : 3u);

        // test for a non-movable object (direct actions)
        HPX_TEST_EQ((
            pass_object<pass_non_movable_object_direct_action, non_movable_object>(id)
        ), is_local ? 1u : 1u);

        // test for movable object ('normal' actions)
        HPX_TEST_EQ((
            move_object<pass_movable_object_action, movable_object>(id)
        ), is_local ? 1u : 1u);

        // test for movable object (direct actions)
        HPX_TEST_EQ((
            move_object<pass_movable_object_direct_action, movable_object>(id)
        ), is_local ? 1u : 1u);

        // test for a non-movable object ('normal' actions)
        HPX_TEST_EQ((
            move_object<pass_non_movable_object_action, non_movable_object>(id)
        ), is_local ? 3u : 3u);

        // test for a non-movable object (direct actions)
        HPX_TEST_EQ((
            move_object<pass_non_movable_object_direct_action, non_movable_object>(id)
        ), is_local ? 1u : 1u);
//.........这里部分代码省略.........
开发者ID:johnforce,项目名称:hpx,代码行数:101,代码来源:plain_action_dataflow_move_semantics.cpp


示例12: hpx_main

int hpx_main(variables_map&)
{
    std::vector<id_type> localities = hpx::find_all_localities();

    BOOST_FOREACH(id_type id, localities)
    {
        bool is_local = (id == find_here()) ? true : false;

        if (is_local) {
            // test the void actions locally only (there is no way to get the
            // overall copy count back)

            HPX_TEST_EQ((
                pass_object_void<
                    pass_movable_object_void_action, movable_object
                >()
            ), 1u);

            /* TODO: Make this compile
            HPX_TEST_EQ((
                pass_object_void<
                    pass_movable_object_void_direct_action, movable_object
                >()
            ), 0u);
            */

            HPX_TEST_EQ((
                pass_object_void<
                    pass_non_movable_object_void_action, non_movable_object
                >()
            ), 4u);

            /* TODO: Make this compile
            HPX_TEST_EQ((
                pass_object_void<
                    pass_non_movable_object_void_direct_action, non_movable_object
                >()
            ), 0u);
            */

            HPX_TEST_EQ((
                move_object_void<
                    pass_movable_object_void_action, movable_object
                >()
            ), 1u);

            /* TODO: Make this compile
            HPX_TEST_EQ((
                move_object_void<
                    pass_movable_object_void_direct_action, movable_object
                >()
            ), 0u);
            */

            HPX_TEST_EQ((
                move_object_void<
                    pass_non_movable_object_void_action, non_movable_object
                >()
            ), 4u);
            
            /* TODO: Make this compile
            HPX_TEST_EQ((
                move_object_void<
                    pass_non_movable_object_void_direct_action, non_movable_object
                >()
            ), 0u);
            */
        }

        // test for movable object ('normal' actions)
        HPX_TEST_EQ((
            pass_object<pass_movable_object_action, movable_object>(id)
        ), is_local ? 1u : 1u);

        /* TODO: Make this compile
        // test for movable object (direct actions)
        HPX_TEST_EQ((
            pass_object<pass_movable_object_direct_action, movable_object>(id)
        ), is_local ? 0u : 0u);
        */

        // test for a non-movable object ('normal' actions)
        HPX_TEST_EQ((
            pass_object<pass_non_movable_object_action, non_movable_object>(id)
        ), is_local ? 4u : 4u);

        /* TODO: Make this compile
        // test for a non-movable object (direct actions)
        HPX_TEST_EQ((
            pass_object<pass_non_movable_object_direct_action, non_movable_object>(id)
        ), is_local ? 0u : 0u);
        */

        // test for movable object ('normal' actions)
        HPX_TEST_EQ((
            move_object<pass_movable_object_action, movable_object>(id)
        ), is_local ? 1u : 1u);

        /* TODO: Make this compile
        // test for movable object (direct actions)
//.........这里部分代码省略.........
开发者ID:Stevejohntest,项目名称:hpx,代码行数:101,代码来源:plain_action_dataflow_move_semantics.cpp


示例13: hpx_main

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

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

    std::size_t mutex_count = 0;

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

    std::size_t iterations = 0;

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

    std::size_t wait = 0;

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

    for (std::size_t i = 0; i < iterations; ++i)
    {
        std::cout << "iteration: " << i << "\n";

        // Have the fifo preallocate storage.
        fifo_type hpxthreads(hpxthread_count);

        std::vector<mutex*> m(mutex_count, 0);
        barrier b0(hpxthread_count + 1), b1(hpxthread_count + 1);

        // Allocate the mutexes.
        for (std::size_t j = 0; j < mutex_count; ++j)
            m[j] = new mutex;

        for (std::size_t j = 0; j < hpxthread_count; ++j)
        {
            // Compute the mutex to be used for this thread.
            const std::size_t index = j % mutex_count;

            register_thread(boost::bind
                (&lock_and_wait, boost::ref(*m[index])
                               , boost::ref(b0)
                               , boost::ref(b1)
                               , boost::ref(hpxthreads)
                               , wait)
              , "lock_and_wait");
        }

        // Tell all hpxthreads that they can start running.
        b0.wait();

        // Wait for all hpxthreads to finish.
        b1.wait();

        // {{{ Print results for this iteration.
        std::pair<thread_id_type, std::size_t>* entry = 0;

        while (hpxthreads.pop(entry))
        {
            HPX_ASSERT(entry);
            std::cout << "  " << entry->first << "," << entry->second << "\n";
            delete entry;
        }
        // }}}

        // Destroy the mutexes.
        for (std::size_t j = 0; j < mutex_count; ++j)
        {
            HPX_ASSERT(m[j]);
            delete m[j];
        }
    }

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


示例14: hpx_main

int hpx_main(
    variables_map& vm
    )
{
    {
        boost::atomic<std::size_t> count(0);

        ///////////////////////////////////////////////////////////////////////
        id_type const here_ = find_here();

        ///////////////////////////////////////////////////////////////////////
        // Sync wait, single future, void return.
        {
            unwrapped(async<null_action>(here_));

            HPX_TEST_EQ(1U, void_counter.load());

            void_counter.store(0);
        }

        ///////////////////////////////////////////////////////////////////////
        // Sync wait, single future, non-void return.
        {
            HPX_TEST_EQ(true, unwrapped(async<null_result_action>(here_)));
            HPX_TEST_EQ(1U, result_counter.load());

            result_counter.store(0);
        }

        ///////////////////////////////////////////////////////////////////////
        // Sync wait, multiple futures, void return.
        {
            unwrapped(async<null_action>(here_)
               , async<null_action>(here_)
               , async<null_action>(here_));

            HPX_TEST_EQ(3U, void_counter.load());

            void_counter.store(0);
        }

        ///////////////////////////////////////////////////////////////////////
        // Sync wait, multiple futures, non-void return.
        {
            hpx::util::tuple<bool, bool, bool> r
                = unwrapped(async<null_result_action>(here_)
                     , async<null_result_action>(here_)
                     , async<null_result_action>(here_));

            HPX_TEST_EQ(true, hpx::util::get<0>(r));
            HPX_TEST_EQ(true, hpx::util::get<1>(r));
            HPX_TEST_EQ(true, hpx::util::get<2>(r));
            HPX_TEST_EQ(3U, result_counter.load());

            result_counter.store(0);
        }

        ///////////////////////////////////////////////////////////////////////
        // Sync wait, vector of futures, void return.
        {
            std::vector<future<void> > futures;
            futures.reserve(64);

            for (std::size_t i = 0; i < 64; ++i)
                futures.push_back(async<null_action>(here_));

            unwrapped(futures);

            HPX_TEST_EQ(64U, void_counter.load());

            void_counter.store(0);
        }

        ///////////////////////////////////////////////////////////////////////
        // Sync wait, vector of futures, non-void return.
        {
            std::vector<future<bool> > futures;
            futures.reserve(64);

            std::vector<bool> values;
            values.reserve(64);

            for (std::size_t i = 0; i < 64; ++i)
                futures.push_back(async<null_result_action>(here_));

            values = unwrapped(futures);

            HPX_TEST_EQ(64U, result_counter.load());

            for (std::size_t i = 0; i < 64; ++i)
                HPX_TEST_EQ(true, values[i]);

            result_counter.store(0);
        }

        ///////////////////////////////////////////////////////////////////////
        // Sync wait, vector of futures, non-void return ignored.
        {
            std::vector<future<bool> > futures;
            futures.reserve(64);
//.........这里部分代码省略.........
开发者ID:Bcorde5,项目名称:hpx,代码行数:101,代码来源:unwrapped.cpp


示例15: test_object_direct_actions

void test_object_direct_actions()
{
    std::vector<id_type> localities = hpx::find_all_localities();

    for (id_type const& id : localities)
    {
        bool is_local = id == find_here();

        // test std::size_t(movable_object const&)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_direct_action, movable_object>(id)
            ), 0u);

            HPX_TEST_EQ((
                move_object<pass_movable_object_direct_action, movable_object>(id)
            ), 0u);
        } else {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_direct_action, movable_object>(id)
            ), 1u); // transfer_action

            HPX_TEST_EQ((
                move_object<pass_movable_object_direct_action, movable_object>(id)
            ), 0u);
        }

        // test std::size_t(non_movable_object const&)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_non_movable_object_direct_action,
                non_movable_object>(id)
            ), 0u);

            HPX_TEST_EQ((
                move_object<pass_non_movable_object_direct_action,
                non_movable_object>(id)
            ), 0u);
        } else {
            HPX_TEST_EQ((
                pass_object<pass_non_movable_object_direct_action,
                non_movable_object>(id)
            ), 3u); // transfer_action + bind + function

            HPX_TEST_EQ((
                move_object<pass_non_movable_object_direct_action,
                non_movable_object>(id)
            ), 3u); // transfer_action + bind + function
        }

        // test std::size_t(movable_object)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_value_direct_action, movable_object>(id)
            ), 1u); // call

            HPX_TEST_EQ((
                move_object<pass_movable_object_value_direct_action, movable_object>(id)
            ), 0u);
        } else {
            HPX_TEST_EQ((
                pass_object<pass_movable_object_value_direct_action, movable_object>(id)
            ), 1u); // transfer_action

            HPX_TEST_EQ((
                move_object<pass_movable_object_value_direct_action, movable_object>(id)
            ), 0u);
        }

        // test std::size_t(non_movable_object)
        if (is_local)
        {
            HPX_TEST_EQ((
                pass_object<pass_non_movable_object_value_direct_action,
                non_movable_object>(id)
            ), 1u); // call

            HPX_TEST_EQ((
                move_object<pass_non_movable_object_value_direct_action,
                non_movable_object>(id)
            ), 1u); // call
        } else {
            HPX_ 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ hsTArray类代码示例发布时间:2022-05-31
下一篇:
C++ hp_i8042_sdc类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap