Skip to content

Commit

Permalink
Merge branch 'master' into fixing_doc_index
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jun 3, 2017
2 parents 1503600 + bd87b09 commit f767188
Show file tree
Hide file tree
Showing 24 changed files with 680 additions and 171 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Expand Up @@ -847,6 +847,14 @@ if(HPX_WITH_ASYNC_FUNCTION_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_ASYNC_FUNCTION_COMPATIBILITY)
endif()

# HPX_WITH_QUEUE_COMPATIBILITY: introduced in V1.1.0
hpx_option(HPX_WITH_QUEUE_COMPATIBILITY BOOL
"Enable old style queue components in API (default: OFF)"
OFF ADVANCED)
if(HPX_WITH_QUEUE_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_QUEUE_COMPATIBILITY)
endif()

# BADBAD: This enables an overload of swap which is necessary to work around the
# problems caused by zip_iterator not being a real random access iterator.
# Dereferencing zip_iterator does not yield a true reference but
Expand Down
5 changes: 2 additions & 3 deletions cmake/HPX_SetupBoost.cmake
Expand Up @@ -131,8 +131,7 @@ if(MSVC)
hpx_option(HPX_WITH_BOOST_ALL_DYNAMIC_LINK BOOL
"Add BOOST_ALL_DYN_LINK to compile flags (default: OFF)"
OFF ADVANCED)
if (HPX_WITH_BOOST_ALL_DYNAMIC_LINK OR HPX_WITH_VCPKG)
set(HPX_WITH_BOOST_ALL_DYNAMIC_LINK ON)
if (HPX_WITH_BOOST_ALL_DYNAMIC_LINK)
hpx_add_config_cond_define(BOOST_ALL_DYN_LINK)
endif()
else()
Expand All @@ -149,7 +148,7 @@ endif()

include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
if((NOT MSVC) OR HPX_WITH_BOOST_ALL_DYNAMIC_LINK)
if((NOT MSVC) OR HPX_WITH_BOOST_ALL_DYNAMIC_LINK OR HPX_WITH_VCPKG)
hpx_libraries(${Boost_LIBRARIES})
else()
hpx_library_dir(${Boost_LIBRARY_DIRS})
Expand Down
1 change: 1 addition & 0 deletions cmake/templates/autodoc.doxy.in
Expand Up @@ -13,4 +13,5 @@ XML_OUTPUT = @doxygen_output_file@
OUTPUT_DIRECTORY = @doxygen_output_dir@
GENERATE_LATEX = NO
INPUT = @doxygen_inputs@
EXCLUDE_SYMBOLS = detail

5 changes: 3 additions & 2 deletions docs/CMakeLists.txt
Expand Up @@ -176,8 +176,9 @@ set(doxygen_dependencies
"${PROJECT_SOURCE_DIR}/hpx/lcos/when_each.hpp"
"${PROJECT_SOURCE_DIR}/hpx/traits/is_execution_policy.hpp"
"${PROJECT_SOURCE_DIR}/hpx/util/invoke.hpp"
"${PROJECT_SOURCE_DIR}/hpx/util/invoke_fused.hpp")

"${PROJECT_SOURCE_DIR}/hpx/util/invoke_fused.hpp"
"${PROJECT_SOURCE_DIR}/hpx/util/unwrapped.hpp"
"${PROJECT_SOURCE_DIR}/hpx/performance_counters/manage_counter_type.hpp")

foreach(doxygen_input ${doxygen_dependencies})
set(doxygen_inputs "${doxygen_inputs} ${doxygen_input}")
Expand Down
4 changes: 4 additions & 0 deletions docs/hpx.idx
Expand Up @@ -515,6 +515,10 @@ invoke_r "" "header\.hpx\.util\.invoke_r.*"
invoke_fused "" "header\.hpx\.util\.invoke_fused.*"
invoke_fused_r "" "header\.hpx\.util\.invoke_fused_r.*"

# hpx/util/unwrapped.hpp
unwrapped "" "header\.hpx\.util\.unwrapped.*"
unwrapped2 "" "header\.hpx\.util\.unwrapped2.*"

