Skip to content

Commit

Permalink
Module cleanup upto level 30
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Feb 3, 2024
1 parent 9c53b99 commit 4981de5
Show file tree
Hide file tree
Showing 96 changed files with 1,128 additions and 1,037 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ namespace hpx {
// set callback functions to executed wait future is ready
set_on_completed_callback(*this);

// if all of the requested futures are already set, our callback
// if all the requested futures are already set, our callback
// above has already been called often enough, otherwise we
// suspend ourselves
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#include <hpx/config.hpp>
#include <hpx/assert.hpp>
#include <hpx/compute_local/detail/get_proxy_type.hpp>
#include <hpx/compute_local/traits/allocator_traits.hpp>
#include <hpx/iterator_support/iterator_adaptor.hpp>
Expand All @@ -27,21 +26,20 @@ namespace hpx::compute::detail {
std::random_access_iterator_tag,
typename traits::allocator_traits<Allocator>::reference>
{
typedef hpx::util::iterator_adaptor<iterator<T, Allocator>,
using base_type = hpx::util::iterator_adaptor<iterator<T, Allocator>,
typename traits::allocator_traits<Allocator>::pointer,
typename traits::allocator_traits<Allocator>::value_type,
std::random_access_iterator_tag,
typename traits::allocator_traits<Allocator>::reference>
base_type;
typename traits::allocator_traits<Allocator>::reference>;

typedef typename get_proxy_type<T>::type* proxy_type;
using proxy_type = typename get_proxy_type<T>::type*;

typedef typename traits::allocator_traits<Allocator>::const_reference
const_reference;
typedef typename traits::allocator_traits<Allocator>::target_type
target_type;
using const_reference =
typename traits::allocator_traits<Allocator>::const_reference;
using target_type =
typename traits::allocator_traits<Allocator>::target_type;

HPX_HOST_DEVICE iterator()
HPX_HOST_DEVICE iterator() noexcept
: base_type(nullptr)
, target_(nullptr)
{
Expand All @@ -50,13 +48,13 @@ namespace hpx::compute::detail {
// FIXME: should be private
HPX_HOST_DEVICE
iterator(typename traits::allocator_traits<Allocator>::pointer p,
std::size_t pos, target_type const& target)
std::size_t pos, target_type const& target) noexcept
: base_type(p + pos)
, target_(&target)
{
}

HPX_HOST_DEVICE iterator(iterator const& other)
HPX_HOST_DEVICE iterator(iterator const& other) noexcept
: base_type(other)
, target_(other.target_)
{
Expand All @@ -71,7 +69,7 @@ namespace hpx::compute::detail {
return *this;
}

HPX_HOST_DEVICE target_type const& target() const
HPX_HOST_DEVICE target_type const& target() const noexcept
{
return *target_;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2020 ETH Zurich
// Copyright (c) 2016 Thomas Heller
// Copyright (c) 2016-2022 Hartmut Kaiser
// Copyright (c) 2016-2024 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand Down Expand Up @@ -29,13 +29,14 @@

#include <cstddef>
#include <limits>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>

namespace hpx::compute::host {

namespace detail {

/// The policy_allocator allocates blocks of memory touched according to
/// the distribution policy of the given executor.
template <typename T, typename Policy,
Expand All @@ -61,76 +62,79 @@ namespace hpx::compute::host {
using other = policy_allocator<U, policy_type>;
};

policy_allocator(Policy&& policy)
explicit policy_allocator(Policy&& policy) noexcept
: policy_(HPX_MOVE(policy))
{
}

policy_allocator(Policy const& policy)
explicit policy_allocator(Policy const& policy)
: policy_(policy)
{
}

policy_type const& policy() const
policy_type const& policy() const noexcept
{
return policy_;
}

// Returns the actual address of x even in presence of overloaded
// operator&
pointer address(reference x) const noexcept
static pointer address(reference x) noexcept
{
return &x;
}

const_pointer address(const_reference x) const noexcept
static const_pointer address(const_reference x) noexcept
{
return &x;
}

// Allocates n * sizeof(T) bytes of uninitialized storage by calling
// topo.allocate(). The pointer hint may be used to provide locality of
// reference: the allocator, if supported by the implementation, will
// attempt to allocate the new memory block as close as possible to hint.
pointer allocate(size_type n, void const* /* hint */ = nullptr)
// topo.allocate(). The pointer hint may be used to provide locality
// of reference: the allocator, if supported by the implementation,
// will attempt to allocate the new memory block as close as
// possible to hint.
static pointer allocate(
size_type n, void const* /* hint */ = nullptr)
{
return reinterpret_cast<pointer>(
return static_cast<pointer>(
hpx::threads::create_topology().allocate(n * sizeof(T)));
}

// Deallocates the storage referenced by the pointer p, which must be a
// pointer obtained by an earlier call to allocate(). The argument n
// must be equal to the first argument of the call to allocate() that
// originally produced p; otherwise, the behavior is undefined.
void deallocate(pointer p, size_type n) noexcept
// Deallocates the storage referenced by the pointer p, which must
// be a pointer obtained by an earlier call to allocate(). The
// argument n must be equal to the first argument of the call to
// allocate() that originally produced p; otherwise, the behavior is
// undefined.
static void deallocate(pointer p, size_type n) noexcept
{
try
{
hpx::threads::create_topology().deallocate(p, n);
}
catch (...)
{
; // just ignore errors from create_topology
// just ignore errors from create_topology
}
}

// Returns the maximum theoretically possible value of n, for which the
// call allocate(n, 0) could succeed. In most implementations, this
// returns std::numeric_limits<size_type>::max() / sizeof(value_type).
size_type max_size() const noexcept
// Returns the maximum theoretically possible value of n, for which
// the call allocate(n, 0) could succeed. In most implementations,
// this returns std::numeric_limits<size_type>::max() /
// sizeof(value_type).
static size_type max_size() noexcept
{
return (std::numeric_limits<size_type>::max)();
}

public:
// Constructs count objects of type T in allocated uninitialized
// storage pointed to by p, using placement-new. This will use the
// underlying executors to distribute the memory according to
// first touch memory placement.
// underlying executors to distribute the memory according to first
// touch memory placement.
template <typename U, typename... Args>
void bulk_construct(U* p, std::size_t count, Args&&... args)
{
if (count == std::size_t(0))
if (count == static_cast<std::size_t>(0))
{
return;
}
Expand All @@ -144,8 +148,7 @@ namespace hpx::compute::host {
using partitioner =
parallel::util::partitioner_with_cleanup<decltype(policy_),
void, partition_result_type>;
using cancellation_token = parallel::util::cancellation_token<
parallel::util::detail::no_data>;
using cancellation_token = parallel::util::cancellation_token<>;

auto&& arguments =
hpx::forward_as_tuple(HPX_FORWARD(Args, args)...);
Expand All @@ -172,7 +175,8 @@ namespace hpx::compute::host {
arguments);
},
// cleanup function, called for all elements of
// current partition which succeeded before exception
// current partition which succeeded before
// exception
[p](iterator_type it) {
std::destroy_at(p + *it);
});
Expand All @@ -182,8 +186,8 @@ namespace hpx::compute::host {
[](auto&&) {
// do nothing
},
// cleanup function, called for each partition which
// didn't fail, but only if at least one failed
// cleanup function, called for each partition which didn't
// fail, but only if at least one failed
[p](partition_result_type&& r) -> void {
while (r.first != r.second)
{
Expand All @@ -207,7 +211,7 @@ namespace hpx::compute::host {
template <typename U>
void bulk_destroy(U* p, std::size_t count)
{
if (count == std::size_t(0))
if (count == static_cast<std::size_t>(0))
{
return;
}
Expand All @@ -220,7 +224,7 @@ namespace hpx::compute::host {

// Calls the destructor of the object pointed to by p
template <typename U>
void destroy(U* p)
static void destroy(U* p)
{
std::destroy_at(p);
}
Expand Down Expand Up @@ -275,13 +279,13 @@ namespace hpx::compute::host {
{
}

block_allocator(target_type const& targets)
explicit block_allocator(target_type const& targets)
: base_type(
policy_type(executor_type(targets), executor_parameters_type()))
{
}

block_allocator(target_type&& targets)
explicit block_allocator(target_type&& targets)
: base_type(policy_type(
executor_type(HPX_MOVE(targets)), executor_parameters_type()))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2016 Thomas Heller
// Copyright (c) 2024 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -14,11 +15,9 @@
#include <hpx/execution/traits/executor_traits.hpp>
#include <hpx/execution_base/traits/is_executor.hpp>
#include <hpx/executors/restricted_thread_pool_executor.hpp>
#include <hpx/functional/deferred_call.hpp>
#include <hpx/futures/future.hpp>
#include <hpx/iterator_support/iterator_range.hpp>
#include <hpx/iterator_support/range.hpp>
#include <hpx/pack_traversal/unwrap.hpp>

#include <algorithm>
#include <atomic>
Expand All @@ -29,7 +28,7 @@
#include <utility>
#include <vector>

namespace hpx { namespace compute { namespace host {
namespace hpx::compute::host {

/// The block executor can be used to build NUMA aware programs.
/// It will distribute work evenly across the passed targets
Expand Down Expand Up @@ -163,7 +162,7 @@ namespace hpx { namespace compute { namespace host {

std::vector<hpx::future<result_type>> results;
std::size_t cnt = util::size(shape);
std::size_t num_executors = executors_.size();
std::size_t const num_executors = executors_.size();

results.reserve(cnt);

Expand Down Expand Up @@ -196,9 +195,9 @@ namespace hpx { namespace compute { namespace host {
}
}
}
catch (std::bad_alloc const& ba)
catch (std::bad_alloc const&)
{
throw ba;
throw;
}
catch (...)
{
Expand Down Expand Up @@ -228,7 +227,7 @@ namespace hpx { namespace compute { namespace host {

std::vector<result_type> results;
std::size_t cnt = util::size(shape);
std::size_t num_executors = executors_.size();
std::size_t const num_executors = executors_.size();

results.reserve(cnt);

Expand All @@ -255,9 +254,9 @@ namespace hpx { namespace compute { namespace host {
}
return results;
}
catch (std::bad_alloc const& ba)
catch (std::bad_alloc const&)
{
throw ba;
throw;
}
catch (...)
{
Expand All @@ -275,7 +274,7 @@ namespace hpx { namespace compute { namespace host {
}

public:
std::vector<host::target> const& targets() const
std::vector<host::target> const& targets() const noexcept
{
return targets_;
}
Expand All @@ -300,13 +299,14 @@ namespace hpx { namespace compute { namespace host {
threads::thread_stacksize::default_;
threads::thread_schedule_hint schedulehint_ = {};
};
}}} // namespace hpx::compute::host
} // namespace hpx::compute::host

namespace hpx::parallel::execution {

namespace hpx { namespace parallel { namespace execution {
template <typename Executor>
struct executor_execution_category<compute::host::block_executor<Executor>>
{
typedef hpx::execution::parallel_execution_tag type;
using type = hpx::execution::parallel_execution_tag;
};

template <typename Executor>
Expand All @@ -332,4 +332,4 @@ namespace hpx { namespace parallel { namespace execution {
: std::true_type
{
};
}}} // namespace hpx::parallel::execution
} // namespace hpx::parallel::execution
Loading

0 comments on commit 4981de5

Please sign in to comment.