Skip to content

Commit

Permalink
Fall back to creating local components using local_new
Browse files Browse the repository at this point in the history
- extend local_new for array syntax
- adding corresponding tests
- flyby: adding more overloads for make_client
- flyby: clean up nqueens, accumulator, and random_access examples
  • Loading branch information
hkaiser committed Nov 1, 2017
1 parent d4e41a8 commit 8a3c8b1
Show file tree
Hide file tree
Showing 29 changed files with 370 additions and 438 deletions.
8 changes: 6 additions & 2 deletions examples/accumulators/accumulator.hpp
Expand Up @@ -41,8 +41,12 @@ namespace examples

/// Create a client side representation for the existing
/// \a server::accumulator instance with the given GID.
accumulator(hpx::future<hpx::id_type> && gid)
: base_type(std::move(gid))
accumulator(hpx::future<hpx::id_type> && id)
: base_type(std::move(id))
{}

accumulator(hpx::id_type && id)
: base_type(std::move(id))
{}

///////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions examples/accumulators/accumulator_client.cpp
Expand Up @@ -33,8 +33,8 @@ int hpx_main()
// Create an accumulator component either on this locality (if the
// example is executed on one locality only) or on any of the remote
// localities (otherwise).
examples::accumulator accu(
hpx::components::new_<accumulator_type>(localities.back()));
examples::accumulator accu =
hpx::new_<accumulator_type>(localities.back());

// Print out the available commands.
std::cout << help << std::endl << "> ";
Expand Down
8 changes: 6 additions & 2 deletions examples/accumulators/template_accumulator.hpp
Expand Up @@ -39,8 +39,12 @@ namespace examples

/// Create a client side representation for the existing
/// \a server::accumulator instance with the given GID.
template_accumulator(hpx::future<hpx::id_type> && gid)
: base_type(std::move(gid))
template_accumulator(hpx::future<hpx::id_type> && id)
: base_type(std::move(id))
{}

template_accumulator(hpx::id_type && id)
: base_type(std::move(id))
{}

///////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions examples/accumulators/template_accumulator_client.cpp
Expand Up @@ -35,8 +35,8 @@ void run_template_accumulator(char const* type)
// Create an accumulator component either on this locality (if the
// example is executed on one locality only) or on any of the remote
// localities (otherwise).
examples::template_accumulator<T> accu(
hpx::components::new_<accumulator_type>(localities.back()));
examples::template_accumulator<T> accu =
hpx::new_<accumulator_type>(localities.back());

// Print out the available commands.
std::cout << std::endl
Expand Down
8 changes: 6 additions & 2 deletions examples/accumulators/template_function_accumulator.hpp
Expand Up @@ -37,8 +37,12 @@ namespace examples

/// Create a client side representation for the existing
/// \a server::managed_accumulator instance with the given GID.
template_function_accumulator(hpx::future<hpx::id_type> && gid)
: base_type(std::move(gid))
template_function_accumulator(hpx::future<hpx::id_type> && id)
: base_type(std::move(id))
{}

template_function_accumulator(hpx::id_type && id)
: base_type(std::move(id))
{}