# hpx/hpx_finalize.hpp
finalize "" "hpx\.finalize.*"
terminate "" "hpx\.terminate.*"
Expand Down
7 changes: 5 additions & 2 deletions docs/whats_new.qbk
Expand Up @@ -24,17 +24,20 @@ particular order):
* The parameter sequence for the `hpx::parallel::transform_inclusive_scan` overload
taking one iterator range has changed (again) to match the changes this algorithm
has undergone while being moved to C++17. The old overloads can be still enabled
at configure time by specifying `-DHPX_WITH_TRANSFORM_REDUCE_COMPATIBILITY=On`
at configure time by passing `-DHPX_WITH_TRANSFORM_REDUCE_COMPATIBILITY=On`
to __cmake__.
* The parameter sequence for the `hpx::parallel::inclusive_scan` overload
taking one iterator range has changed to match the changes this algorithm
has undergone while being moved to C++17. The old overloads can be still enabled
at configure time by specifying `-DHPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY=On`
at configure time by passing `-DHPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY=On`
to __cmake__.
* Added a helper facility `hpx::local_new` which is equivalent to `hpx::new_`
except that it creates components locally only. As a consequence, the used
component constructor may accept non-serializable argument types and/or
non-const references or pointers.
* Removed the (broken) component type `hpx::lcos::queue<T>`. The old type is
still available at configure time by passing
`-DHPX_WITH_QUEUE_COMPATIBILITY=On` to __cmake__.

[heading Breaking Changes]

