本文整理汇总了C++中hpx::partitioned_vector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ partitioned_vector::begin方法的具体用法?C++ partitioned_vector::begin怎么用?C++ partitioned_vector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hpx::partitioned_vector
的用法示例。
在下文中一共展示了partitioned_vector::begin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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";
}
示例2: T
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>());
}
示例3: 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);
}
示例4: 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);
}
示例5: 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());
}
示例6: 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);
}
示例7: 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";
}
示例8: 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));
}
}
示例9: 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);
}
示例10: 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);
}
}
}
示例11: 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());
}
示例12: 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;
}
示例13: 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);
}
示例14: 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;
}