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

C++ hpx::partitioned_vector类代码示例

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

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



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

示例1: exclusive_scan_algo_tests_with_policy

void exclusive_scan_algo_tests_with_policy(
    std::size_t size, DistPolicy const& dist_policy,
    hpx::partitioned_vector<T>& in,
    std::vector<T> ver, ExPolicy const& policy)
{
    msg7(typeid(ExPolicy).name(), typeid(DistPolicy).name(), typeid(T).name(),
        regular, size, dist_policy.get_num_partitions(),
        dist_policy.get_localities().size());
    hpx::util::high_resolution_timer t1;

    std::vector<T> out(in.size());
    T val(0);

    double e1 = t1.elapsed();
    t1.restart();

    hpx::parallel::exclusive_scan(policy,
        in.begin(), in.end(), out.begin(), val, opt<T>());

    double e2 = t1.elapsed();
    t1.restart();

    HPX_TEST(std::equal(out.begin(), out.end(), ver.begin()));

    double e3 = t1.elapsed();
    std::cout << std::setprecision(4) << "\t" << e1 << " " << e2 << " " << e3 << "\n";
}
开发者ID:Sanac,项目名称:hpx,代码行数:27,代码来源:partitioned_vector_exclusive_scan.cpp


示例2: exclusive_scan_algo_tests_segmented_out_with_policy

void exclusive_scan_algo_tests_segmented_out_with_policy(
    std::size_t size, DistPolicy const& in_dist_policy,
    DistPolicy const& out_dist_policy,
    hpx::partitioned_vector<T>& in, hpx::partitioned_vector<T> out,
    std::vector<T> ver, ExPolicy const& policy)
{
    msg9(typeid(ExPolicy).name(), typeid(DistPolicy).name(), typeid(T).name(),
        segmented, size,
        in_dist_policy.get_num_partitions(), in_dist_policy.get_localities().size(),
        out_dist_policy.get_num_partitions(), out_dist_policy.get_localities().size());
    hpx::util::high_resolution_timer t1;

    T val(0);

    double e1 = t1.elapsed();
    t1.restart();

    hpx::parallel::exclusive_scan(policy,
        in.begin(), in.end(), out.begin(), val, opt<T>());

    double e2 = t1.elapsed();
    t1.restart();

    verify_values(out, ver);

    double e3 = t1.elapsed();
    std::cout << std::setprecision(4) << "\t" << e1 << " " << e2 << " " << e3 << "\n";
}
开发者ID:Sanac,项目名称:hpx,代码行数:28,代码来源:partitioned_vector_exclusive_scan.cpp


示例3: iota_vector

void iota_vector(hpx::partitioned_vector<T>& v, T val)
{
    auto first = v.begin();
    auto last = v.end();

    typedef hpx::traits::segmented_iterator_traits<decltype(first)> traits;
    typedef typename traits::segment_iterator segment_iterator;
    typedef typename traits::local_iterator local_iterator_type;

    segment_iterator sit = traits::segment(first);
    segment_iterator send = traits::segment(last);

    T temp_val = val;

    for (; sit != send; ++sit)
    {
        local_iterator_type beg = traits::begin(sit);
        local_iterator_type end = traits::end(sit);

        hpx::parallel::v1::detail::dispatch(traits::get_id(sit),
            iota(), hpx::parallel::seq, std::true_type(), beg, end, temp_val
        );

        temp_val = T(temp_val + std::distance(beg, end));
    }
}
开发者ID:brycelelbach,项目名称:hpx,代码行数:26,代码来源:partitioned_vector_scan.hpp


示例4: test_all_async

void test_all_async(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues,
    Func&& f, bool expected_result)
{
    bool result =
        hpx::parallel::all_of(policy, xvalues.begin(), xvalues.end(), f).get();
    HPX_TEST_EQ(result, expected_result);
}
开发者ID:K-ballo,项目名称:hpx,代码行数:7,代码来源:partitioned_vector_all_of1.cpp


示例5: test_transform_reduce_binary_async