Expand Down
7 changes: 6 additions & 1 deletion examples/CMakeLists.txt
Expand Up @@ -20,7 +20,6 @@ set(subdirs
jacobi_smp
nqueen
performance_counters
queue
quickstart
qt
random_mem_access
Expand All @@ -32,6 +31,12 @@ set(subdirs
transpose
)

if(HPX_WITH_QUEUE_COMPATIBILITY)
set(subdirs ${subdirs}
queue
)
endif()

if(HPX_WITH_FORTRAN)
set(subdirs ${subdirs}
sheneos
Expand Down
8 changes: 6 additions & 2 deletions examples/queue/queue_client.cpp
Expand Up @@ -6,6 +6,7 @@
#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>

#if defined(HPX_HAVE_QUEUE_COMPATIBILITY)
#include <hpx/include/lcos.hpp>

#include <iostream>
Expand All @@ -32,10 +33,12 @@ void break_queue(queue_type queue)
{
queue.abort_pending();
}
#endif

///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map &vm)
{
#if defined(HPX_HAVE_QUEUE_COMPATIBILITY)
// Create a new queue of integers.
queue_type queue = hpx::new_<queue_type>(hpx::find_here());

Expand All @@ -53,13 +56,14 @@ int hpx_main(boost::program_options::variables_map &vm)
hpx::apply(hpx::util::bind(&worker, queue));

hpx::apply(hpx::util::bind(&break_queue, queue));
#endif

hpx::finalize();
return 0;
return hpx::finalize();
}

///////////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
return hpx::init("queue_of_ints_client", argc, argv);
}

4 changes: 3 additions & 1 deletion hpx/include/lcos.hpp
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2015 Hartmut Kaiser
// Copyright (c) 2007-2017 Hartmut Kaiser
// Copyright (c) 2011 Bryce Lelbach
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -19,7 +19,9 @@
#include <hpx/lcos/channel.hpp>
#include <hpx/lcos/gather.hpp>
#include <hpx/lcos/latch.hpp>
#if defined(HPX_HAVE_QUEUE_COMPATIBILITY)
#include <hpx/lcos/queue.hpp>
#endif
#include <hpx/lcos/reduce.hpp>

#include <hpx/include/async.hpp>
Expand Down
177 changes: 177 additions & 0 deletions hpx/lcos/local/spmd_block.hpp
@@ -0,0 +1,177 @@
// Copyright (c) 2017 Antoine Tran Tan
//
// 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_LCOS_LOCAL_SPMD_BLOCK_HPP)
#define HPX_LCOS_LOCAL_SPMD_BLOCK_HPP

#include <hpx/lcos/future.hpp>
#include <hpx/lcos/local/barrier.hpp>
#include <hpx/parallel/execution_policy.hpp>
#include <hpx/traits/is_execution_policy.hpp>
#include <hpx/util/first_argument.hpp>

#include <boost/range/irange.hpp>

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

namespace hpx { namespace lcos { namespace local
{
/// The class spmd_block defines an interface for launching
/// multiple images while giving handles to each image to interact with
/// the remaining images. The \a define_spmd_block function templates create
/// multiple images of a user-defined function (or lambda) and launches them
/// in a possibly separate thread. A temporary spmd block object is created
/// and diffused to each image. The constraint for the function (or lambda)
/// given to the define_spmd_block function is to accept a spmd_block as
/// first parameter.
struct spmd_block
{
explicit spmd_block(std::size_t num_images, std::size_t image_id,
hpx::lcos::local::barrier & barrier)
: num_images_(num_images), image_id_(image_id), barrier_(barrier)
{}

// Note: spmd_block class is movable/move-assignable
// but not copyable/copy-assignable

spmd_block(spmd_block &&) = default;
spmd_block(spmd_block const &) = delete;

spmd_block & operator=(spmd_block &&) = default;
spmd_block & operator=(spmd_block const &) = delete;

std::size_t get_num_images() const
{
return num_images_;
}

std::size_t this_image() const
{
return image_id_;
}

void sync_all() const
{
barrier_.get().wait();
}

private:
std::size_t num_images_;
std::size_t image_id_;
mutable std::reference_wrapper<hpx::lcos::local::barrier> barrier_;
};

namespace detail
{
template <typename F>
struct spmd_block_helper
{
mutable std::shared_ptr<hpx::lcos::local::barrier> barrier_;
typename std::decay<F>::type f_;
std::size_t num_images_;

template <typename ... Ts>
void operator()(std::size_t image_id, Ts && ... ts) const
{
spmd_block block(num_images_, image_id, *barrier_);
hpx::util::invoke(
f_, std::move(block), std::forward<Ts>(ts)...);
}
};
}

// Asynchronous version
template <typename ExPolicy, typename F, typename ... Args,
typename = typename std::enable_if<
hpx::parallel::v1::is_async_execution_policy<ExPolicy>::value>::type
>
std::vector<hpx::future<void>>
define_spmd_block(ExPolicy && policy,
std::size_t num_images, F && f, Args && ... args)
{
static_assert(
parallel::execution::is_execution_policy<ExPolicy>::value,
"parallel::execution::is_execution_policy<ExPolicy>::value");

using ftype = typename std::decay<F>::type;

using first_type =
typename hpx::util::first_argument<ftype>::type;

using executor_type =
typename hpx::util::decay<ExPolicy>::type::executor_type;

static_assert(std::is_same<spmd_block, first_type>::value,
"define_spmd_block() needs a function or lambda that " \
"has at least a local spmd_block as 1st argument");

std::shared_ptr<hpx::lcos::local::barrier> barrier
= std::make_shared<hpx::lcos::local::barrier>(num_images);

return
hpx::parallel::executor_traits<
typename std::decay<executor_type>::type
>::bulk_async_execute(
policy.executor(),
detail::spmd_block_helper<F>{
barrier, std::forward<F>(f), num_images
},
boost::irange(std::size_t(0), num_images),
std::forward<Args>(args)...);
}

// Synchronous version
template <typename ExPolicy, typename F, typename ... Args,
typename = typename std::enable_if<
!hpx::parallel::v1::is_async_execution_policy<ExPolicy>::value>::type
>
void
define_spmd_block(ExPolicy && policy,
std::size_t num_images, F && f, Args && ... args)
{
static_assert(
parallel::execution::is_execution_policy<ExPolicy>::value,
"parallel::execution::is_execution_policy<ExPolicy>::value");

using ftype = typename std::decay<F>::type;

using first_type =
typename hpx::util::first_argument<ftype>::type;

using executor_type =
typename hpx::util::decay<ExPolicy>::type::executor_type;

static_assert(std::is_same<spmd_block, first_type>::value,
"define_spmd_block() needs a lambda that " \
"has at least a spmd_block as 1st argument");

std::shared_ptr<hpx::lcos::local::barrier> barrier
= std::make_shared<hpx::lcos::local::barrier>(num_images);

hpx::parallel::executor_traits<
typename std::decay<executor_type>::type
>::bulk_execute(
policy.executor(),
detail::spmd_block_helper<F>{
barrier, std::forward<F>(f), num_images
},
boost::irange(std::size_t(0), num_images),
std::forward<Args>(args)...);
}

template <typename F, typename ... Args>
void define_spmd_block(std::size_t num_images, F && f, Args && ... args)
{
define_spmd_block(parallel::execution::par,
num_images, std::forward<F>(f), std::forward<Args>(args)...);
}
}}}

#endif
3 changes: 3 additions & 0 deletions hpx/lcos/queue.hpp
Expand Up @@ -7,6 +7,8 @@
#define HPX_LCOS_QUEUE_FEB_10_2011_1232PM

#include <hpx/config.hpp>

#if defined(HPX_HAVE_QUEUE_COMPATIBILITY)
#include <hpx/lcos/server/queue.hpp>
#include <hpx/runtime/components/client_base.hpp>

Expand Down Expand Up @@ -134,4 +136,5 @@ namespace hpx { namespace lcos
}}

#endif
#endif

3 changes: 3 additions & 0 deletions hpx/lcos/server/queue.hpp
Expand Up @@ -7,6 +7,8 @@
#define HPX_LCOS_SERVER_QUEUE_FEB_09_2011_1204PM

#include <hpx/config.hpp>

#if defined(HPX_HAVE_QUEUE_COMPATIBILITY)
#include <hpx/error_code.hpp>
#include <hpx/exception_fwd.hpp>
#include <hpx/lcos/base_lco_with_value.hpp>
Expand Down Expand Up @@ -197,4 +199,5 @@ namespace hpx { namespace lcos { namespace server
/**/

#endif
#endif

0 comments on commit f767188

Please sign in to comment.