diff --git a/CMakeLists.txt b/CMakeLists.txt index 921c2692fcbb..2d5b397c4b29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,10 +333,12 @@ if(HPX_WITH_CUDA) string(APPEND HPX_CUDA_CLANG_FLAGS " --cuda-gpu-arch=${arch}") endforeach() string(REGEX REPLACE ";" " " HPX_WITH_CUDA_ARCH_INFO "${HPX_WITH_CUDA_ARCH}") -else() - set(HPX_TLL_PUBLIC "PUBLIC") # keywords for target_link_libraries - set(HPX_TLL_PRIVATE "PRIVATE") + # keywords for target_link_libraries (cuda) + set(CUDA_LINK_LIBRARIES_KEYWORD "PRIVATE") endif() +# keywords for target_link_libraries (hpx) +set(HPX_TLL_PUBLIC "PUBLIC") +set(HPX_TLL_PRIVATE "PRIVATE") if(HPX_WITH_CUDA_CLANG AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")) hpx_error("To use Cuda Clang, please select Clang as your default C++ compiler") endif() @@ -956,38 +958,6 @@ if(HPX_WITH_TUPLE_RVALUE_SWAP) hpx_add_config_define(HPX_HAVE_TUPLE_RVALUE_SWAP) endif() -# HPX_WITH_BOOST_CHRONO_COMPATIBILITY: introduced in V1.0.0 -hpx_option(HPX_WITH_BOOST_CHRONO_COMPATIBILITY BOOL - "Enable support for boost::chrono (default: OFF)" - OFF ADVANCED) -if(HPX_WITH_BOOST_CHRONO_COMPATIBILITY) - hpx_add_config_define(HPX_HAVE_BOOST_CHRONO_COMPATIBILITY) -endif() - -# HPX_WITH_EXECUTOR_COMPATIBILITY: introduced in V1.0.0 -hpx_option(HPX_WITH_EXECUTOR_COMPATIBILITY BOOL - "Enable old (pre-concurrency TS) executor API (default: OFF)" - OFF ADVANCED) -if(HPX_WITH_EXECUTOR_COMPATIBILITY) - hpx_add_config_define(HPX_HAVE_EXECUTOR_COMPATIBILITY) -endif() - -# HPX_WITH_EXECUTION_POLICY_COMPATIBILITY: introduced in V1.0.0 -hpx_option(HPX_WITH_EXECUTION_POLICY_COMPATIBILITY BOOL - "Enable old execution policy names in API (default: OFF)" - OFF ADVANCED) -if(HPX_WITH_EXECUTION_POLICY_COMPATIBILITY) - hpx_add_config_define(HPX_HAVE_EXECUTION_POLICY_COMPATIBILITY) -endif() - -# HPX_WITH_TRANSFORM_REDUCE_COMPATIBILITY: introduced in V1.0.0 -hpx_option(HPX_WITH_TRANSFORM_REDUCE_COMPATIBILITY BOOL - "Enable old overloads for transform_reduce and inner_product (default: OFF)" - OFF ADVANCED) -if(HPX_WITH_TRANSFORM_REDUCE_COMPATIBILITY) - hpx_add_config_define(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) -endif() - # HPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY: introduced in V1.1.0 hpx_option(HPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY BOOL "Enable old overloads for inclusive_scan (default: ON)" diff --git a/cmake/HPX_SetupBoost.cmake b/cmake/HPX_SetupBoost.cmake index ffdb8349426c..257b5287450e 100644 --- a/cmake/HPX_SetupBoost.cmake +++ b/cmake/HPX_SetupBoost.cmake @@ -34,7 +34,7 @@ if(HPX_WITH_THREAD_COMPATIBILITY OR NOT(HPX_WITH_CXX11_THREAD)) set(__boost_need_thread ON) endif() -if(HPX_WITH_BOOST_CHRONO_COMPATIBILITY OR __boost_need_thread) +if(__boost_need_thread) set(__boost_libraries ${__boost_libraries} chrono) endif() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 929f238edf37..408501ed8172 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -103,7 +103,6 @@ set(doxygen_dependencies "${PROJECT_SOURCE_DIR}/hpx/parallel/executors/service_executors.hpp" "${PROJECT_SOURCE_DIR}/hpx/parallel/executors/static_chunk_size.hpp" "${PROJECT_SOURCE_DIR}/hpx/parallel/executors/thread_pool_executors.hpp" - "${PROJECT_SOURCE_DIR}/hpx/parallel/executors/v1/timed_executor_traits.hpp" "${PROJECT_SOURCE_DIR}/hpx/performance_counters/manage_counter_type.hpp" "${PROJECT_SOURCE_DIR}/hpx/runtime_fwd.hpp" "${PROJECT_SOURCE_DIR}/hpx/runtime/applier_fwd.hpp" diff --git a/docs/sphinx/manual/writing_single_node_hpx_applications.rst b/docs/sphinx/manual/writing_single_node_hpx_applications.rst index 5b060b56a11f..6eba390529db 100644 --- a/docs/sphinx/manual/writing_single_node_hpx_applications.rst +++ b/docs/sphinx/manual/writing_single_node_hpx_applications.rst @@ -790,120 +790,15 @@ Parallel algorithms * Implements loop functionality over a range specified by integral or iterator bounds. * ```` -.. _executors: - -Executors and executor traits -============================= - -The existing Version 1 of the Parallelism TS (|cpp11_n4104|_) exposes parallel -execution to the programmer in the form of standard algorithms that accept -execution policies. A companion executor facility both provides a suitable -substrate for implementing these algorithms in a standard way and provide a -mechanism for exercising programmatic control over where parallel work should be -executed. - -The algorithms and execution policies specified by the Parallelism TS are -designed to permit implementation on the broadest range of platforms. In -addition to preemptive thread pools common on some platforms, implementations of -these algorithms may want to take advantage of a number of mechanisms for -parallel execution, including cooperative fibers, GPU threads, and SIMD vector -units, among others. This diversity of possible execution resources strongly -suggests that a suitable abstraction encapsulating the details of how work is -created across diverse platforms would be of significant value to parallel -algorithm implementations. Suitably defined executors provide just such a -facility. - -An executor is an object responsible for creating execution agents on which work -is performed, thus abstracting the (potentially platform-specific) mechanisms -for launching work. To accommodate the goals of the Parallelism TS, whose -algorithms aim to support the broadest range of possible platforms, the -requirements that all executors are expected to fulfill are small. They are also -consistent with a broad range of execution semantics, including preemptive -threads, cooperative fibers, GPU threads, and SIMD vector units, among others. - -The executors implemented by |hpx| are aligned with the interfaces proposed by -|cpp11_n4406|_ (Parallel Algorithms Need Executors). - -Executors are modular components for requisitioning execution agents. During -parallel algorithm execution, execution policies generate execution agents by -requesting their creation from an associated executor. Rather than focusing on -asynchronous task queuing, our complementary treatment of executors casts them -as modular components for invoking functions over the points of an index space. -We believe that executors may be conceived of as allocators for execution agents -and our interface's design reflects this analogy. The process of requesting -agents from an executor is mediated via the -:cpp:class:`hpx::parallel::executor_traits` API, which is analogous to the -interaction between containers and allocator_traits. - -With ``executor_traits`` clients manipulate all types of executors uniformly:: - - executor_traits::execute(my_executor, - [](size_t i){ // perform task i }, - range(0, n)); - -This call synchronously creates a group of invocations of the given function, -where each individual invocation within the group is identified by a unique -integer ``i`` in ``[0, n)`` Other functions in the interface exist to create -groups of invocations asynchronously and support the special case of creating a -singleton group, resulting in four different combinations. - -Though this interface appears to require executor authors to implement four -different basic operations, there is really only one requirement: -``async_execute()``. In practice, the other operations may be defined in terms -of this single basic primitive. However, some executors will naturally -specialize all four operations for maximum efficiency. - -For maximum implementation flexibility, ``executor_traits`` does not require -executors to implement a particular exception reporting mechanism. Executors may -choose whether or not to report exceptions, and if so, in what manner they are -communicated back to the caller. However, all executors in |hpx| report -exceptions in a manner consistent with the behavior of execution policies -described by the Parallelism TS, where multiple exceptions are collected into an -__exception_list__. This list is reported through ``async_execute()`` s returned -future, or thrown directly by ``execute()``. - -.. note:: - - Please note that the executor interface as described above has now been - deprecated. It has been replaced by separate executor customization points, - one for each of the exposed functions. Please see __cpp20_p0443__ for more - details. The old interface based on ``executor_traits`` will be supported for - some time, you might have to enable the ``HPX_WITH_EXECUTOR_COMPATIBILITY`` - configuration setting, however. - -In |hpx| we have implemented the following executor types: - -* :cpp:class:`hpx::parallel::execution::sequenced_executor`: creates groups of - sequential execution agents which execute in the calling thread. The - sequential order is given by the lexicographical order of indices in the index - space. -* :cpp:class:`hpx::parallel::execution::parallel_executor`: creates groups of - parallel execution agents which execute in threads implicitly created by the - executor. This executor uses a given launch policy. -* :cpp:class:`hpx::parallel::execution::service_executor`: creates groups of - parallel execution agents which execute in one of the kernel threads - associated with a given pool category (I/O, :term:`parcel`, or timer pool, or - on the main thread of the application). -* :cpp:class:`hpx::parallel::execution::local_priority_queue_executor`, - :cpp:class:`hpx::parallel::execution::local_queue_executor`, - :cpp:class:`hpx::parallel::execution::static_priority_queue_executor` create - executors on top of the corresponding |hpx| schedulers. -* :cpp:class:`hpx::parallel::execution::distribution_policy_executor` creates - executors using any of the existing distribution policies (like - :cpp:class:`hpx::components::colocating_distribution_policy` et.al.). - .. _executor_parameters: Executor parameters and executor parameter traits ------------------------------------------------- -Executors as described in the previous section add a powerful customization -capability to any facility which exposes management of parallel execution. -However, sometimes it is necessary to be able to customize certain parameters of -the execution as well. In |hpx| we introduce the notion of execution parameters -and execution parameter traits. At this point, the only parameter which can be -customized is the size of the chunks of work executed on a single |hpx|-thread -(such as the number of loop iterations combined to run as a single task). +In |hpx| we introduce the notion of execution parameters and execution parameter +traits. At this point, the only parameter which can be customized is the size of +the chunks of work executed on a single |hpx|-thread (such as the number of loop +iterations combined to run as a single task). An executor parameter object is responsible for exposing the calculation of the size of the chunks scheduled. It abstracts the (potential platform-specific) diff --git a/hpx/apply.hpp b/hpx/apply.hpp index 5da14b95ef6a..27a8c227d907 100644 --- a/hpx/apply.hpp +++ b/hpx/apply.hpp @@ -19,10 +19,6 @@ #include #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#endif #include #include @@ -55,29 +51,6 @@ namespace hpx { namespace detail } }; -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - // parallel::executor - template - struct apply_dispatch::value - >::type> - { - template - HPX_FORCEINLINE static - typename std::enable_if< - traits::detail::is_deferred_invocable::value, - bool - >::type - call(Executor& exec, F&& f, Ts&&... ts) - { - parallel::executor_traits::apply_execute(exec, - std::forward(f), std::forward(ts)...); - return false; - } - }; -#endif - // The overload for hpx::apply taking an executor simply forwards to the // corresponding executor customization point. // diff --git a/hpx/async.hpp b/hpx/async.hpp index f5cd95987916..b69e986b91e8 100644 --- a/hpx/async.hpp +++ b/hpx/async.hpp @@ -20,10 +20,6 @@ #include #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#endif #include #include @@ -55,30 +51,6 @@ namespace hpx { namespace detail } }; -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - // parallel::executor - template - struct async_dispatch::value - >::type> - { - template - HPX_FORCEINLINE static - typename std::enable_if< - traits::detail::is_deferred_invocable::value, - hpx::future< - typename util::detail::invoke_deferred_result::type - > - >::type - call(Executor& exec, F && f, Ts &&... ts) - { - return parallel::executor_traits::async_execute( - exec, std::forward(f), std::forward(ts)...); - } - }; -#endif - // The overload for hpx::async taking an executor simply forwards to the // corresponding executor customization point. // diff --git a/hpx/include/parallel_executor_information.hpp b/hpx/include/parallel_executor_information.hpp index ca8f31864ba1..fc0578427065 100644 --- a/hpx/include/parallel_executor_information.hpp +++ b/hpx/include/parallel_executor_information.hpp @@ -8,9 +8,6 @@ #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#endif #include #include diff --git a/hpx/include/parallel_inner_product.hpp b/hpx/include/parallel_inner_product.hpp deleted file mode 100644 index 457ea0e3b0e2..000000000000 --- a/hpx/include/parallel_inner_product.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2015 Daniel Bourgeois -// -// 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) - -#if !defined(HPX_INNER_PRODUCT_JULY_16_0830AM) -#define HPX_INNER_PRODUCT_JULY_16_0830AM - -#include - -#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) -#include -#endif - -#endif diff --git a/hpx/include/traits.hpp b/hpx/include/traits.hpp index 541580968926..bcec771a6c5e 100644 --- a/hpx/include/traits.hpp +++ b/hpx/include/traits.hpp @@ -42,10 +42,6 @@ #include #include #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#endif #include #include #include diff --git a/hpx/lcos/dataflow.hpp b/hpx/lcos/dataflow.hpp index e3fbc33a5adb..570360d864de 100644 --- a/hpx/lcos/dataflow.hpp +++ b/hpx/lcos/dataflow.hpp @@ -36,10 +36,6 @@ #include #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#endif #include #include @@ -267,21 +263,6 @@ namespace hpx { namespace lcos { namespace detail } } -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - // handle executors through their executor_traits - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) HPX_FORCEINLINE - typename std::enable_if< - traits::is_executor::value - >::type - finalize(Executor& exec, Futures&& futures) - { - boost::intrusive_ptr this_(this); - parallel::executor_traits::apply_execute(exec, - &dataflow_frame::done, std::move(this_), std::move(futures)); - } -#endif - // The overload for hpx::dataflow taking an executor simply forwards // to the corresponding executor customization point. // @@ -441,9 +422,6 @@ namespace hpx { namespace lcos { namespace detail // threads::executor template struct dataflow_dispatch::value || -#endif traits::is_one_way_executor::value || traits::is_two_way_executor::value || traits::is_threads_executor::value @@ -472,9 +450,6 @@ namespace hpx { namespace lcos { namespace detail struct dataflow_dispatch::value && !( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - traits::is_executor::value || -#endif traits::is_one_way_executor::value || traits::is_two_way_executor::value || traits::is_threads_executor::value) diff --git a/hpx/lcos/future.hpp b/hpx/lcos/future.hpp index 30fa6bdf5b31..d79f936e89aa 100644 --- a/hpx/lcos/future.hpp +++ b/hpx/lcos/future.hpp @@ -22,9 +22,6 @@ #include #include #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#endif #include #include #include @@ -387,15 +384,6 @@ namespace hpx { namespace lcos { namespace detail >::type make_continuation(Future const& future, Policy && policy, F && f); -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - template - inline typename hpx::traits::detail::shared_state_ptr< - typename continuation_result::type - >::type - make_continuation_exec_v1(Future const& future, Executor& exec, F && f); -#endif - // create non-unwrapping continuations template @@ -466,43 +454,6 @@ namespace hpx { namespace lcos { namespace detail } }; -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - // parallel executors v1 - template - struct future_then_dispatch::value - >::type> - { - template - HPX_FORCEINLINE - static typename hpx::traits::future_then_result::type - call(Future && fut, Executor_ && exec, F && f) - { - using result_type = - typename hpx::traits::future_then_result::result_type; - using continuation_result_type = - typename hpx::util::invoke_result::type; - - typename hpx::traits::detail::shared_state_ptr::type p = - detail::make_continuation_exec_v1( - std::move(fut), std::forward(exec), - std::forward(f)); - return hpx::traits::future_access >::create( - std::move(p)); - } - - template - HPX_FORCEINLINE - static typename hpx::traits::future_then_result::type - call_alloc(Allocator const&, Future && fut, Executor_ && exec, F && f) - { - return call(std::forward(fut), - std::forward(exec), std::forward(f)); - } - }; -#endif - // The overload for future::then taking an executor simply forwards to the // corresponding executor customization point. // @@ -542,9 +493,6 @@ namespace hpx { namespace lcos { namespace detail template struct future_then_dispatch::value && -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - !traits::is_executor::value && -#endif !( traits::is_one_way_executor::value || traits::is_two_way_executor::value || @@ -1076,10 +1024,6 @@ namespace hpx { namespace lcos typename util::lazy_enable_if< !hpx::traits::is_launch_policy< typename std::decay::type>::value && -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - !hpx::traits::is_executor< - typename std::decay::type>::value && -#endif !hpx::traits::is_one_way_executor< typename std::decay::type>::value && !hpx::traits::is_two_way_executor< @@ -1109,21 +1053,6 @@ namespace hpx { namespace lcos std::forward(policy), std::forward(f), ec); } -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - typename util::lazy_enable_if< - hpx::traits::is_executor::value - , hpx::traits::future_then_result - >::type - then(Executor && exec, F && f, error_code& ec = throws) - { - invalidate on_exit(*this); - return base_type::then(std::move(*this), - exec, std::forward(f), ec); - } -#endif - template typename util::lazy_enable_if< hpx::traits::is_one_way_executor< @@ -1424,10 +1353,6 @@ namespace hpx { namespace lcos typename std::decay::type>::value && !hpx::traits::is_threads_executor< typename std::decay::type>::value && -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - !hpx::traits::is_executor< - typename std::decay::type>::value && -#endif !hpx::traits::is_one_way_executor< typename std::decay::type>::value && !hpx::traits::is_two_way_executor< @@ -1461,20 +1386,6 @@ namespace hpx { namespace lcos sched, std::forward(f), ec); } -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - typename util::lazy_enable_if< - hpx::traits::is_executor::value - , hpx::traits::future_then_result - >::type - then(Executor && exec, F && f, error_code& ec = throws) const - { - return base_type::then(shared_future(*this), - exec, std::forward(f), ec); - } -#endif - template typename util::lazy_enable_if< hpx::traits::is_one_way_executor< diff --git a/hpx/lcos/local/packaged_continuation.hpp b/hpx/lcos/local/packaged_continuation.hpp index 0cb28bed1cbf..875898e6a6a2 100644 --- a/hpx/lcos/local/packaged_continuation.hpp +++ b/hpx/lcos/local/packaged_continuation.hpp @@ -15,9 +15,6 @@ #include #include #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#endif #include #include #include @@ -353,51 +350,6 @@ namespace hpx { namespace lcos { namespace detail async(std::move(f), priority, throws); } -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - void async_exec_v1( - typename traits::detail::shared_state_ptr_for< - Future - >::type && f, - Executor& exec, error_code& ec) - { - { - std::unique_lock l(this->mtx_); - if (started_) { - l.unlock(); - HPX_THROWS_IF(ec, task_already_started, - "continuation::async_exec_v1", - "this task has already been started"); - return; - } - started_ = true; - } - - boost::intrusive_ptr this_(this); - threads::thread_result_type (continuation::*async_impl_ptr)( - typename traits::detail::shared_state_ptr_for::type && - ) = &continuation::async_impl; - - parallel::executor_traits::apply_execute(exec, - util::one_shot(async_impl_ptr), std::move(this_), std::move(f)); - - if (&ec != &throws) - ec = make_success_code(); - } - - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - void async_exec_v1( - typename traits::detail::shared_state_ptr_for< - Future - >::type && f, - Executor& exec) - { - async_exec_v1(std::move(f), exec, throws); - } -#endif - template void async_exec( typename traits::detail::shared_state_ptr_for< @@ -517,38 +469,6 @@ namespace hpx { namespace lcos { namespace detail )); } -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - void attach_exec_v1(Future const& future, Executor& exec) - { - typedef - typename traits::detail::shared_state_ptr_for::type - shared_state_ptr; - - // bind an on_completed handler to this future which will invoke - // the continuation - boost::intrusive_ptr this_(this); - void (continuation::*cb)(shared_state_ptr &&, Executor&) = - &continuation::async_exec_v1; - - shared_state_ptr state = traits::detail::get_shared_state(future); - typename shared_state_ptr::element_type* ptr = state.get(); - - if (ptr == nullptr) - { - HPX_THROW_EXCEPTION(no_state, - "continuation::attach_exec_v1", - "the future to attach has no valid shared state"); - } - - ptr->execute_deferred(); - ptr->set_on_completed( - util::deferred_call(cb, std::move(this_), std::move(state), - std::ref(exec))); - } -#endif - template void attach_exec(Future const& future, typename std::remove_reference::type& exec) @@ -734,27 +654,6 @@ namespace hpx { namespace lcos { namespace detail return r; } -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - inline typename traits::detail::shared_state_ptr< - typename continuation_result::type - >::type - make_continuation_exec_v1(Future const& future, Executor& exec, F && f) - { - typedef typename continuation_result::type result_type; - typedef detail::continuation shared_state; - typedef typename shared_state::init_no_addref init_no_addref; - - // create a continuation - typename traits::detail::shared_state_ptr::type p( - new shared_state(init_no_addref{}, std::forward(f)), false); - static_cast(p.get())->attach_exec_v1(future, exec); - return p; - } -#endif - template inline typename traits::detail::shared_state_ptr::type diff --git a/hpx/parallel/algorithms/inner_product.hpp b/hpx/parallel/algorithms/inner_product.hpp deleted file mode 100644 index 02cb22d9af00..000000000000 --- a/hpx/parallel/algorithms/inner_product.hpp +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (c) 2015 Daniel Bourgeois -// Copyright (c) 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) - -/// \file parallel/algorithms/inner_product.hpp - -#if !defined(HPX_PARALLEL_ALGORITHM_INNER_PRODUCT_JUL_15_2015_0730AM) -#define HPX_PARALLEL_ALGORITHM_INNER_PRODUCT_JUL_15_2015_0730AM - -#include - -#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) - -#include -#include -#include - -#include -#include - -namespace hpx { namespace parallel { inline namespace v1 -{ - /////////////////////////////////////////////////////////////////////////// - /// Returns the result of accumulating init with the inner products of the - /// pairs formed by the elements of two ranges starting at first1 and - /// first2. - /// - /// \note Complexity: O(\a last - \a first) applications of the - /// predicate \a op2. - /// \tparam ExPolicy The type of the execution policy to use (deduced). - /// It describes the manner in which the execution - /// of the algorithm may be parallelized and the manner - /// in which it executes the assignments. - /// \tparam FwdIter1 The type of the first source iterators used - /// (deduced). This iterator type must meet the - /// requirements of an input iterator. - /// \tparam FwdIter2 The type of the second source iterators used - /// (deduced). This iterator type must meet the - /// requirements of an input iterator. - /// \tparam T The type of the value to be used as return) - /// values (deduced). - /// \param policy The execution policy to use for the scheduling of - /// the iterations. - /// \param first1 Refers to the beginning of the first sequence of - /// elements the result will be calculated with. - /// \param last1 Refers to the end of the first sequence of elements - /// the algorithm will be applied to. - /// \param first2 Refers to the beginning of the second sequence of - /// elements the result will be calculated with. - /// \param init The initial value for the sum. - /// - /// The operations in the parallel \a inner_product algorithm invoked - /// with an execution policy object of type \a sequential_execution_policy - /// execute in sequential order in the calling thread. - /// - /// The operations in the parallel \a inner_product algorithm invoked - /// with an execution policy object of type \a parallel_execution_policy - /// or \a parallel_task_execution_policy are permitted to execute in an unordered - /// fashion in unspecified threads, and indeterminately sequenced - /// within each thread. - /// - /// \returns The \a inner_product algorithm returns a \a hpx::future if - /// the execution policy is of type - /// \a sequential_task_execution_policy or - /// \a parallel_task_execution_policy and - /// returns \a T otherwise. - /// - /// \note This function is deprecated and is replaced by the binary version - /// of \a transform_reduce. - /// - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - inline typename std::enable_if< - execution::is_execution_policy::value, - typename util::detail::algorithm_result::type - >::type - inner_product(ExPolicy&& policy, FwdIter1 first1, FwdIter1 last1, - FwdIter2 first2, T init) - { - return transform_reduce( - std::forward(policy), first1, last1, first2, - std::move(init)); - } - - /////////////////////////////////////////////////////////////////////////// - /// Returns the result of accumulating init with the inner products of the - /// pairs formed by the elements of two ranges starting at first1 and - /// first2. - /// - /// \note Complexity: O(\a last - \a first) applications of the - /// predicate \a op2. - /// \tparam ExPolicy The type of the execution policy to use (deduced). - /// It describes the manner in which the execution - /// of the algorithm may be parallelized and the manner - /// in which it executes the assignments. - /// \tparam FwdIter1 The type of the first source iterators used - /// (deduced). This iterator type must meet the - /// requirements of an forward iterator. - /// \tparam FwdIter2 The type of the second source iterators used - /// (deduced). This iterator type must meet the - /// requirements of an forward iterator. - /// \tparam T The type of the value to be used as return) - /// values (deduced). - /// \tparam Op1 The type of the binary function object used for - /// the summation operation. - /// \tparam Op2 The type of the binary function object used for - /// the multiplication operation. - /// - /// \param policy The execution policy to use for the scheduling of - /// the iterations. - /// \param first1 Refers to the beginning of the first sequence of - /// elements the result will be calculated with. - /// \param last1 Refers to the end of the first sequence of elements - /// the algorithm will be applied to. - /// \param first2 Refers to the beginning of the second sequence of - /// elements the result will be calculated with. - /// \param init The initial value for the sum. - /// \param op1 Specifies the function (or function object) which - /// will be invoked for each of the input values - /// of the sequence. This is a binary predicate. The - /// signature of this predicate should be equivalent to - /// \code - /// Ret fun(const Type1 &a, const Type2 &b); - /// \endcode \n - /// The signature does not need to have const&, but - /// the function must not modify the objects passed to - /// it. - /// The type \a Ret must be such that it can be - /// implicitly converted to an object for the second - /// argument type of \a op2. - /// \param op2 Specifies the function (or function object) which - /// will be invoked for the initial value and each - /// of the return values of \a op1. - /// This is a binary predicate. The - /// signature of this predicate should be equivalent to - /// should be equivalent to: - /// \code - /// Ret fun(const Type1 &a, const Type1 &b); - /// \endcode \n - /// The signature does not need to have const&, but - /// the function must not modify the objects passed to - /// it. - /// The type \a Ret must be - /// such that it can be implicitly converted to a type - /// of \a T. - /// - /// The operations in the parallel \a inner_product algorithm invoked - /// with an execution policy object of type \a sequential_execution_policy - /// execute in sequential order in the calling thread. - /// - /// The operations in the parallel \a inner_product algorithm invoked - /// with an execution policy object of type \a parallel_execution_policy - /// or \a parallel_task_execution_policy are permitted to execute in an unordered - /// fashion in unspecified threads, and indeterminately sequenced - /// within each thread. - /// - /// \returns The \a inner_product algorithm returns a \a hpx::future if - /// the execution policy is of type - /// \a sequential_task_execution_policy or - /// \a parallel_task_execution_policy and - /// returns \a T otherwise. - /// - /// \note This function is deprecated and is replaced by the binary version - /// of \a transform_reduce. - /// - template - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - inline typename std::enable_if< - execution::is_execution_policy::value, - typename util::detail::algorithm_result::type - >::type - inner_product(ExPolicy&& policy, FwdIter1 first1, FwdIter1 last1, - FwdIter2 first2, T init, Op1 && op1, Op2 && op2) - { - return transform_reduce( - std::forward(policy), first1, last1, first2, - std::move(init), std::forward(op1), std::forward(op2)); - } -}}} - -#endif -#endif diff --git a/hpx/parallel/algorithms/transform_exclusive_scan.hpp b/hpx/parallel/algorithms/transform_exclusive_scan.hpp index a128e676a458..e41d6dd0490d 100644 --- a/hpx/parallel/algorithms/transform_exclusive_scan.hpp +++ b/hpx/parallel/algorithms/transform_exclusive_scan.hpp @@ -338,38 +338,6 @@ namespace hpx { namespace parallel { inline namespace v1 first, last, dest, std::forward(conv), std::move(init), std::forward(op), is_segmented()); } - -#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) - /// \cond NOINTERNAL - template ::value && - hpx::traits::is_iterator::value && - hpx::traits::is_iterator::value && - hpx::traits::is_invocable::value_type - >::value && - hpx::traits::is_invocable::value_type - >::type, - typename hpx::util::invoke_result::value_type - >::type - >::value)> - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - typename util::detail::algorithm_result::type - transform_exclusive_scan(ExPolicy && policy, FwdIter1 first, FwdIter1 last, - FwdIter2 dest, Conv && conv, T init, Op && op) - { - typedef hpx::traits::is_segmented_iterator is_segmented; - return detail::transform_exclusive_scan_(std::forward(policy), - first, last, dest, std::forward(conv), std::move(init), - std::forward(op), is_segmented()); - } - /// \endcond -#endif }}} #endif diff --git a/hpx/parallel/algorithms/transform_inclusive_scan.hpp b/hpx/parallel/algorithms/transform_inclusive_scan.hpp index 2f9e6c6ffe68..da6047561125 100644 --- a/hpx/parallel/algorithms/transform_inclusive_scan.hpp +++ b/hpx/parallel/algorithms/transform_inclusive_scan.hpp @@ -341,65 +341,6 @@ namespace hpx { namespace parallel { inline namespace v1 std::forward(op), is_segmented()); } -#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) - /// \cond NOINTERNAL - template ::value && - hpx::traits::is_iterator::value && - hpx::traits::is_iterator::value && - hpx::traits::is_invocable::value_type - >::value && - hpx::traits::is_invocable::value_type - >::type, - typename hpx::util::invoke_result::value_type - >::type - >::value)> - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - typename util::detail::algorithm_result::type - transform_inclusive_scan(ExPolicy && policy, FwdIter1 first, FwdIter1 last, - FwdIter2 dest, T init, Op && op, Conv && conv) - { - typedef hpx::traits::is_segmented_iterator is_segmented; - return detail::transform_inclusive_scan_(std::forward(policy), - first, last, dest, std::forward(conv), std::move(init), - std::forward(op), is_segmented()); - } - - template ::value && - hpx::traits::is_iterator::value && - hpx::traits::is_iterator::value && - hpx::traits::is_invocable::value_type - >::value && - hpx::traits::is_invocable::value_type - >::type, - typename hpx::util::invoke_result::value_type - >::type - >::value)> - typename util::detail::algorithm_result::type - transform_inclusive_scan(ExPolicy && policy, FwdIter1 first, FwdIter1 last, - FwdIter2 dest, Conv && conv, T init, Op && op) - { - typedef hpx::traits::is_segmented_iterator is_segmented; - return detail::transform_inclusive_scan_(std::forward(policy), - first, last, dest, std::forward(conv), std::move(init), - std::forward(op), is_segmented()); - } - /// \endcond -#endif - /////////////////////////////////////////////////////////////////////////// /// Assigns through each iterator \a i in [result, result + (last - first)) /// the value of @@ -527,40 +468,6 @@ namespace hpx { namespace parallel { inline namespace v1 first, last, dest, std::forward(conv), value_type(), std::forward(op), is_segmented()); } - -#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) - /// \cond NOINTERNAL - template ::value && - hpx::traits::is_iterator::value && - hpx::traits::is_iterator::value && - hpx::traits::is_invocable::value_type - >::value && - hpx::traits::is_invocable::value_type - >::type, - typename hpx::util::invoke_result::value_type - >::type - >::value)> - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - typename util::detail::algorithm_result::type - transform_inclusive_scan(ExPolicy&& policy, FwdIter1 first, FwdIter1 last, - FwdIter2 dest, Conv && conv, Op && op) - { - typedef typename std::iterator_traits::value_type value_type; - - typedef hpx::traits::is_segmented_iterator is_segmented; - return detail::transform_inclusive_scan_(std::forward(policy), - first, last, dest, std::forward(conv), value_type(), - std::forward(op), is_segmented()); - } - /// \endcond -#endif }}} #endif diff --git a/hpx/parallel/algorithms/transform_reduce.hpp b/hpx/parallel/algorithms/transform_reduce.hpp index 283ce2d65c78..0f2e97c23b42 100644 --- a/hpx/parallel/algorithms/transform_reduce.hpp +++ b/hpx/parallel/algorithms/transform_reduce.hpp @@ -282,49 +282,6 @@ namespace hpx { namespace parallel { inline namespace v1 std::forward(red_op), std::forward(conv_op), is_segmented()); } - -#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) - /// \cond NOINTERNAL - template ::value && - hpx::traits::is_iterator::value && - hpx::traits::is_invocable::value_type - >::value && - hpx::traits::is_invocable::value_type - >::type, - typename hpx::util::invoke_result::value_type - >::type - >::value)> - HPX_DEPRECATED(HPX_DEPRECATED_MSG) - typename util::detail::algorithm_result::type - transform_reduce(ExPolicy && policy, FwdIter first, FwdIter last, - T init, Convert && conv_op, Reduce && red_op) - { -#if defined(HPX_HAVE_ALGORITHM_INPUT_ITERATOR_SUPPORT) - static_assert( - (hpx::traits::is_input_iterator::value), - "Requires at least input iterator."); -#else - static_assert( - (hpx::traits::is_forward_iterator::value), - "Requires at least forward iterator."); -#endif - - typedef hpx::traits::is_segmented_iterator is_segmented; - - return detail::transform_reduce_( - std::forward(policy), first, last, std::move(init), - std::forward(red_op), std::forward(conv_op), - is_segmented()); - } - /// \endcond -#endif }}} #endif diff --git a/hpx/parallel/datapar/execution_policy.hpp b/hpx/parallel/datapar/execution_policy.hpp index 0bba02295560..e109383ed983 100644 --- a/hpx/parallel/datapar/execution_policy.hpp +++ b/hpx/parallel/datapar/execution_policy.hpp @@ -99,14 +99,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -245,14 +239,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor_ && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -396,14 +384,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -538,14 +520,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor_ && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -691,14 +667,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -826,14 +796,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -966,14 +930,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor_ && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -1115,14 +1073,8 @@ namespace hpx { namespace parallel { namespace execution { inline namespace v1 on(Executor_ && exec) const { static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -1386,38 +1338,5 @@ namespace hpx { namespace parallel { namespace execution } }}} -#if defined(HPX_HAVE_EXECUTION_POLICY_COMPATIBILITY) -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer for changes introduced by C++17 -namespace hpx { namespace parallel { inline namespace v1 -{ - /////////////////////////////////////////////////////////////////////////// - using dataseq_task_execution_policy = execution::dataseq_task_policy; - using dataseq_execution_policy = execution::dataseq_policy; - - template - using dataseq_task_execution_policy_shim = - execution::dataseq_task_policy_shim; - template - using dataseq_execution_policy_shim = - execution::dataseq_policy_shim; - - /////////////////////////////////////////////////////////////////////////// - using datapar_task_execution_policy = execution::datapar_task_policy; - using datapar_execution_policy = execution::datapar_policy; - - template - using datapar_task_execution_policy_shim = - execution::datapar_task_policy_shim; - template - using datapar_execution_policy_shim = - execution::datapar_policy_shim; - - /////////////////////////////////////////////////////////////////////////// - HPX_STATIC_CONSTEXPR dataseq_execution_policy dataseq_execution; - HPX_STATIC_CONSTEXPR datapar_execution_policy datapar_execution; -}}} -#endif - #endif #endif diff --git a/hpx/parallel/execution_policy.hpp b/hpx/parallel/execution_policy.hpp index ee4ba307a2e3..c6f952d85b3a 100644 --- a/hpx/parallel/execution_policy.hpp +++ b/hpx/parallel/execution_policy.hpp @@ -112,14 +112,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -260,14 +254,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -420,14 +408,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -564,14 +546,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -726,14 +702,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -868,14 +838,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -1022,14 +986,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -1164,14 +1122,8 @@ namespace hpx { namespace parallel { namespace execution typedef typename std::decay::type executor_type; static_assert( -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - hpx::traits::is_executor::value || -#endif hpx::traits::is_threads_executor::value || hpx::traits::is_executor_any::value, -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - "hpx::traits::is_executor::value || " -#endif "hpx::traits::is_threads_executor::value || " "hpx::traits::is_executor_any::value"); @@ -1494,50 +1446,4 @@ namespace hpx { namespace parallel { namespace execution } }}} -#if defined(HPX_HAVE_EXECUTION_POLICY_COMPATIBILITY) -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer for changes introduced by C++17 -namespace hpx { namespace parallel { inline namespace v1 -{ - /////////////////////////////////////////////////////////////////////////// - using sequential_task_execution_policy = - parallel::execution::sequenced_task_policy; - using sequential_execution_policy = - parallel::execution::sequenced_policy; - - template - using sequential_task_execution_policy_shim = - parallel::execution::sequenced_task_policy_shim; - template - using sequential_execution_policy_shim = - parallel::execution::sequenced_policy_shim; - - /////////////////////////////////////////////////////////////////////////// - using parallel_task_execution_policy = - parallel::execution::parallel_task_policy; - using parallel_execution_policy = - parallel::execution::parallel_policy; - - template - using parallel_task_execution_policy_shim = - parallel::execution::parallel_task_policy_shim; - template - using parallel_execution_policy_shim = - parallel::execution::parallel_policy_shim; - - /////////////////////////////////////////////////////////////////////////// - using parallel_vector_execution_policy = - parallel::execution::parallel_unsequenced_policy; - - using task_execution_policy_tag = parallel::execution::task_policy_tag; - - /////////////////////////////////////////////////////////////////////////// - HPX_STATIC_CONSTEXPR sequential_execution_policy seq; - HPX_STATIC_CONSTEXPR parallel_execution_policy par; - HPX_STATIC_CONSTEXPR parallel_vector_execution_policy par_vec; - - HPX_STATIC_CONSTEXPR task_execution_policy_tag task; -}}} -#endif - #endif diff --git a/hpx/parallel/executor_parameters.hpp b/hpx/parallel/executor_parameters.hpp index 7e3c7d070a4d..e68006cedd9f 100644 --- a/hpx/parallel/executor_parameters.hpp +++ b/hpx/parallel/executor_parameters.hpp @@ -13,9 +13,5 @@ #include #include #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#endif #endif diff --git a/hpx/parallel/executors.hpp b/hpx/parallel/executors.hpp index 4c2ab902df25..502e4395dfab 100644 --- a/hpx/parallel/executors.hpp +++ b/hpx/parallel/executors.hpp @@ -8,17 +8,6 @@ #include -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include -#include -#include -#include -#endif - #include #include #include diff --git a/hpx/parallel/executors/auto_chunk_size.hpp b/hpx/parallel/executors/auto_chunk_size.hpp index a17e0e5593af..443967f2a6d4 100644 --- a/hpx/parallel/executors/auto_chunk_size.hpp +++ b/hpx/parallel/executors/auto_chunk_size.hpp @@ -110,16 +110,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - using auto_chunk_size = execution::auto_chunk_size; -}}} - -#endif - #endif diff --git a/hpx/parallel/executors/default_executor.hpp b/hpx/parallel/executors/default_executor.hpp index 75fd73d5635c..5f9f00300a57 100644 --- a/hpx/parallel/executors/default_executor.hpp +++ b/hpx/parallel/executors/default_executor.hpp @@ -22,13 +22,4 @@ namespace hpx { namespace parallel { namespace execution using default_executor = threads::executors::default_executor; }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - using default_executor = execution::default_executor; -}}} -#endif - #endif diff --git a/hpx/parallel/executors/distribution_policy_executor.hpp b/hpx/parallel/executors/distribution_policy_executor.hpp index dce59d7a707a..f1302cc01ad5 100644 --- a/hpx/parallel/executors/distribution_policy_executor.hpp +++ b/hpx/parallel/executors/distribution_policy_executor.hpp @@ -205,61 +205,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -#include - -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer -namespace hpx { namespace parallel { inline namespace v3 -{ - /// \cond NOINTERNAL - - // this must be a type distinct from parallel::execution::parallel_executor - // to avoid ambiguities - template - struct distribution_policy_executor - : execution::distribution_policy_executor - { - template ::type>::value>::type> - distribution_policy_executor(DistPolicy_ && policy) - : execution::distribution_policy_executor( - std::forward(policy)) - {} - - template - typename execution::detail::distribution_policy_execute_result< - F, Ts... - >::type - execute(F && f, Ts &&... ts) const - { - return execution::distribution_policy_executor:: - sync_execute(std::forward(f), std::forward(ts)...); - } - }; - - template - distribution_policy_executor::type> - make_distribution_policy_executor(DistPolicy && policy) - { - typedef typename hpx::util::decay::type dist_policy_type; - return distribution_policy_executor( - std::forward(policy)); - } - - namespace detail - { - template - struct is_executor > - : std::true_type - {}; - } - /// \endcond -}}} - -#endif - #endif diff --git a/hpx/parallel/executors/dynamic_chunk_size.hpp b/hpx/parallel/executors/dynamic_chunk_size.hpp index cb36293fc48a..9b35d903b8f4 100644 --- a/hpx/parallel/executors/dynamic_chunk_size.hpp +++ b/hpx/parallel/executors/dynamic_chunk_size.hpp @@ -75,15 +75,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - using dynamic_chunk_size = execution::dynamic_chunk_size; -}}} - -#endif - #endif diff --git a/hpx/parallel/executors/guided_chunk_size.hpp b/hpx/parallel/executors/guided_chunk_size.hpp index 3656c25ab9ac..d28fce37f285 100644 --- a/hpx/parallel/executors/guided_chunk_size.hpp +++ b/hpx/parallel/executors/guided_chunk_size.hpp @@ -96,15 +96,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - using guided_chunk_size = execution::guided_chunk_size; -}}} - -#endif - #endif diff --git a/hpx/parallel/executors/parallel_executor.hpp b/hpx/parallel/executors/parallel_executor.hpp index aa917b19e31e..9593a352b5d9 100644 --- a/hpx/parallel/executors/parallel_executor.hpp +++ b/hpx/parallel/executors/parallel_executor.hpp @@ -257,47 +257,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /// \cond NOINTERNAL - - // this must be a type distinct from parallel::execution::parallel_executor - // to avoid ambiguities - struct parallel_executor - : parallel::execution::parallel_executor - { - HPX_CONSTEXPR parallel_executor( - launch l = hpx::detail::async_policy{}, - std::size_t spread = 4, std::size_t tasks = std::size_t(-1)) - : parallel::execution::parallel_executor(l, spread, tasks) - {} - - template - std::vector::type - > > - bulk_async_execute(F && f, S const& shape, Ts &&... ts) - { - using base_type = parallel::execution::parallel_executor; - return base_type::bulk_async_execute(std::forward(f), shape, - std::forward(ts)...); - } - }; - - namespace detail - { - template <> - struct is_executor - : std::true_type - {}; - } - /// \endcond -}}} -#endif - #endif diff --git a/hpx/parallel/executors/persistent_auto_chunk_size.hpp b/hpx/parallel/executors/persistent_auto_chunk_size.hpp index 8ba063226456..982c86379ace 100644 --- a/hpx/parallel/executors/persistent_auto_chunk_size.hpp +++ b/hpx/parallel/executors/persistent_auto_chunk_size.hpp @@ -130,15 +130,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - using persistent_auto_chunk_size = execution::persistent_auto_chunk_size; -}}} - -#endif - #endif diff --git a/hpx/parallel/executors/rebind_executor.hpp b/hpx/parallel/executors/rebind_executor.hpp index 21b786853cfc..f6e260c4c32d 100644 --- a/hpx/parallel/executors/rebind_executor.hpp +++ b/hpx/parallel/executors/rebind_executor.hpp @@ -12,6 +12,8 @@ #include #include +#include + namespace hpx { namespace parallel { namespace execution { /////////////////////////////////////////////////////////////////////////// @@ -72,45 +74,4 @@ namespace hpx { namespace parallel { namespace execution }; }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -#include - -namespace hpx { namespace parallel { inline namespace v1 -{ - /////////////////////////////////////////////////////////////////////////// - /// Function invocations executed by a group of sequential execution agents - /// execute in sequential order. - using sequential_execution_tag = - parallel::execution::sequenced_execution_tag; - - /// Function invocations executed by a group of parallel execution agents - /// execute in unordered fashion. Any such invocations executing in the - /// same thread are indeterminately sequenced with respect to each other. - /// - /// \note \a parallel_execution_tag is weaker than - /// \a sequential_execution_tag. - using parallel_execution_tag = - parallel::execution::parallel_execution_tag; - - /// Function invocations executed by a group of vector execution agents are - /// permitted to execute in unordered fashion when executed in different - /// threads, and un-sequenced with respect to one another when executed in - /// the same thread. - /// - /// \note \a vector_execution_tag is weaker than - /// \a parallel_execution_tag. - using vector_execution_tag = - parallel::execution::unsequenced_execution_tag; - - /////////////////////////////////////////////////////////////////////////// - // Rebind the type of executor used by an execution policy. The execution - // category of Executor shall not be weaker than that of ExecutionPolicy. - template - using rebind_executor = parallel::execution:: - rebind_executor; -}}} -#endif - #endif diff --git a/hpx/parallel/executors/sequenced_executor.hpp b/hpx/parallel/executors/sequenced_executor.hpp index d32081b3f248..1e23e0b8126e 100644 --- a/hpx/parallel/executors/sequenced_executor.hpp +++ b/hpx/parallel/executors/sequenced_executor.hpp @@ -169,58 +169,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /// \cond NOINTERNAL - - // this must be a type distinct from parallel::execution::sequenced_executor - // to avoid ambiguities - struct sequential_executor - : parallel::execution::sequenced_executor - { - using base_type = parallel::execution::sequenced_executor; - - template - static typename hpx::util::detail::invoke_deferred_result::type - execute(F && f, Ts &&... ts) - { - return base_type::sync_execute(std::forward(f), - std::forward(ts)...); - } - - template - std::vector::type - > > - bulk_async_execute(F && f, S const& shape, Ts &&... ts) - { - return base_type::bulk_async_execute(std::forward(f), shape, - std::forward(ts)...); - } - - template - static typename v3::detail::bulk_execute_result::type - bulk_execute(F && f, S const& shape, Ts &&... ts) - { - return base_type::bulk_sync_execute(std::forward(f), shape, - std::forward(ts)...); - } - }; - - namespace detail - { - template <> - struct is_executor - : std::true_type - {}; - } - /// \endcond -}}} -#endif - #endif diff --git a/hpx/parallel/executors/service_executors.hpp b/hpx/parallel/executors/service_executors.hpp index e6c5f75a87d2..ac4610eee83b 100644 --- a/hpx/parallel/executors/service_executors.hpp +++ b/hpx/parallel/executors/service_executors.hpp @@ -63,60 +63,4 @@ namespace hpx { namespace parallel { namespace execution using main_pool_executor = threads::executors::main_pool_executor; }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer -namespace hpx { namespace parallel { inline namespace v3 -{ - /// \cond NOINTERNAL - struct service_executor - : threads::executors::service_executor - { - typedef static_chunk_size executor_parameters_type; - - service_executor( - threads::executors::service_executor_type t, - char const* name_suffix = "") - : threads::executors::service_executor(t, name_suffix) - {} - }; - - struct io_pool_executor : service_executor - { - io_pool_executor() - : service_executor( - threads::executors::service_executor_type::io_thread_pool) - {} - }; - - struct parcel_pool_executor : service_executor - { - parcel_pool_executor(char const* name_suffix = "-tcp") - : service_executor( - threads::executors::service_executor_type::parcel_thread_pool, - name_suffix) - {} - }; - - struct timer_pool_executor : service_executor - { - timer_pool_executor() - : service_executor( - threads::executors::service_executor_type::timer_thread_pool) - {} - }; - - struct main_pool_executor : service_executor - { - main_pool_executor() - : service_executor( - threads::executors::service_executor_type::main_thread) - {} - }; - /// \endcond -}}} -#endif - #endif diff --git a/hpx/parallel/executors/static_chunk_size.hpp b/hpx/parallel/executors/static_chunk_size.hpp index ffe957988ce4..bbc8d05ea82d 100644 --- a/hpx/parallel/executors/static_chunk_size.hpp +++ b/hpx/parallel/executors/static_chunk_size.hpp @@ -97,17 +97,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) - -#include -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - using static_chunk_size = execution::static_chunk_size; -}}} - -#endif - #endif diff --git a/hpx/parallel/executors/this_thread_executors.hpp b/hpx/parallel/executors/this_thread_executors.hpp index 5b50974943e7..f80dafb14a90 100644 --- a/hpx/parallel/executors/this_thread_executors.hpp +++ b/hpx/parallel/executors/this_thread_executors.hpp @@ -28,24 +28,4 @@ namespace hpx { namespace parallel { namespace execution #endif }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// -#if defined(HPX_HAVE_STATIC_SCHEDULER) - using this_thread_static_queue_executor = - execution::this_thread_static_queue_executor; -#endif - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - using this_thread_static_priority_queue_executor = - execution::this_thread_static_priority_queue_executor; -#endif -}}} -#endif - #endif diff --git a/hpx/parallel/executors/thread_pool_attached_executors.hpp b/hpx/parallel/executors/thread_pool_attached_executors.hpp index a25b7e6d2f8c..b2732b8c8bba 100644 --- a/hpx/parallel/executors/thread_pool_attached_executors.hpp +++ b/hpx/parallel/executors/thread_pool_attached_executors.hpp @@ -37,32 +37,4 @@ namespace hpx { namespace parallel { namespace execution #endif }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// -#if defined(HPX_HAVE_LOCAL_SCHEDULER) - using local_queue_attached_executor = - threads::executors::local_queue_attached_executor; -#endif - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - using static_queue_attached_executor = - threads::executors::static_queue_attached_executor; -#endif - - using local_priority_queue_attached_executor = - threads::executors::local_priority_queue_attached_executor; - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - using static_priority_queue_attached_executor = - threads::executors::static_priority_queue_attached_executor; -#endif -}}} -#endif - #endif diff --git a/hpx/parallel/executors/thread_pool_executors.hpp b/hpx/parallel/executors/thread_pool_executors.hpp index fb38f2904702..75d93c7ba904 100644 --- a/hpx/parallel/executors/thread_pool_executors.hpp +++ b/hpx/parallel/executors/thread_pool_executors.hpp @@ -68,33 +68,4 @@ namespace hpx { namespace parallel { namespace execution #endif }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// -#if defined(HPX_HAVE_LOCAL_SCHEDULER) - using local_queue_executor = - threads::executors::local_queue_executor; -#endif - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - using static_queue_executor = - threads::executors::static_queue_executor; -#endif - - using local_priority_queue_executor = - threads::executors::local_priority_queue_executor; - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - using static_priority_queue_executor = - threads::executors::static_priority_queue_executor; -#endif - -}}} -#endif - #endif diff --git a/hpx/parallel/executors/thread_pool_os_executors.hpp b/hpx/parallel/executors/thread_pool_os_executors.hpp index b45765faa4bb..e41e6f6c153d 100644 --- a/hpx/parallel/executors/thread_pool_os_executors.hpp +++ b/hpx/parallel/executors/thread_pool_os_executors.hpp @@ -70,31 +70,4 @@ namespace hpx { namespace parallel { namespace execution #endif }}} -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer -namespace hpx { namespace parallel { inline namespace v3 -{ -#if defined(HPX_HAVE_LOCAL_SCHEDULER) - using local_queue_os_executor = - threads::executors::local_queue_os_executor; -#endif - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - using static_queue_os_executor = - threads::executors::static_queue_os_executor; -#endif - - using local_priority_queue_os_executor = - threads::executors::local_priority_queue_os_executor; - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - using static_priority_queue_os_executor = - threads::executors::static_priority_queue_os_executor; -#endif -}}} -#endif - #endif diff --git a/hpx/parallel/executors/v1/executor_information_traits.hpp b/hpx/parallel/executors/v1/executor_information_traits.hpp deleted file mode 100644 index cdf5b470d9ee..000000000000 --- a/hpx/parallel/executors/v1/executor_information_traits.hpp +++ /dev/null @@ -1,281 +0,0 @@ -// 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) - -/// \file parallel/executors/executor_information_traits.hpp - -#if !defined(HPX_PARALLEL_EXECUTOR_INFORMATION_TRAITS_AUG_26_2015_1133AM) -#define HPX_PARALLEL_EXECUTOR_INFORMATION_TRAITS_AUG_26_2015_1133AM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -// forward declaration only -namespace hpx { namespace threads -{ - HPX_API_EXPORT threads::mask_cref_type get_pu_mask(threads::topology& topo, - std::size_t thread_num); -}} - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - namespace detail - { - /// \cond NOINTERNAL - - /////////////////////////////////////////////////////////////////////// - template - std::size_t call_processing_units_parameter_count(Parameters && params, - Executor && exec); - - struct processing_units_count_helper - { - template - static std::size_t call(hpx::traits::detail::wrap_int, - Executor& exec, Parameters& params) - { - return call_processing_units_parameter_count(params, exec); - } - - template - static auto call(int, Executor& exec, Parameters&) - -> decltype(exec.processing_units_count()) - { - return exec.processing_units_count(); - } - }; - - template - std::size_t call_processing_units_count(Executor& exec, - Parameters& params) - { - return processing_units_count_helper::call(0, exec, params); - } - - /////////////////////////////////////////////////////////////////////// - struct has_pending_closures_helper - { - template - static auto call(hpx::traits::detail::wrap_int, - Executor const& exec) -> bool - { - return false; // assume stateless scheduling - } - - template - static auto call(int, Executor const& exec) - -> decltype(exec.has_pending_closures()) - { - return exec.has_pending_closures(); - } - }; - - template - bool call_has_pending_closures(Executor const& exec) - { - return has_pending_closures_helper::call(0, exec); - } - - /////////////////////////////////////////////////////////////////////// - struct get_pu_mask_helper - { - template - static threads::mask_cref_type call(hpx::traits::detail::wrap_int, - Executor const&, threads::topology& topo, std::size_t thread_num) - { - return hpx::threads::get_pu_mask(topo, thread_num); - } - - template - static auto call(int, Executor const& exec, - threads::topology& topo, std::size_t thread_num) - -> decltype(exec.get_pu_mask(topo, thread_num)) - { - return exec.get_pu_mask(topo, thread_num); - } - }; - - template - threads::mask_cref_type call_get_pu_mask(Executor const& exec, - threads::topology& topo, std::size_t thread_num) - { - return get_pu_mask_helper::call(0, exec, topo, thread_num); - } - - /////////////////////////////////////////////////////////////////////// - struct set_scheduler_mode_helper - { - template - static void call(hpx::traits::detail::wrap_int, Executor& exec, - Mode const& mode) - { - } - - template - static auto call(int, Executor& exec, Mode const& mode) - -> decltype(exec.set_scheduler_mode(mode)) - { - exec.set_scheduler_mode(mode); - } - }; - - template - void call_set_scheduler_mode(Executor& exec, Mode const& mode) - { - set_scheduler_mode_helper::call(0, exec, mode); - } - /// \endcond - } - - /////////////////////////////////////////////////////////////////////////// - /// The executor_information_traits type is used to various pieces of - /// information from an executor. - /// - template - struct executor_information_traits - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef Executor executor_type; - - /// Retrieve the number of (kernel-)threads used by the associated - /// executor. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// - /// \note This calls exec.os_thread_count() if it exists; - /// otherwise it executes hpx::get_os_thread_count(). - /// - template - static std::size_t processing_units_count(executor_type const& exec, - Parameters& params) - { - return detail::call_processing_units_count(exec, params); - } - - /// Retrieve whether this executor has operations pending or not. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// - /// \note If the executor does not expose this information, this call - /// will always return \a false - /// - static bool has_pending_closures(executor_type const& exec) - { - return detail::call_has_pending_closures(exec); - } - - /// Retrieve the bitmask describing the processing units the given - /// thread is allowed to run on - /// All threads::executors invoke sched.get_pu_mask(). - /// - /// \param exec [in] The executor object to use for querying the - /// number of pending tasks. - /// - static threads::mask_cref_type get_pu_mask(executor_type const& exec, - threads::topology& topo, std::size_t thread_num) - { - return detail::call_get_pu_mask(exec, topo, thread_num); - } - - /// Set various modes of operation on the scheduler underneath the - /// given executor. - /// - /// \param exec [in] The executor object to use. - /// \param mode [in] The new mode for the scheduler to pick up - /// - /// \note This calls exec.set_scheduler_mode(mode) if it exists; - /// otherwise it does nothing. - /// - template - static void set_scheduler_mode(executor_type& exec, Mode const& mode) - { - detail::call_set_scheduler_mode(exec, mode); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // compatibility layer mapping new customization points onto - // executor_information_traits - - // processing_units_count() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor::value, std::size_t - >::type - processing_units_count(Executor && exec, Parameters& params) - { - typedef typename std::decay::type executor_type; - return executor_information_traits< - executor_type>::processing_units_count(std::forward(exec), - params); - } - - // has_pending_closures() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor::value, bool - >::type - has_pending_closures(Executor && exec) - { - typedef typename std::decay::type executor_type; - return executor_information_traits::has_pending_closures( - std::forward(exec)); - } - - // get_pu_mask() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor::value, - threads::mask_cref_type - >::type - get_pu_mask(Executor && exec, threads::topology& topo, - std::size_t thread_num) - { - typedef typename std::decay::type executor_type; - return executor_information_traits::get_pu_mask( - std::forward(exec), topo, thread_num); - } - - // set_scheduler_mode() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor::value - >::type - set_scheduler_mode(Executor && exec, Mode const& mode) - { - typedef typename std::decay::type executor_type; - return executor_information_traits::set_scheduler_mode( - std::forward(exec), mode); - } -}}} - -#endif -#endif diff --git a/hpx/parallel/executors/v1/executor_parameter_traits.hpp b/hpx/parallel/executors/v1/executor_parameter_traits.hpp deleted file mode 100644 index 3c8b66a19268..000000000000 --- a/hpx/parallel/executors/v1/executor_parameter_traits.hpp +++ /dev/null @@ -1,592 +0,0 @@ -// 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) - -/// \file parallel/executors/v1/executor_parameter_traits.hpp - -#if !defined(HPX_PARALLEL_EXECUTOR_PARAMETER_TRAITS_JUL_30_2015_0914PM) -#define HPX_PARALLEL_EXECUTOR_PARAMETER_TRAITS_JUL_30_2015_0914PM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - // Placeholder type to use predefined executor parameters - using sequential_executor_parameters = - execution::sequential_executor_parameters; - - /////////////////////////////////////////////////////////////////////////// - namespace detail - { - /// \cond NOINTERNAL - - // If an executor exposes 'executor_parameter_type' this type is - // assumed to represent the default parameters for the given executor - // type. - template - using extract_executor_parameters = - execution::extract_executor_parameters; - - /////////////////////////////////////////////////////////////////////// - // If a parameters type exposes 'has_variable_chunk_size' aliased to - // std::true_type it is assumed that the number of loop iterations to - // combine is different for each of the generated chunks. - template - using extract_has_variable_chunk_size = - execution::extract_has_variable_chunk_size; - - /////////////////////////////////////////////////////////////////////// - template - struct processing_units_count_parameter_helper - { - template - static std::size_t call(hpx::traits::detail::wrap_int, - Parameters && params, Executor && exec) - { - return hpx::get_os_thread_count(); - } - - template - static auto call(int, Parameters && params, Executor && exec) - -> decltype(params.processing_units_count( - std::forward(exec))) - { - return params.processing_units_count( - std::forward(exec)); - } - - template - static std::size_t call(Parameters_& params, Executor && exec) - { - return call(0, params, std::forward(exec)); - } - - template - static std::size_t call(Parameters params, Executor && exec) - { - return call(static_cast(params), - std::forward(exec)); - } - }; - - template - std::size_t call_processing_units_parameter_count(Parameters && params, - Executor && exec) - { - return processing_units_count_parameter_helper< - typename hpx::util::decay_unwrap::type - >::call(std::forward(params), - std::forward(exec)); - } - - template - using has_processing_units_count = - execution::detail::has_count_processing_units; - - /////////////////////////////////////////////////////////////////////// - template - struct get_chunk_size_helper - { - template - static std::size_t - call(hpx::traits::detail::wrap_int, Parameters &&, Executor &&, - F &&, std::size_t cores, std::size_t num_tasks) - { - return num_tasks; // assume sequential execution - } - - template - static auto call(int, Parameters && params, Executor && exec, - F && f, std::size_t cores, std::size_t num_tasks) - -> decltype( - params.get_chunk_size(std::forward(exec), - std::forward(f), cores, num_tasks) - ) - { - return params.get_chunk_size(std::forward(exec), - std::forward(f), cores, num_tasks); - } - - template - static std::size_t - call(Parameters_& params, Executor && exec, F && f, - std::size_t cores, std::size_t num_tasks) - { - return call(0, params, std::forward(exec), - std::forward(f), cores, num_tasks); - } - - template - static std::size_t - call(Parameters params, Executor && exec, F && f, - std::size_t cores, std::size_t num_tasks) - { - return call(static_cast(params), - std::forward(exec), std::forward(f), - cores, num_tasks); - } - }; - - template - std::size_t call_get_chunk_size(Parameters && params, Executor && exec, - F && f, std::size_t cores, std::size_t num_tasks) - { - return get_chunk_size_helper< - typename hpx::util::decay_unwrap::type - >::call(std::forward(params), - std::forward(exec), std::forward(f), - cores, num_tasks); - } - - template - using has_get_chunk_size = execution::detail::has_get_chunk_size; - - /////////////////////////////////////////////////////////////////////// - template - struct maximal_number_of_chunks_helper - { - template - static std::size_t - call(hpx::traits::detail::wrap_int, Parameters &&, Executor &&, - std::size_t cores, std::size_t num_tasks) - { - return 4 * cores; // assume 4 times the number of cores - } - - template - static auto call(int, Parameters && params, Executor && exec, - std::size_t cores, std::size_t num_tasks) - -> decltype( - params.maximal_number_of_chunks( - std::forward(exec), cores, num_tasks) - ) - { - return params.maximal_number_of_chunks( - std::forward(exec), cores, num_tasks); - } - - template - static std::size_t - call(Parameters_& params, Executor && exec, std::size_t cores, - std::size_t num_tasks) - { - return call(0, params, std::forward(exec), cores, - num_tasks); - } - - template - static std::size_t - call(Parameters params, Executor && exec, std::size_t cores, - std::size_t num_tasks) - { - return call(static_cast(params), - std::forward(exec), cores, num_tasks); - } - }; - - template - std::size_t call_maximal_number_of_chunks(Parameters && params, - Executor && exec, std::size_t cores, std::size_t num_tasks) - { - return maximal_number_of_chunks_helper< - typename hpx::util::decay_unwrap::type - >::call(std::forward(params), - std::forward(exec), cores, num_tasks); - } - - template - using has_maximal_number_of_chunks = - execution::detail::has_maximal_number_of_chunks; - - /////////////////////////////////////////////////////////////////////// - template - struct reset_thread_distribution_helper - { - template - static void call(hpx::traits::detail::wrap_int, Parameters &&, - Executor &&) - { - } - - template - static auto call(int, Parameters && params, Executor && exec) - -> decltype( - params.reset_thread_distribution( - std::forward(exec)) - ) - { - params.reset_thread_distribution(std::forward(exec)); - } - - template - static void call(Parameters_& params, Executor && exec) - { - call(0, params, std::forward(exec)); - } - - template - static void call(Parameters params, Executor && exec) - { - call(static_cast(params), - std::forward(exec)); - } - }; - - template - void call_reset_thread_distribution(Parameters && params, - Executor && exec) - { - reset_thread_distribution_helper< - typename hpx::util::decay_unwrap::type - >::call(std::forward(params), - std::forward(exec)); - } - - template - using has_reset_thread_distribution = - execution::detail::has_reset_thread_distribution; - - /////////////////////////////////////////////////////////////////////// - template - struct mark_begin_execution_helper - { - template - static void call(hpx::traits::detail::wrap_int, Parameters &&, - Executor &&) - { - } - - template - static auto call(int, Parameters && params, Executor && exec) - -> decltype(params.mark_begin_execution(std::forward(exec))) - { - params.mark_begin_execution(std::forward(exec)); - } - - template - static void call(Parameters_& params, Executor && exec) - { - call(0, params, std::forward(exec)); - } - - template - static void call(Parameters params, Executor && exec) - { - call(static_cast(params), - std::forward(exec)); - } - }; - - template - void call_mark_begin_execution(Parameters && params, Executor && exec) - { - mark_begin_execution_helper< - typename hpx::util::decay_unwrap::type - >::call(std::forward(params), - std::forward(exec)); - } - - template - using has_mark_begin_execution = - execution::detail::has_mark_begin_execution; - - /////////////////////////////////////////////////////////////////////// - template - struct mark_end_execution_helper - { - template - static void call(hpx::traits::detail::wrap_int, Parameters &&, - Executor &&) - { - } - - template - static auto call(int, Parameters && params, Executor && exec) - -> decltype(params.mark_end_execution(std::forward(exec))) - { - params.mark_end_execution(std::forward(exec)); - } - - template - static void call(Parameters_& params, Executor && exec) - { - call(0, params, std::forward(exec)); - } - - template - static void call(Parameters params, Executor && exec) - { - call(static_cast(params), - std::forward(exec)); - } - }; - - template - void call_mark_end_execution(Parameters && params, Executor && exec) - { - mark_end_execution_helper< - typename hpx::util::decay_unwrap::type - >::call(std::forward(params), - std::forward(exec)); - } - - template - using has_mark_end_execution = - execution::detail::has_mark_end_execution; - - /// \endcond - } - - /////////////////////////////////////////////////////////////////////////// - /// The executor_parameter_traits type is used to manage parameters for - /// an executor. - template - struct executor_parameter_traits - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef Parameters executor_parameters_type; - - /// The compile-time information about whether the number of loop - /// iterations to combine is different for each of the generated chunks. - /// - /// \note This calls extracts parameters_type::has_variable_chunk_size, - /// if available, otherwise it returns std::false_type. - /// - typedef typename detail::extract_has_variable_chunk_size< - executor_parameters_type - >::type has_variable_chunk_size; - - /// Return the number of invocations of the given function \a f which - /// should be combined into a single task - /// - /// \param params [in] The executor parameters object to use for - /// determining the chunk size for the given number of - /// tasks \a num_tasks. - /// \param exec [in] The executor object which will be used - /// for scheduling of the loop iterations. - /// \param f [in] The function which will be optionally scheduled - /// using the given executor. - /// \param cores [in] The number of cores the number of chunks - /// should be determined for. - /// \param num_tasks [in] The number of tasks the chunk size should be - /// determined for - /// - /// \note The parameter \a f is expected to be a nullary function - /// returning a `std::size_t` representing the number of - /// iteration the function has already executed (i.e. which - /// don't have to be scheduled anymore). - /// - template - static std::size_t get_chunk_size(Parameters_ && params, - Executor && exec, F && f, std::size_t cores, std::size_t num_tasks) - { - return detail::call_get_chunk_size(std::forward(params), - std::forward(exec), std::forward(f), cores, num_tasks); - } - - /// Return the largest reasonable number of chunks to create for a - /// single algorithm invocation. - /// - /// \param params [in] The executor parameters object to use for - /// determining the number of chunks for the given - /// number of \a cores. - /// \param exec [in] The executor object which will be used - /// for scheduling of the loop iterations. - /// \param cores [in] The number of cores the number of chunks - /// should be determined for. - /// \param num_tasks [in] The number of tasks the chunk size should be - /// determined for - /// - template - static std::size_t maximal_number_of_chunks( - Parameters_ && params, Executor && exec, std::size_t cores, - std::size_t num_tasks) - { - return detail::call_maximal_number_of_chunks( - std::forward(params), std::forward(exec), - cores, num_tasks); - } - - /// Reset the internal round robin thread distribution scheme for the - /// given executor. - /// - /// \param params [in] The executor parameters object to use for - /// resetting the thread distribution scheme. - /// \param exec [in] The executor object to use. - /// - /// \note This calls params.reset_thread_distribution(exec) if it exists; - /// otherwise it does nothing. - /// - template - static void reset_thread_distribution(Parameters_ && params, - Executor && exec) - { - detail::call_reset_thread_distribution( - std::forward(params), std::forward(exec)); - } - - /// Retrieve the number of (kernel-)threads used by the associated - /// executor. - /// - /// \param params [in] The executor parameters object to use as a - /// fallback if the executor does not expose - /// - /// \note This calls params.processing_units_count() if it exists; - /// otherwise it forwards the request to the executor parameters - /// object. - /// - template - static std::size_t processing_units_count(Parameters_ && params, - Executor && exec) - { - return detail::call_processing_units_parameter_count( - std::forward(params), std::forward(exec)); - } - - /// Mark the begin of a parallel algorithm execution - /// - /// \param params [in] The executor parameters object to use as a - /// fallback if the executor does not expose - /// - /// \note This calls params.mark_begin_execution(exec) if it exists; - /// otherwise it does nothing. - /// - template - static void mark_begin_execution(Parameters_ && params, Executor && exec) - { - detail::call_mark_begin_execution(std::forward(params), - std::forward(exec)); - } - - /// Mark the end of a parallel algorithm execution - /// - /// \param params [in] The executor parameters object to use as a - /// fallback if the executor does not expose - /// - /// \note This calls params.mark_end_execution(exec) if it exists; - /// otherwise it does nothing. - /// - template - static void mark_end_execution(Parameters_ && params, Executor && exec) - { - detail::call_mark_end_execution(std::forward(params), - std::forward(exec)); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // compatibility layer mapping new customization points onto - // executor_information_traits - - // get_chunk_size() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor_parameters::value && - hpx::traits::is_executor::value, - std::size_t - >::type - get_chunk_size(Parameters && params, Executor && exec, F && f, - std::size_t cores, std::size_t num_tasks) - { - typedef typename std::decay::type parameter_type; - return executor_parameter_traits::get_chunk_size( - std::forward(params), std::forward(exec), - std::forward(f), cores, num_tasks); - } - - // maximal_number_of_chunks() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor_parameters::value && - hpx::traits::is_executor::value, - std::size_t - >::type - maximal_number_of_chunks(Parameters && params, Executor && exec, - std::size_t cores, std::size_t num_tasks) - { - typedef typename std::decay::type parameter_type; - return executor_parameter_traits:: - maximal_number_of_chunks(std::forward(params), - std::forward(exec), cores, num_tasks); - } - - // reset_thread_distribution() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor_parameters::value && - hpx::traits::is_executor::value - >::type - reset_thread_distribution(Parameters && params, Executor && exec) - { - typedef typename std::decay::type parameter_type; - return executor_parameter_traits::reset_thread_distribution( - std::forward(params), std::forward(exec)); - } - - // count_processing_units() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor_parameters::value && - hpx::traits::is_executor::value - >::type - count_processing_units(Parameters && params, Executor && exec) - { - typedef typename std::decay::type parameter_type; - return executor_parameter_traits::processing_units_count( - std::forward(params), std::forward(exec)); - } - - // mark_begin_execution() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor_parameters::value && - hpx::traits::is_executor::value - >::type - mark_begin_execution(Parameters && params, Executor && exec) - { - typedef typename std::decay::type parameter_type; - return executor_parameter_traits::mark_begin_execution( - std::forward(params), std::forward(exec)); - } - - // mark_end_execution() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor_parameters::value && - hpx::traits::is_executor::value - >::type - mark_end_execution(Parameters && params, Executor && exec) - { - typedef typename std::decay::type parameter_type; - return executor_parameter_traits::mark_end_execution( - std::forward(params), std::forward(exec)); - } -}}} - -#endif -#endif diff --git a/hpx/parallel/executors/v1/executor_traits.hpp b/hpx/parallel/executors/v1/executor_traits.hpp deleted file mode 100644 index 138f2bfb44e9..000000000000 --- a/hpx/parallel/executors/v1/executor_traits.hpp +++ /dev/null @@ -1,635 +0,0 @@ -// Copyright (c) 2007-2017 Hartmut Kaiser -// Copyright (c) 2015 Daniel Bourgeois -// -// 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) - -/// \file parallel/executors/v1/executor_traits.hpp - -#if !defined(HPX_PARALLEL_EXECUTOR_TRAITS_MAY_10_2015_1128AM) -#define HPX_PARALLEL_EXECUTOR_TRAITS_MAY_10_2015_1128AM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - HPX_STATIC_CONSTEXPR parallel::execution::task_policy_tag task{}; - - /////////////////////////////////////////////////////////////////////////// - namespace detail - { - /// \cond NOINTERNAL - - /////////////////////////////////////////////////////////////////////// - template - struct execution_category - { - typedef parallel::execution::parallel_execution_tag type; - }; - - template - struct execution_category::type> - { - typedef typename Executor::execution_category type; - }; - - /////////////////////////////////////////////////////////////////////// - template - struct future_type - { - typedef hpx::future type; - }; - - template - struct future_type::type - >::type> - { - typedef typename Executor::template future_type::type type; - }; - - /////////////////////////////////////////////////////////////////////// - struct apply_helper - { - template - static void call(hpx::traits::detail::wrap_int, Executor&& exec, - F && f, Ts &&... ts) - { - exec.async_execute(std::forward(f), std::forward(ts)...); - } - - template - static auto call(int, Executor&& exec, F && f, Ts &&... ts) - -> decltype( - exec.post(std::forward(f), std::forward(ts)...) - ) - { - exec.post(std::forward(f), std::forward(ts)...); - } - }; - - template - void call_post(Executor&& exec, F && f, Ts && ... ts) - { - apply_helper::call(0, std::forward(exec), - std::forward(f), std::forward(ts)...); - } - - /////////////////////////////////////////////////////////////////////// - struct execute_helper - { - template - static auto call_impl(Executor&& exec, F && f, std::false_type, - Ts &&... ts) - -> decltype( - hpx::util::invoke(std::forward(f), std::forward(ts)...) - ) - { - try { - typedef typename hpx::util::detail::invoke_deferred_result< - F, Ts... - >::type result_type; - - // older versions of gcc are not able to capture parameter - // packs (gcc < 4.9) - auto && args = - hpx::util::forward_as_tuple(std::forward(ts)...); - - hpx::util::optional out; - auto && wrapper = - [&]() mutable - { - out.emplace(hpx::util::invoke_fused( - std::forward(f), std::move(args))); - }; - - // use async execution, wait for result, propagate exceptions - exec.async_execute(std::ref(wrapper)).get(); - return std::move(*out); - } - catch (std::bad_alloc const& ba) { - throw ba; - } - catch (...) { - throw exception_list(std::current_exception()); - } - } - - template - static void call_impl(Executor&& exec, F && f, std::true_type, - Ts &&... ts) - { - exec.async_execute( - std::forward(f), std::forward(ts)... - ).get(); - } - - template - static auto call(hpx::traits::detail::wrap_int, Executor&& exec, - F && f, Ts &&... ts) - -> decltype( - hpx::util::invoke(std::forward(f), std::forward(ts)...) - ) - { - typedef std::is_void< - typename hpx::util::detail::invoke_deferred_result< - F, Ts... - >::type - > is_void; - return call_impl(std::forward(exec), - std::forward(f), is_void(), std::forward(ts)...); - } - - template - static auto call(int, Executor&& exec, F && f, Ts &&... ts) - -> decltype( - exec.execute(std::forward(f), std::forward(ts)...) - ) - { - return exec.execute(std::forward(f), - std::forward(ts)...); - } - }; - - template - auto call_execute(Executor&& exec, F && f, Ts &&... ts) - -> decltype( - execute_helper::call(0, std::forward(exec), - std::forward(f), std::forward(ts)...) - ) - { - return execute_helper::call(0, std::forward(exec), - std::forward(f), std::forward(ts)...); - } - - /////////////////////////////////////////////////////////////////////// - template - struct bulk_async_execute_result - { - typedef typename - hpx::traits::range_traits::value_type - value_type; - typedef typename - hpx::util::detail::invoke_deferred_result< - F, value_type, Ts... - >::type - type; - }; - - /////////////////////////////////////////////////////////////////////// - struct bulk_async_execute_helper - { - template - static auto - call(hpx::traits::detail::wrap_int, Executor&& exec, F && f, - S const& shape, Ts &&... ts) - -> std::vector::type, - typename bulk_async_execute_result::type - >::type> - { - std::vector::type, - typename bulk_async_execute_result::type - >::type> results; - results.reserve(hpx::util::size(shape)); - - for (auto const& elem: shape) - { - results.push_back(exec.async_execute(f, elem, ts...)); - } - - return results; - } - - template - static auto - call(int, Executor&& exec, F && f, S const& shape, Ts &&... ts) - -> decltype( - exec.bulk_async_execute(std::forward(f), shape, - std::forward(ts)...) - ) - { - return exec.bulk_async_execute(std::forward(f), shape, - std::forward(ts)...); - } - }; - - template - auto call_bulk_async_execute(Executor&& exec, F && f, S const& shape, - Ts &&... ts) - -> decltype( - bulk_async_execute_helper::call(0, std::forward(exec), - std::forward(f), shape, std::forward(ts)...) - ) - { - return bulk_async_execute_helper::call( - 0, std::forward(exec), std::forward(f), shape, - std::forward(ts)...); - } - - /////////////////////////////////////////////////////////////////////// - template - struct bulk_execute_result_impl; - - template - struct bulk_execute_result_impl - { - typedef decltype( - util::unwrap(std::declval::type>())) type; - }; - - template - struct bulk_execute_result_impl - { - typedef void type; - }; - - template - struct bulk_execute_result - : bulk_execute_result_impl::type - >::value, - Ts...> - {}; - - /////////////////////////////////////////////////////////////////////// - template - struct bulk_result_helper - { - typedef std::vector type; - }; - - template <> - struct bulk_result_helper - { - typedef void type; - }; - - struct bulk_execute_helper - { - // returns void if F returns void - template - static auto call(hpx::traits::detail::wrap_int, Executor&& exec, - F && f, S const& shape, Ts &&... ts) - -> typename bulk_result_helper::type - { - std::vector::type, - typename bulk_async_execute_result::type - >::type> results; - results.reserve(hpx::util::size(shape)); - - try { - for (auto const& elem: shape) - { - results.push_back(exec.async_execute(f, elem, ts...)); - } - return hpx::util::unwrap(results); - } - catch (std::bad_alloc const& ba) { - throw ba; - } - catch (...) { - throw exception_list(std::current_exception()); - } - } - - template - static auto - call(int, Executor&& exec, F && f, S const& shape, Ts &&... ts) - -> decltype( - std::declval().bulk_execute(std::forward(f), shape, - std::forward(ts)...) - ) - { - return exec.bulk_execute(std::forward(f), shape, - std::forward(ts)...); - } - }; - - template - auto call_bulk_execute(Executor&& exec, F && f, S const& shape, Ts &&... ts) - -> decltype( - bulk_execute_helper::call(0, std::forward(exec), - std::forward(f), shape, std::forward(ts)...) - ) - { - return bulk_execute_helper::call(0, std::forward(exec), - std::forward(f), shape, std::forward(ts)...); - } - /// \endcond - } - - /////////////////////////////////////////////////////////////////////////// - /// The executor_traits type is used to request execution agents from an - /// executor. It is analogous to the interaction between containers and - /// allocator_traits. - /// - /// \note For maximum implementation flexibility, executor_traits does not - /// require executors to implement a particular exception reporting - /// mechanism. Executors may choose whether or not to report - /// exceptions, and if so, in what manner they are communicated back - /// to the caller. However, we expect many executors to report - /// exceptions in a manner consistent with the behavior of execution - /// policies described by the Parallelism TS, where multiple exceptions - /// are collected into an exception_list. This list would be reported - /// through async_execute()'s returned future, or thrown directly by - /// execute(). - /// - template - struct executor_traits - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef Executor executor_type; - - /// The category of agents created by the bulk-form execute() and - /// async_execute() - /// - /// \note This evaluates to executor_type::execution_category if it - /// exists; otherwise it evaluates to \a parallel_execution_tag. - /// - typedef typename detail::execution_category::type - execution_category; - - /// The type of future returned by async_execute() - /// - /// \note This evaluates to executor_type::future_type if it exists; - /// otherwise it evaluates to \a hpx::future - /// - template - struct future - { - /// The future type returned from async_execute - typedef typename detail::future_type::type type; - }; - - /// \brief Singleton form of asynchronous fire & forget execution agent - /// creation. - /// - /// This asynchronously (fire & forget) creates a single function - /// invocation f() using the associated executor. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \note This calls exec.post(f, ts...), if available, otherwise - /// it calls exec.async_execute() while discarding the returned - /// future - /// - template - static void apply_execute(Executor_ && exec, F && f, Ts &&... ts) - { - detail::call_post(std::forward(exec), - std::forward(f), std::forward(ts)...); - } - - /// \brief Singleton form of asynchronous execution agent creation. - /// - /// This asynchronously creates a single function invocation f() using - /// the associated executor. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \note Executors have to implement only `async_execute()`. All other - /// functions will be emulated by this `executor_traits` in terms - /// of this single basic primitive. However, some executors will - /// naturally specialize all operations for maximum efficiency. - /// - /// \note This calls exec.async_execute(f) - /// - /// \returns f(ts...)'s result through a future - /// - template - static auto async_execute(Executor_ && exec, F && f, Ts &&... ts) - -> decltype( - std::declval().async_execute(std::forward(f), - std::forward(ts)...) - ) - { - return exec.async_execute(std::forward(f), std::forward(ts)...); - } - - /// \brief Singleton form of synchronous execution agent creation. - /// - /// This synchronously creates a single function invocation f() using - /// the associated executor. The execution of the supplied function - /// synchronizes with the caller - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result - /// - /// \note This calls exec.execute(f) if it exists; - /// otherwise hpx::async(f).get() - /// - template - static auto execute(Executor_ && exec, F && f, Ts &&...ts) - -> decltype( - detail::call_execute(std::forward(exec), - std::forward(f), std::forward(ts)...) - ) - { - return detail::call_execute(std::forward(exec), - std::forward(f), std::forward(ts)...); - } - - /// \brief Bulk form of asynchronous execution agent creation - /// - /// This asynchronously creates a group of function invocations f(i) - /// whose ordering is given by the execution_category associated with - /// the executor. - /// - /// Here \a i takes on all values in the index space implied by shape. - /// All exceptions thrown by invocations of f(i) are reported in a - /// manner consistent with parallel algorithm execution through the - /// returned future. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param shape [in] The shape objects which defines the iteration - /// boundaries for the arguments to be passed to \a f. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \returns The return type of \a executor_type::async_execute if - /// defined by \a executor_type. Otherwise a vector - /// of futures holding the returned value of each invocation - /// of \a f. - /// - /// \note This calls exec.async_execute(f, shape) if it exists; - /// otherwise it executes hpx::async(f, i) as often as needed. - /// - template - static auto - bulk_async_execute(Executor_ && exec, F && f, Shape const& shape, - Ts &&... ts) - -> decltype( - detail::call_bulk_async_execute(std::forward(exec), - std::forward(f), shape, std::forward(ts)...) - ) - { - return detail::call_bulk_async_execute( - std::forward(exec), std::forward(f), shape, - std::forward(ts)...); - } - - /// \brief Bulk form of synchronous execution agent creation - /// - /// This synchronously creates a group of function invocations f(i) - /// whose ordering is given by the execution_category associated with - /// the executor. The function synchronizes the execution of all - /// scheduled functions with the caller. - /// - /// Here \a i takes on all values in the index space implied by shape. - /// All exceptions thrown by invocations of f(i) are reported in a - /// manner consistent with parallel algorithm execution through the - /// returned future. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param shape [in] The shape objects which defines the iteration - /// boundaries for the arguments to be passed to \a f. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \returns The return type of \a executor_type::execute if defined - /// by \a executor_type. Otherwise a vector holding the - /// returned value of each invocation of \a f except when - /// \a f returns void, which case void is returned. - /// - /// \note This calls exec.execute(f, shape) if it exists; - /// otherwise it executes hpx::async(f, i) as often as needed. - /// - template - static auto - bulk_execute(Executor_ && exec, F && f, Shape const& shape, Ts &&... ts) - -> decltype( - detail::call_bulk_execute(std::forward(exec), - std::forward(f), shape, std::forward(ts)...) - ) - { - return detail::call_bulk_execute(std::forward(exec), - std::forward(f), shape, std::forward(ts)...); - } - }; - - /////////////////////////////////////////////////////////////////////////// - /// 1. The type is_executor can be used to detect executor types - /// for the purpose of excluding function signatures - /// from otherwise ambiguous overload resolution participation. - /// 2. If T is the type of a standard or implementation-defined executor, - /// is_executor shall be publicly derived from - /// integral_constant, otherwise from - /// integral_constant. - /// 3. The behavior of a program that adds specializations for - /// is_executor is undefined. - /// - template - struct is_executor; // defined in hpx/traits/v1/is_executor.hpp - - /////////////////////////////////////////////////////////////////////////// - // compatibility layer mapping new customization points onto executor_traits - - // async_execute() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor::value, - hpx::lcos::future< - typename hpx::util::detail::invoke_deferred_result::type - > - >::type - async_execute(Executor && exec, F && f, Ts &&... ts) - { - typedef typename std::decay::type executor_type; - return executor_traits::async_execute( - std::forward(exec), std::forward(f), - std::forward(ts)...); - } - - // sync_execute() - template - HPX_FORCEINLINE - typename std::enable_if< - hpx::traits::is_executor::value, - typename hpx::util::detail::invoke_deferred_result::type - >::type - sync_execute(Executor && exec, F && f, Ts &&... ts) - { - typedef typename std::decay::type executor_type; - return executor_traits::execute( - std::forward(exec), std::forward(f), - std::forward(ts)...); - } - - // bulk_async_execute() - template - typename std::enable_if< - hpx::traits::is_executor::value, - std::vector::type - > > - >::type - bulk_async_execute(Executor && exec, F && f, Shape const& shape, Ts &&... ts) - { - typedef typename std::decay::type executor_type; - return executor_traits::bulk_async_execute( - std::forward(exec), std::forward(f), shape, - std::forward(ts)...); - } -}}} - -#endif - -#endif diff --git a/hpx/parallel/executors/v1/thread_executor_information_traits.hpp b/hpx/parallel/executors/v1/thread_executor_information_traits.hpp deleted file mode 100644 index 1ef595119e32..000000000000 --- a/hpx/parallel/executors/v1/thread_executor_information_traits.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// 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) - -/// \file parallel/executors/v1/thread_executor_information_traits.hpp - -#if !defined(HPX_PARALLEL_THREAD_EXECUTOR_INFORMATION_TRAITS_AUG_26_2015_1141AM) -#define HPX_PARALLEL_THREAD_EXECUTOR_INFORMATION_TRAITS_AUG_26_2015_1141AM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include - -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - /// Specialization for executor_traits for types which conform to - /// traits::is_threads_executor - template - struct executor_information_traits::value - >::type> - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef Executor executor_type; - - /// Retrieve the number of (kernel-)threads used by the associated - /// executor. All threads::executors invoke - /// hpx::get_os_thread_count(sched). - /// - /// \param sched [in] The executor object to use for the number of - /// os-threads used to schedule tasks. - /// - /// \note This calls exec.os_thread_count() if it exists; - /// otherwise it executes hpx::get_os_thread_count(). - /// - template - static std::size_t processing_units_count(executor_type const& sched, - Parameters&) - { - return hpx::get_os_thread_count(sched); - } - - /// Retrieve whether this executor has operations pending or not. - /// All threads::executors invoke sched.num_pending_closures(). - /// - /// \param sched [in] The executor object to use for querying the - /// number of pending tasks. - /// - static bool has_pending_closures(executor_type const& sched) - { - return sched.num_pending_closures(); - } - - /// Retrieve the bitmask describing the processing units the given - /// thread is allowed to run on - /// All threads::executors invoke sched.get_pu_mask(). - /// - /// \param sched [in] The executor object to use for querying the - /// number of pending tasks. - /// - static threads::mask_cref_type get_pu_mask(executor_type const& sched, - threads::topology& topo, std::size_t thread_num) - { - return sched.get_pu_mask(topo, thread_num); - } - - /// Set various modes of operation on the scheduler underneath the - /// given executor. - /// - /// \param params [in] The executor parameters object to use for - /// resetting the thread distribution scheme. - /// \param sched [in] The executor object to use. - /// - template - static void set_scheduler_mode(executor_type& sched, Mode mode) - { - sched.set_scheduler_mode( - static_cast(mode) - ); - } - }; -}}} - -#endif -#endif diff --git a/hpx/parallel/executors/v1/thread_executor_parameter_traits.hpp b/hpx/parallel/executors/v1/thread_executor_parameter_traits.hpp deleted file mode 100644 index c052c9d81222..000000000000 --- a/hpx/parallel/executors/v1/thread_executor_parameter_traits.hpp +++ /dev/null @@ -1,166 +0,0 @@ -// 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) - -/// \file parallel/executors/v1/executor_parameter_traits.hpp - -#if !defined(HPX_PARALLEL_THREAD_EXECUTOR_PARAMETER_TRAITS_AUG_26_2015_1204PM) -#define HPX_PARALLEL_THREAD_EXECUTOR_PARAMETER_TRAITS_AUG_26_2015_1204PM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - template - struct executor_parameter_traits::value - >::type> - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef Parameters executor_parameters_type; - - /// The compile-time information about whether the number of loop - /// iterations to combine is different for each of the generated chunks. - /// - /// \note This calls extracts parameters_type::has_variable_chunk_size, - /// if available, otherwise it returns std::false_type. - /// - typedef typename detail::extract_has_variable_chunk_size< - executor_parameters_type - >::type has_variable_chunk_size; - - /// Return the number of invocations of the given function \a f which - /// should be combined into a single task - /// - /// \param params [in] The executor parameters object to use for - /// determining the chunk size for the given number of - /// tasks \a num_tasks. - /// \param sched [in] The executor object which will be used - /// for scheduling of the loop iterations. - /// \param f [in] The function which will be optionally scheduled - /// using the given executor. - /// \param cores [in] The number of cores the number of chunks - /// should be determined for. - /// \param num_tasks [in] The number of tasks the chunk size should be - /// determined for - /// - /// \note The parameter \a f is expected to be a nullary function - /// returning a `std::size_t` representing the number of - /// iteration the function has already executed (i.e. which - /// don't have to be scheduled anymore). - /// - template - static std::size_t get_chunk_size(Parameters_ && params, - Executor && sched, F && f, std::size_t cores, std::size_t num_tasks) - { - return detail::call_get_chunk_size( - std::forward(params), std::forward(sched), - std::forward(f), cores, num_tasks); - } - - /// Return the largest reasonable number of chunks to create for a - /// single algorithm invocation. - /// - /// \param params [in] The executor parameters object to use for - /// determining the number of chunks for the given - /// number of \a cores. - /// \param exec [in] The executor object which will be used used - /// for scheduling of the the loop iterations. - /// \param cores [in] The number of cores the number of chunks - /// should be determined for. - /// \param num_tasks [in] The number of tasks the chunk size should be - /// determined for - /// - template - static std::size_t maximal_number_of_chunks( - Parameters_ && params, Executor && sched, std::size_t cores, - std::size_t num_tasks) - { - return detail::call_maximal_number_of_chunks( - std::forward(params), std::forward(sched), - cores, num_tasks); - } - - /// Reset the internal round robin thread distribution scheme for the - /// given executor. - /// - /// \param params [in] The executor parameters object to use for - /// resetting the thread distribution scheme. - /// \param sched [in] The executor object to use. - /// - template - static void reset_thread_distribution(Parameters_ &&, - Executor && sched) - { - sched.reset_thread_distribution(); - } - - /// Retrieve the number of (kernel-)threads used by the associated - /// executor. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param params [in] The executor parameters object to use as a - /// fallback if the executor does not expose - /// - /// \note This calls exec.processing_units_count() if it exists; - /// otherwise it forwards teh request to the executor parameters - /// object. - /// - template - static std::size_t processing_units_count(Parameters_ && params, - Executor && exec) - { - return detail::call_processing_units_parameter_count( - std::forward(params), - std::forward(exec)); - } - - /// Mark the begin of a parallel algorithm execution - /// - /// \param params [in] The executor parameters object to use as a - /// fallback if the executor does not expose - /// - /// \note This calls params.mark_begin_execution(exec) if it exists; - /// otherwise it does nothing. - /// - template - static void mark_begin_execution(Parameters_ && params) - { - detail::call_mark_begin_execution( - std::forward(params)); - } - - /// Mark the end of a parallel algorithm execution - /// - /// \param params [in] The executor parameters object to use as a - /// fallback if the executor does not expose - /// - /// \note This calls params.mark_end_execution(exec) if it exists; - /// otherwise it does nothing. - /// - template - static void mark_end_execution(Parameters_ && params) - { - detail::call_mark_end_execution(std::forward(params)); - } - }; -}}} - -#endif -#endif diff --git a/hpx/parallel/executors/v1/thread_executor_traits.hpp b/hpx/parallel/executors/v1/thread_executor_traits.hpp deleted file mode 100644 index 024ba62844a5..000000000000 --- a/hpx/parallel/executors/v1/thread_executor_traits.hpp +++ /dev/null @@ -1,306 +0,0 @@ -// 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) - -/// \file parallel/executors/v1/thread_executor_traits.hpp - -#if !defined(HPX_PARALLEL_THREAD_EXECUTOR_TRAITS_AUG_07_2015_0826AM) -#define HPX_PARALLEL_THREAD_EXECUTOR_TRAITS_AUG_07_2015_0826AM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - /// Specialization for executor_traits for types which conform to - /// traits::is_threads_executor - template - struct executor_traits::value - >::type> - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef Executor executor_type; - - /// The category of agents created by the bulk-form execute() and - /// async_execute(). All threads::executors create parallel execution - /// agents - /// - typedef parallel_execution_tag execution_category; - - /// The type of future returned by async_execute(). All - /// threads::executors return hpx::future. - /// - template - struct future - { - typedef hpx::future type; - }; - - /// \brief Singleton form of asynchronous fire & forget execution agent - /// creation. - /// - /// This asynchronously (fire & forget) creates a single function - /// invocation f() using the associated executor. All - /// threads::executors invoke hpx::apply(sched, f). - /// - /// \param sched [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - template - static void post(Executor_ && sched, F && f, Ts &&... ts) - { - sched.add( - util::deferred_call( - std::forward(f), std::forward(ts)...), - "hpx::parallel::v3::thread_executor_traits::post"); - } - - /// \brief Singleton form of asynchronous execution agent creation. - /// - /// This asynchronously creates a single function invocation f() using - /// the associated executor. All threads::executors invoke - /// hpx::async(sched, f). - /// - /// \param sched [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result through a future - /// - template - static hpx::future< - typename hpx::util::detail::invoke_deferred_result::type - > - async_execute(Executor_ && sched, F && f, Ts &&... ts) - { - typedef typename util::detail::invoke_deferred_result::type - result_type; - - lcos::local::futures_factory p( - std::forward(sched), - util::deferred_call(std::forward(f), std::forward(ts)...)); - p.apply(); - return p.get_future(); - } - - /// \brief Singleton form of synchronous execution agent creation. - /// - /// This synchronously creates a single function invocation f() using - /// the associated executor. The execution of the supplied function - /// synchronizes with the caller. All threads::executors invoke - /// hpx::async(sched, f).get(). - /// - /// \param sched [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result through a future - /// - template - static typename hpx::util::detail::invoke_deferred_result::type - execute(Executor_ && sched, F && f, Ts &&... ts) - { - return async_execute(std::forward(sched), - std::forward(f), std::forward(ts)...).get(); - } - - /// \brief Bulk form of asynchronous execution agent creation - /// - /// This asynchronously creates a group of function invocations f(i) - /// whose ordering is given by the execution_category associated with - /// the executor. - /// - /// Here \a i takes on all values in the index space implied by shape. - /// All exceptions thrown by invocations of f(i) are reported in a - /// manner consistent with parallel algorithm execution through the - /// returned future. - /// - /// \param sched [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param shape [in] The shape objects which defines the iteration - /// boundaries for the arguments to be passed to \a f. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns The return type of \a executor_type::async_execute if - /// defined by \a executor_type. Otherwise a vector - /// of futures holding the returned value of each invocation - /// of \a f. - /// - template - static std::vector::type - > > - bulk_async_execute(Executor_ && sched, F && f, Shape const& shape, - Ts &&... ts) - { - std::vector::type - > > results; - std::size_t size = hpx::util::size(shape); - results.resize(size); - - static std::size_t num_tasks = - (std::min)(std::size_t(128), hpx::get_os_thread_count()); - - spawn(sched, results, 0, size, num_tasks, f, hpx::util::begin(shape), - ts...).get(); - - return results; - } - - /// \cond NOINTERNAL - template - static hpx::future - spawn(Executor_& sched, std::vector >& results, - std::size_t base, std::size_t size, std::size_t num_tasks, - F const& func, Iter it, Ts const&... ts) - { - const std::size_t num_spread = 4; - - if (size > num_tasks) - { - // spawn hierarchical tasks - std::size_t chunk_size = (size + num_spread) / num_spread - 1; - chunk_size = (std::max)(chunk_size, num_tasks); - - std::vector > tasks; - tasks.reserve(num_spread); - - hpx::future (*spawn_func)( - Executor_&, std::vector >&, - std::size_t, std::size_t, std::size_t, F const&, Iter, - Ts const&... - ) = &executor_traits::spawn; - - while (size != 0) - { - std::size_t curr_chunk_size = (std::min)(chunk_size, size); - - hpx::future f = async_execute(sched, - spawn_func, std::ref(sched), std::ref(results), base, - curr_chunk_size, num_tasks, std::ref(func), it, - std::ref(ts)...); - tasks.push_back(std::move(f)); - - base += curr_chunk_size; - it = hpx::parallel::v1::detail::next(it, curr_chunk_size); - size -= curr_chunk_size; - } - - HPX_ASSERT(size == 0); - - return hpx::when_all(tasks); - } - - // spawn all tasks sequentially - HPX_ASSERT(base + size <= results.size()); - - for (std::size_t i = 0; i != size; ++i, ++it) - { - results[base + i] = async_execute(sched, func, *it, ts...); - } - - return hpx::make_ready_future(); - } - /// \endcond - - /// \brief Bulk form of synchronous execution agent creation - /// - /// This synchronously creates a group of function invocations f(i) - /// whose ordering is given by the execution_category associated with - /// the executor. The function synchronizes the execution of all - /// scheduled functions with the caller. - /// - /// Here \a i takes on all values in the index space implied by shape. - /// All exceptions thrown by invocations of f(i) are reported in a - /// manner consistent with parallel algorithm execution through the - /// returned future. - /// - /// \param sched [in] The executor object to use for scheduling of the - /// function \a f. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param shape [in] The shape objects which defines the iteration - /// boundaries for the arguments to be passed to \a f. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns The return type of \a executor_type::execute if defined - /// by \a executor_type. Otherwise a vector holding the - /// returned value of each invocation of \a f except when - /// \a f returns void, which case void is returned. - /// - template - static typename detail::bulk_execute_result::type - bulk_execute(Executor_ && sched, F && f, Shape const& shape, - Ts &&... ts) - { - std::vector::type - > > results; - - for (auto const& elem: shape) - { - results.push_back(async_execute(sched, std::forward(f), - elem, ts...)); - } - - return hpx::util::unwrap(results); - } - - /// Retrieve whether this executor has operations pending or not. - /// All threads::executors invoke sched.num_pending_closures(). - /// - /// \param sched [in] The executor object to use for querying the - /// number of pending tasks. - /// - template - static bool has_pending_closures(Executor_ && sched) - { - return sched.num_pending_closures() != 0; - } - }; -}}} - -#endif - -#endif diff --git a/hpx/parallel/executors/v1/thread_timed_executor_traits.hpp b/hpx/parallel/executors/v1/thread_timed_executor_traits.hpp deleted file mode 100644 index 9ec6e17ecedb..000000000000 --- a/hpx/parallel/executors/v1/thread_timed_executor_traits.hpp +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright (c) 2007-2015 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) - -/// \file parallel/executors/v1/thread_timed_executor_traits.hpp - -#if !defined(HPX_PARALLEL_THREAD_TIMED_EXECUTOR_TRAITS_AUG_07_2015_0328PM) -#define HPX_PARALLEL_THREAD_TIMED_EXECUTOR_TRAITS_AUG_07_2015_0328PM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - /// The timed_executor_traits type is used to request execution agents from - /// an executor. It is analogous to the interaction between containers and - /// allocator_traits. The generated execution agents support - /// timed scheduling functionality (in addition to what is supported - /// execution agents generated using execution_traits type). - /// - /// This is the specialization for threads::executor types - /// - template - struct timed_executor_traits::value - >::type> - : executor_traits - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef typename executor_traits::executor_type - executor_type; - - /// The category of agents created by the bulk-form execute() and - /// async_execute() - /// - typedef typename executor_traits::execution_category - execution_category; - - /// The type of future returned by async_execute(). All - /// threads::executors return hpx::future. - /// - template - struct future - { - typedef hpx::future type; - }; - - /// \brief Singleton form of asynchronous fire & forget execution agent - /// creation supporting timed execution. - /// - /// This asynchronously (fire & forget) creates a single function - /// invocation f() using the associated executor at the given point in - /// time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param abs_time [in] The point in time the given function should be - /// scheduled at to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \note This calls exec.post_at(abs_time, f), if available, - /// otherwise it emulates timed scheduling by delaying calling - /// exec.post() on the underlying non-scheduled - /// execution agent while discarding the returned future. - /// - template - static void apply_execute_at(Executor_ && sched, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - sched.add_at(abs_time, - hpx::util::deferred_call( - std::forward(f), std::forward(ts)...), - "post_at"); - } - - /// \brief Singleton form of asynchronous fire & forget execution agent - /// creation supporting timed execution. - /// - /// This asynchronously (fire & forget) creates a single function - /// invocation f() using the associated executor after the given amount - /// of time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param rel_time [in] The duration of time after which the given - /// function should be scheduled to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - template - static void apply_execute_after(Executor_ && sched, - hpx::util::steady_duration const& rel_time, F && f, Ts &&... ts) - { - sched.add_after(rel_time, - hpx::util::deferred_call( - std::forward(f), std::forward(ts)...), - "post_at"); - } - - /// \brief Singleton form of asynchronous execution agent creation - /// supporting timed execution. - /// - /// This asynchronously creates a single function invocation f() using - /// the associated executor at the given point in time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param abs_time [in] The point in time the given function should be - /// scheduled at to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result through a future - /// - template - static hpx::future< - typename hpx::util::detail::invoke_deferred_result::type - > - async_execute_at(Executor_ && sched, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - typedef typename hpx::util::detail::invoke_deferred_result< - F, Ts... - >::type result_type; - - lcos::local::packaged_task - task(std::forward(f)); - - hpx::future result = task.get_future(); - sched.add_at(abs_time, - hpx::util::deferred_call( - std::move(task), std::forward(ts)...), - "async_execute_at"); - return result; - } - - /// \brief Singleton form of asynchronous execution agent creation - /// supporting timed execution. - /// - /// This asynchronously creates a single function invocation f() using - /// the associated executor after the given amount of time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param rel_time [in] The duration of time after which the given - /// function should be scheduled to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result through a future - /// - template - static hpx::future< - typename hpx::util::detail::invoke_deferred_result::type - > - async_execute_after(Executor_ && sched, - hpx::util::steady_duration const& rel_time, F && f, Ts &&... ts) - { - typedef typename hpx::util::detail::invoke_deferred_result< - F, Ts... - >::type result_type; - - lcos::local::packaged_task - task(std::forward(f)); - - hpx::future result = task.get_future(); - sched.add_after(rel_time, - hpx::util::deferred_call( - std::move(task), std::forward(ts)...), - "async_execute_after"); - return result; - } - - /// \brief Singleton form of synchronous execution agent creation - /// supporting timed execution. - /// - /// This synchronously creates a single function invocation f() using - /// the associated executor at the given point in time. The execution - /// of the supplied function synchronizes with the caller. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param abs_time [in] The point in time the given function should be - /// scheduled at to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result - /// - template - static typename hpx::util::detail::invoke_deferred_result::type - execute_at(Executor_ && sched, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - return async_execute_at(std::forward(sched), abs_time, - std::forward(f), std::forward(ts)...).get(); - } - - /// \brief Singleton form of synchronous execution agent creation - /// supporting timed execution. - /// - /// This synchronously creates a single function invocation f() using - /// the associated executor after the given amount of time. The - /// execution of the supplied function synchronizes with the caller. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param rel_time [in] The duration of time after which the given - /// function should be scheduled to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts... [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result - /// - template - static typename hpx::util::detail::invoke_deferred_result::type - execute_after(Executor_ && sched, - hpx::util::steady_duration const& rel_time, F && f, Ts &&... ts) - { - return async_execute_after(std::forward(sched), rel_time, - std::forward(f), std::forward(ts)...).get(); - } - }; -}}} - -#endif -#endif diff --git a/hpx/parallel/executors/v1/timed_executor_traits.hpp b/hpx/parallel/executors/v1/timed_executor_traits.hpp deleted file mode 100644 index 1ee773c86ee1..000000000000 --- a/hpx/parallel/executors/v1/timed_executor_traits.hpp +++ /dev/null @@ -1,574 +0,0 @@ -// Copyright (c) 2007-2016 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) - -/// \file parallel/executors/v1/timed_executor_traits.hpp - -#if !defined(HPX_PARALLEL_TIMED_EXECUTOR_TRAITS_AUG_04_2015_0525PM) -#define HPX_PARALLEL_TIMED_EXECUTOR_TRAITS_AUG_04_2015_0525PM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - namespace detail - { - /// \cond NOINTERNAL - - /////////////////////////////////////////////////////////////////////// - template - struct post_at_helper - { - template - void operator()(hpx::future && fut, Executor& exec, F && f, - Ts &&... ts) const - { - fut.get(); // rethrow exceptions - call_post(exec, std::forward(f), - std::forward(ts)...); - } - - template - static void call(hpx::traits::detail::wrap_int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - make_ready_future_at(abs_time) - .then( - hpx::launch::sync, - hpx::util::bind( - hpx::util::one_shot(post_at_helper()), - hpx::util::placeholders::_1, std::ref(exec), - hpx::util::deferred_call( - std::forward(f), std::forward(ts)... - ) - ) - ); - } - - template - static auto call(int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - exec.post_at(abs_time, std::forward(f), - std::forward(ts)...) - ) - { - return exec.post_at(abs_time, std::forward(f), - std::forward(ts)...); - } - }; - - template <> - struct post_at_helper - { - template - static void call(hpx::traits::detail::wrap_int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - this_thread::sleep_until(abs_time); - call_post(std::forward(exec), - std::forward(f), std::forward(ts)...); - } - - template - static auto call(int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype(exec.post_at(abs_time, std::forward(f))) - { - exec.post_at(abs_time, std::forward(f), - std::forward(ts)...); - } - }; - - template - void call_post_at(Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - typedef typename detail::execution_category< - typename hpx::util::decay::type - >::type tag; - return post_at_helper::call(0, - std::forward(exec), abs_time, - std::forward(f), std::forward(ts)...); - } - - /////////////////////////////////////////////////////////////////////// - template - struct async_execute_at_helper - { - template - auto operator()(hpx::future && fut, Executor& exec, F && f, - Ts &&... ts) const - -> decltype( - exec.async_execute(std::forward(f), - std::forward(ts)...) - ) - { - fut.get(); // rethrow exceptions - return exec.async_execute(std::forward(f), - std::forward(ts)...); - } - - template - static auto call(hpx::traits::detail::wrap_int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - exec.async_execute(std::forward(f), - std::forward(ts)...) - ) - { - return make_ready_future_at(abs_time) - .then( - hpx::launch::sync, - hpx::util::bind( - hpx::util::one_shot(async_execute_at_helper()), - hpx::util::placeholders::_1, std::ref(exec), - hpx::util::deferred_call( - std::forward(f), std::forward(ts)... - ) - ) - ); - } - - template - static auto call(int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - exec.async_execute_at(abs_time, std::forward(f), - std::forward(ts)...) - ) - { - return exec.async_execute_at(abs_time, std::forward(f), - std::forward(ts)...); - } - }; - - template <> - struct async_execute_at_helper - { - template - static auto call(hpx::traits::detail::wrap_int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - exec.async_execute(std::forward(f), - std::forward(ts)...) - ) - { - this_thread::sleep_until(abs_time); - return exec.async_execute(std::forward(f), - std::forward(ts)...); - } - - template - static auto call(int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - exec.async_execute_at(abs_time, std::forward(f), - std::forward(ts)...) - ) - { - return exec.async_execute_at(abs_time, std::forward(f), - std::forward(ts)...); - } - }; - - template - auto call_async_execute_at(Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - -> decltype( - async_execute_at_helper< - typename detail::execution_category< - typename hpx::util::decay::type - >::type - >::call(0, std::forward(exec), abs_time, - std::forward(f), std::forward(ts)...) - ) - { - typedef typename detail::execution_category< - typename hpx::util::decay::type - >::type tag; - return async_execute_at_helper::call(0, - std::forward(exec), abs_time, - std::forward(f), std::forward(ts)...); - } - - /////////////////////////////////////////////////////////////////////// - template - struct execute_at_helper - { - template - auto operator()(hpx::future && fut, Executor& exec, F && f, - Ts &&... ts) const - -> decltype( - call_execute(exec, std::forward(f), - std::forward(ts)...) - ) - { - fut.get(); // rethrow exceptions - return call_execute(std::forward(exec), - std::forward(f), std::forward(ts)...); - } - - template - static auto call(hpx::traits::detail::wrap_int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - call_execute(std::forward(exec), - std::forward(f), std::forward(ts)...) - ) - { - return make_ready_future_at(abs_time) - .then( - hpx::launch::sync, - hpx::util::bind( - hpx::util::one_shot(execute_at_helper()), - hpx::util::placeholders::_1, std::ref(exec), - hpx::util::deferred_call( - std::forward(f), std::forward(ts)... - ) - ) - ).get(); - } - - template - static auto call(int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - exec.execute_at(abs_time, std::forward(f), - std::forward(ts)...) - ) - { - return exec.execute_at(abs_time, std::forward(f), - std::forward(ts)...); - } - }; - - template <> - struct execute_at_helper - { - template - static auto call(hpx::traits::detail::wrap_int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - call_execute(std::forward(exec), - std::forward(f), std::forward(ts)...)) - { - this_thread::sleep_until(abs_time); - return call_execute(std::forward(exec), - std::forward(f), std::forward(ts)...); - } - - template - static auto call(int, Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - exec.execute_at(abs_time, std::forward(f), - std::forward(ts)...)) - { - return exec.execute_at(abs_time, std::forward(f), - std::forward(ts)...); - } - }; - - template - auto call_execute_at(Executor && exec, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - -> decltype( - execute_at_helper< - typename detail::execution_category< - typename hpx::util::decay::type - >::type - >::call(0, std::forward(exec), abs_time, - std::forward(f), std::forward(ts)...) - ) - { - typedef typename detail::execution_category< - typename hpx::util::decay::type - >::type tag; - return execute_at_helper::call(0, std::forward(exec), - abs_time, std::forward(f), std::forward(ts)...); - } - - /// \endcond - } - - /////////////////////////////////////////////////////////////////////////// - /// The timed_executor_traits type is used to request execution agents from - /// an executor. It is analogous to the interaction between containers and - /// allocator_traits. The generated execution agents support - /// timed scheduling functionality (in addition to what is supported - /// execution agents generated using execution_traits type). - /// - template - struct timed_executor_traits : executor_traits - { - /// The type of the executor associated with this instance of - /// \a executor_traits - typedef typename executor_traits::executor_type - executor_type; - - /// The category of agents created by the bulk-form execute() and - /// async_execute() - /// - /// \note This evaluates to executor_type::execution_category if it - /// exists; otherwise it evaluates to \a parallel_execution_tag. - /// - typedef typename executor_traits::execution_category - execution_category; - - /// The type of future returned by async_execute() - /// - /// \note This evaluates to executor_type::future_type if it exists; - /// otherwise it evaluates to \a hpx::future - /// - template - struct future - { - /// The future type returned from async_execute - typedef typename detail::future_type::type type; - }; - - /// \brief Singleton form of asynchronous fire & forget execution agent - /// creation supporting timed execution. - /// - /// This asynchronously (fire & forget) creates a single function - /// invocation f() using the associated executor at the given point in - /// time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param abs_time [in] The point in time the given function should be - /// scheduled at to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \note This calls exec.post_at(abs_time, f), if available, - /// otherwise it emulates timed scheduling by delaying calling - /// exec.post() on the underlying non-scheduled - /// execution agent while discarding the returned future. - /// - template - static void apply_execute_at(Executor_ && exec, - hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - detail::call_post_at(std::forward(exec), - abs_time, std::forward(f), std::forward(ts)...); - } - - /// \brief Singleton form of asynchronous fire & forget execution agent - /// creation supporting timed execution. - /// - /// This asynchronously (fire & forget) creates a single function - /// invocation f() using the associated executor after the given amount - /// of time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param rel_time [in] The duration of time after which the given - /// function should be scheduled to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \note This calls exec.post_at(abs_time, f), if available, - /// otherwise it emulates timed scheduling by delaying calling - /// exec.post() on the underlying non-scheduled - /// execution agent while discarding the returned future. - /// - template - static void apply_execute_after(Executor_ && exec, - hpx::util::steady_duration const& rel_time, F && f, Ts &&... ts) - { - detail::call_post_at(std::forward(exec), - rel_time.from_now(), std::forward(f), std::forward(ts)...); - } - - /// \brief Singleton form of asynchronous execution agent creation - /// supporting timed execution. - /// - /// This asynchronously creates a single function invocation f() using - /// the associated executor at the given point in time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param abs_time [in] The point in time the given function should be - /// scheduled at to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \note This calls exec.async_execute_at(abs_time, f), if available, - /// otherwise it emulates timed scheduling by delaying calling - /// exec.async_execute() on the underlying non-scheduled - /// execution agent. - /// - /// \returns f(ts...)'s result through a future - /// - template - static auto async_execute_at(Executor_ && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - detail::call_async_execute_at(std::forward(exec), - abs_time, std::forward(f), std::forward(ts)...) - ) - { - return detail::call_async_execute_at(std::forward(exec), - abs_time, std::forward(f), std::forward(ts)...); - } - - /// \brief Singleton form of asynchronous execution agent creation - /// supporting timed execution. - /// - /// This asynchronously creates a single function invocation f() using - /// the associated executor after the given amount of time. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param rel_time [in] The duration of time after which the given - /// function should be scheduled to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \note This calls exec.async_execute_at(abs_time, f), if available, - /// otherwise it emulates timed scheduling by delaying calling - /// exec.async_execute() on the underlying non-scheduled - /// execution agent. - /// - /// \returns f(ts...)'s result through a future - /// - template - static auto async_execute_after(Executor_ && exec, - hpx::util::steady_duration const& rel_time, F && f, - Ts &&... ts) - -> decltype( - detail::call_async_execute_at(std::forward(exec), - rel_time.from_now(), std::forward(f), - std::forward(ts)...) - ) - { - return detail::call_async_execute_at(std::forward(exec), - rel_time.from_now(), std::forward(f), std::forward(ts)...); - } - - /// \brief Singleton form of synchronous execution agent creation - /// supporting timed execution. - /// - /// This synchronously creates a single function invocation f() using - /// the associated executor at the given point in time. The execution - /// of the supplied function synchronizes with the caller. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param abs_time [in] The point in time the given function should be - /// scheduled at to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result - /// - /// \note This calls exec.execute(f) if it exists; - /// otherwise it emulates timed scheduling by delaying calling - /// exec.execute() on the underlying non-scheduled - /// execution agent. - /// - template - static auto - execute_at(Executor_ && exec, - hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - -> decltype( - detail::call_execute_at(std::forward(exec), abs_time, - std::forward(f), std::forward(ts)...)) - { - return detail::call_execute_at(std::forward(exec), - abs_time, std::forward(f), std::forward(ts)...); - } - - /// \brief Singleton form of synchronous execution agent creation - /// supporting timed execution. - /// - /// This synchronously creates a single function invocation f() using - /// the associated executor after the given amount of time. The - /// execution of the supplied function synchronizes with the caller. - /// - /// \param exec [in] The executor object to use for scheduling of the - /// function \a f. - /// \param rel_time [in] The duration of time after which the given - /// function should be scheduled to run. - /// \param f [in] The function which will be scheduled using the - /// given executor. - /// \param ts [in] Additional arguments to use to invoke \a f. - /// - /// \returns f(ts...)'s result - /// - /// \note This calls exec.execute(f) if it exists; - /// otherwise it emulates timed scheduling by delaying calling - /// exec.execute() on the underlying non-scheduled - /// execution agent. - /// - template - static auto - execute_after(Executor_ && exec, - hpx::util::steady_duration const& rel_time, F && f, - Ts &&... ts) - -> decltype( - detail::call_execute_at(std::forward(exec), - rel_time.from_now(), std::forward(f), - std::forward(ts)...) - ) - { - return detail::call_execute_at(std::forward(exec), - rel_time.from_now(), std::forward(f), std::forward(ts)...); - } - }; - - /////////////////////////////////////////////////////////////////////////// - /// 1. The type is_timed_executor can be used to detect executor types - /// for the purpose of excluding function signatures - /// from otherwise ambiguous overload resolution participation. - /// 2. If T is the type of a standard or implementation-defined executor, - /// is_timed_executor shall be publicly derived from - /// integral_constant, otherwise from - /// integral_constant. - /// 3. The behavior of a program that adds specializations for - /// is_timed_executor is undefined. - /// - template - struct is_timed_executor - : hpx::traits::is_timed_executor - {}; -}}} - -#endif -#endif diff --git a/hpx/parallel/numeric.hpp b/hpx/parallel/numeric.hpp index a9a55d4926f6..32067b545a29 100644 --- a/hpx/parallel/numeric.hpp +++ b/hpx/parallel/numeric.hpp @@ -21,8 +21,4 @@ #include #include -#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY) -#include -#endif - #endif diff --git a/hpx/runtime/actions/action_support.hpp b/hpx/runtime/actions/action_support.hpp index 36b31dc5cede..b93fad01df8b 100644 --- a/hpx/runtime/actions/action_support.hpp +++ b/hpx/runtime/actions/action_support.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #if HPX_HAVE_ITTNOTIFY != 0 && !defined(HPX_HAVE_APEX) #include #endif @@ -72,7 +73,7 @@ namespace hpx { namespace actions static_assert( traits::needs_automatic_registration::value, "HPX_REGISTER_ACTION_DECLARATION missing"); - return util::type_id::typeid_.type_id(); + return util::debug::type_id::typeid_.type_id(); } #endif diff --git a/hpx/runtime/actions/continuation.hpp b/hpx/runtime/actions/continuation.hpp index 4307e5e9083b..5d90725eb208 100644 --- a/hpx/runtime/actions/continuation.hpp +++ b/hpx/runtime/actions/continuation.hpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/hpx/runtime/serialization/detail/polymorphic_intrusive_factory.hpp b/hpx/runtime/serialization/detail/polymorphic_intrusive_factory.hpp index 65d8d8db3ecc..1785af5d76de 100644 --- a/hpx/runtime/serialization/detail/polymorphic_intrusive_factory.hpp +++ b/hpx/runtime/serialization/detail/polymorphic_intrusive_factory.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include @@ -157,12 +157,12 @@ namespace hpx { namespace serialization { namespace detail #define HPX_SERIALIZATION_POLYMORPHIC_TEMPLATE(Class) \ HPX_SERIALIZATION_POLYMORPHIC_WITH_NAME( \ - Class, hpx::util::type_id::typeid_.type_id();) \ + Class, hpx::util::debug::type_id::typeid_.type_id();) \ /**/ #define HPX_SERIALIZATION_POLYMORPHIC_TEMPLATE_SPLITTED(Class) \ HPX_SERIALIZATION_POLYMORPHIC_WITH_NAME_SPLITTED( \ - Class, hpx::util::type_id::typeid_.type_id();) \ + Class, hpx::util::debug::type_id::typeid_.type_id();) \ /**/ #endif diff --git a/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp b/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp index d383a97e8593..087e4418a9fb 100644 --- a/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp +++ b/hpx/runtime/serialization/detail/polymorphic_nonintrusive_factory.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -48,7 +48,7 @@ namespace hpx { namespace serialization { namespace detail static_assert( traits::needs_automatic_registration::value, "HPX_REGISTER_ACTION_DECLARATION missing"); - return util::type_id::typeid_.type_id(); + return util::debug::type_id::typeid_.type_id(); } }; #endif @@ -281,7 +281,7 @@ namespace hpx { namespace serialization { namespace detail #define HPX_SERIALIZATION_REGISTER_CLASS_TEMPLATE(Parameters, Template) \ HPX_SERIALIZATION_REGISTER_CLASS_NAME_TEMPLATE( \ Parameters, Template, \ - hpx::util::type_id::typeid_.type_id())\ + hpx::util::debug::type_id::typeid_.type_id())\ HPX_PP_STRIP_PARENS(Parameters) hpx::serialization::detail::register_class< \ HPX_PP_STRIP_PARENS(Template)> \ HPX_PP_STRIP_PARENS(Template)::hpx_register_class_instance; \ diff --git a/hpx/traits/is_execution_policy.hpp b/hpx/traits/is_execution_policy.hpp index c4a6ef865515..c2c11cb630bc 100644 --- a/hpx/traits/is_execution_policy.hpp +++ b/hpx/traits/is_execution_policy.hpp @@ -146,37 +146,4 @@ namespace hpx { namespace parallel { namespace execution /// \endcond }}} -#if defined(HPX_HAVE_EXECUTION_POLICY_COMPATIBILITY) -/////////////////////////////////////////////////////////////////////////////// -// Compatibility layer for changes introduced by C++17 -namespace hpx { namespace parallel { inline namespace v1 -{ - /// \cond NOINTERNAL - template - using is_execution_policy = - execution::is_execution_policy; - - template - using is_parallel_execution_policy = - execution::is_parallel_execution_policy; - - template - using is_sequenced_execution_policy = - execution::is_sequenced_execution_policy; - - template - using is_async_execution_policy = - execution::is_async_execution_policy; - - template - using is_rebound_execution_policy = - execution::is_rebound_execution_policy; - - template - using is_vectorpack_execution_policy = - execution::is_vectorpack_execution_policy; - /// \endcond -}}} -#endif - #endif diff --git a/hpx/traits/is_executor.hpp b/hpx/traits/is_executor.hpp index ba5b423d14d3..31fd2653a317 100644 --- a/hpx/traits/is_executor.hpp +++ b/hpx/traits/is_executor.hpp @@ -8,7 +8,6 @@ #include #include -#include // backwards compatibility #include diff --git a/hpx/traits/is_executor_parameters.hpp b/hpx/traits/is_executor_parameters.hpp index affa25ab8207..5b04d9f27c2a 100644 --- a/hpx/traits/is_executor_parameters.hpp +++ b/hpx/traits/is_executor_parameters.hpp @@ -12,7 +12,6 @@ #include #include -#include // backwards compatibility #include #include diff --git a/hpx/traits/v1/is_executor.hpp b/hpx/traits/v1/is_executor.hpp deleted file mode 100644 index 3bc417c81d89..000000000000 --- a/hpx/traits/v1/is_executor.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2016 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) - -#if !defined(HPX_TRAITS_IS_EXECUTOR_MAY_13_2015_1213PM) -#define HPX_TRAITS_IS_EXECUTOR_MAY_13_2015_1213PM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -#include - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - struct executor_tag {}; - - namespace detail - { - /// \cond NOINTERNAL - template - struct is_executor - : std::is_base_of - {}; - - template <> - struct is_executor - : std::false_type - {}; - /// \endcond - } - - template - struct is_executor - : detail::is_executor::type> - {}; - - template - struct executor_traits; - - template - struct executor_information_traits; -}}} - -namespace hpx { namespace traits -{ - // new executor framework - template - struct is_executor - : parallel::v3::is_executor - {}; -}} - -#endif -#endif - diff --git a/hpx/traits/v1/is_executor_parameters.hpp b/hpx/traits/v1/is_executor_parameters.hpp deleted file mode 100644 index 573ad4897a55..000000000000 --- a/hpx/traits/v1/is_executor_parameters.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2014-2017 Hartmut Kaiser -// Copyright (c) 2016 Marcin Copik -// -// 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) - -#if !defined(HPX_TRAITS_IS_EXECUTOR_PARAMETERS_V1_AUG_01_2015_0709AM) -#define HPX_TRAITS_IS_EXECUTOR_PARAMETERS_V1_AUG_01_2015_0709AM - -#include - -#if defined(HPX_HAVE_EXECUTOR_COMPATIBILITY) -#include - -namespace hpx { namespace parallel { namespace execution { namespace detail -{ - template - struct is_executor_parameters; -}}}} - -namespace hpx { namespace parallel { inline namespace v3 -{ - /////////////////////////////////////////////////////////////////////////// - /// 1. The type is_executor_parameters can be used to detect executor - /// parameters types for the purpose of excluding function signatures - /// from otherwise ambiguous overload resolution participation. - /// 2. If T is the type of a standard or implementation-defined executor, - /// is_executor_parameters shall be publicly derived from - /// integral_constant, otherwise from - /// integral_constant. - /// 3. The behavior of a program that adds specializations for - /// is_executor_parameters is undefined. - /// - template - using is_executor_parameters = execution::detail::is_executor_parameters; - - template - struct executor_parameter_traits; -}}} - -#endif -#endif - diff --git a/hpx/util/debug/demangle_helper.hpp b/hpx/util/debug/demangle_helper.hpp new file mode 100644 index 000000000000..d84694e67e7b --- /dev/null +++ b/hpx/util/debug/demangle_helper.hpp @@ -0,0 +1,122 @@ +// Copyright (c) 2017 John Biddiscombe +// Copyright (c) 2007-2012 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) + +#if !defined(HPX_UTIL_DEBUG_DEMANGLE_HELPER_OCT_28_2011_0410PM) +#define HPX_UTIL_DEBUG_DEMANGLE_HELPER_OCT_28_2011_0410PM + +#include +#include +#include +#include +#include + +// -------------------------------------------------------------------- +// Always present regardless of compiler : used by serialization code +// -------------------------------------------------------------------- +namespace hpx { namespace util { namespace debug +{ + template + struct demangle_helper + { + char const* type_id() const + { + return typeid(T).name(); + } + }; +}}} + +#if defined(__GNUG__) + +#include +#include +#include + +// -------------------------------------------------------------------- +// if available : demangle an arbitrary c++ type using gnu utility +// -------------------------------------------------------------------- +namespace hpx { namespace util { namespace debug +{ + template + class cxxabi_demangle_helper + { + public: + cxxabi_demangle_helper() : + demangled_ {abi::__cxa_demangle(typeid(T).name(), 0, 0, 0), std::free} {} + + char const* type_id() const + { + return demangled_ ? demangled_.get() : typeid(T).name(); + } + + private: + std::unique_ptr demangled_; + }; + +}}} + +#else + +namespace hpx { namespace util { namespace debug +{ + template + using cxxabi_demangle_helper = demangle_helper; +}}} + +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace hpx { namespace util { namespace debug +{ + template + struct type_id + { + static demangle_helper typeid_; + }; + + template + demangle_helper type_id::typeid_ = demangle_helper(); + +#if defined(__GNUG__) + template + struct cxx_type_id + { + static cxxabi_demangle_helper typeid_; + }; + + template + cxxabi_demangle_helper cxx_type_id::typeid_ = cxxabi_demangle_helper(); +#else + template + using cxx_type_id = type_id; +#endif + + // -------------------------------------------------------------------- + // print type information + // usage : std::cout << print_type("separator") + // separator is appended if the number of types > 1 + // -------------------------------------------------------------------- + template + inline std::string print_type(const char *delim="") + { + return std::string(cxx_type_id::typeid_.type_id()); + } + + template <> + inline std::string print_type<>(const char *) + { + return "void"; + } + + template + inline typename std::enable_if::type + print_type(const char *delim="") + { + std::string temp(cxx_type_id::typeid_.type_id()); + return temp + delim + print_type(delim); + } +}}} + +#endif diff --git a/hpx/util/demangle_helper.hpp b/hpx/util/demangle_helper.hpp deleted file mode 100644 index ef0318206635..000000000000 --- a/hpx/util/demangle_helper.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2007-2012 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) - -#if !defined(HPX_UTIL_DEMANGLE_HELPER_OCT_28_2011_0410PM) -#define HPX_UTIL_DEMANGLE_HELPER_OCT_28_2011_0410PM - -#include - -// disable the code specific to gcc for now as this causes problems -// (see #811: simple_central_tuplespace_client run error) -#if 0 // defined(__GNUC__) -#include - -namespace hpx { namespace util -{ - template - class demangle_helper - { - public: - demangle_helper() - : demangled_(abi::__cxa_demangle(typeid(T).name(), 0, 0, 0)) - {} - - ~demangle_helper() - { - free(demangled_); - } - - char const* type_id() const - { - return demangled_ ? demangled_ : typeid(T).name(); - } - - private: - char* demangled_; - }; -}} - -#else - -#include - -namespace hpx { namespace util -{ - template - struct demangle_helper - { - char const* type_id() const - { - return typeid(T).name(); - } - }; -}} - -#endif - -/////////////////////////////////////////////////////////////////////////////// -namespace hpx { namespace util -{ - template - struct type_id - { - static demangle_helper typeid_; - }; - - template - demangle_helper type_id::typeid_ = demangle_helper(); -}} - -#endif - diff --git a/hpx/util/detail/function_registration.hpp b/hpx/util/detail/function_registration.hpp index a75a67cbe9c8..2511dab1b2e2 100644 --- a/hpx/util/detail/function_registration.hpp +++ b/hpx/util/detail/function_registration.hpp @@ -9,7 +9,7 @@ #define HPX_UTIL_DETAIL_FUNCTION_REGISTRATION_HPP #include -#include +#include #include #include @@ -30,7 +30,7 @@ namespace hpx { namespace util { namespace detail static char const* call() #ifdef HPX_HAVE_AUTOMATIC_SERIALIZATION_REGISTRATION { - return util::type_id::typeid_.type_id(); + return debug::type_id::typeid_.type_id(); } #else = delete; diff --git a/hpx/util/detail/pack_traversal_async_impl.hpp b/hpx/util/detail/pack_traversal_async_impl.hpp index e27ed3f5b15f..107ca5318d6e 100644 --- a/hpx/util/detail/pack_traversal_async_impl.hpp +++ b/hpx/util/detail/pack_traversal_async_impl.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -362,6 +363,12 @@ namespace util { return Range{std::begin(element), std::end(element)}; } + template > + Range make_dynamic_async_range(std::reference_wrapper ref_element) + { + return Range{std::begin(ref_element.get()), std::end(ref_element.get())}; + } + /// Represents a particular point in a asynchronous traversal hierarchy template class async_traversal_point @@ -483,7 +490,7 @@ namespace util { void async_traverse_one(Current&& current) { using ElementType = - typename std::decay::type; + typename hpx::util::decay_unwrap::type; return async_traverse_one_impl( container_category_of_t{}, std::forward(current)); diff --git a/hpx/util/detail/pack_traversal_impl.hpp b/hpx/util/detail/pack_traversal_impl.hpp index f651a85c3912..9eebaebee632 100644 --- a/hpx/util/detail/pack_traversal_impl.hpp +++ b/hpx/util/detail/pack_traversal_impl.hpp @@ -902,7 +902,7 @@ namespace util { auto traverse(Strategy, T&& element) -> decltype(std::declval().match( std::declval::type>>(), + typename hpx::util::decay_unwrap::type>>(), std::declval())); /// \copybrief traverse @@ -910,14 +910,14 @@ namespace util { auto try_traverse(Strategy, T&& element) -> decltype(std::declval().try_match( std::declval::type>>(), + typename hpx::util::decay_unwrap::type>>(), std::declval())) { // We use tag dispatching here, to categorize the type T whether // it satisfies the container or tuple like requirements. // Then we can choose the underlying implementation accordingly. return try_match( - container_category_of_t::type>{}, + container_category_of_t::type>{}, std::forward(element)); } diff --git a/hpx/util/steady_clock.hpp b/hpx/util/steady_clock.hpp index 5930c02d65b1..c9c878b7820e 100644 --- a/hpx/util/steady_clock.hpp +++ b/hpx/util/steady_clock.hpp @@ -12,10 +12,6 @@ #include -#if HPX_HAVE_BOOST_CHRONO_COMPATIBILITY -# include -#endif - #include namespace hpx { namespace util @@ -37,18 +33,6 @@ namespace hpx { namespace util steady_clock::now() + (abs_time - Clock::now()))) {} -#if HPX_HAVE_BOOST_CHRONO_COMPATIBILITY - template - steady_time_point(boost::chrono::time_point const& abs_time) - { - std::chrono::nanoseconds duration( - boost::chrono::duration_cast( - abs_time - Clock::now()).count()); - - _abs_time = steady_clock::now() + duration; - } -#endif - value_type const& value() const noexcept { return _abs_time; @@ -75,20 +59,6 @@ namespace hpx { namespace util ++_rel_time; } -#if HPX_HAVE_BOOST_CHRONO_COMPATIBILITY - template - steady_duration(boost::chrono::duration const& rel_time) - { - std::chrono::nanoseconds duration( - boost::chrono::duration_cast( - rel_time).count()); - - _rel_time = std::chrono::duration_cast(duration); - if (_rel_time < duration) - ++_rel_time; - } -#endif - value_type const& value() const noexcept { return _rel_time; diff --git a/tests/unit/component/CMakeLists.txt b/tests/unit/component/CMakeLists.txt index 773389864fac..7029b3ad8267 100644 --- a/tests/unit/component/CMakeLists.txt +++ b/tests/unit/component/CMakeLists.txt @@ -52,12 +52,6 @@ if(HPX_WITH_NETWORKING) ) endif() -if(HPX_WITH_EXECUTOR_COMPATIBILITY) - set(tests ${tests} - distribution_policy_executor_v1 - ) -endif() - set(action_invoke_no_more_than_PARAMETERS THREADS_PER_LOCALITY 4) set(action_invoke_no_more_than_FLAGS @@ -131,11 +125,6 @@ foreach(test ${tests}) source_group("Source Files" FILES ${sources}) set(folder_name "Tests/Unit/Components") - string(FIND ${test} "_v1" _is_v1_test) - - if(NOT (_is_v1_test EQUAL -1)) - set(folder_name "Tests/Unit/Components/V1") - endif() # add example executable add_hpx_executable(${test}_test diff --git a/tests/unit/component/distribution_policy_executor_v1.cpp b/tests/unit/component/distribution_policy_executor_v1.cpp deleted file mode 100644 index 4ba857466832..000000000000 --- a/tests/unit/component/distribution_policy_executor_v1.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2015-2016 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 -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::id_type call() { return hpx::find_here(); } - -HPX_PLAIN_ACTION(call, call_action); - -struct call_pfo -{ - hpx::id_type operator()() const - { - return hpx::find_here(); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -void test_distribution_policy_executor() -{ - using namespace hpx::parallel; - - for (hpx::id_type const& loc: hpx::find_all_localities()) - { - auto exec = make_distribution_policy_executor(hpx::colocated(loc)); - typedef executor_traits executor_traits; - - HPX_TEST_EQ(executor_traits::async_execute(exec, call_pfo()).get(), loc); - HPX_TEST_EQ(executor_traits::async_execute(exec, call_action()).get(), loc); - } - - for (hpx::id_type const& loc: hpx::find_all_localities()) - { - auto exec = make_distribution_policy_executor(hpx::colocated(loc)); - typedef executor_traits executor_traits; - - HPX_TEST_EQ(executor_traits::execute(exec, call_pfo()), loc); - HPX_TEST_EQ(executor_traits::execute(exec, call_action()), loc); - } -} - -int main() -{ - test_distribution_policy_executor(); - return 0; -} - diff --git a/tests/unit/lcos/CMakeLists.txt b/tests/unit/lcos/CMakeLists.txt index a5d06d5b3ddf..b06ac3e114d5 100644 --- a/tests/unit/lcos/CMakeLists.txt +++ b/tests/unit/lcos/CMakeLists.txt @@ -72,15 +72,6 @@ set(tests when_some_std_array ) -if(HPX_WITH_EXECUTOR_COMPATIBILITY) - set(tests ${tests} - apply_local_executor_v1 - async_local_executor_v1 - future_then_executor_v1 - local_dataflow_executor_v1 - ) -endif() - if(HPX_WITH_AWAIT) set(tests ${tests} await) set(await_PARAMETERS THREADS_PER_LOCALITY 4) @@ -143,11 +134,6 @@ foreach(test ${tests}) source_group("Source Files" FILES ${sources}) set(folder_name "Tests/Unit/LCOs") - string(FIND ${test} "_v1" _is_v1_test) - - if(NOT (_is_v1_test EQUAL -1)) - set(folder_name "Tests/Unit/LCOs/V1") - endif() # add example executable add_hpx_executable(${test}_test diff --git a/tests/unit/lcos/apply_local_executor_v1.cpp b/tests/unit/lcos/apply_local_executor_v1.cpp deleted file mode 100644 index a67e485ee869..000000000000 --- a/tests/unit/lcos/apply_local_executor_v1.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) 2007-2015 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -std::atomic accumulator; -hpx::lcos::local::condition_variable_any result_cv; - -void increment(std::int32_t i) -{ - accumulator += i; - result_cv.notify_one(); -} - -void increment_with_future(hpx::shared_future fi) -{ - accumulator += fi.get(); - result_cv.notify_one(); -} - -/////////////////////////////////////////////////////////////////////////////// -struct increment_function_object -{ - void operator()(std::int32_t i) const - { - accumulator += i; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -struct increment_type -{ - void call(std::int32_t i) const - { - accumulator += i; - } -}; - -auto increment_lambda = [](std::int32_t i){ accumulator += i; }; - -/////////////////////////////////////////////////////////////////////////////// -template -void test_apply_with_executor(Executor& exec) -{ - accumulator.store(0); - - { - using hpx::util::placeholders::_1; - - hpx::apply(exec, &increment, 1); - hpx::apply(exec, hpx::util::bind(&increment, 1)); - hpx::apply(exec, hpx::util::bind(&increment, _1), 1); - } - - { - hpx::promise p; - hpx::shared_future f = p.get_future(); - - p.set_value(1); - - using hpx::util::placeholders::_1; - - hpx::apply(exec, &increment_with_future, f); - hpx::apply(exec, hpx::util::bind(&increment_with_future, f)); - hpx::apply(exec, hpx::util::bind(&increment_with_future, _1), f); - } - - { - using hpx::util::placeholders::_1; - - hpx::apply(exec, increment, 1); - hpx::apply(exec, hpx::util::bind(increment, 1)); - hpx::apply(exec, hpx::util::bind(increment, _1), 1); - } - - { - increment_type inc; - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::apply(exec, &increment_type::call, inc, 1); - hpx::apply(exec, hpx::util::bind(&increment_type::call, inc, 1)); - hpx::apply(exec, hpx::util::bind(&increment_type::call, inc, _1), 1); - } - - { - increment_function_object obj; - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::apply(exec, obj, 1); - hpx::apply(exec, hpx::util::bind(obj, 1)); - hpx::apply(exec, hpx::util::bind(obj, _1), 1); - } - - { - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::apply(exec, increment_lambda, 1); - hpx::apply(exec, hpx::util::bind(increment_lambda, 1)); - hpx::apply(exec, hpx::util::bind(increment_lambda, _1), 1); - } - - hpx::lcos::local::no_mutex result_mutex; - std::unique_lock l(result_mutex); - result_cv.wait_for(l, std::chrono::seconds(1), - hpx::util::bind(std::equal_to(), - std::ref(accumulator), 18)); - - HPX_TEST_EQ(accumulator.load(), 18); -} - -int hpx_main() -{ - { - hpx::parallel::sequential_executor exec; - test_apply_with_executor(exec); - } - - { - hpx::parallel::parallel_executor exec; - test_apply_with_executor(exec); - } - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} - diff --git a/tests/unit/lcos/async_local_executor_v1.cpp b/tests/unit/lcos/async_local_executor_v1.cpp deleted file mode 100644 index a54d40827ea8..000000000000 --- a/tests/unit/lcos/async_local_executor_v1.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) 2007-2015 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 -#include -#include -#include -#include -#include -#include - -#include - -/////////////////////////////////////////////////////////////////////////////// -std::int32_t increment(std::int32_t i) -{ - return i + 1; -} - -std::int32_t increment_with_future(hpx::shared_future fi) -{ - return fi.get() + 1; -} - -/////////////////////////////////////////////////////////////////////////////// -struct mult2 -{ - std::int32_t operator()(std::int32_t i) const - { - return i * 2; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -struct decrement -{ - std::int32_t call(std::int32_t i) const - { - return i - 1; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -void do_nothing(std::int32_t i) -{ -} - -struct do_nothing_obj -{ - void operator()(std::int32_t i) const - { - } -}; - -struct do_nothing_member -{ - void call(std::int32_t i) const - { - } -}; - -/////////////////////////////////////////////////////////////////////////////// -template -void test_async_with_executor(Executor& exec) -{ - { - hpx::future f1 = hpx::async(exec, &increment, 42); - HPX_TEST_EQ(f1.get(), 43); - - hpx::future f2 = hpx::async(exec, &do_nothing, 42); - f2.get(); - } - - { - hpx::promise p; - hpx::shared_future f = p.get_future(); - - hpx::future f1 = - hpx::async(exec, &increment_with_future, f); - hpx::future f2 = - hpx::async(exec, &increment_with_future, f); - - p.set_value(42); - HPX_TEST_EQ(f1.get(), 43); - HPX_TEST_EQ(f2.get(), 43); - } - - { - using hpx::util::placeholders::_1; - - hpx::future f1 = - hpx::async(exec, hpx::util::bind(&increment, 42)); - HPX_TEST_EQ(f1.get(), 43); - - hpx::future f2 = - hpx::async(exec, hpx::util::bind(&increment, _1), 42); - HPX_TEST_EQ(f2.get(), 43); - } - - { - hpx::future f1 = hpx::async(exec, increment, 42); - HPX_TEST_EQ(f1.get(), 43); - - hpx::future f2 = hpx::async(exec, do_nothing, 42); - f2.get(); - } - - { - mult2 mult; - - hpx::future f1 = hpx::async(exec, mult, 42); - HPX_TEST_EQ(f1.get(), 84); - } - - { - mult2 mult; - - hpx::future f1 = - hpx::async(exec, hpx::util::bind(mult, 42)); - HPX_TEST_EQ(f1.get(), 84); - - using hpx::util::placeholders::_1; - - hpx::future f2 = - hpx::async(exec, hpx::util::bind(mult, _1), 42); - HPX_TEST_EQ(f2.get(), 84); - - do_nothing_obj do_nothing_f; - hpx::future f3 = hpx::async(exec, - hpx::util::bind(do_nothing_f, _1), 42); - f3.get(); - } - - { - decrement dec; - - hpx::future f1 = - hpx::async(exec, &decrement::call, dec, 42); - HPX_TEST_EQ(f1.get(), 41); - - do_nothing_member dnm; - hpx::future f2 = hpx::async(exec, - &do_nothing_member::call, dnm, 42); - f2.get(); - } - - { - decrement dec; - - using hpx::util::placeholders::_1; - - hpx::future f1 = - hpx::async(exec, hpx::util::bind(&decrement::call, dec, 42)); - HPX_TEST_EQ(f1.get(), 41); - - hpx::future f2 = - hpx::async(exec, hpx::util::bind(&decrement::call, dec, _1), 42); - HPX_TEST_EQ(f2.get(), 41); - - do_nothing_member dnm; - hpx::future f3 = hpx::async(exec, - hpx::util::bind(&do_nothing_member::call, dnm, _1), 42); - f3.get(); - } -} - -int hpx_main() -{ - { - hpx::parallel::sequential_executor exec; - test_async_with_executor(exec); - } - - { - hpx::parallel::parallel_executor exec; - test_async_with_executor(exec); - } - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} - diff --git a/tests/unit/lcos/future_then_executor_v1.cpp b/tests/unit/lcos/future_then_executor_v1.cpp deleted file mode 100644 index 0f17ac34fcc8..000000000000 --- a/tests/unit/lcos/future_then_executor_v1.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright (C) 2012-2013 Vicente Botet -// Copyright (c) 2013 Agustin Berge -// Copyright (c) 2015 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -int p1() -{ - hpx::this_thread::sleep_for(std::chrono::milliseconds(500)); - return 1; -} - -int p2(hpx::lcos::future f) -{ - HPX_TEST(f.valid()); - int i = f.get(); - hpx::this_thread::sleep_for(std::chrono::milliseconds(500)); - return 2 * i; -} - -void p3(hpx::lcos::future f) -{ - HPX_TEST(f.valid()); - int i = f.get(); - (void)i; - hpx::this_thread::sleep_for(std::chrono::milliseconds(500)); - return; -} - -hpx::lcos::future p4(hpx::lcos::future f) -{ - return hpx::async(p2, std::move(f)); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_return_int(Executor& exec) -{ - hpx::lcos::future f1 = hpx::async(exec, &p1); - HPX_TEST(f1.valid()); - hpx::lcos::future f2 = f1.then(exec, &p2); - HPX_TEST(f2.valid()); - try { - HPX_TEST(f2.get()==2); - } - catch (hpx::exception const& /*ex*/) { - HPX_TEST(false); - } - catch (...) { - HPX_TEST(false); - } -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_return_void(Executor& exec) -{ - hpx::lcos::future f1 = hpx::async(exec, &p1); - HPX_TEST(f1.valid()); - hpx::lcos::future f2 = f1.then(exec, &p3); - HPX_TEST(f2.valid()); - try { - f2.wait(); - } - catch (hpx::exception const& /*ex*/) { - HPX_TEST(false); - } - catch (...) { - HPX_TEST(false); - } -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_implicit_unwrapping(Executor& exec) -{ - hpx::lcos::future f1 = hpx::async(exec, &p1); - HPX_TEST(f1.valid()); - hpx::lcos::future f2 = f1.then(exec, &p4); - HPX_TEST(f2.valid()); - try { - HPX_TEST(f2.get()==2); - } - catch (hpx::exception const& /*ex*/) { - HPX_TEST(false); - } - catch (...) { - HPX_TEST(false); - } -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_simple_then(Executor& exec) -{ - hpx::lcos::future f2 = hpx::async(exec, p1).then(exec, &p2); - HPX_TEST(f2.get()==2); -} - -template -void test_simple_deferred_then(Executor& exec) -{ - hpx::lcos::future f2 = hpx::async(exec, p1).then(exec, &p2); - HPX_TEST(f2.get()==2); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_complex_then(Executor& exec) -{ - hpx::lcos::future f1 = hpx::async(exec, p1); - hpx::lcos::future f21 = f1.then(exec, &p2); - hpx::lcos::future f2= f21.then(exec, &p2); - HPX_TEST(f2.get()==4); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_complex_then_chain_one(Executor& exec) -{ - hpx::lcos::future f1 = hpx::async(exec, p1); - hpx::lcos::future f2= f1.then(exec, &p2).then(exec, &p2); - HPX_TEST(f2.get()==4); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_complex_then_chain_two(Executor& exec) -{ - hpx::lcos::future f2 = - hpx::async(exec, p1).then(exec, &p2).then(exec, &p2); - HPX_TEST(f2.get()==4); -} - -template -void test_then(Executor& exec) -{ - test_return_int(exec); - test_return_void(exec); - test_implicit_unwrapping(exec); - test_simple_then(exec); - test_simple_deferred_then(exec); - test_complex_then(exec); - test_complex_then_chain_one(exec); - test_complex_then_chain_two(exec); -} - -/////////////////////////////////////////////////////////////////////////////// -using boost::program_options::variables_map; -using boost::program_options::options_description; - -int hpx_main(variables_map&) -{ - { - hpx::parallel::sequential_executor exec; - test_then(exec); - } - - { - hpx::parallel::parallel_executor exec; - test_then(exec); - } - - hpx::finalize(); - return hpx::util::report_errors(); -} - -/////////////////////////////////////////////////////////////////////////////// -int main(int argc, char* argv[]) -{ - // Configure application-specific options - options_description cmdline("Usage: " HPX_APPLICATION_STRING " [options]"); - - // We force this test to use several threads by default. - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - return hpx::init(cmdline, argc, argv, cfg); -} - diff --git a/tests/unit/lcos/local_dataflow_executor_v1.cpp b/tests/unit/lcos/local_dataflow_executor_v1.cpp deleted file mode 100644 index 9b599c644608..000000000000 --- a/tests/unit/lcos/local_dataflow_executor_v1.cpp +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright (c) 2013 Thomas Heller -// Copyright (c) 2015 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -using boost::program_options::variables_map; -using boost::program_options::options_description; -using boost::program_options::value; - -using hpx::dataflow; -using hpx::util::bind; - -using hpx::async; -using hpx::future; -using hpx::shared_future; - -using hpx::make_ready_future; - -using hpx::init; -using hpx::finalize; - -using hpx::util::report_errors; -using hpx::util::unwrapping; - -/////////////////////////////////////////////////////////////////////////////// - -std::atomic void_f_count; -std::atomic int_f_count; - -void void_f() {++void_f_count;} -int int_f() {++int_f_count; return 42; } - -std::atomic void_f1_count; -std::atomic int_f1_count; - -void void_f1(int) {++void_f1_count;} -int int_f1(int i) {++int_f1_count; return i+42; } - -std::atomic int_f2_count; -int int_f2(int l, int r) {++int_f2_count; return l + r; } - -std::atomic int_f_vector_count; - -int int_f_vector(std::vector const & vf) -{ - int sum = 0; - for (int f : vf) - { - sum += f; - } - return sum; -} - -template -void function_pointers(Executor& exec) -{ - void_f_count.store(0); - int_f_count.store(0); - void_f1_count.store(0); - int_f1_count.store(0); - int_f2_count.store(0); - - future f1 = dataflow(exec, unwrapping(&void_f1), async(&int_f)); - future - f2 = dataflow(exec, - unwrapping(&int_f1) - , dataflow(exec, - unwrapping(&int_f1) - , make_ready_future(42)) - ); - future - f3 = dataflow(exec, - unwrapping(&int_f2) - , dataflow(exec, - unwrapping(&int_f1) - , make_ready_future(42) - ) - , dataflow(exec, - unwrapping(&int_f1) - , make_ready_future(37) - ) - ); - - int_f_vector_count.store(0); - std::vector > vf; - for(std::size_t i = 0; i < 10; ++i) - { - vf.push_back(dataflow(exec, unwrapping(&int_f1), make_ready_future(42))); - } - future f4 = dataflow(exec, unwrapping(&int_f_vector), std::move(vf)); - - future - f5 = dataflow(exec, - unwrapping(&int_f1) - , dataflow(exec, - unwrapping(&int_f1) - , make_ready_future(42)) - , dataflow(exec, - unwrapping(&void_f) - , make_ready_future()) - ); - - f1.wait(); - HPX_TEST_EQ(f2.get(), 126); - HPX_TEST_EQ(f3.get(), 163); - HPX_TEST_EQ(f4.get(), 10 * 84); - HPX_TEST_EQ(f5.get(), 126); - HPX_TEST_EQ(void_f_count, 1u); - HPX_TEST_EQ(int_f_count, 1u); - HPX_TEST_EQ(void_f1_count, 1u); - HPX_TEST_EQ(int_f1_count, 16u); - HPX_TEST_EQ(int_f2_count, 1u); -} - -/////////////////////////////////////////////////////////////////////////////// - -std::atomic future_void_f1_count; -std::atomic future_void_f2_count; - -void future_void_f1(future f1) -{ - HPX_TEST(f1.is_ready()); - ++future_void_f1_count; -} - -void future_void_sf1(shared_future f1) -{ - HPX_TEST(f1.is_ready()); - ++future_void_f1_count; -} - -void future_void_f2(future f1, future f2) -{ - HPX_TEST(f1.is_ready()); - HPX_TEST(f2.is_ready()); - ++future_void_f2_count; -} - -std::atomic future_int_f1_count; -std::atomic future_int_f2_count; - -int future_int_f1(future f1) -{ - HPX_TEST(f1.is_ready()); - ++future_int_f1_count; - return 1; -} - -int future_int_f2(future f1, future f2) -{ - HPX_TEST(f1.is_ready()); HPX_TEST(f2.is_ready()); - ++future_int_f2_count; - return f1.get() + f2.get(); -} - -std::atomic future_int_f_vector_count; - -int future_int_f_vector(std::vector >& vf) -{ - int sum = 0; - for (future& f : vf) - { - HPX_TEST(f.is_ready()); - sum += f.get(); - } - return sum; -} - -template -void future_function_pointers(Executor& exec) -{ - future_void_f1_count.store(0); - future_void_f2_count.store(0); - future_int_f1_count.store(0); - future_int_f2_count.store(0); - - future f1 - = dataflow(exec, - &future_void_f1 - , async(&future_void_sf1, shared_future(make_ready_future())) - ); - - f1.wait(); - - HPX_TEST_EQ(future_void_f1_count, 2u); - future_void_f1_count.store(0); - - future f2 = dataflow(exec, - &future_void_f2 - , async(&future_void_sf1, shared_future(make_ready_future())) - , async(&future_void_sf1, shared_future(make_ready_future())) - ); - - f2.wait(); - HPX_TEST_EQ(future_void_f1_count, 2u); - HPX_TEST_EQ(future_void_f2_count, 1u); - - future_void_f1_count.store(0); - future_void_f2_count.store(0); - future_int_f1_count.store(0); - future_int_f2_count.store(0); - - future f3 = dataflow(exec, - &future_int_f1 - , make_ready_future() - ); - - HPX_TEST_EQ(f3.get(), 1); - HPX_TEST_EQ(future_int_f1_count, 1u); - future_int_f1_count.store(0); - - future f4 = dataflow(exec, - &future_int_f2 - , dataflow(exec, &future_int_f1, make_ready_future()) - , dataflow(exec, &future_int_f1, make_ready_future()) - ); - - HPX_TEST_EQ(f4.get(), 2); - HPX_TEST_EQ(future_int_f1_count, 2u); - HPX_TEST_EQ(future_int_f2_count, 1u); - future_int_f1_count.store(0); - future_int_f2_count.store(0); - - future_int_f_vector_count.store(0); - std::vector > vf; - for(std::size_t i = 0; i < 10; ++i) - { - vf.push_back(dataflow(exec, &future_int_f1, make_ready_future())); - } - future f5 = dataflow(exec, &future_int_f_vector, std::ref(vf)); - - HPX_TEST_EQ(f5.get(), 10); -} - -/////////////////////////////////////////////////////////////////////////////// -std::atomic void_f4_count; -std::atomic int_f4_count; - -void void_f4(int) { ++void_f4_count; } -int int_f4(int i) { ++int_f4_count; return i+42; } - -std::atomic void_f5_count; -std::atomic int_f5_count; - -void void_f5(int, hpx::future) { ++void_f5_count; } -int int_f5(int i, hpx::future j) { ++int_f5_count; return i+j.get()+42; } - -template -void plain_arguments(Executor& exec) -{ - void_f4_count.store(0); - int_f4_count.store(0); - - { - future f1 = dataflow(exec, &void_f4, 42); - future f2 = dataflow(exec, &int_f4, 42); - - f1.wait(); - HPX_TEST_EQ(void_f4_count, 1u); - - HPX_TEST_EQ(f2.get(), 84); - HPX_TEST_EQ(int_f4_count, 1u); - } - - void_f5_count.store(0); - int_f5_count.store(0); - - { - future f1 = dataflow(exec, &void_f5, 42, async(&int_f)); - future f2 = dataflow(exec, &int_f5, 42, async(&int_f)); - - f1.wait(); - HPX_TEST_EQ(void_f5_count, 1u); - - HPX_TEST_EQ(f2.get(), 126); - HPX_TEST_EQ(int_f5_count, 1u); - } -} - -template -void plain_deferred_arguments(Executor& exec) -{ - void_f5_count.store(0); - int_f5_count.store(0); - - { - future f1 = dataflow( - exec, &void_f5, 42, async(hpx::launch::deferred, &int_f)); - future f2 = dataflow( - exec, &int_f5, 42, async(hpx::launch::deferred, &int_f)); - - f1.wait(); - HPX_TEST_EQ(void_f5_count, 1u); - - HPX_TEST_EQ(f2.get(), 126); - HPX_TEST_EQ(int_f5_count, 1u); - } -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(variables_map&) -{ - { - hpx::parallel::sequential_executor exec; - function_pointers(exec); - future_function_pointers(exec); - plain_arguments(exec); - plain_deferred_arguments(exec); - } - - { - hpx::parallel::parallel_executor exec; - function_pointers(exec); - future_function_pointers(exec); - plain_arguments(exec); - plain_deferred_arguments(exec); - } - - return hpx::finalize(); -} - -/////////////////////////////////////////////////////////////////////////////// -int main(int argc, char* argv[]) -{ - // Configure application-specific options - options_description - desc_commandline("Usage: " HPX_APPLICATION_STRING " [options]"); - - // We force this test to use several threads by default. - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(init(desc_commandline, argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - return report_errors(); -} diff --git a/tests/unit/parallel/algorithms/CMakeLists.txt b/tests/unit/parallel/algorithms/CMakeLists.txt index ce7528741189..28055fcf947b 100644 --- a/tests/unit/parallel/algorithms/CMakeLists.txt +++ b/tests/unit/parallel/algorithms/CMakeLists.txt @@ -131,16 +131,6 @@ set(tests unique_copy ) -if(HPX_WITH_EXECUTOR_COMPATIBILITY) - set(tests ${tests} - foreach_executors_v1 - foreach_prefetching_executors_v1 - inclusive_scan_executors_v1 - is_sorted_executors_v1 - uninitialized_copy_executors_v1 - ) -endif() - if(HPX_WITH_ALGORITHM_INPUT_ITERATOR_SUPPORT) set(tests ${tests} copyif_input @@ -156,11 +146,6 @@ foreach(test ${tests}) source_group("Source Files" FILES ${sources}) set(folder_name "Tests/Unit/Parallel/Algorithms") - string(FIND ${test} "_v1" _is_v1_test) - - if(NOT (_is_v1_test EQUAL -1)) - set(folder_name "Tests/Unit/Parallel/Algorithms/V1") - endif() # add example executable add_hpx_executable(${test}_test diff --git a/tests/unit/parallel/algorithms/foreach_executors_v1.cpp b/tests/unit/parallel/algorithms/foreach_executors_v1.cpp deleted file mode 100644 index 139912c7fb15..000000000000 --- a/tests/unit/parallel/algorithms/foreach_executors_v1.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2015 Daniel Bourgeois -// -// 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 -#include - -#include -#include -#include -#include - -#include "foreach_tests.hpp" - -//////////////////////////////////////////////////////////////////////////////// -template -void test_executors(ExPolicy && policy) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_for_each_exception(policy, iterator_tag()); - test_for_each_bad_alloc(policy, iterator_tag()); - test_for_each(std::forward(policy), iterator_tag()); -} - -template -void test_executors_async(ExPolicy && p) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_for_each_exception_async(p, iterator_tag()); - test_for_each_bad_alloc_async(p, iterator_tag()); - test_for_each_async(std::forward(p), iterator_tag()); -} - -void for_each_executors_test() -{ - using namespace hpx::parallel; - - { - parallel_executor exec; - - test_executors(par.on(exec)); - test_executors_async(par(execution::task).on(exec)); - } - - { - sequential_executor exec; - - test_executors(seq.on(exec)); - test_executors_async(seq(execution::task).on(exec)); - - test_executors(par.on(exec)); - test_executors_async(par(execution::task).on(exec)); - } -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(boost::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int)std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - for_each_executors_test(); - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace boost::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options() - ("seed,s", value(), - "the random number generator seed to use for this run") - ; - - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/algorithms/foreach_prefetching_executors_v1.cpp b/tests/unit/parallel/algorithms/foreach_prefetching_executors_v1.cpp deleted file mode 100644 index a4a5af4a1b66..000000000000 --- a/tests/unit/parallel/algorithms/foreach_prefetching_executors_v1.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2016 Zahra Khatami -// Copyright (c) 2016 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 -#include - -#include -#include -#include -#include - -#include "foreach_tests_prefetching.hpp" - -/////////////////////////////////////////////////////////////////////////////// -template -void test_prefetching_executors(ExPolicy && policy) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_for_each_prefetching_exception(policy, iterator_tag()); - test_for_each_prefetching_bad_alloc(policy, iterator_tag()); - test_for_each_prefetching(std::forward(policy), - iterator_tag()); -} - -template -void test_prefetching_executors_async(ExPolicy && p) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_for_each_prefetching_exception_async(p, iterator_tag()); - test_for_each_prefetching_bad_alloc_async(p, iterator_tag()); - test_for_each_prefetching_async(std::forward(p), - iterator_tag()); -} - -void for_each_prefetching_executors_test() -{ - using namespace hpx::parallel; - - { - parallel_executor exec; - - test_prefetching_executors(execution::par.on(exec)); - test_prefetching_executors_async(execution::par(execution::task).on(exec)); - } - - { - sequential_executor exec; - test_prefetching_executors(execution::par.on(exec)); - test_prefetching_executors_async(execution::par(execution::task).on(exec)); - } -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(boost::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int)std::time(0); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - for_each_prefetching_executors_test(); - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace boost::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options() - ("seed,s", value(), - "the random number generator seed to use for this run") - ; - - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/algorithms/inclusive_scan_executors_v1.cpp b/tests/unit/parallel/algorithms/inclusive_scan_executors_v1.cpp deleted file mode 100644 index 4d86284c8a12..000000000000 --- a/tests/unit/parallel/algorithms/inclusive_scan_executors_v1.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2015 Daniel Bourgeois -// -// 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 -#include - -#include -#include -#include -#include - -#include "inclusive_scan_tests.hpp" - -//////////////////////////////////////////////////////////////////////////////// -template -void test_executors(ExPolicy && policy) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_inclusive_scan2(policy, iterator_tag()); - test_inclusive_scan3(policy, iterator_tag()); - test_inclusive_scan_exception(policy, iterator_tag()); - test_inclusive_scan_bad_alloc(policy, iterator_tag()); - test_inclusive_scan1(std::forward(policy), iterator_tag()); -} - -template -void test_executors_async(ExPolicy && p) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_inclusive_scan2_async(p, iterator_tag()); - test_inclusive_scan3_async(p, iterator_tag()); - test_inclusive_scan_exception_async(p, iterator_tag()); - test_inclusive_scan_bad_alloc_async(p, iterator_tag()); - test_inclusive_scan1_async(std::forward(p), iterator_tag()); -} - -void inclusive_scan_executors_test() -{ - using namespace hpx::parallel; - - { - parallel_executor exec; - - test_executors(execution::par.on(exec)); - test_executors_async(execution::par(execution::task).on(exec)); - } - - { - sequential_executor exec; - - test_executors(execution::seq.on(exec)); - test_executors_async(execution::seq(execution::task).on(exec)); - - test_executors(execution::par.on(exec)); - test_executors_async(execution::par(execution::task).on(exec)); - } -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(boost::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int)std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - inclusive_scan_executors_test(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace boost::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options() - ("seed,s", value(), - "the random number generator seed to use for this run") - ; - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/algorithms/is_sorted_executors_v1.cpp b/tests/unit/parallel/algorithms/is_sorted_executors_v1.cpp deleted file mode 100644 index 0f168c6cb459..000000000000 --- a/tests/unit/parallel/algorithms/is_sorted_executors_v1.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2015 Daniel Bourgeois -// -// 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 -#include - -#include -#include -#include -#include - -#include "is_sorted_tests.hpp" - -//////////////////////////////////////////////////////////////////////////////// -template -void test_executors(ExPolicy && policy) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_sorted2(policy, iterator_tag()); - test_sorted3(policy, iterator_tag()); - test_sorted_exception(policy, iterator_tag()); - test_sorted_bad_alloc(policy, iterator_tag()); - test_sorted1(std::forward(policy), iterator_tag()); -} - -template -void test_executors_async(ExPolicy && p) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_sorted2_async(p, iterator_tag()); - test_sorted3_async(p, iterator_tag()); - test_sorted_exception_async(p, iterator_tag()); - test_sorted_bad_alloc_async(p, iterator_tag()); - test_sorted1_async(std::forward(p), iterator_tag()); -} - -void sorted_executors_test() -{ - using namespace hpx::parallel; - - { - parallel_executor exec; - - test_executors(execution::par.on(exec)); - test_executors_async(execution::par(execution::task).on(exec)); - } - - { - sequential_executor exec; - - test_executors(execution::seq.on(exec)); - test_executors_async(execution::seq(execution::task).on(exec)); - - test_executors(execution::par.on(exec)); - test_executors_async(execution::par(execution::task).on(exec)); - } -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(boost::program_options::variables_map& vm) -{ - sorted_executors_test(); - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - using namespace boost::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - std::vector const cfg = { - "hpx.os_threads=all" - }; - - HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/algorithms/uninitialized_copy_executors_v1.cpp b/tests/unit/parallel/algorithms/uninitialized_copy_executors_v1.cpp deleted file mode 100644 index 93468d8c7f52..000000000000 --- a/tests/unit/parallel/algorithms/uninitialized_copy_executors_v1.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -// Copyright (c) 2015 Daniel Bourgeois -// -// 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 -#include - -#include -#include -#include -#include - -#include "uninitialized_copy_tests.hpp" - -//////////////////////////////////////////////////////////////////////////////// -template -void test_executors(ExPolicy && policy) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_uninitialized_copy(policy, iterator_tag()); - test_uninitialized_copy_exception(policy, iterator_tag()); - test_uninitialized_copy_bad_alloc(policy, iterator_tag()); - test_uninitialized_copy( - std::forward(policy), iterator_tag()); -} - -template -void test_executors_async(ExPolicy && p) -{ - typedef std::random_access_iterator_tag iterator_tag; - - test_uninitialized_copy_async(p, iterator_tag()); - test_uninitialized_copy_exception_async(p, iterator_tag()); - test_uninitialized_copy_bad_alloc_async(p, iterator_tag()); - test_uninitialized_copy_async( - std::forward(p), iterator_tag()); -} - -void uninitialized_copy_executors_test() -{ - using namespace hpx::parallel; - - { - parallel_executor exec; - - test_executors(execution::par.on(exec)); - test_executors_async(execution::par(execution::task).on(exec)); - } - - { - sequential_executor exec; - - test_executors(execution::seq.on(exec)); - test_executors_async(execution::seq(execution::task).on(exec)); - - test_executors(execution::par.on(exec)); - test_executors_async(execution::par(execution::task).on(exec)); - } -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(boost::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int)std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - uninitialized_copy_executors_test(); - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace boost::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options() - ("seed,s", value(), - "the random number generator seed to use for this run") - ; - - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/CMakeLists.txt b/tests/unit/parallel/executors/CMakeLists.txt index 42fb1b72ffcf..5e903856ed71 100644 --- a/tests/unit/parallel/executors/CMakeLists.txt +++ b/tests/unit/parallel/executors/CMakeLists.txt @@ -28,29 +28,6 @@ set(tests timed_thread_pool_executors ) -if(HPX_WITH_EXECUTOR_COMPATIBILITY) - set(tests ${tests} - bulk_async_v1 - created_executor_v1 - minimal_async_executor_v1 - minimal_sync_executor_v1 - minimal_timed_async_executor_v1 - minimal_timed_sync_executor_v1 - parallel_executor_v1 - parallel_fork_executor_v1 - sequential_executor_v1 - service_executors_v1 - shared_parallel_executor_v1 - this_thread_executors_v1 - thread_pool_attached_executors_v1 - thread_pool_executors_v1 -# thread_pool_os_executors_v1 - timed_parallel_executor_v1 - timed_this_thread_executors_v1 - timed_thread_pool_executors_v1 - ) -endif() - foreach(test ${tests}) set(sources ${test}.cpp) @@ -60,11 +37,6 @@ foreach(test ${tests}) source_group("Source Files" FILES ${sources}) set(folder_name "Tests/Unit/Parallel/Executors") - string(FIND ${test} "_v1" _is_v1_test) - - if(NOT (_is_v1_test EQUAL -1)) - set(folder_name "Tests/Unit/Parallel/Executors/V1") - endif() # add example executable add_hpx_executable(${test}_test diff --git a/tests/unit/parallel/executors/bulk_async_v1.cpp b/tests/unit/parallel/executors/bulk_async_v1.cpp deleted file mode 100644 index 9608d03a431c..000000000000 --- a/tests/unit/parallel/executors/bulk_async_v1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2015 Daniel Bourgeois -// -// 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -//////////////////////////////////////////////////////////////////////////////// -int bulk_test(hpx::thread::id tid, int value, bool is_par, int passed_through) //-V813 -{ - HPX_TEST(is_par == (tid != hpx::this_thread::get_id())); - HPX_TEST_EQ(passed_through, 42); - return value; -} - -template -void test_bulk_async(Executor& exec, bool is_par = true) -{ - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), 0); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - std::vector > results = traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, tid, _1, is_par, _2), v, 42); - - HPX_TEST(std::equal( - std::begin(results), std::end(results), std::begin(v), - [](hpx::future& lhs, const int& rhs) - { - return lhs.get() == rhs; - })); -} - -//////////////////////////////////////////////////////////////////////////////// -int hpx_main(int argc, char* argv[]) -{ - using namespace hpx::parallel; - - sequential_executor seq_exec; - parallel_executor par_exec; - parallel_executor par_fork_exec(hpx::launch::fork); - - test_bulk_async(seq_exec, false); - test_bulk_async(par_exec); - test_bulk_async(par_fork_exec); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/created_executor_v1.cpp b/tests/unit/parallel/executors/created_executor_v1.cpp deleted file mode 100644 index 462b6e116027..000000000000 --- a/tests/unit/parallel/executors/created_executor_v1.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (c) 2015 Daniel Bourgeois -// -// 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using hpx::parallel::v3::parallel_executor; -using hpx::util::deferred_call; -typedef std::vector::iterator iter; - -//////////////////////////////////////////////////////////////////////////////// -// A parallel executor that returns void for bulk_execute and hpx::future -// for bulk_async_execute -struct void_parallel_executor : parallel_executor -{ - template - std::vector > - bulk_async_execute(F && f, Shape const& shape, Ts &&... ts) - { - std::vector > results; - for(auto const& elem: shape) - { - results.push_back(this->parallel_executor::async_execute( - f, elem, ts...)); - } - return results; - } - - template - void bulk_execute(F && f, Shape const& shape, Ts &&... ts) - { - return hpx::util::unwrap( - bulk_async_execute(std::forward(f), shape, - std::forward(ts)...)); - } -}; - -//////////////////////////////////////////////////////////////////////////////// -// Tests to void_parallel_executor behavior for the bulk executes - -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -void test_void_bulk_sync() -{ - typedef void_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -void test_void_bulk_async() -{ - typedef void_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - hpx::when_all( - traits::bulk_async_execute(exec, - hpx::util::bind(&bulk_test, _1, tid, _2), v, 42) - ).get(); - hpx::when_all(traits::bulk_async_execute(exec, &bulk_test, v, tid, 42)).get(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Sum using hpx's parallel_executor and the above void_parallel_executor - -// Create shape argument for parallel_executor -std::vector > -split(iter first, iter last, int parts) -{ - typedef std::iterator_traits::difference_type sz_type; - sz_type count = std::distance(first, last); - sz_type increment = count/parts; - - std::vector > results; - while(first != last) - { - iter prev = first; - std::advance( - first, - (std::min)(increment, std::distance(first,last)) - ); - results.push_back(hpx::util::make_iterator_range(prev, first)); - } - return results; -} - -// parallel sum using hpx's parallel executor -int parallel_sum(iter first, iter last, int num_parts) -{ - parallel_executor exec; - typedef hpx::parallel::executor_traits traits; - - std::vector > input = - split(first, last, num_parts); - - std::vector > v = - traits::bulk_async_execute(exec, - [](hpx::util::iterator_range const& rng) -> int - { - return std::accumulate(std::begin(rng), std::end(rng), 0); - }, - input); - - return std::accumulate( - std::begin(v), std::end(v), 0, - [](int a, hpx::future& b) -> int - { - return a + b.get(); - }); -} - -// parallel sum using void parallel executer -int void_parallel_sum(iter first, iter last, int num_parts) -{ - void_parallel_executor exec; - typedef hpx::parallel::executor_traits traits; - - std::vector temp(num_parts + 1, 0); - std::iota(std::begin(temp), std::end(temp), 0); - - std::ptrdiff_t section_size = std::distance(first, last) / num_parts; - - std::vector > f = traits::bulk_async_execute(exec, - [&](const int& i) - { - iter b = first + i*section_size; //-V104 - iter e = first + (std::min)( - std::distance(first, last), - static_cast((i+1)*section_size) //-V104 - ); - temp[i] = std::accumulate(b, e, 0); //-V108 - }, - temp); - - hpx::when_all(f).get(); - - return std::accumulate(std::begin(temp), std::end(temp), 0); -} - -void sum_test() -{ - std::vector vec(10007); - auto random_num = [](){ return std::rand() % 50 - 25; }; - std::generate(std::begin(vec), std::end(vec), random_num); - - int sum = std::accumulate(std::begin(vec), std::end(vec), 0); - int num_parts = std::rand() % 5 + 3; - - // Return futures holding results of parallel_sum and void_parallel_sum - parallel_executor exec; - - typedef hpx::parallel::executor_traits traits; - hpx::future f_par = - traits::async_execute(exec, ¶llel_sum, - std::begin(vec), std::end(vec), num_parts); - - hpx::future f_void_par = - traits::async_execute(exec, &void_parallel_sum, - std::begin(vec), std::end(vec), num_parts); - - HPX_TEST(f_par.get() == sum); - HPX_TEST(f_void_par.get() == sum); -} - -//////////////////////////////////////////////////////////////////////////////// -int hpx_main(boost::program_options::variables_map& vm) -{ - unsigned int seed = static_cast(std::time(nullptr)); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - test_void_bulk_sync(); - test_void_bulk_async(); - sum_test(); - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace boost::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options() - ("seed,s", value(), - "the random number generator seed to use for this run") - ; - - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(desc_commandline, argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/minimal_async_executor_v1.cpp b/tests/unit/parallel/executors/minimal_async_executor_v1.cpp deleted file mode 100644 index b5ff968de2a7..000000000000 --- a/tests/unit/parallel/executors/minimal_async_executor_v1.cpp +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id async_test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void apply_test(hpx::lcos::local::latch& l, hpx::thread::id& id, - int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - id = hpx::this_thread::get_id(); - l.count_down(1); -} - -void async_bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_apply(Executor& exec) -{ - hpx::lcos::local::latch l(2); - hpx::thread::id id; - - typedef hpx::parallel::executor_traits traits; - traits::apply_execute(exec, &apply_test, std::ref(l), std::ref(id), 42); - l.count_down_and_wait(); - - HPX_TEST(id != hpx::this_thread::get_id()); -} - -template -void test_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - HPX_TEST(traits::execute(exec, &async_test, 42) != hpx::this_thread::get_id()); -} - -template -void test_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - HPX_TEST( - traits::async_execute(exec, &async_test, 42).get() != - hpx::this_thread::get_id()); -} - -template -void test_bulk_sync(Executor& exec) -{ - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - typedef hpx::parallel::executor_traits traits; - traits::bulk_execute(exec, - hpx::util::bind(&async_bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &async_bulk_test, v, tid, 42); -} - -template -void test_bulk_async(Executor& exec) -{ - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - typedef hpx::parallel::executor_traits traits; - hpx::when_all( - traits::bulk_async_execute( - exec, hpx::util::bind(&async_bulk_test, _1, tid, _2), v, 42) - ).get(); - hpx::when_all( - traits::bulk_async_execute(exec, &async_bulk_test, v, tid, 42) - ).get(); -} - -template -void test_executor() -{ - typedef typename hpx::parallel::executor_traits< - Executor - >::execution_category execution_category; - - HPX_TEST((std::is_same< - hpx::parallel::parallel_execution_tag, execution_category - >::value)); - - Executor exec; - - test_apply(exec); - test_sync(exec); - test_async(exec); - test_bulk_sync(exec); - test_bulk_async(exec); -} - -/////////////////////////////////////////////////////////////////////////////// -struct test_async_executor2 : hpx::parallel::executor_tag -{ - template - hpx::future::type> - async_execute(F && f, Ts &&... ts) - { - return hpx::async(hpx::launch::async, std::forward(f), - std::forward(ts)...); - } -}; - -struct test_async_executor1 : test_async_executor2 -{ - template - typename hpx::util::detail::invoke_deferred_result::type - execute(F && f, Ts &&... ts) - { - return hpx::async(hpx::launch::async, std::forward(f), - std::forward(ts)...).get(); - } -}; - -struct test_async_executor3 : test_async_executor2 -{ - template - void bulk_execute(F f, Shape const& shape, Ts &&... ts) - { - std::vector > results; - for (auto const& elem: shape) - { - results.push_back(hpx::async(hpx::launch::async, f, elem, ts...)); - } - hpx::when_all(results).get(); - } -}; - -struct test_async_executor4 : test_async_executor2 -{ - template - std::vector > - bulk_async_execute(F f, Shape const& shape, Ts &&... ts) - { - std::vector > results; - for (auto const& elem: shape) - { - results.push_back(hpx::async(hpx::launch::async, f, elem, ts...)); - } - return results; - } -}; - -struct test_async_executor5 : test_async_executor2 -{ - template - void post(F && f, Ts &&... ts) - { - hpx::apply(std::forward(f), std::forward(ts)...); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(int argc, char* argv[]) -{ - test_executor(); - test_executor(); - test_executor(); - test_executor(); - test_executor(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/minimal_sync_executor_v1.cpp b/tests/unit/parallel/executors/minimal_sync_executor_v1.cpp deleted file mode 100644 index d72ec95c3539..000000000000 --- a/tests/unit/parallel/executors/minimal_sync_executor_v1.cpp +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id sync_test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void apply_test(hpx::lcos::local::latch& l, hpx::thread::id& id, - int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - id = hpx::this_thread::get_id(); - l.count_down(1); -} - -void sync_bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid == hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_apply(Executor& exec) -{ - hpx::lcos::local::latch l(2); - hpx::thread::id id; - - typedef hpx::parallel::executor_traits traits; - traits::apply_execute(exec, &apply_test, std::ref(l), std::ref(id), 42); - l.count_down_and_wait(); - - HPX_TEST(id == hpx::this_thread::get_id()); -} - -template -void test_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - HPX_TEST(traits::execute(exec, &sync_test, 42) == hpx::this_thread::get_id()); -} - -template -void test_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - HPX_TEST( - traits::async_execute(exec, &sync_test, 42).get() == - hpx::this_thread::get_id()); -} - -template -void test_bulk_sync(Executor& exec) -{ - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - typedef hpx::parallel::executor_traits traits; - traits::bulk_execute(exec, - hpx::util::bind(&sync_bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &sync_bulk_test, v, tid, 42); -} - -template -void test_bulk_async(Executor& exec) -{ - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - typedef hpx::parallel::executor_traits traits; - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&sync_bulk_test, _1, tid, _2), v, 42) - ).get(); - hpx::when_all(traits::bulk_async_execute( - exec, &sync_bulk_test, v, tid, 42) - ).get(); -} - -template -void test_executor() -{ - typedef typename hpx::parallel::executor_traits< - Executor - >::execution_category execution_category; - - HPX_TEST((std::is_same< - hpx::parallel::sequential_execution_tag, execution_category - >::value)); - - Executor exec; - - test_apply(exec); - test_sync(exec); - test_async(exec); - test_bulk_sync(exec); - test_bulk_async(exec); -} - -/////////////////////////////////////////////////////////////////////////////// -struct test_sync_executor2 : hpx::parallel::executor_tag -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - hpx::future::type> - async_execute(F && f, Ts &&... ts) - { - return hpx::async(hpx::launch::sync, std::forward(f), - std::forward(ts)...); - } - - std::size_t processing_units_count() - { - return 1; - } -}; - -struct test_sync_executor1 : test_sync_executor2 -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - typename hpx::util::detail::invoke_deferred_result::type - execute(F && f, Ts &&... ts) - { - return hpx::util::invoke(std::forward(f), std::forward(ts)...); - } -}; - -struct test_sync_executor3 : test_sync_executor2 -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - void bulk_execute(F f, Shape const& shape, Ts &&... ts) - { - for (auto const& elem: shape) - { - hpx::util::invoke(f, elem, ts...); - } - } -}; - -struct test_sync_executor4 : test_sync_executor2 -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - std::vector > - bulk_async_execute(F f, Shape const& shape, Ts &&... ts) - { - std::vector > results; - for (auto const& elem: shape) - { - results.push_back(async_execute(f, elem, ts...)); - } - return results; - } -}; - -struct test_sync_executor5 : test_sync_executor1 // derive from sync execute -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - void post(F && f, Ts &&... ts) - { - this->execute(std::forward(f), std::forward(ts)...); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(int argc, char* argv[]) -{ - test_executor(); - test_executor(); - test_executor(); - test_executor(); - test_executor(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/minimal_timed_async_executor_v1.cpp b/tests/unit/parallel/executors/minimal_timed_async_executor_v1.cpp deleted file mode 100644 index 7dc9855d3aa4..000000000000 --- a/tests/unit/parallel/executors/minimal_timed_async_executor_v1.cpp +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::chrono; - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id sync_test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void apply_test(hpx::lcos::local::latch& l, hpx::thread::id& id, - int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - id = hpx::this_thread::get_id(); - l.count_down(1); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_timed_apply(Executor& exec) -{ - { - hpx::lcos::local::latch l(3); - hpx::thread::id id; - - typedef hpx::parallel::timed_executor_traits traits; - - using hpx::util::placeholders::_1; - traits::apply_execute_after(exec, milliseconds(10), - hpx::util::bind(&apply_test, std::ref(l), std::ref(id), _1), 42 - ); - - traits::apply_execute_after(exec, milliseconds(10), - &apply_test, std::ref(l), std::ref(id), 42); - - l.count_down_and_wait(); - - HPX_TEST(id != hpx::this_thread::get_id()); - } - - { - hpx::lcos::local::latch l(3); - hpx::thread::id id; - - typedef hpx::parallel::timed_executor_traits traits; - traits::apply_execute_at(exec, steady_clock::now() + milliseconds(10), - hpx::util::deferred_call( - &apply_test, std::ref(l), std::ref(id), 42)); - - traits::apply_execute_at(exec, steady_clock::now() + milliseconds(10), - &apply_test, std::ref(l), std::ref(id), 42); - - l.count_down_and_wait(); - - HPX_TEST(id != hpx::this_thread::get_id()); - } -} - -template -void test_timed_sync(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - HPX_TEST(traits::execute_after(exec, milliseconds(10), &sync_test, 42) != - hpx::this_thread::get_id()); - HPX_TEST(traits::execute_at( - exec, steady_clock::now() + milliseconds(10), &sync_test, 42) != - hpx::this_thread::get_id()); -} - -template -void test_timed_async(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - HPX_TEST( - traits::async_execute_after( - exec, milliseconds(10), &sync_test, 42 - ).get() != hpx::this_thread::get_id()); - HPX_TEST( - traits::async_execute_at( - exec, steady_clock::now() + milliseconds(10), &sync_test, 42 - ).get() != hpx::this_thread::get_id()); -} - -template -void test_timed_executor() -{ - typedef typename hpx::parallel::timed_executor_traits< - Executor - >::execution_category execution_category; - - HPX_TEST((std::is_same< - hpx::parallel::parallel_execution_tag, execution_category - >::value)); - - Executor exec; - - test_timed_apply(exec); - test_timed_sync(exec); - test_timed_async(exec); -} - -/////////////////////////////////////////////////////////////////////////////// -struct test_timed_async_executor2 -{ - typedef hpx::parallel::parallel_execution_tag execution_category; - - template - hpx::future::type> - async_execute(F && f, Ts &&... ts) - { - return hpx::async(hpx::launch::async, std::forward(f), - std::forward(ts)...); - } - - template - hpx::future::type> - async_execute_at(hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - { - hpx::this_thread::sleep_until(abs_time); - return hpx::async(hpx::launch::async, std::forward(f), - std::forward(ts)...); - } -}; - -struct test_timed_async_executor1 : test_timed_async_executor2 -{ - typedef hpx::parallel::parallel_execution_tag execution_category; - - template - typename hpx::util::detail::invoke_deferred_result::type - execute_at(hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - hpx::this_thread::sleep_until(abs_time); - return hpx::async(hpx::launch::async, std::forward(f), - std::forward(ts)...).get(); - } -}; - -struct test_timed_async_executor3 : test_timed_async_executor1 -{ - typedef hpx::parallel::parallel_execution_tag execution_category; - - template - void post(hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - { - hpx::this_thread::sleep_until(abs_time); - hpx::apply(std::forward(f), std::forward(ts)...); - } -}; - -namespace hpx { namespace traits -{ - template <> - struct is_timed_executor - : std::true_type - {}; - - template <> - struct is_timed_executor - : std::true_type - {}; - - template <> - struct is_timed_executor - : std::true_type - {}; -}} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(int argc, char* argv[]) -{ - test_timed_executor(); - test_timed_executor(); - test_timed_executor(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/minimal_timed_sync_executor_v1.cpp b/tests/unit/parallel/executors/minimal_timed_sync_executor_v1.cpp deleted file mode 100644 index 10c85624c1b9..000000000000 --- a/tests/unit/parallel/executors/minimal_timed_sync_executor_v1.cpp +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::chrono; - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id sync_test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void apply_test(hpx::lcos::local::latch& l, hpx::thread::id& id, - int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - id = hpx::this_thread::get_id(); - l.count_down(1); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_timed_apply(Executor& exec) -{ - { - hpx::lcos::local::latch l(3); - hpx::thread::id id; - - typedef hpx::parallel::timed_executor_traits traits; - traits::apply_execute_after(exec, milliseconds(10), - hpx::util::bind(&apply_test, std::ref(l), std::ref(id), 42) - ); - - traits::apply_execute_after(exec, milliseconds(10), - &apply_test, std::ref(l), std::ref(id), 42); - - l.count_down_and_wait(); - - HPX_TEST(id == hpx::this_thread::get_id()); - } - - { - hpx::lcos::local::latch l(3); - hpx::thread::id id; - - typedef hpx::parallel::timed_executor_traits traits; - traits::apply_execute_at(exec, steady_clock::now() + milliseconds(10), - hpx::util::deferred_call( - &apply_test, std::ref(l), std::ref(id), 42) - ); - - traits::apply_execute_at(exec, steady_clock::now() + milliseconds(10), - &apply_test, std::ref(l), std::ref(id), 42); - - l.count_down_and_wait(); - - HPX_TEST(id == hpx::this_thread::get_id()); - } -} - -template -void test_timed_sync(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - HPX_TEST(traits::execute_after(exec, milliseconds(10), &sync_test, 42) == - hpx::this_thread::get_id()); - HPX_TEST(traits::execute_at( - exec, steady_clock::now() + milliseconds(10), &sync_test, 42) == - hpx::this_thread::get_id()); -} - -template -void test_timed_async(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - HPX_TEST( - traits::async_execute_after( - exec, milliseconds(10), &sync_test, 42 - ).get() == hpx::this_thread::get_id()); - HPX_TEST( - traits::async_execute_at( - exec, steady_clock::now() + milliseconds(10), &sync_test, 42 - ).get() == hpx::this_thread::get_id()); -} - -template -void test_timed_executor() -{ - typedef typename hpx::parallel::timed_executor_traits< - Executor - >::execution_category execution_category; - - HPX_TEST((std::is_same< - hpx::parallel::sequential_execution_tag, execution_category - >::value)); - - Executor exec; - - test_timed_apply(exec); - test_timed_sync(exec); - test_timed_async(exec); -} - -/////////////////////////////////////////////////////////////////////////////// -struct test_timed_async_executor2 -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - hpx::future::type> - async_execute(F && f, Ts &&... ts) - { - return hpx::async(hpx::launch::sync, std::forward(f), - std::forward(ts)...); - } - - template - hpx::future::type> - async_execute_at(hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - { - hpx::this_thread::sleep_until(abs_time); - return hpx::async(hpx::launch::sync, std::forward(f), - std::forward(ts)...); - } - - std::size_t processing_units_count() - { - return 1; - } -}; - -struct test_timed_async_executor1 : test_timed_async_executor2 -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - typename hpx::util::detail::invoke_deferred_result::type - execute_at(hpx::util::steady_time_point const& abs_time, F && f, Ts &&... ts) - { - hpx::this_thread::sleep_until(abs_time); - return hpx::util::invoke(std::forward(f), std::forward(ts)...); - } -}; - -struct test_timed_async_executor3 : test_timed_async_executor1 -{ - typedef hpx::parallel::sequential_execution_tag execution_category; - - template - void post_at(hpx::util::steady_time_point const& abs_time, F && f, - Ts &&... ts) - { - this->execute_at(abs_time, std::forward(f), std::forward(ts)...); - } -}; - -namespace hpx { namespace traits -{ - template <> - struct is_timed_executor - : std::true_type - {}; - - template <> - struct is_timed_executor - : std::true_type - {}; - - template <> - struct is_timed_executor - : std::true_type - {}; -}} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(int argc, char* argv[]) -{ - test_timed_executor(); - test_timed_executor(); - test_timed_executor(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/parallel_executor_v1.cpp b/tests/unit/parallel/executors/parallel_executor_v1.cpp deleted file mode 100644 index 814bec1afa7d..000000000000 --- a/tests/unit/parallel/executors/parallel_executor_v1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void test_sync() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - HPX_TEST(traits::execute(exec, &test, 42) != hpx::this_thread::get_id()); -} - -void test_async() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - HPX_TEST( - traits::async_execute(exec, &test, 42).get() != - hpx::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -void test_bulk_sync() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -void test_bulk_async() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42) - ).get(); - hpx::when_all( - traits::bulk_async_execute(exec, &bulk_test, v, tid, 42) - ).get(); -} - -int hpx_main(int argc, char* argv[]) -{ - test_sync(); - test_async(); - test_bulk_sync(); - test_bulk_async(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/parallel_fork_executor_v1.cpp b/tests/unit/parallel/executors/parallel_fork_executor_v1.cpp deleted file mode 100644 index 7e0f3a69f6f0..000000000000 --- a/tests/unit/parallel/executors/parallel_fork_executor_v1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void test_sync() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec(hpx::launch::fork); - HPX_TEST(traits::execute(exec, &test, 42) != hpx::this_thread::get_id()); -} - -void test_async() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec(hpx::launch::fork); - HPX_TEST( - traits::async_execute(exec, &test, 42).get() != - hpx::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -void test_bulk_sync() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec(hpx::launch::fork); - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -void test_bulk_async() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec(hpx::launch::fork); - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42) - ).get(); - hpx::when_all( - traits::bulk_async_execute(exec, &bulk_test, v, tid, 42) - ).get(); -} - -int hpx_main(int argc, char* argv[]) -{ - test_sync(); - test_async(); - test_bulk_sync(); - test_bulk_async(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/sequential_executor_v1.cpp b/tests/unit/parallel/executors/sequential_executor_v1.cpp deleted file mode 100644 index 956d8396ebf5..000000000000 --- a/tests/unit/parallel/executors/sequential_executor_v1.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void test_sync() -{ - typedef hpx::parallel::sequential_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - HPX_TEST(traits::execute(exec, &test, 42) == hpx::this_thread::get_id()); -} - -void test_async() -{ - typedef hpx::parallel::sequential_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - HPX_TEST( - traits::async_execute(exec, &test, 42).get() == - hpx::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid == hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -void test_bulk_sync() -{ - typedef hpx::parallel::sequential_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -void test_bulk_async() -{ - typedef hpx::parallel::sequential_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42) - ).get(); - hpx::when_all( - traits::bulk_async_execute(exec, &bulk_test, v, tid, 42) - ).get(); -} - -int hpx_main(int argc, char* argv[]) -{ - test_sync(); - test_async(); - test_bulk_sync(); - test_bulk_async(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/service_executors_v1.cpp b/tests/unit/parallel/executors/service_executors_v1.cpp deleted file mode 100644 index d4b9c4715882..000000000000 --- a/tests/unit/parallel/executors/service_executors_v1.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace compat = hpx::compat; - -/////////////////////////////////////////////////////////////////////////////// -compat::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return compat::this_thread::get_id(); -} - -template -void test_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - HPX_TEST(traits::execute(exec, &test, 42) != compat::this_thread::get_id()); -} - -template -void test_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST( - traits::async_execute(exec, &test, 42).get() != - compat::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, compat::thread::id tid, int passed_through) -{ - HPX_TEST(tid != compat::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -template -void test_bulk_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - compat::thread::id tid = compat::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -template -void test_bulk_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - compat::thread::id tid = compat::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42)).get(); - hpx::when_all(traits::bulk_async_execute(exec, &bulk_test, v, tid, 42)).get(); -} - -template -void test_service_executor(Executor& exec) -{ - test_sync(exec); - test_async(exec); - test_bulk_sync(exec); - test_bulk_async(exec); -} - -int hpx_main(int argc, char* argv[]) -{ - using hpx::threads::executors::service_executor_type; - - { - hpx::parallel::service_executor exec(service_executor_type::io_thread_pool); - test_service_executor(exec); - } - - { - hpx::parallel::service_executor exec(service_executor_type::parcel_thread_pool); - test_service_executor(exec); - } - - { - hpx::parallel::service_executor exec(service_executor_type::timer_thread_pool); - test_service_executor(exec); - } - - { - hpx::parallel::service_executor exec(service_executor_type::main_thread); - test_service_executor(exec); - } - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/shared_parallel_executor_v1.cpp b/tests/unit/parallel/executors/shared_parallel_executor_v1.cpp deleted file mode 100644 index 6129d0e8f66c..000000000000 --- a/tests/unit/parallel/executors/shared_parallel_executor_v1.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -struct shared_parallel_executor - : hpx::parallel::executor_tag -{ - template - struct future_type - { - typedef hpx::shared_future type; - }; - - template - hpx::shared_future::type> - async_execute(F && f, Ts &&... ts) - { - return hpx::async(std::forward(f), std::forward(ts)...); - } -}; - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void test_sync() -{ - typedef shared_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - HPX_TEST(traits::execute(exec, &test, 42) != hpx::this_thread::get_id()); -} - -void test_async() -{ - typedef shared_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - - hpx::shared_future fut = - traits::async_execute(exec, &test, 42); - - HPX_TEST( - fut.get() != - hpx::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -void test_bulk_sync() -{ - typedef shared_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -void test_bulk_async() -{ - typedef shared_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - executor exec; - std::vector > futs = - traits::bulk_async_execute(exec, - hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - hpx::when_all(futs).get(); - - futs = traits::bulk_async_execute(exec, &bulk_test, v, tid, 42); - hpx::when_all(futs).get(); -} - -/////////////////////////////////////////////////////////////////////////////// -void void_test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); -} - -void test_sync_void() -{ - typedef shared_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - traits::execute(exec, &void_test, 42); -} - -void test_async_void() -{ - typedef shared_parallel_executor executor; - typedef hpx::parallel::executor_traits traits; - - executor exec; - hpx::shared_future fut = traits::async_execute(exec, &void_test, 42); - fut.get(); -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(int argc, char* argv[]) -{ - test_sync(); - test_async(); - test_bulk_sync(); - test_bulk_async(); - - test_sync_void(); - test_async_void(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/this_thread_executors_v1.cpp b/tests/unit/parallel/executors/this_thread_executors_v1.cpp deleted file mode 100644 index e44b2849b4c1..000000000000 --- a/tests/unit/parallel/executors/this_thread_executors_v1.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -std::size_t test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::get_worker_thread_num(); -} - -template -void test_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST(traits::execute(exec, &test, 42) == hpx::get_worker_thread_num()); -} - -template -void test_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST( - traits::async_execute(exec, &test, 42).get() == - hpx::get_worker_thread_num()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, std::size_t tid, int passed_through) -{ - HPX_TEST(tid == hpx::get_worker_thread_num()); - HPX_TEST_EQ(passed_through, 42); -} - -template -void test_bulk_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - std::size_t tid = hpx::get_worker_thread_num(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -template -void test_bulk_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - std::size_t tid = hpx::get_worker_thread_num(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42)).get(); - hpx::when_all(traits::bulk_async_execute(exec, &bulk_test, v, tid, 42)).get(); -} - -template -void test_this_thread_executor(Executor& exec) -{ - test_sync(exec); - test_async(exec); - test_bulk_sync(exec); - test_bulk_async(exec); -} - -int hpx_main(int argc, char* argv[]) -{ -#if defined(HPX_HAVE_STATIC_SCHEDULER) - { - hpx::parallel::this_thread_static_queue_executor exec; - test_this_thread_executor(exec); - } -#endif - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - { - hpx::parallel::this_thread_static_priority_queue_executor exec; - test_this_thread_executor(exec); - } -#endif - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/thread_pool_attached_executors_v1.cpp b/tests/unit/parallel/executors/thread_pool_attached_executors_v1.cpp deleted file mode 100644 index 874ce7c68f3b..000000000000 --- a/tests/unit/parallel/executors/thread_pool_attached_executors_v1.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -template -void test_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST(traits::execute(exec, &test, 42) != hpx::this_thread::get_id()); -} - -template -void test_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST( - traits::async_execute(exec, &test, 42).get() != - hpx::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -template -void test_bulk_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -template -void test_bulk_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42)).get(); - hpx::when_all(traits::bulk_async_execute(exec, &bulk_test, v, tid, 42)).get(); -} - -template -void test_thread_pool_attached_executor(Executor& exec) -{ - test_sync(exec); - test_async(exec); - test_bulk_sync(exec); - test_bulk_async(exec); -} - -int hpx_main(int argc, char* argv[]) -{ - std::size_t num_threads = hpx::get_os_thread_count(); - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - { - hpx::parallel::static_queue_attached_executor exec(0, num_threads); - test_thread_pool_attached_executor(exec); - } -#endif - - { - hpx::parallel::local_priority_queue_attached_executor exec(0, num_threads); - test_thread_pool_attached_executor(exec); - } - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - { - hpx::parallel::static_priority_queue_attached_executor exec(0, num_threads); - test_thread_pool_attached_executor(exec); - } -#endif - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on one core (the executors create more - // threads) - std::vector const cfg = { - "hpx.os_threads=1" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/thread_pool_executors_v1.cpp b/tests/unit/parallel/executors/thread_pool_executors_v1.cpp deleted file mode 100644 index f9e903d36192..000000000000 --- a/tests/unit/parallel/executors/thread_pool_executors_v1.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -template -void test_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST(traits::execute(exec, &test, 42) != hpx::this_thread::get_id()); -} - -template -void test_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST( - traits::async_execute(exec, &test, 42).get() != - hpx::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -template -void test_bulk_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -template -void test_bulk_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42)).get(); - hpx::when_all(traits::bulk_async_execute(exec, &bulk_test, v, tid, 42)).get(); -} - -template -void test_thread_pool_executor(Executor& exec) -{ - test_sync(exec); - test_async(exec); - test_bulk_sync(exec); - test_bulk_async(exec); -} - -int hpx_main(int argc, char* argv[]) -{ - std::size_t num_threads = hpx::get_os_thread_count(); - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - { - hpx::parallel::static_queue_executor exec(num_threads); - test_thread_pool_executor(exec); - } -#endif - - { - hpx::parallel::local_priority_queue_executor exec(num_threads); - test_thread_pool_executor(exec); - } - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - { - hpx::parallel::static_priority_queue_executor exec(num_threads); - test_thread_pool_executor(exec); - } -#endif - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/thread_pool_os_executors_v1.cpp b/tests/unit/parallel/executors/thread_pool_os_executors_v1.cpp deleted file mode 100644 index e53dd7360717..000000000000 --- a/tests/unit/parallel/executors/thread_pool_os_executors_v1.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -template -void test_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST(traits::execute(exec, &test, 42) != hpx::this_thread::get_id()); -} - -template -void test_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - HPX_TEST( - traits::async_execute(exec, &test, 42).get() != - hpx::this_thread::get_id()); -} - -/////////////////////////////////////////////////////////////////////////////// -void bulk_test(int value, hpx::thread::id tid, int passed_through) //-V813 -{ - HPX_TEST(tid != hpx::this_thread::get_id()); - HPX_TEST_EQ(passed_through, 42); -} - -template -void test_bulk_sync(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - traits::bulk_execute(exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42); - traits::bulk_execute(exec, &bulk_test, v, tid, 42); -} - -template -void test_bulk_async(Executor& exec) -{ - typedef hpx::parallel::executor_traits traits; - - hpx::thread::id tid = hpx::this_thread::get_id(); - - std::vector v(107); - std::iota(std::begin(v), std::end(v), std::rand()); - - using hpx::util::placeholders::_1; - using hpx::util::placeholders::_2; - - hpx::when_all(traits::bulk_async_execute( - exec, hpx::util::bind(&bulk_test, _1, tid, _2), v, 42)).get(); - hpx::when_all(traits::bulk_async_execute(exec, &bulk_test, v, tid, 42)).get(); -} - -template -void test_thread_pool_os_executor(Executor& exec) -{ - test_sync(exec); - test_async(exec); - test_bulk_sync(exec); - test_bulk_async(exec); -} - -int hpx_main(int argc, char* argv[]) -{ - std::size_t num_threads = hpx::get_os_thread_count(); - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - { - hpx::parallel::static_queue_os_executor exec(num_threads); - test_thread_pool_os_executor(exec); - } -#endif - - { - hpx::parallel::local_priority_queue_os_executor exec(num_threads); - test_thread_pool_os_executor(exec); - } - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - { - hpx::parallel::static_priority_queue_os_executor exec(num_threads); - test_thread_pool_os_executor(exec); - } -#endif - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on one core (the executors create more - // threads) - std::vector const cfg = { - "hpx.os_threads=1" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/timed_parallel_executor_v1.cpp b/tests/unit/parallel/executors/timed_parallel_executor_v1.cpp deleted file mode 100644 index 8d527ed2a6ae..000000000000 --- a/tests/unit/parallel/executors/timed_parallel_executor_v1.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace std::chrono; - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -void test_timed_sync() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::timed_executor_traits traits; - - executor exec; - HPX_TEST( - traits::execute_after( - exec, milliseconds(1), &test, 42 - ) != hpx::this_thread::get_id()); - - HPX_TEST( - traits::execute_at( - exec, steady_clock::now() + milliseconds(1), &test, 42 - ) != hpx::this_thread::get_id()); -} - -void test_timed_async() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::timed_executor_traits traits; - - executor exec; - HPX_TEST( - traits::async_execute_after( - exec, milliseconds(1), &test, 42 - ).get() != hpx::this_thread::get_id()); - HPX_TEST( - traits::async_execute_at( - exec, steady_clock::now() + milliseconds(1), &test, 42 - ).get() != hpx::this_thread::get_id()); -} - -void test_timed_apply() -{ - typedef hpx::parallel::parallel_executor executor; - typedef hpx::parallel::timed_executor_traits traits; - - executor exec; - traits::apply_execute_after(exec, milliseconds(1), &test, 42); - traits::apply_execute_at( - exec, steady_clock::now() + milliseconds(1), &test, 42); -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(int argc, char* argv[]) -{ - test_timed_sync(); - test_timed_async(); - test_timed_apply(); - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/timed_this_thread_executors_v1.cpp b/tests/unit/parallel/executors/timed_this_thread_executors_v1.cpp deleted file mode 100644 index 57be297b4605..000000000000 --- a/tests/unit/parallel/executors/timed_this_thread_executors_v1.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2007-2015 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace std::chrono; - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -template -void test_timed_sync(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - - HPX_TEST( - traits::execute_after( - exec, milliseconds(1), &test, 42 - ) != hpx::this_thread::get_id()); - - HPX_TEST( - traits::execute_at( - exec, steady_clock::now()+milliseconds(1), &test, 42 - ) != hpx::this_thread::get_id()); -} - -template -void test_timed_async(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - - HPX_TEST( - traits::async_execute_after( - exec, milliseconds(1), &test, 42 - ).get() != hpx::this_thread::get_id()); - - HPX_TEST( - traits::async_execute_at( - exec, steady_clock::now()+milliseconds(1), &test, 42 - ).get() != hpx::this_thread::get_id()); -} - -template -void test_timed_apply(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - - traits::apply_execute_after(exec, milliseconds(1), &test, 42); - traits::apply_execute_at( - exec, steady_clock::now() + milliseconds(1), &test, 42); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_timed_this_thread_executor(Executor& exec) -{ - test_timed_sync(exec); - test_timed_async(exec); - test_timed_apply(exec); -} - -int hpx_main(int argc, char* argv[]) -{ - std::size_t num_threads = hpx::get_os_thread_count(); - HPX_UNUSED(num_threads); - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - { - hpx::parallel::this_thread_static_queue_executor exec; - test_timed_this_thread_executor(exec); - } -#endif - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - { - hpx::parallel::this_thread_static_priority_queue_executor exec; - test_timed_this_thread_executor(exec); - } -#endif - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/tests/unit/parallel/executors/timed_thread_pool_executors_v1.cpp b/tests/unit/parallel/executors/timed_thread_pool_executors_v1.cpp deleted file mode 100644 index 0c577f474597..000000000000 --- a/tests/unit/parallel/executors/timed_thread_pool_executors_v1.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) 2007-2016 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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace std::chrono; - -/////////////////////////////////////////////////////////////////////////////// -hpx::thread::id test(int passed_through) -{ - HPX_TEST_EQ(passed_through, 42); - return hpx::this_thread::get_id(); -} - -template -void test_timed_sync(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - - HPX_TEST( - traits::execute_after( - exec, milliseconds(1), &test, 42 - ) != hpx::this_thread::get_id()); - - HPX_TEST( - traits::execute_at( - exec, steady_clock::now() + milliseconds(1), &test, 42 - ) != hpx::this_thread::get_id()); -} - -template -void test_timed_async(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - - HPX_TEST( - traits::async_execute_after( - exec, milliseconds(1), &test, 42 - ).get() != hpx::this_thread::get_id()); - - HPX_TEST( - traits::async_execute_at( - exec, steady_clock::now() + milliseconds(1), &test, 42 - ).get() != hpx::this_thread::get_id()); -} - -template -void test_timed_apply(Executor& exec) -{ - typedef hpx::parallel::timed_executor_traits traits; - - traits::apply_execute_after(exec, milliseconds(1), &test, 42); - traits::apply_execute_at( - exec, steady_clock::now() + milliseconds(1), &test, 42); -} - -/////////////////////////////////////////////////////////////////////////////// -template -void test_timed_thread_pool_executor(Executor& exec) -{ - test_timed_sync(exec); - test_timed_async(exec); - test_timed_apply(exec); -} - -int hpx_main(int argc, char* argv[]) -{ - std::size_t num_threads = hpx::get_os_thread_count(); - -#if defined(HPX_HAVE_STATIC_SCHEDULER) - { - hpx::parallel::static_queue_executor exec(num_threads); - test_timed_thread_pool_executor(exec); - } -#endif - - { - hpx::parallel::local_priority_queue_executor exec(num_threads); - test_timed_thread_pool_executor(exec); - } - -#if defined(HPX_HAVE_STATIC_PRIORITY_SCHEDULER) - { - hpx::parallel::static_priority_queue_executor exec(num_threads); - test_timed_thread_pool_executor(exec); - } -#endif - - return hpx::finalize(); -} - -int main(int argc, char* argv[]) -{ - // By default this test should run on all available cores - std::vector const cfg = { - "hpx.os_threads=all" - }; - - // Initialize and run HPX - HPX_TEST_EQ_MSG(hpx::init(argc, argv, cfg), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -}