Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement parallel::executor_traits for thread-executors #1708

Merged
merged 1 commit into from Aug 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 0 additions & 63 deletions hpx/parallel/executors/detail/thread_executor.hpp

This file was deleted.

14 changes: 6 additions & 8 deletions hpx/parallel/executors/executor_traits.hpp
Expand Up @@ -13,13 +13,11 @@
#include <hpx/exception.hpp>
#include <hpx/async.hpp>
#include <hpx/traits/is_executor.hpp>
#include <hpx/lcos/when_all.hpp>
#include <hpx/util/decay.hpp>
#include <hpx/util/always_void.hpp>
#include <hpx/util/result_of.hpp>
#include <hpx/util/deferred_call.hpp>
#include <hpx/util/unwrapped.hpp>
#include <hpx/traits/is_callable.hpp>
#include <hpx/parallel/config/inline_namespace.hpp>

#include <type_traits>
Expand Down Expand Up @@ -207,9 +205,9 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3)

for (auto const& elem: shape)
{
results.push_back(
exec.async_execute(hpx::util::deferred_call(f, elem))
);
results.push_back(exec.async_execute(
hpx::util::deferred_call(std::forward<F>(f), elem)
));
}

return results;
Expand Down Expand Up @@ -267,9 +265,9 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3)

for (auto const& elem: shape)
{
results.push_back(
exec.async_execute(hpx::util::deferred_call(f, elem))
);
results.push_back(exec.async_execute(
hpx::util::deferred_call(std::forward<F>(f), elem)
));
}

return hpx::util::unwrapped(results);
Expand Down
69 changes: 9 additions & 60 deletions hpx/parallel/executors/service_executors.hpp
Expand Up @@ -9,68 +9,13 @@
#define HPX_PARALLEL_EXECUTORS_SERVICE_EXECUTORS_MAY_15_2015_0548PM

#include <hpx/config.hpp>
#include <hpx/runtime/threads/executors/service_executors.hpp>
#include <hpx/parallel/config/inline_namespace.hpp>
#include <hpx/parallel/executors/executor_traits.hpp>
#include <hpx/parallel/executors/thread_executor_traits.hpp>
#include <hpx/parallel/executors/static_chunk_size.hpp>
#include <hpx/parallel/executors/detail/thread_executor.hpp>
#include <hpx/runtime/threads/executors/service_executors.hpp>
#include <hpx/util/move.hpp>

#include <type_traits>

#include <boost/detail/scoped_enum_emulation.hpp>

namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3)
{
///////////////////////////////////////////////////////////////////////////
/// The type of the HPX thread pool to use for a given service_executor
///
/// This enum type allows to specify the kind of the HPX thread pool to use
/// for a given \a service_executor.
BOOST_SCOPED_ENUM_START(service_executor_type)
{
io_thread_pool, ///< Selects creating a service executor using
///< the I/O pool of threads
parcel_thread_pool, ///< Selects creating a service executor using
///< the parcel pool of threads
timer_thread_pool, ///< Selects creating a service executor using
///< the timer pool of threads
main_thread ///< Selects creating a service executor using
///< the main thread
};
BOOST_SCOPED_ENUM_END

namespace detail
{
/// \cond NOINTERNAL
inline threads::executor
get_service_executor(BOOST_SCOPED_ENUM(service_executor_type) t)
{
switch(t)
{
case service_executor_type::io_thread_pool:
return threads::executors::io_pool_executor();

case service_executor_type::parcel_thread_pool:
return threads::executors::parcel_pool_executor();

case service_executor_type::timer_thread_pool:
return threads::executors::timer_pool_executor();

case service_executor_type::main_thread:
return threads::executors::main_pool_executor();

default:
break;
}

HPX_THROW_EXCEPTION(bad_parameter,
"hpx::parallel::v3::detail::get_service_executor",
"unknown pool executor type");
}
/// \endcond
}

/// A \a service_executor exposes one of the predefined HPX thread pools
/// through an executor interface.
///
Expand All @@ -80,7 +25,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3)
///
struct service_executor
#if !defined(DOXYGEN)
: detail::threads_executor
: threads::executors::service_executor
#endif
{
// Associate the static_chunk_size executor parameters type as a default
Expand All @@ -90,9 +35,13 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3)
/// Create a new service executor for the given HPX thread pool
///
/// \param t [in] Specifies the HPX thread pool to encapsulate
/// \param name_suffix [in] The name suffix to use for the underlying
/// thread pool
///
service_executor(BOOST_SCOPED_ENUM(service_executor_type) t)
: threads_executor(detail::get_service_executor(t))
service_executor(
BOOST_SCOPED_ENUM(threads::executors::service_executor_type) t,
char const* name_suffix = "")
: threads::executors::service_executor(t, name_suffix)
{}
};
}}}
Expand Down
55 changes: 6 additions & 49 deletions hpx/parallel/executors/this_thread_executors.hpp
Expand Up @@ -9,65 +9,22 @@
#define HPX_PARALLEL_EXECUTORS_THIS_THREAD_EXECUTORS_JUL_16_2015_0809PM

#include <hpx/config.hpp>
#include <hpx/parallel/config/inline_namespace.hpp>
#include <hpx/parallel/executors/executor_traits.hpp>
#include <hpx/parallel/executors/detail/thread_executor.hpp>
#include <hpx/runtime/threads/executors/this_thread_executors.hpp>
#include <hpx/util/move.hpp>

#include <type_traits>
#include <hpx/parallel/config/inline_namespace.hpp>
#include <hpx/parallel/executors/thread_executor_traits.hpp>

namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3)
{
///////////////////////////////////////////////////////////////////////////
#if defined(HPX_HAVE_STATIC_SCHEDULER)
struct this_thread_static_queue_executor
#if !defined(DOXYGEN)
: detail::threads_executor
#endif
{
/// Creates a new local_queue_executor
///
explicit this_thread_static_queue_executor()
: threads_executor(
threads::executors::this_thread_static_queue_executor())
{}
};
#endif

#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER)
struct this_thread_static_priority_queue_executor
#if !defined(DOXYGEN)
: detail::threads_executor
#endif
{
/// Creates a new static_priority_queue_executor
///
explicit this_thread_static_priority_queue_executor()
: threads_executor(
threads::executors::this_thread_static_priority_queue_executor())
{}
};
#endif

namespace detail
{
/// \cond NOINTERNAL
#if defined(HPX_HAVE_STATIC_SCHEDULER)
template <>
struct is_executor<this_thread_static_queue_executor>
: std::true_type
{};
typedef threads::executors::this_thread_static_queue_executor
this_thread_static_queue_executor;
#endif

#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER)
template <>
struct is_executor<this_thread_static_priority_queue_executor>
: std::true_type
{};
typedef threads::executors::this_thread_static_priority_queue_executor
this_thread_static_priority_queue_executor;
#endif
/// \endcond
}
}}}

#endif