Permalink
Browse files

Use `unwrap` and `unwrapping` in the tests

  • Loading branch information...
Naios committed Jul 24, 2017
1 parent e4465fc commit 347be2f5f57e906cc3d3e66345b5d4675708e624
@@ -59,7 +59,7 @@ double measure(Policy policy)
cores.push_back(hpx::async(&measure_one<Policy>, policy));
}
std::vector<double> times = hpx::util::unwrapped(cores);
std::vector<double> times = hpx::util::unwrap(cores);
return std::accumulate(times.begin(), times.end(), 0.0);
}
@@ -220,7 +220,7 @@ int hpx_main(
for (std::uint64_t i = 0; i < count; ++i)
futures.push_back(async<null_action>(here, i));
wait_each(hpx::util::unwrapped(
wait_each(hpx::util::unwrapping(
[] (double r) { global_scratch += r; }),
futures);
@@ -246,7 +246,7 @@ int hpx_main(
for (std::uint64_t i = 0; i < count; ++i)
futures.push_back(async<null_action>(here, i));
wait_each(hpx::util::unwrapped(
wait_each(hpx::util::unwrapping(
[] (double r) { global_scratch += r; }),
futures);
@@ -11,7 +11,7 @@
#include <hpx/include/actions.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <hpx/util/lightweight_test.hpp>
@@ -26,7 +26,7 @@ using hpx::lcos::shared_future;
using hpx::wait_all;
using hpx::async;
using hpx::dataflow;
using hpx::util::unwrapped;
using hpx::util::unwrapping;
struct block {
int size;
@@ -130,34 +130,34 @@ void LU( int numBlocks)
dfArray[0][0][0] = async( ProcessDiagonalBlock, blockList[0][0] );
diag_block = &dfArray[0][0][0];
for(int i = 1; i < numBlocks; i++) {
dfArray[0][0][i] = dataflow( unwrapped( &ProcessBlockOnRow ),
dfArray[0][0][i] = dataflow( unwrapping( &ProcessBlockOnRow ),
hpx::make_ready_future( blockList[0][i] ), *diag_block);
}
for(int i = 1; i < numBlocks; i++) {
dfArray[0][i][0] = dataflow( unwrapped( &ProcessBlockOnColumn ),
dfArray[0][i][0] = dataflow( unwrapping( &ProcessBlockOnColumn ),
hpx::make_ready_future( blockList[i][0] ), *diag_block);
first_col = &dfArray[0][i][0];
for(int j = 1; j < numBlocks; j++) {
dfArray[0][i][j] = dataflow( unwrapped( &ProcessInnerBlock ),
dfArray[0][i][j] = dataflow( unwrapping( &ProcessInnerBlock ),
hpx::make_ready_future( blockList[i][j]), dfArray[0][0][j], *first_col );
}
}
//all calculation after initialization. Each iteration,
//the number of tasks/blocks spawned is decreased.
for(int i = 1; i < numBlocks; i++) {
dfArray[i][i][i] = dataflow( unwrapped( &ProcessDiagonalBlock ),
dfArray[i][i][i] = dataflow( unwrapping( &ProcessDiagonalBlock ),
dfArray[i-1][i][i]);
diag_block = &dfArray[i][i][i];
for(int j = i + 1; j < numBlocks; j++){
dfArray[i][i][j] = dataflow( unwrapped(&ProcessBlockOnRow),
dfArray[i][i][j] = dataflow( unwrapping(&ProcessBlockOnRow),
dfArray[i-1][i][j], *diag_block);
}
for(int j = i + 1; j < numBlocks; j++){
dfArray[i][j][i] = dataflow( unwrapped( &ProcessBlockOnColumn ),
dfArray[i][j][i] = dataflow( unwrapping( &ProcessBlockOnColumn ),
dfArray[i-1][j][i], *diag_block);
first_col = &dfArray[i][j][i];
for(int k = i + 1; k < numBlocks; k++) {
dfArray[i][j][k] = dataflow( unwrapped( &ProcessInnerBlock ),
dfArray[i][j][k] = dataflow( unwrapping( &ProcessInnerBlock ),
dfArray[i-1][j][k], dfArray[i][i][k], *first_col );
}
}
@@ -9,7 +9,7 @@
#include <hpx/hpx.hpp>
#include <hpx/hpx_main.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
typedef hpx::lcos::shared_future< double > future_type;
@@ -30,7 +30,7 @@ struct mul
int main()
{
auto functor = hpx::util::unwrapped(mul<double>( 0.5 ));
auto functor = hpx::util::unwrapping(mul<double>( 0.5 ));
future_type f1 = hpx::make_ready_future( 1.0 );
future_type f2 = hpx::dataflow( functor , f1 , f1 );
@@ -10,15 +10,15 @@
#include <hpx/hpx_main.hpp>
#include <hpx/compat/thread.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <hpx/include/iostreams.hpp>
#include <boost/format.hpp>
#include <chrono>
#include <iostream>
using hpx::util::unwrapped;
using hpx::util::unwrapping;
typedef hpx::lcos::shared_future< double > future_type;
@@ -37,16 +37,16 @@ double dummy(double x, double) { std::cout << "dummy: " << x << "\n"; return x;
void future_swap( future_type &f1 , future_type &f2 )
{
future_type tmp = f1;
f1 = hpx::dataflow( unwrapped( &dummy ) , f2 , f1 );
f2 = hpx::dataflow( unwrapped( &dummy ) , tmp, f1 );
f1 = hpx::dataflow( unwrapping( &dummy ) , f2 , f1 );
f2 = hpx::dataflow( unwrapping( &dummy ) , tmp, f1 );
}
int main()
{
future_type f1 = hpx::make_ready_future( 2.0 );
future_type f2 = hpx::make_ready_future( 3.0 );
f1 = hpx::dataflow( unwrapped(mul()) , f1 , f2 );
f1 = hpx::dataflow( unwrapping(mul()) , f1 , f2 );
future_swap( f1 , f2 );
@@ -10,15 +10,15 @@
#include <hpx/hpx_main.hpp>
#include <hpx/compat/thread.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <hpx/include/iostreams.hpp>
#include <boost/format.hpp>
#include <chrono>
#include <iostream>
using hpx::util::unwrapped;
using hpx::util::unwrapping;
typedef hpx::lcos::shared_future< double > future_type;
@@ -45,11 +45,11 @@ struct divide
void future_swap( future_type &f1 , future_type &f2 )
{
//future_type tmp = hpx::dataflow(
// unwrapped( []( double x ){ return x; } ) , f1 );
// unwrapping( []( double x ){ return x; } ) , f1 );
future_type tmp = f1;
f1 = hpx::dataflow( unwrapped( []( double x ,
f1 = hpx::dataflow( unwrapping( []( double x ,
double sync ){ return x; } ) , f2 , f1 );
f2 = hpx::dataflow( unwrapped( []( double x ,
f2 = hpx::dataflow( unwrapping( []( double x ,
double sync ){ return x; } ) , tmp , f1 );
}
@@ -60,9 +60,9 @@ int main()
for( int n=0 ; n<20 ; ++n )
{
f1 = hpx::dataflow( hpx::launch::async , unwrapped(mul()) ,
f1 = hpx::dataflow( hpx::launch::async , unwrapping(mul()) ,
f1 , f2 );
f2 = hpx::dataflow( hpx::launch::async , unwrapped(divide()) ,
f2 = hpx::dataflow( hpx::launch::async , unwrapping(divide()) ,
f1 , f2 );
future_swap( f1 , f2 );
}
@@ -9,7 +9,7 @@
#include <hpx/hpx.hpp>
#include <hpx/hpx_main.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <iostream>
@@ -34,7 +34,7 @@ struct mul
int main()
{
auto functor = hpx::util::unwrapped(mul<double>( 0.5 ));
auto functor = hpx::util::unwrapping(mul<double>( 0.5 ));
future_type f1 = hpx::make_ready_future( 1.0 );
future_type f2 = dataflow( hpx::launch::sync, functor , f1 , f1 );
@@ -9,7 +9,7 @@
#include <hpx/hpx.hpp>
#include <hpx/hpx_main.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <iostream>
@@ -35,13 +35,13 @@ struct mul
int main()
{
auto functor = hpx::util::unwrapped(mul<double>( 0.5 ));
auto functor = hpx::util::unwrapping(mul<double>( 0.5 ));
future_type f1 = hpx::make_ready_future( 1.0 );
// compile error even when using full namespace
future_type f2 = hpx::dataflow( functor , f1 , f1 );
future_type f3 = hpx::dataflow(
hpx::util::unwrapped(mul<double>( 2.0 )) , f1 , f1 );
hpx::util::unwrapping(mul<double>( 2.0 )) , f1 , f1 );
hpx::wait_all(f1, f2, f3);
@@ -10,7 +10,7 @@
#include <hpx/include/plain_actions.hpp>
#include <hpx/include/async.hpp>
#include <hpx/include/runtime.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <boost/random.hpp>
#include <boost/format.hpp>
@@ -122,7 +122,7 @@ double null_tree(
null_function(seed, delay_iterations);
hpx::lcos::wait_each(
hpx::util::unwrapped([&] (double r) { d += r; }),
hpx::util::unwrapping([&] (double r) { d += r; }),
futures);
return d;
@@ -11,11 +11,11 @@
#include <hpx/include/actions.hpp>
#include <hpx/util/lightweight_test.hpp>
#include <hpx/dataflow.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
using hpx::lcos::shared_future;
using hpx::lcos::make_ready_future;
using hpx::util::unwrapped;
using hpx::util::unwrapping;
// define large action
double func(double x1 , double x2 , double x3 , double x4 ,
@@ -29,7 +29,7 @@ int main()
shared_future< double > f = make_ready_future( 1.0 );
f = hpx::dataflow(
hpx::launch::sync,
unwrapped(&func),
unwrapping(&func),
f, f, f, f, f, f, f);
return hpx::util::report_errors();
}
@@ -5,7 +5,7 @@
#include <hpx/hpx.hpp>
#include <hpx/lcos/future.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <vector>
@@ -14,5 +14,5 @@ void noop(){}
int main()
{
std::vector<hpx::future<void>> fs;
hpx::util::unwrapped(&noop)(fs);
hpx::util::unwrapping(&noop)(fs);
}
@@ -8,7 +8,7 @@
#include <hpx/include/threads.hpp>
#include <hpx/include/local_lcos.hpp>
#include <hpx/util/lightweight_test.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/util/unwrap.hpp>
#include <boost/atomic.hpp>
@@ -36,7 +36,7 @@ using hpx::init;
using hpx::finalize;
using hpx::util::report_errors;
using hpx::util::unwrapped;
using hpx::util::unwrapping;
///////////////////////////////////////////////////////////////////////////////
@@ -75,23 +75,23 @@ void function_pointers()
int_f1_count.store(0);
int_f2_count.store(0);
future<void> f1 = dataflow(unwrapped(&void_f1), async(&int_f));
future<void> f1 = dataflow(unwrapping(&void_f1), async(&int_f));
future<int>
f2 = dataflow(
unwrapped(&int_f1)
unwrapping(&int_f1)
, dataflow(
unwrapped(&int_f1)
unwrapping(&int_f1)
, make_ready_future(42))
);
future<int>
f3 = dataflow(
unwrapped(&int_f2)
unwrapping(&int_f2)
, dataflow(
unwrapped(&int_f1)
unwrapping(&int_f1)
, make_ready_future(42)
)
, dataflow(
unwrapped(&int_f1)
unwrapping(&int_f1)
, make_ready_future(37)
)
);
@@ -100,18 +100,18 @@ void function_pointers()
std::vector<future<int> > vf;
for(std::size_t i = 0; i < 10; ++i)
{
vf.push_back(dataflow(unwrapped(&int_f1), make_ready_future(42)));
vf.push_back(dataflow(unwrapping(&int_f1), make_ready_future(42)));
}
future<int> f4 = dataflow(unwrapped(&int_f_vector), std::move(vf));
future<int> f4 = dataflow(unwrapping(&int_f_vector), std::move(vf));
future<int>
f5 = dataflow(
unwrapped(&int_f1)
unwrapping(&int_f1)
, dataflow(
unwrapped(&int_f1)
unwrapping(&int_f1)
, make_ready_future(42))
, dataflow(
unwrapped(&void_f)
unwrapping(&void_f)
, make_ready_future())
);
Oops, something went wrong.

0 comments on commit 347be2f

Please sign in to comment.