Skip to content

Commit

Permalink
Updated tests for other algorithms for multiple localities
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajai V George committed Jun 21, 2017
1 parent 16a3660 commit 1c28b70
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void for_each_tests(std::vector<hpx::id_type> &localities)
std::size_t const length = 12;

{
hpx::partitioned_vector<T> v(0,hpx::container_layout(localities));
hpx::partitioned_vector<T> v();
hpx::parallel::for_each(hpx::parallel::execution::seq,
v.begin(), v.end(), pfo());
hpx::parallel::for_each(hpx::parallel::execution::par,
Expand Down Expand Up @@ -182,7 +182,7 @@ void for_each_n_tests(std::vector<hpx::id_type> &localities)
std::size_t const length = 12;

{
hpx::partitioned_vector<T> v(0,hpx::container_layout(localities));
hpx::partitioned_vector<T> v();
hpx::parallel::for_each_n(hpx::parallel::execution::seq,
v.begin(), 0, pfo());
hpx::parallel::for_each_n(hpx::parallel::execution::par,
Expand All @@ -196,7 +196,7 @@ void for_each_n_tests(std::vector<hpx::id_type> &localities)
}

{
hpx::partitioned_vector<T> v(0,hpx::container_layout(localities));
hpx::partitioned_vector<T> v();
hpx::parallel::for_each_n(hpx::parallel::execution::seq,
v.begin(), -1, pfo());
hpx::parallel::for_each_n(hpx::parallel::execution::par,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,18 @@ void reduce_tests(std::size_t num,
}

template <typename T>
void reduce_tests()
void reduce_tests(std::vector<hpx::id_type> &localities)
{
std::size_t const num = 10007;

{
hpx::partitioned_vector<T> xvalues(num, T(1));
reduce_tests(num, xvalues);
}

{
hpx::partitioned_vector<T> xvalues(num, T(1), hpx::container_layout(2));
reduce_tests(num, xvalues);
}
hpx::partitioned_vector<T> xvalues(num, T(1),hpx::container_layout(localities));
reduce_tests(num, xvalues);
}

///////////////////////////////////////////////////////////////////////////////
int main()
{
reduce_tests<int>();
reduce_tests<double>();

std::vector<hpx::id_type> localities = hpx::find_all_localities();
reduce_tests<int>(localities);
reduce_tests<double>(localities);
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ void test_transform_binary2_async(ExPolicy && policy,

///////////////////////////////////////////////////////////////////////////////
template <typename T, typename U=T>
void transform_tests()
void transform_tests(std::vector<hpx::id_type> &localities)
{
std::size_t const length = 12;

{
hpx::partitioned_vector<T> v;
hpx::partitioned_vector<U> w;
hpx::partitioned_vector<T> v();
hpx::partitioned_vector<U> w();
hpx::parallel::transform(hpx::parallel::execution::seq,
v.begin(), v.end(), w.begin(), pfo<U>());
hpx::parallel::transform(hpx::parallel::execution::par,
Expand All @@ -217,8 +217,8 @@ void transform_tests()
}

{
hpx::partitioned_vector<T> v(length, T(1));
hpx::partitioned_vector<U> w(length);
hpx::partitioned_vector<T> v(length,T(1),hpx::container_layout(localities));
hpx::partitioned_vector<U> w(length,hpx::container_layout(localities));
test_transform(hpx::parallel::execution::seq, v, w, U(1));
test_transform(hpx::parallel::execution::par, v, w, U(1));
test_transform_async(
Expand All @@ -230,14 +230,14 @@ void transform_tests()
}
}
template <typename T, typename U=T, typename V=T>
void transform_binary_tests()
void transform_binary_tests(std::vector<hpx::id_type> &localities)
{
std::size_t const length = 12;

{
hpx::partitioned_vector<T> v;
hpx::partitioned_vector<U> w;
hpx::partitioned_vector<V> x;
hpx::partitioned_vector<T> v();
hpx::partitioned_vector<U> w();
hpx::partitioned_vector<V> x();
hpx::parallel::transform(hpx::parallel::execution::seq,
v.begin(), v.end(), w.begin(), x.begin(), add<V>());
hpx::parallel::transform(hpx::parallel::execution::par,
Expand All @@ -251,9 +251,9 @@ void transform_binary_tests()
}

{
hpx::partitioned_vector<T> v(length, T(1));
hpx::partitioned_vector<U> w(length, U(1));
hpx::partitioned_vector<V> x(length);
hpx::partitioned_vector<T> v(length, T(1),hpx::container_layout(localities));
hpx::partitioned_vector<U> w(length, U(1),hpx::container_layout(localities));
hpx::partitioned_vector<V> x(length,hpx::container_layout(localities));
test_transform_binary(hpx::parallel::execution::seq, v, w, x, V(1));
test_transform_binary(hpx::parallel::execution::par, v, w, x, V(1));
test_transform_binary_async(
Expand All @@ -266,13 +266,13 @@ void transform_binary_tests()
}

template <typename T, typename U=T, typename V=T>
void transform_binary2_tests()
void transform_binary2_tests(std::vector<hpx::id_type> &localities)
{
std::size_t const length = 12;
{
hpx::partitioned_vector<T> v;
hpx::partitioned_vector<U> w;
hpx::partitioned_vector<V> x;
hpx::partitioned_vector<T> v();
hpx::partitioned_vector<U> w();
hpx::partitioned_vector<V> x();
hpx::parallel::transform(hpx::parallel::execution::seq,
v.begin(), v.end(), w.begin(), w.end(), x.begin(), add<V>());
hpx::parallel::transform(hpx::parallel::execution::par,
Expand All @@ -286,9 +286,9 @@ void transform_binary2_tests()
}

{
hpx::partitioned_vector<T> v(length, T(1));
hpx::partitioned_vector<U> w(length, U(1));
hpx::partitioned_vector<V> x(length);
hpx::partitioned_vector<T> v(length, T(1),hpx::container_layout(localities));
hpx::partitioned_vector<U> w(length, U(1),hpx::container_layout(localities));
hpx::partitioned_vector<V> x(length,hpx::container_layout(localities));
test_transform_binary2(hpx::parallel::execution::seq, v, w, x, V(1));
test_transform_binary2(hpx::parallel::execution::par, v, w, x, V(1));
test_transform_binary2_async(
Expand All @@ -304,11 +304,12 @@ void transform_binary2_tests()
///////////////////////////////////////////////////////////////////////////////
int main()
{
transform_tests<int,double>();
transform_tests<double,int>();
transform_binary_tests<int,int,double>();
transform_binary_tests<double,double,int>();
transform_binary2_tests<int,int,double>();
transform_binary2_tests<double,double,int>();
std::vector<hpx::id_type> localities = hpx::find_all_localities();
transform_tests<int,double>(localities);
transform_tests<double,int>(localities);
transform_binary_tests<int,int,double>(localities);
transform_binary_tests<double,double,int>(localities);
transform_binary2_tests<int,int,double>(localities);
transform_binary2_tests<double,double,int>(localities);
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,27 @@ void transform_reduce_tests(std::size_t num,
}

template <typename T>
void transform_reduce_tests()
void transform_reduce_tests(std::vector<hpx::id_type> &localities)
{
std::size_t const num = 10007;

{
hpx::partitioned_vector<T> xvalues(num, T(1));
hpx::partitioned_vector<T> yvalues(num, T(1));

hpx::partitioned_vector<T> xvalues(num,T(1));
hpx::partitioned_vector<T> yvalues(num,T(1));
transform_reduce_tests(num, xvalues, yvalues);
}

{
hpx::partitioned_vector<T> xvalues(num, T(1), hpx::container_layout(2));
hpx::partitioned_vector<T> yvalues(num, T(1), hpx::container_layout(2));

hpx::partitioned_vector<T> xvalues(num,T(1),hpx::container_layout(localities));
hpx::partitioned_vector<T> yvalues(num,T(1),hpx::container_layout(localities));
transform_reduce_tests(num, xvalues, yvalues);
}
}

///////////////////////////////////////////////////////////////////////////////
int main()
{
transform_reduce_tests<int>();
transform_reduce_tests<double>();

std::vector<hpx::id_type> localities = hpx::find_all_localities();
transform_reduce_tests<int>(localities);
transform_reduce_tests<double>(localities);
return 0;
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ template <typename ExPolicy, typename T>
void test_transform_inclusive_scan(ExPolicy && policy,
hpx::partitioned_vector<T> & xvalues, hpx::partitioned_vector<T> & out)
{
// auto op = [](std::size_t v1, std::size_t v2) { return v1 + v2; };
// auto conv = [](std::size_t val) { return 2*val; };
hpx::parallel::transform_inclusive_scan(policy, xvalues.begin(),
xvalues.end(), out.begin(), conv(), T(0), op());
}
Expand All @@ -50,8 +48,6 @@ void
test_transform_inclusive_scan_async(ExPolicy && policy,
hpx::partitioned_vector<T> & xvalues, hpx::partitioned_vector<T> & out)
{
// auto op = [](std::size_t v1, std::size_t v2) { return v1 + v2; };
// auto conv = [](std::size_t val) { return 2*val; };
hpx::parallel::transform_inclusive_scan(policy,
xvalues.begin(), xvalues.end(), out.begin(),
conv(), T(0), op()).get();
Expand All @@ -61,8 +57,6 @@ template <typename ExPolicy, typename T>
void test_transform_exclusive_scan(ExPolicy && policy,
hpx::partitioned_vector<T> & xvalues, hpx::partitioned_vector<T> & out)
{
// auto op = [](std::size_t v1, std::size_t v2) { return v1 + v2; };
// auto conv = [](std::size_t val) { return 2*val; };
hpx::parallel::transform_exclusive_scan(policy, xvalues.begin(),
xvalues.end(), out.begin(), conv(), T(0), op());
}
Expand All @@ -72,8 +66,6 @@ void
test_transform_exclusive_scan_async(ExPolicy && policy,
hpx::partitioned_vector<T> & xvalues, hpx::partitioned_vector<T> & out)
{
// auto op = [](std::size_t v1, std::size_t v2) { return v1 + v2; };
// auto conv = [](std::size_t val) { return 2*val; };
hpx::parallel::transform_exclusive_scan(policy,
xvalues.begin(), xvalues.end(), out.begin(),
conv(), T(0), op()).get();
Expand Down Expand Up @@ -111,21 +103,19 @@ void transform_scan_tests(std::size_t num,
}

template <typename T>
void transform_scan_tests()
void transform_scan_tests(std::vector<hpx::id_type> &localities)
{
std::size_t const num = 12;

{
hpx::partitioned_vector<T> xvalues(num, T(1));
hpx::partitioned_vector<T> out(num);
transform_scan_tests(num, xvalues, out);
}
hpx::partitioned_vector<T> xvalues(num, T(1),hpx::container_layout(localities));
hpx::partitioned_vector<T> out(num,hpx::container_layout(localities));
transform_scan_tests(num, xvalues, out);
}

///////////////////////////////////////////////////////////////////////////////
int main()
{
transform_scan_tests<int>();
transform_scan_tests<double>();
std::vector<hpx::id_type> localities = hpx::find_all_localities();
transform_scan_tests<int>(localities);
transform_scan_tests<double>(localities);
return 0;
}

0 comments on commit 1c28b70

Please sign in to comment.