///////////////////////////////////////////////////////////////////////
Expand Down
Expand Up @@ -33,7 +33,7 @@ int hpx_main()
{
// Create an accumulator component on this locality.
examples::template_function_accumulator accu =
hpx::components::new_<examples::template_function_accumulator>(
hpx::new_<examples::template_function_accumulator>(
hpx::find_here());

// Print out the available commands.
Expand Down
30 changes: 7 additions & 23 deletions examples/nqueen/nqueen.cpp
Expand Up @@ -5,42 +5,26 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <hpx/hpx.hpp>
#include <hpx/runtime/components/component_factory.hpp>

#include "server/nqueen.hpp"

HPX_REGISTER_COMPONENT_MODULE();

typedef hpx::components::component<
nqueen::server::board
> board_type;

typedef hpx::components::component<nqueen::server::board> board_type;

HPX_REGISTER_COMPONENT(board_type, board);

// Serialization support for the board actions
HPX_REGISTER_ACTION(board_type::wrapped_type::init_action, board_init_action);

HPX_REGISTER_ACTION(
board_type::wrapped_type::init_action,
board_init_action);

HPX_REGISTER_ACTION(
board_type::wrapped_type::check_action,
board_check_action);
HPX_REGISTER_ACTION(board_type::wrapped_type::check_action, board_check_action);

HPX_REGISTER_ACTION(
board_type::wrapped_type::access_action,
HPX_REGISTER_ACTION(board_type::wrapped_type::access_action,
board_access_action);

HPX_REGISTER_ACTION(
board_type::wrapped_type::update_action,
HPX_REGISTER_ACTION(board_type::wrapped_type::update_action,
board_update_action);

HPX_REGISTER_ACTION(
board_type::wrapped_type::solve_action,
board_solve_action);

HPX_REGISTER_ACTION(
board_type::wrapped_type::clear_action,
board_clear_action);
HPX_REGISTER_ACTION(board_type::wrapped_type::solve_action, board_solve_action);

HPX_REGISTER_ACTION(board_type::wrapped_type::clear_action, board_clear_action);
81 changes: 46 additions & 35 deletions examples/nqueen/nqueen.hpp
Expand Up @@ -10,75 +10,86 @@
#include <hpx/runtime.hpp>
#include <hpx/include/client.hpp>

#include <examples/nqueen/stubs/nqueen.hpp>
#include <examples/nqueen/server/nqueen.hpp>

#include <cstddef>
#include <utility>

namespace nqueen
{
class board
: public hpx::components::client_base<board, stubs::board>
class board : public hpx::components::client_base<board, server::board>
{
typedef hpx::components::client_base<board, stubs::board> base_type;
typedef hpx::components::client_base<board, server::board> base_type;

public:
board()
{}
board(hpx::future<hpx::naming::id_type> && gid)
: base_type(std::move(gid))
{}

void init_board(std::size_t size ){
return this->base_type::init_board(get_id(), size);
board() {}
board(hpx::id_type&& gid)
: base_type(std::move(gid))
{
}
board(hpx::future<hpx::id_type>&& gid)
: base_type(std::move(gid))
{
}
//-------------------------------------------------------

list_type access_board(){
return this->base_type::access_board(get_id());
void init_board(std::size_t size)
{
hpx::apply<server::board::init_action>(this->get_id(), size);
}

hpx::lcos::future<list_type> access_board_async(){
return this->base_type::access_board_async(get_id());
//-------------------------------------------------------
list_type access_board()
{
return access_board_async().get();
}
//------------------------------------------------------

void update_board(std::size_t level, std::size_t pos){
return this->base_type::update_board(get_id(), level, pos);
hpx::lcos::future<list_type> access_board_async()
{
typedef server::board::access_action action_type;
return hpx::async<action_type>(this->get_id());
}
//-----------------------------------------------------

bool check_board(list_type const& list, std::size_t level){
return this->base_type::check_board(get_id(), list, level);
//------------------------------------------------------
void update_board(std::size_t level, std::size_t pos)
{
hpx::apply<server::board::update_action>(
this->get_id(), level, pos);
}

//-----------------------------------------------------
bool check_board(list_type const& list, std::size_t level)
{
return check_board_async(list, level).get();
}

hpx::lcos::future<bool> check_board_async(list_type const& list,
std::size_t level)
{
return this->base_type::check_board_async(get_id(), list, level);
typedef server::board::check_action action_type;
return hpx::async<action_type>(this->get_id(), list, level);
}
//---------------------------------------------------------

//---------------------------------------------------------
std::size_t solve_board(list_type const& list, std::size_t size,
std::size_t level, std::size_t col)
{
return this->base_type::solve_board(get_id(), list, size, level, col);
return solve_board_async(list, size, level, col).get();
}

hpx::lcos::future<std::size_t>
solve_board_async(list_type const& list, std::size_t size,
std::size_t level, std::size_t col)
hpx::lcos::future<std::size_t> solve_board_async(list_type const& list,
std::size_t size, std::size_t level, std::size_t col)
{
return this->base_type::solve_board_async
(get_id(), list, size, level, col);
typedef server::board::solve_action action_type;
return hpx::async<action_type>(
this->get_id(), list, size, level, col);
}
//---------------------------------------------------------

void clear_board(){
return this->base_type::clear_board(get_id());
//---------------------------------------------------------
void clear_board()
{
hpx::apply<server::board::clear_action>(this->get_id());
}
};

}

#endif // HPX_527D225B_F1EC_4BC5_9245_3A69C6AE5304
Expand Down
7 changes: 2 additions & 5 deletions examples/nqueen/nqueen_client.cpp
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2012 Hartmut Kaiser, Richard D Guidry Jr.
// Copyright (c) 2007-2017 Hartmut Kaiser, Richard D Guidry Jr.
// Copyright (c) 2011 Vinay C Amatya
// Copyright (c) 2011 Bryce Lelbach
//
Expand Down Expand Up @@ -114,8 +114,5 @@ int hpx_main(boost::program_options::variables_map&)

int main(int argc, char* argv[])
{
boost::program_options::options_description
desc_commandline("Usage: " HPX_APPLICATION_STRING " [options]");

return hpx::init(desc_commandline, argc, argv);
return hpx::init(argc, argv);
}

0 comments on commit 8a3c8b1

Please sign in to comment.