Skip to content

Commit

Permalink
Implement iota_range utility
Browse files Browse the repository at this point in the history
  • Loading branch information
K-ballo committed Jul 23, 2017
1 parent 5640334 commit 1860039
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 65 deletions.
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_4.cpp
Expand Up @@ -18,7 +18,7 @@
#include <hpx/hpx.hpp>

#include <hpx/include/parallel_algorithm.hpp>
#include <boost/range/irange.hpp>
#include <hpx/util/iota_range.hpp>

#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -142,7 +142,7 @@ struct stepper

// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
auto range = hpx::util::make_iota_range(b, np);
using hpx::parallel::execution::par;
hpx::parallel::for_each(par, std::begin(range), std::end(range),
[&U, nx](std::size_t i)
Expand Down
6 changes: 3 additions & 3 deletions examples/1d_stencil/1d_stencil_4_repart.cpp
Expand Up @@ -20,8 +20,8 @@

#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/performance_counters.hpp>
#include <hpx/util/iota_range.hpp>

#include <boost/range/irange.hpp>
#include <boost/format.hpp>

#include <algorithm>
Expand Down Expand Up @@ -229,7 +229,7 @@ struct stepper
if (!data) {
// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
auto range = hpx::util::make_iota_range(b, np);
using hpx::parallel::execution::par;
hpx::parallel::for_each(
par, std::begin(range), std::end(range),
Expand All @@ -243,7 +243,7 @@ struct stepper
else {
// Initialize from existing data
std::size_t b = 0;
auto range = boost::irange(b, np);
auto range = hpx::util::make_iota_range(b, np);
using hpx::parallel::execution::par;
hpx::parallel::for_each(
par, std::begin(range), std::end(range),
Expand Down
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_4_throttle.cpp
Expand Up @@ -18,12 +18,12 @@
#include <hpx/hpx.hpp>

#include <hpx/include/parallel_algorithm.hpp>
#include <boost/range/irange.hpp>

#include "print_time_results.hpp"
#include <hpx/include/performance_counters.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/util.hpp>
#include <hpx/util/iota_range.hpp>

#include <boost/format.hpp>

Expand Down Expand Up @@ -211,7 +211,7 @@ struct stepper

// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
auto range = hpx::util::make_iota_range(b, np);
using hpx::parallel::execution::par;
hpx::parallel::for_each(par, std::begin(range), std::end(range),
[&U, nx](std::size_t i)
Expand Down
11 changes: 5 additions & 6 deletions examples/transpose/transpose_await.cpp
Expand Up @@ -8,8 +8,7 @@

#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/parallel_numeric.hpp>

#include <boost/range/irange.hpp>
#include <hpx/util/iota_range.hpp>

#include <algorithm>
#include <cstddef>
Expand Down Expand Up @@ -192,7 +191,7 @@ hpx::future<sub_block> transpose_phase(
const std::uint64_t from_phase = b;
const std::uint64_t A_offset = from_phase * block_size;

auto phase_range = boost::irange(
auto phase_range = hpx::util::make_iota_range(
static_cast<std::uint64_t>(0), num_blocks);
for(std::uint64_t phase: phase_range)
{
Expand Down Expand Up @@ -281,7 +280,7 @@ int hpx_main(boost::program_options::variables_map& vm)
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);
for_each(par, std::begin(range), std::end(range),
[&](std::uint64_t b)
{
Expand Down Expand Up @@ -311,7 +310,7 @@ int hpx_main(boost::program_options::variables_map& vm)
{
hpx::util::high_resolution_timer t;

auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);

const std::uint64_t block_size = block_order * block_order;
for_each(par, std::begin(range), std::end(range),
Expand Down Expand Up @@ -437,7 +436,7 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);
double errsq =
transform_reduce(par, std::begin(range), std::end(range), 0.0,
[](double lhs, double rhs) { return lhs + rhs; },
Expand Down
11 changes: 5 additions & 6 deletions examples/transpose/transpose_block.cpp
Expand Up @@ -8,8 +8,7 @@

#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/parallel_numeric.hpp>

#include <boost/range/irange.hpp>
#include <hpx/util/iota_range.hpp>

#include <algorithm>
#include <cstddef>
Expand Down Expand Up @@ -246,7 +245,7 @@ int hpx_main(boost::program_options::variables_map& vm)
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);
for_each(par, std::begin(range), std::end(range),
[&](std::uint64_t b)
{
Expand Down Expand Up @@ -292,7 +291,7 @@ int hpx_main(boost::program_options::variables_map& vm)
{
hpx::util::high_resolution_timer t;

auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);

std::vector<hpx::future<void> > block_futures;
block_futures.resize(num_local_blocks);
Expand All @@ -303,7 +302,7 @@ int hpx_main(boost::program_options::variables_map& vm)
std::vector<hpx::future<void> > phase_futures;
phase_futures.reserve(num_blocks);

auto phase_range = boost::irange(
auto phase_range = hpx::util::make_iota_range(
static_cast<std::uint64_t>(0), num_blocks);
for(std::uint64_t phase: phase_range)
{
Expand Down Expand Up @@ -449,7 +448,7 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);
double errsq =
transform_reduce(par, std::begin(range), std::end(range), 0.0,
[](double lhs, double rhs) { return lhs + rhs; },
Expand Down
14 changes: 7 additions & 7 deletions examples/transpose/transpose_block_numa.cpp
Expand Up @@ -10,12 +10,11 @@
#include <hpx/include/parallel_executors.hpp>
#include <hpx/include/parallel_numeric.hpp>
#include <hpx/include/serialization.hpp>
#include <hpx/util/iota_range.hpp>
#include <hpx/util/safe_lexical_cast.hpp>

#include <hpx/parallel/util/numa_allocator.hpp>

#include <boost/range/irange.hpp>

#include <algorithm>
#include <cstddef>
#include <cstdint>
Expand Down Expand Up @@ -303,7 +302,7 @@ int hpx_main(boost::program_options::variables_map& vm)
std::uint64_t blocks_start = id * num_local_blocks;
std::uint64_t blocks_end = (id + 1) * num_local_blocks;

std::vector<boost::integer_range<std::uint64_t> > numa_ranges;
std::vector<hpx::util::iota_range<std::uint64_t> > numa_ranges;
numa_ranges.reserve(numa_nodes);

// Actually allocate the block components in AGAS
Expand All @@ -321,7 +320,8 @@ int hpx_main(boost::program_options::variables_map& vm)
{
std::cout << block_numa_node << ": "
<< numa_block_begin << " " << b + 1 << "\n";
numa_ranges.push_back(boost::irange(numa_block_begin, b + 1));
numa_ranges.push_back(
hpx::util::make_iota_range(numa_block_begin, b + 1));
numa_block_begin = b + 1;
++block_numa_node;
numa_blocks_allocated = 0;
Expand Down Expand Up @@ -355,7 +355,7 @@ int hpx_main(boost::program_options::variables_map& vm)
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);
for_each(par, std::begin(range), std::end(range),
[&](std::uint64_t b)
{
Expand Down Expand Up @@ -436,7 +436,7 @@ int hpx_main(boost::program_options::variables_map& vm)
std::vector<hpx::future<void> > phase_futures;
phase_futures.reserve(num_blocks);

auto phase_range = boost::irange(
auto phase_range = hpx::util::make_iota_range(
static_cast<std::uint64_t>(0), num_blocks);
for(std::uint64_t phase: phase_range)
{
Expand Down Expand Up @@ -645,7 +645,7 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
auto range = hpx::util::make_iota_range(blocks_start, blocks_end);
double errsq =
transform_reduce(
par.on(execs[domain]),
Expand Down
11 changes: 5 additions & 6 deletions examples/transpose/transpose_smp.cpp
Expand Up @@ -8,8 +8,7 @@

#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/parallel_numeric.hpp>

#include <boost/range/irange.hpp>
#include <hpx/util/iota_range.hpp>

#include <algorithm>
#include <cstdint>
Expand Down Expand Up @@ -57,7 +56,7 @@ int hpx_main(boost::program_options::variables_map& vm)
const std::uint64_t start = 0;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(start, order);
auto range = hpx::util::make_iota_range(start, order);
// parallel for
for_each(par, std::begin(range), std::end(range),
[&](std::uint64_t i)
Expand All @@ -80,7 +79,7 @@ int hpx_main(boost::program_options::variables_map& vm)
hpx::util::high_resolution_timer t;
if(tile_size < order)
{
auto range = boost::irange(start, order+tile_size, tile_size);
auto range = hpx::util::make_iota_range(start, order+tile_size, tile_size);
// parallel for
for_each(par, std::begin(range), std::end(range),
[&](std::uint64_t i)
Expand All @@ -103,7 +102,7 @@ int hpx_main(boost::program_options::variables_map& vm)
}
else
{
auto range = boost::irange(start, order);
auto range = hpx::util::make_iota_range(start, order);
// parallel for
for_each(par, std::begin(range), std::end(range),
[&](std::uint64_t i)
Expand Down Expand Up @@ -183,7 +182,7 @@ double test_results(std::uint64_t order, std::vector<double> const & trans)

const std::uint64_t start = 0;

auto range = boost::irange(start, order);
auto range = hpx::util::make_iota_range(start, order);
// parallel reduce
double errsq =
transform_reduce(par, std::begin(range), std::end(range), 0.0,
Expand Down
9 changes: 4 additions & 5 deletions examples/transpose/transpose_smp_block.cpp
Expand Up @@ -8,8 +8,7 @@

#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/parallel_numeric.hpp>

#include <boost/range/irange.hpp>
#include <hpx/util/iota_range.hpp>

#include <algorithm>
#include <cstdint>
Expand Down Expand Up @@ -68,7 +67,7 @@ int hpx_main(boost::program_options::variables_map& vm)
const std::uint64_t start = 0;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(start, num_blocks);
auto range = hpx::util::make_iota_range(start, num_blocks);
for_each(par, std::begin(range), std::end(range),
[&](std::uint64_t b)
{
Expand All @@ -94,7 +93,7 @@ int hpx_main(boost::program_options::variables_map& vm)
{
hpx::util::high_resolution_timer t;

auto range = boost::irange(start, num_blocks);
auto range = hpx::util::make_iota_range(start, num_blocks);

std::vector<hpx::shared_future<void> > transpose_futures;
transpose_futures.resize(num_blocks);
Expand Down Expand Up @@ -228,7 +227,7 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
const std::uint64_t end = trans.size();

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(start, end);
auto range = hpx::util::make_iota_range(start, end);
double errsq =
transform_reduce(par, std::begin(range), std::end(range), 0.0,
[](double lhs, double rhs) { return lhs + rhs; },
Expand Down
7 changes: 3 additions & 4 deletions hpx/compute/host/block_allocator.hpp
Expand Up @@ -22,11 +22,10 @@
#include <hpx/runtime/threads/topology.hpp>
#include <hpx/util/functional/new.hpp>
#include <hpx/util/invoke_fused.hpp>
#include <hpx/util/iota_range.hpp>
#include <hpx/util/range.hpp>
#include <hpx/util/tuple.hpp>

#include <boost/range/irange.hpp>

#include <cstddef>
#include <limits>
#include <type_traits>
Expand Down Expand Up @@ -162,7 +161,7 @@ namespace hpx { namespace compute { namespace host
template <typename U, typename ... Args>
void bulk_construct(U* p, std::size_t count, Args &&... args)
{
auto irange = boost::irange(std::size_t(0), count);
auto irange = util::make_iota_range(std::size_t(0), count);
auto policy =
hpx::parallel::execution::parallel_policy()
.on(executor_)
Expand Down Expand Up @@ -237,7 +236,7 @@ namespace hpx { namespace compute { namespace host
void bulk_destroy(U* p, std::size_t count)
{
// keep memory locality, use executor...
auto irange = boost::irange(std::size_t(0), count);
auto irange = util::make_iota_range(std::size_t(0), count);
hpx::parallel::for_each(
hpx::parallel::execution::par
.on(executor_)
Expand Down
7 changes: 3 additions & 4 deletions hpx/lcos/local/spmd_block.hpp
Expand Up @@ -11,8 +11,7 @@
#include <hpx/parallel/execution_policy.hpp>
#include <hpx/traits/is_execution_policy.hpp>
#include <hpx/util/first_argument.hpp>

#include <boost/range/irange.hpp>
#include <hpx/util/iota_range.hpp>

#include <cstddef>
#include <functional>
Expand Down Expand Up @@ -123,7 +122,7 @@ namespace hpx { namespace lcos { namespace local
detail::spmd_block_helper<F>{
barrier, std::forward<F>(f), num_images
},
boost::irange(std::size_t(0), num_images),
util::make_iota_range(std::size_t(0), num_images),
std::forward<Args>(args)...);
}

Expand Down Expand Up @@ -162,7 +161,7 @@ namespace hpx { namespace lcos { namespace local
detail::spmd_block_helper<F>{
barrier, std::forward<F>(f), num_images
},
boost::irange(std::size_t(0), num_images),
util::make_iota_range(std::size_t(0), num_images),
std::forward<Args>(args)...);
}

Expand Down
5 changes: 2 additions & 3 deletions hpx/lcos/spmd_block.hpp
Expand Up @@ -17,8 +17,7 @@
#include <hpx/traits/concepts.hpp>
#include <hpx/traits/is_action.hpp>
#include <hpx/util/first_argument.hpp>

#include <boost/range/irange.hpp>
#include <hpx/util/iota_range.hpp>

#include <cstddef>
#include <functional>
Expand Down Expand Up @@ -152,7 +151,7 @@ namespace hpx { namespace lcos
exec,
detail::spmd_block_helper<F>{
name,images_per_locality, num_images},
boost::irange(
util::make_iota_range(
offset, offset + images_per_locality),
args...);
}
Expand Down

0 comments on commit 1860039

Please sign in to comment.