Skip to content

Commit

Permalink
Merge pull request #3039 from STEllAR-GROUP/fixing_3027
Browse files Browse the repository at this point in the history
Consistently use executors to schedule work
  • Loading branch information
sithhell committed Dec 8, 2017
2 parents 9713d65 + a67dcd3 commit 141890e
Show file tree
Hide file tree
Showing 104 changed files with 2,185 additions and 1,443 deletions.
10 changes: 4 additions & 6 deletions examples/nqueen/server/nqueen.hpp
Expand Up @@ -24,8 +24,6 @@ namespace server
{
private:
list_type list_;
std::size_t level_;
std::size_t size_;
std::size_t count_;

// here board is a component
Expand All @@ -40,14 +38,14 @@ namespace server
// }

public:
board():list_(0), level_(0), size_(0), count_(0)
board() : list_(0), count_(0)
{}

board(list_type const& list, std::size_t size, std::size_t level)
: list_(list), level_(level), size_(size), count_(0)
board(list_type const& list, std::size_t, std::size_t)
: list_(list), count_(0)
{}

~board(){}
~board() = default;


void init_board(std::size_t size)
Expand Down
8 changes: 4 additions & 4 deletions examples/quickstart/fractals_executor.cpp
Expand Up @@ -7,10 +7,10 @@

#include <hpx/hpx_init.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/util.hpp>
#include <hpx/include/lcos.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/include/thread_executors.hpp>
#include <hpx/include/lcos.hpp>
#include <hpx/include/parallel_execution.hpp>
#include <hpx/include/util.hpp>

#include <vector>

Expand Down Expand Up @@ -63,7 +63,7 @@ int hpx_main()
t.restart();

{
hpx::threads::executors::local_queue_executor exec;
hpx::parallel::execution::local_queue_executor exec;

for (int i = 0; i < sizeX; ++i)
{
Expand Down
6 changes: 3 additions & 3 deletions examples/quickstart/simple_future_continuation.cpp
@@ -1,12 +1,12 @@
// Copyright (c) 2007-2013 Hartmut Kaiser
// Copyright (c) 2007-2017 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <hpx/hpx_main.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/include/parallel_execution.hpp>
#include <hpx/include/threads.hpp>
#include <hpx/include/thread_executors.hpp>

#include <iostream>

Expand Down Expand Up @@ -56,7 +56,7 @@ int main(int argc, char* argv[])

// executing continuation cont2 on UI (main) thread
{
hpx::threads::executors::main_pool_executor exec;
hpx::parallel::execution::main_pool_executor exec;
hpx::future<int> t = hpx::async(&func1);
hpx::future<int> t2 = t.then(exec, &cont2);
t2.get();
Expand Down
Expand Up @@ -7,7 +7,7 @@
#include <hpx/hpx_init.hpp>
//
#include <hpx/parallel/algorithms/for_loop.hpp>
#include <hpx/parallel/executors.hpp>
#include <hpx/parallel/execution.hpp>
//
#include <hpx/runtime/resource/partitioner.hpp>
#include <hpx/runtime/threads/cpu_mask.hpp>
Expand Down
Expand Up @@ -7,7 +7,7 @@
#include <hpx/hpx_init.hpp>
//
#include <hpx/parallel/algorithms/for_loop.hpp>
#include <hpx/parallel/executors.hpp>
#include <hpx/parallel/execution.hpp>
//
#include <hpx/runtime/resource/partitioner.hpp>
#include <hpx/runtime/threads/cpu_mask.hpp>
Expand Down
47 changes: 15 additions & 32 deletions hpx/apply.hpp
Expand Up @@ -7,7 +7,7 @@
#define HPX_APPLY_APR_16_20012_0943AM

#include <hpx/config.hpp>
#include <hpx/async.hpp>
#include <hpx/lcos/future.hpp>
#include <hpx/runtime/applier/apply.hpp>
#include <hpx/runtime/applier/apply_continue.hpp>
#include <hpx/runtime/threads/thread_executor.hpp>
Expand All @@ -24,6 +24,7 @@
#include <hpx/parallel/executors/v1/executor_traits.hpp>
#endif
#include <hpx/parallel/executors/execution.hpp>
#include <hpx/parallel/executors/parallel_executor.hpp>

#include <type_traits>
#include <utility>
Expand All @@ -45,34 +46,11 @@ namespace hpx { namespace detail
traits::detail::is_deferred_invocable<F, Ts...>::value,
bool
>::type
call(F&& f, Ts&&... ts)
call(F && f, Ts &&... ts)
{
util::thread_description desc(f, "apply_dispatch::call");
threads::register_thread_nullary(
util::deferred_call(std::forward<F>(f), std::forward<Ts>(ts)...),
desc);
return false;
}
};

// threads::executor
template <typename Executor>
struct apply_dispatch<Executor,
typename std::enable_if<
traits::is_threads_executor<Executor>::value
>::type>
{
template <typename F, typename ...Ts>
HPX_FORCEINLINE static
typename std::enable_if<
traits::detail::is_deferred_invocable<F, Ts...>::value,
bool
>::type
call(Executor& sched, F&& f, Ts&&... ts)
{
sched.add(
util::deferred_call(std::forward<F>(f), std::forward<Ts>(ts)...),
"hpx::apply");
parallel::execution::parallel_executor exec;
parallel::execution::post(
exec, std::forward<F>(f), std::forward<Ts>(ts)...);
return false;
}
};
Expand Down Expand Up @@ -100,23 +78,28 @@ namespace hpx { namespace detail
};
#endif

// The overload for hpx::apply taking an executor simply forwards to the
// corresponding executor customization point.
//
// parallel::execution::executor
// threads::executor
template <typename Executor>
struct apply_dispatch<Executor,
typename std::enable_if<
traits::is_one_way_executor<Executor>::value ||
traits::is_two_way_executor<Executor>::value
traits::is_two_way_executor<Executor>::value ||
traits::is_threads_executor<Executor>::value
>::type>
{
template <typename F, typename ...Ts>
template <typename Executor_, typename F, typename ...Ts>
HPX_FORCEINLINE static
typename std::enable_if<
traits::detail::is_deferred_invocable<F, Ts...>::value,
bool
>::type
call(Executor& exec, F && f, Ts &&... ts)
call(Executor_ && exec, F && f, Ts &&... ts)
{
parallel::execution::post(exec,
parallel::execution::post(std::forward<Executor_>(exec),
std::forward<F>(f), std::forward<Ts>(ts)...);
return false;
}
Expand Down

0 comments on commit 141890e

Please sign in to comment.