Skip to content

Commit

Permalink
Fixing problems with new execution parameters interface
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Oct 3, 2017
1 parent fed3fea commit 05c00ee
Show file tree
Hide file tree
Showing 15 changed files with 360 additions and 192 deletions.
9 changes: 6 additions & 3 deletions hpx/parallel/algorithms/detail/dispatch.hpp
Expand Up @@ -106,10 +106,13 @@ namespace hpx { namespace parallel { inline namespace v1 { namespace detail
typedef typename
hpx::util::decay<ExPolicy>::type::executor_parameters_type
parameters_type;
typedef typename
hpx::util::decay<ExPolicy>::type::executor_type
executor_type;

parallel::util::detail::scoped_executor_parameters<
parameters_type
> scoped_param(policy.parameters());
parallel::util::detail::scoped_executor_parameters_ref<
parameters_type, executor_type
> scoped_param(policy.parameters(), policy.executor());

return parallel::util::detail::algorithm_result<
ExPolicy, local_result_type
Expand Down
15 changes: 9 additions & 6 deletions hpx/parallel/executors/execution_information.hpp
Expand Up @@ -31,8 +31,9 @@ namespace hpx { namespace threads
namespace hpx { namespace parallel { inline namespace v3 { namespace detail
{
/// \cond NOINTERNAL
template <typename Parameters>
std::size_t call_processing_units_parameter_count(Parameters && params);
template <typename Parameters, typename Executor>
std::size_t call_processing_units_parameter_count(Parameters && params,
Executor && exec);
/// \endcond
}}}}

Expand All @@ -56,18 +57,20 @@ namespace hpx { namespace parallel { namespace execution
template <typename AnyExecutor, typename Parameters>
HPX_FORCEINLINE static auto
call(hpx::traits::detail::wrap_int, AnyExecutor && exec,
Parameters& params)
Parameters& params)
-> decltype(parallel::v3::detail::
call_processing_units_parameter_count(params))
call_processing_units_parameter_count(params,
std::forward<Executor>(exec)))
{
return parallel::v3::detail::
call_processing_units_parameter_count(params);
call_processing_units_parameter_count(params,
std::forward<Executor>(exec));
}

template <typename AnyExecutor, typename Parameters>
HPX_FORCEINLINE static auto
call(int, AnyExecutor && exec, Parameters&)
-> decltype(exec.processing_units_count())
-> decltype(exec.processing_units_count())
{
return exec.processing_units_count();
}
Expand Down
4 changes: 2 additions & 2 deletions hpx/parallel/executors/execution_information_fwd.hpp
Expand Up @@ -120,8 +120,8 @@ namespace hpx { namespace parallel { namespace execution
template <typename Executor, typename Parameters>
HPX_FORCEINLINE auto operator()(
Executor&& exec, Parameters& params) const
-> decltype(processing_units_count(std::forward<Executor>(exec),
params))
-> decltype(processing_units_count(
std::forward<Executor>(exec), params))
{
return processing_units_count(
std::forward<Executor>(exec), params);
Expand Down
139 changes: 89 additions & 50 deletions hpx/parallel/executors/execution_parameters.hpp
Expand Up @@ -41,8 +41,11 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// customization point for interface get_chunk_size()
template <typename Parameters, typename Enable>
struct get_chunk_size_fn_helper
template <typename Parameters, typename Executor_>
struct get_chunk_size_fn_helper<Parameters, Executor_,
typename std::enable_if<
hpx::traits::is_executor_any<Executor_>::value
>::type>
{
template <typename AnyParameters, typename Executor, typename F>
HPX_FORCEINLINE static std::size_t
Expand Down Expand Up @@ -90,8 +93,11 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// customization point for interface maximal_number_of_chunks()
template <typename Parameters, typename Enable>
struct maximal_number_of_chunks_fn_helper
template <typename Parameters, typename Executor_>
struct maximal_number_of_chunks_fn_helper<Parameters, Executor_,
typename std::enable_if<
hpx::traits::is_executor_any<Executor_>::value
>::type>
{
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static std::size_t
Expand Down Expand Up @@ -174,96 +180,124 @@ namespace hpx { namespace parallel { namespace execution

///////////////////////////////////////////////////////////////////////
// customization point for interface count_processing_units()
template <typename Parameters, typename Enable>
struct count_processing_units_fn_helper
template <typename Parameters, typename Executor_>
struct count_processing_units_fn_helper<Parameters, Executor_,
typename std::enable_if<
hpx::traits::is_executor_any<Executor_>::value
>::type>
{
template <typename AnyParameters>
HPX_FORCEINLINE static std::size_t call(hpx::traits::detail::wrap_int,
AnyParameters && params)
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static std::size_t call(
hpx::traits::detail::wrap_int,
AnyParameters && params, Executor&& exec)
{
return hpx::get_os_thread_count();
}

template <typename AnyParameters>
HPX_FORCEINLINE static auto call(int, AnyParameters && params)
-> decltype(params.processing_units_count())
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static auto call(int, AnyParameters && params,
Executor && exec)
-> decltype(params.processing_units_count(
std::forward<Executor>(exec)))
{
return params.processing_units_count();
return params.processing_units_count(
std::forward<Executor>(exec));
}

HPX_FORCEINLINE static std::size_t call(Parameters& params)
template <typename Executor>
HPX_FORCEINLINE static std::size_t call(Parameters& params,
Executor && exec)
{
return call(0, params);
return call(0, params, std::forward<Executor>(exec));
}

template <typename AnyParameters>
HPX_FORCEINLINE static std::size_t call(AnyParameters params)
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static std::size_t call(AnyParameters params,
Executor && exec)
{
return call(static_cast<Parameters&>(params));
return call(static_cast<Parameters&>(params),
std::forward<Executor>(exec));
}
};

HPX_HAS_MEMBER_XXX_TRAIT_DEF(count_processing_units);

///////////////////////////////////////////////////////////////////////
// customization point for interface mark_begin_execution()
template <typename Parameters, typename Enable>
struct mark_begin_execution_fn_helper
template <typename Parameters, typename Executor_>
struct mark_begin_execution_fn_helper<Parameters, Executor_,
typename std::enable_if<
hpx::traits::is_executor_any<Executor_>::value
>::type>
{
template <typename AnyParameters>
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static void call(hpx::traits::detail::wrap_int,
AnyParameters &&)
AnyParameters &&, Executor &&)
{
}

template <typename AnyParameters>
HPX_FORCEINLINE static auto call(int, AnyParameters && params)
-> decltype(params.mark_begin_execution())
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static auto call(int, AnyParameters && params,
Executor && exec)
-> decltype(params.mark_begin_execution(
std::forward<Executor>(exec)))
{
params.mark_begin_execution();
params.mark_begin_execution(std::forward<Executor>(exec));
}

HPX_FORCEINLINE static void call(Parameters& params)
template <typename Executor>
HPX_FORCEINLINE static void call(Parameters& params,
Executor && exec)
{
call(0, params);
call(0, params, std::forward<Executor>(exec));
}

template <typename AnyParameters>
HPX_FORCEINLINE static void call(AnyParameters params)
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static void call(AnyParameters params,
Executor && exec)
{
call(static_cast<Parameters&>(params));
call(static_cast<Parameters&>(params),
std::forward<Executor>(exec));
}
};

HPX_HAS_MEMBER_XXX_TRAIT_DEF(mark_begin_execution);

///////////////////////////////////////////////////////////////////////
// customization point for interface mark_end_execution()
template <typename Parameters, typename Enable>
struct mark_end_execution_fn_helper
template <typename Parameters, typename Executor_>
struct mark_end_execution_fn_helper<Parameters, Executor_,
typename std::enable_if<
hpx::traits::is_executor_any<Executor_>::value
>::type>
{
template <typename AnyParameters>
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static void call(hpx::traits::detail::wrap_int,
AnyParameters &&)
AnyParameters &&, Executor &&)
{
}

template <typename AnyParameters>
HPX_FORCEINLINE static auto call(int, AnyParameters && params)
-> decltype(params.mark_end_execution())
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static auto call(int, AnyParameters && params,
Executor&& exec)
-> decltype(params.mark_end_execution(std::forward<Executor>(exec)))
{
params.mark_end_execution();
params.mark_end_execution(std::forward<Executor>(exec));
}

HPX_FORCEINLINE static void call(Parameters& params)
template <typename Executor>
HPX_FORCEINLINE static void call(Parameters& params,
Executor&& exec)
{
call(0, params);
call(0, params, std::forward<Executor>(exec));
}

template <typename AnyParameters>
HPX_FORCEINLINE static void call(AnyParameters params)
template <typename AnyParameters, typename Executor>
HPX_FORCEINLINE static void call(AnyParameters params,
Executor&& exec)
{
call(static_cast<Parameters&>(params));
call(static_cast<Parameters&>(params),
std::forward<Executor>(exec));
}
};

Expand Down Expand Up @@ -380,9 +414,10 @@ namespace hpx { namespace parallel { namespace execution
: wrap_(wrap)
{}

HPX_FORCEINLINE void mark_begin_execution()
template <typename Executor>
HPX_FORCEINLINE void mark_begin_execution(Executor && exec)
{
wrap_.get().mark_begin_execution();
wrap_.get().mark_begin_execution(std::forward<Executor>(exec));
}

private:
Expand All @@ -404,9 +439,10 @@ namespace hpx { namespace parallel { namespace execution
: wrap_(wrap)
{}

HPX_FORCEINLINE void mark_end_execution()
template <typename Executor>
HPX_FORCEINLINE void mark_end_execution(Executor && exec)
{
wrap_.get().mark_end_execution();
wrap_.get().mark_end_execution(std::forward<Executor>(exec));
}

private:
Expand All @@ -430,9 +466,12 @@ namespace hpx { namespace parallel { namespace execution
: wrap_(wrap)
{}

HPX_FORCEINLINE std::size_t processing_units_count()
template <typename Executor>
HPX_FORCEINLINE std::size_t
processing_units_count(Executor && exec)
{
return wrap_.get().processing_units_count();
return wrap_.get().processing_units_count(
std::forward<Executor>(exec));
}

private:
Expand Down

0 comments on commit 05c00ee

Please sign in to comment.