hpx::future<T> test_transform_reduce_binary_async(ExPolicy&& policy,
    hpx::partitioned_vector<T>& xvalues,
    hpx::partitioned_vector<T>& yvalues)
{
    return hpx::parallel::transform_reduce(policy, xvalues.begin(),
        xvalues.end(), yvalues.begin(), T(1), std::plus<T>(),
        std::multiplies<T>());
}
开发者ID:K-ballo,项目名称:hpx,代码行数:8,代码来源:partitioned_vector_transform_reduce_binary2.cpp


示例6: partitioned_vector_view

    explicit partitioned_vector_view(hpx::partitioned_vector<T>& data)
      : segment_iterator_(data.segment_begin(hpx::get_locality_id()))
    {
#if defined(HPX_DEBUG)
        // this view assumes that there is exactly one segment per locality
        typedef typename traits::local_segment_iterator local_segment_iterator;
        local_segment_iterator sit = segment_iterator_;
        HPX_ASSERT(++sit == data.segment_end(hpx::get_locality_id()));
#endif
    }
开发者ID:HadrienG2,项目名称:hpx,代码行数:10,代码来源:partitioned_vector_spmd_foreach.cpp


示例7: test_for_each_n

void test_for_each_n(ExPolicy && policy, hpx::partitioned_vector<T>& v, T val)
{
    verify_values(policy, v, val);
    verify_values_count(policy, v, val);

    hpx::parallel::for_each_n(policy, v.begin(), v.end() - v.begin(), pfo());

    verify_values(policy, v, ++val);
    verify_values_count(policy, v, val);
}
开发者ID:K-ballo,项目名称:hpx,代码行数:10,代码来源:partitioned_vector_for_each.cpp


示例8: test_transform_binary2

void test_transform_binary2(ExPolicy && policy, hpx::partitioned_vector<T>& v,
    hpx::partitioned_vector<U>& w, hpx::partitioned_vector<V>& x, V val)
{
    verify_values(policy, v, val);
    verify_values_count(policy, v, val);
    verify_values(policy, w, val);
    verify_values_count(policy, w, val);

    hpx::parallel::transform(policy, v.begin(), v.end(), w.begin(), w.end(),
        x.begin(), add<V>());

    verify_values(policy, x, 2*val);
    verify_values_count(policy, x, 2*val);
}
开发者ID:K-ballo,项目名称:hpx,代码行数:14,代码来源:test_transform_binary2.hpp


示例9: verify_values

void verify_values(ExPolicy && policy, hpx::partitioned_vector<T> const& v,
    U const& val)
{
    typedef typename hpx::partitioned_vector<T>::const_iterator const_iterator;

    std::size_t size = 0;

    const_iterator end = v.end();
    for (const_iterator it = v.begin(); it != end; ++it, ++size)
    {
        HPX_TEST_EQ(*it, val);
    }

    HPX_TEST_EQ(size, v.size());
}
开发者ID:K-ballo,项目名称:hpx,代码行数:15,代码来源:test_transform_binary2.hpp


示例10: run_minmax_element_benchmark

double run_minmax_element_benchmark(int test_count,
    hpx::partitioned_vector<int> const& v)
{
    boost::uint64_t time = hpx::util::high_resolution_clock::now();

    for (int i = 0; i != test_count; ++i)
    {
        // invoke minmax
        using namespace hpx::parallel;
        /*auto iters = */minmax_element(par, v.begin(), v.end());
    }

    time = hpx::util::high_resolution_clock::now() - time;

    return (time * 1e-9) / test_count;
}
开发者ID:7ev3n,项目名称:hpx,代码行数:16,代码来源:minmax_element_performance.cpp


示例11: initialize

void initialize(hpx::partitioned_vector<T>& xvalues)
{
    T init_array[SIZE] = {1, 2, 3, 4, 5, 1, 2, 3, 3, 5, 5, 3, 4, 2, 3, 2, 1, 2,
        3, 4, 5, 6, 5, 6, 1, 2, 3, 4, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4,
        1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 7, 6, 5, 7, 5, 4, 2, 3, 4, 5, 2};
    for (int i = 0; i < SIZE; i++)
    {
        xvalues.set_value(i, init_array[i]);
    }
}
开发者ID:K-ballo,项目名称:hpx,代码行数:10,代码来源:partitioned_vector_all_of1.cpp


