-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start matrix transpose project, mute previous CMake Projects
Showing
8 changed files
with
313 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
cmake_minimum_required (VERSION 2.8.11) | ||
|
||
add_subdirectory (dist_objects_1) | ||
add_subdirectory (dist_objects_2) | ||
add_subdirectory (dist_objects_3) | ||
add_subdirectory (dist_objects_4) | ||
#add_subdirectory (dist_objects_1) | ||
#add_subdirectory (dist_objects_2) | ||
#add_subdirectory (dist_objects_3) | ||
#add_subdirectory (dist_objects_4) | ||
add_subdirectory (maxtrix_transpose) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.11) | ||
|
||
PROJECT(maxtrix_transpose CXX) | ||
|
||
# Instruct cmake to find the HPX settings | ||
find_package(HPX) | ||
|
||
ADD_SUBDIRECTORY( src ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
set(examples | ||
template_dist_object | ||
) | ||
|
||
# TODO: Add non-interactive version that can be tested. | ||
|
||
# for all targets specified above | ||
foreach(example ${examples}) | ||
set(client_sources ${example}_client.cpp) | ||
set(component_sources ${example}.cpp) | ||
set(component_headers ${example}.hpp server/${example}.hpp) | ||
|
||
source_group("Source Files" FILES ${client_sources} ${component_sources}) | ||
|
||
# add example components | ||
add_hpx_component(${example} | ||
SOURCES ${component_sources} | ||
HEADERS ${component_headers} | ||
FOLDER "${example}") | ||
|
||
# add example executable | ||
add_hpx_executable(${example}_client | ||
SOURCES ${client_sources} | ||
DEPENDENCIES ${example}_component | ||
FOLDER "${example}") | ||
|
||
# add a custom target for this example | ||
add_hpx_pseudo_target(examples.${example}) | ||
|
||
# make pseudo-targets depend on master pseudo-target | ||
add_hpx_pseudo_dependencies(examples | ||
examples.${example}) | ||
|
||
# add dependencies to pseudo-target | ||
add_hpx_pseudo_dependencies(examples.${example} | ||
${example}_client) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright (c) 2019 Weile Wei | ||
// Copyright (c) 2019 Maxwell Reesser | ||
// Copyright (c) 2019 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_TEMPLATE_DIST_OBJECT_SERVER_MAR_20_2019_0325PM) | ||
#define HPX_TEMPLATE_DIST_OBJECT_SERVER_MAR_20_2019_0325PM | ||
|
||
#include <hpx/include/actions.hpp> | ||
#include <hpx/include/components.hpp> | ||
#include <hpx/util/detail/pp/cat.hpp> | ||
|
||
#include <vector> | ||
|
||
namespace dist_object { | ||
namespace server { | ||
template <typename T> | ||
class partition : public hpx::components::locking_hook< | ||
hpx::components::component_base<partition<T>>> { | ||
public: | ||
typedef std::vector<T> data_type; | ||
partition() {} | ||
|
||
partition(data_type const &data) : data_(data) {} | ||
|
||
partition(data_type &&data) : data_(std::move(data)) {} | ||
|
||
size_t size() { return data_.size(); } | ||
|
||
data_type &operator*() { return data_; } | ||
|
||
data_type const &operator*() const { return data_;} | ||
|
||
data_type const* operator->() const | ||
{ | ||
return &data_; | ||
} | ||
|
||
data_type* operator->() | ||
{ | ||
return &data_; | ||
} | ||
|
||
data_type fetch() const | ||
{ | ||
return data_; | ||
} | ||
|
||
HPX_DEFINE_COMPONENT_ACTION(partition, size); | ||
HPX_DEFINE_COMPONENT_ACTION(partition, fetch); | ||
|
||
private: | ||
data_type data_; | ||
}; | ||
} | ||
} | ||
|
||
#define REGISTER_PARTITION_DECLARATION(type) \ | ||
HPX_REGISTER_ACTION_DECLARATION( \ | ||
\ | ||
HPX_REGISTER_ACTION_DECLARATION( \ | ||
dist_object::server::partition<type>::size_action, \ | ||
HPX_PP_CAT(__partition_size_action_, type)); \ | ||
HPX_REGISTER_ACTION_DECLARATION( \ | ||
dist_object::server::partition<type>::fetch_action, \ | ||
HPX_PP_CAT(__partition_fetch_action_, type)); \ | ||
/**/ | ||
|
||
#define REGISTER_PARTITION(type) \ | ||
HPX_REGISTER_ACTION(dist_object::server::partition<type>::size_action, \ | ||
HPX_PP_CAT(__partition_size_action_, type)); \ | ||
HPX_REGISTER_ACTION( \ | ||
dist_object::server::partition<type>::fetch_action, \ | ||
HPX_PP_CAT(__partition_fetch_action_, type)); \ | ||
typedef ::hpx::components::component<dist_object::server::partition<type>> \ | ||
HPX_PP_CAT(__partition_, type); \ | ||
HPX_REGISTER_COMPONENT(HPX_PP_CAT(__partition_, type)) \ | ||
/**/ | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2019 Weile Wei | ||
// Copyright (c) 2019 Maxwell Reesser | ||
// Copyright (c) 2019 Hartmut Kaiser | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
#include <hpx/hpx.hpp> | ||
#include <hpx/runtime/components/component_factory.hpp> | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// Add factory registration functionality. | ||
HPX_REGISTER_COMPONENT_MODULE(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Copyright (c) 2019 Weile Wei | ||
// Copyright (c) 2019 Maxwell Reesser | ||
// Copyright (c) 2019 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_TEMPLATE_DIST_OBJECT_SERVER_MAR_20_2019_0328PM) | ||
#define HPX_TEMPLATE_DIST_OBJECT_SERVER_MAR_20_2019_0328PM | ||
|
||
#include <hpx/include/components.hpp> | ||
#include <hpx/util/assert.hpp> | ||
|
||
#include "server/template_dist_object.hpp" | ||
|
||
#include <string> | ||
#include <utility> | ||
|
||
namespace dist_object { | ||
template <typename T> | ||
class dist_object | ||
: hpx::components::client_base<dist_object<T>, server::partition<T>> { | ||
typedef hpx::components::client_base<dist_object<T>, server::partition<T>> | ||
base_type; | ||
|
||
typedef typename server::partition<T>::data_type data_type; | ||
|
||
private: | ||
template <typename Arg> | ||
static hpx::future<hpx::id_type> create_server(Arg &&value) { | ||
return hpx::new_<server::partition<T>>(hpx::find_here(), std::forward<Arg>(value)); | ||
} | ||
|
||
public: | ||
dist_object() {} | ||
|
||
dist_object(std::string base, data_type const &data) | ||
: base_type(create_server(data)), base_(base) | ||
{ | ||
basename_registration_helper(base); | ||
} | ||
|
||
dist_object(std::string base, data_type &&data) | ||
: base_type(create_server(std::move(data))), base_(base) | ||
{ | ||
basename_registration_helper(base); | ||
} | ||
|
||
dist_object(std::string base, hpx::future<hpx::id_type> &&id) | ||
: base_type(std::move(id)), base_(base) | ||
{ | ||
basename_registration_helper(base); | ||
} | ||
|
||
dist_object(std::string base, hpx::id_type &&id) | ||
: base_type(std::move(id)), base_(base) | ||
{ | ||
basename_registration_helper(base); | ||
} | ||
|
||
size_t size() { | ||
HPX_ASSERT(this->get_id()); | ||
ensure_ptr(); | ||
return (**ptr).size(); | ||
} | ||
|
||
data_type const &operator*() const { | ||
HPX_ASSERT(this->get_id()); | ||
ensure_ptr(); | ||
return **ptr; | ||
} | ||
|
||
data_type &operator*() { | ||
HPX_ASSERT(this->get_id()); | ||
ensure_ptr(); | ||
return **ptr; | ||
} | ||
|
||
data_type const* operator->() const | ||
{ | ||
HPX_ASSERT(this->get_id()); | ||
ensure_ptr(); | ||
return &**ptr; | ||
} | ||
|
||
data_type* operator->() | ||
{ | ||
HPX_ASSERT(this->get_id()); | ||
ensure_ptr(); | ||
return &**ptr; | ||
} | ||
|
||
hpx::future<data_type> fetch(int idx) | ||
{ | ||
HPX_ASSERT(this->get_id()); | ||
hpx::id_type lookup = get_basename_helper(idx); | ||
typedef typename server::partition<T>::fetch_action | ||
action_type; | ||
return hpx::async<action_type>(lookup); | ||
} | ||
|
||
private: | ||
mutable std::shared_ptr<server::partition<T>> ptr; | ||
std::string base_; | ||
void ensure_ptr() const { | ||
if (!ptr) { | ||
ptr = hpx::get_ptr<server::partition<T>>(hpx::launch::sync, get_id()); | ||
} | ||
} | ||
private: | ||
std::vector<hpx::id_type> basename_list; | ||
hpx::id_type get_basename_helper(int idx) { | ||
if (!basename_list[idx]) { | ||
basename_list[idx] = hpx::find_from_basename(base_ + std::to_string(idx), idx).get(); | ||
} | ||
return basename_list[idx]; | ||
} | ||
void basename_registration_helper(std::string base) { | ||
hpx::register_with_basename(base + std::to_string(hpx::get_locality_id()), get_id()); | ||
basename_list.resize(hpx::find_all_localities().size()); | ||
} | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2019 Weile Wei | ||
// Copyright (c) 2019 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) | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
/// This is a dist_object example using HPX component. | ||
/// | ||
/// A distributed object is a single logical object partitioned across | ||
/// a set of localities. (A locality is a single node in a cluster or a | ||
/// NUMA domian in a SMP machine.) Each locality constructs an instance of | ||
/// dist_object<T>, where a value of type T represents the value of this | ||
/// this locality's instance value. Once dist_object<T> is conctructed, it | ||
/// has a universal name which can be used on any locality in the given | ||
/// localities to locate the resident instance. | ||
|
||
#include <hpx/hpx_init.hpp> | ||
#include <hpx/include/iostreams.hpp> | ||
#include <hpx/lcos/barrier.hpp> | ||
|
||
#include "template_dist_object.hpp" | ||
|
||
#include <cassert> | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
|
||
REGISTER_PARTITION(int); | ||
using myVectorInt = std::vector<int>; | ||
REGISTER_PARTITION(myVectorInt); | ||
|
||
void run_matrix_transposition() { | ||
return; | ||
} | ||
|
||
|
||
int hpx_main() { | ||
run_matrix_transposition(); | ||
std::cout << "Hello world from locality " << hpx::get_locality_id() << std::endl; | ||
return hpx::finalize(); | ||
} | ||
|
||
int main(int argc, char *argv[]) { return hpx::init(argc, argv); } |