示例12: verify_values

void verify_values(hpx::partitioned_vector<T> v1, std::vector<T> v2)
{
    auto first = v1.begin();
    auto last = v1.end();

    typedef hpx::traits::segmented_iterator_traits<decltype(first)> traits;
    typedef typename traits::segment_iterator segment_iterator;
    typedef typename traits::local_iterator local_iterator_type;

    segment_iterator sit = traits::segment(first);
    segment_iterator send = traits::segment(last);

    auto beg2 = v2.begin();

    std::vector<bool> results;

    for (; sit != send; ++sit)
    {
        local_iterator_type beg = traits::begin(sit);
        local_iterator_type end = traits::end(sit);

        std::vector<T> test(std::distance(beg, end));
        std::copy_n(beg2, test.size(), test.begin());

        results.push_back(
            hpx::parallel::v1::detail::dispatch(traits::get_id(sit),
                verify<bool>(), hpx::parallel::seq, std::true_type(), beg, end, test
        ));

        beg2 += std::distance(beg, end);
    }
    bool final_result = std::all_of(results.begin(), results.end(),
        [](bool v) { return v; });

    HPX_TEST(final_result);
}
开发者ID:brycelelbach,项目名称:hpx,代码行数:36,代码来源:partitioned_vector_scan.hpp


示例13: test_adjacent_find

void test_adjacent_find(ExPolicy&& policy, hpx::partitioned_vector<T>& xvalues)
{
    auto result =
        hpx::parallel::adjacent_find(policy, xvalues.begin(), xvalues.end());
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 31);

    result = hpx::parallel::adjacent_find(policy, xvalues.begin(),
        xvalues.end(), pred());
    HPX_TEST_EQ(std::distance(xvalues.begin(), result), 4);
}
开发者ID:zao,项目名称:hpx,代码行数:10,代码来源:partitioned_vector_adjacent_find1.cpp


示例14: verify_values_count_async

void verify_values_count_async(ExPolicy && policy,
    hpx::partitioned_vector<T> const& v, U const& val)
{
    HPX_TEST_EQ(
        std::size_t(hpx::parallel::count(
            policy, v.begin(), v.end(), val).get()),
        v.size());
    HPX_TEST_EQ(
        std::size_t(hpx::parallel::count_if(
            policy, v.begin(), v.end(), cmp<T>(val)).get()),
        v.size());
}
开发者ID:K-ballo,项目名称:hpx,代码行数:12,代码来源:test_transform_binary2.hpp


示例15: compare_vectors

void compare_vectors(hpx::partitioned_vector<T> const& v1,
    hpx::partitioned_vector<T> const& v2, bool must_be_equal = true)
{
    typedef typename hpx::partitioned_vector<T>::const_iterator const_iterator;

    HPX_TEST_EQ(v1.size(), v2.size());

    const_iterator it1 = v1.begin(), it2 = v2.begin();
    const_iterator end1 = v1.end(), end2 = v2.end();
    for (/**/; it1 != end1 && it2 != end2; ++it1, ++it2)
    {
        if (must_be_equal)
        {
            HPX_TEST_EQ(*it1, *it2);
        }
        else
        {
            HPX_TEST_NEQ(*it1, *it2);
        }
    }
}
开发者ID:devangb,项目名称:hpx,代码行数:21,代码来源:partitioned_vector_copy.cpp


示例16: fill_vector

void fill_vector(hpx::partitioned_vector<T>& v, T const& val)
{
    typename hpx::partitioned_vector<T>::iterator it = v.begin(), end = v.end();
    for (/**/; it != end; ++it)
        *it = val;
}
开发者ID:devangb,项目名称:hpx,代码行数:6,代码来源:partitioned_vector_copy.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ local::condition_variable类代码示例发布时间:2022-05-31
下一篇:
C++ hpx::future类代码示例发布时间: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