Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Adapting to HPX V1.5 #643

Open
wants to merge 9 commits into
base: 1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cinch
5 changes: 3 additions & 2 deletions config/project.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ endif()

list(APPEND FLECSI_LIBRARY_DEPENDENCIES ${COLORING_LIBRARIES})

if(FLECSI_RUNTIME_MODEL STREQUAL "mpi")
if(FLECSI_RUNTIME_MODEL STREQUAL "mpi" OR
FLECSI_RUNTIME_MODEL STREQUAL "hpx")
#------------------------------------------------------------------------------#
# Use lazy aggregated dense field communication
#------------------------------------------------------------------------------#
Expand Down Expand Up @@ -582,7 +583,7 @@ if (ENABLE_KOKKOS)
target_link_libraries(
FleCSI PUBLIC ${Kokkos_LIBRARIES}
)
if(ENABLE_FLECSI_TUTORIAL)
if(ENABLE_FLECSI_TUTORIAL)
target_link_libraries(FleCSI-Tut PUBLIC ${Kokkos_LIBRARIES})
endif()
endif()
Expand Down
48 changes: 27 additions & 21 deletions flecsi/coloring/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ set(coloring_HEADERS
# runtime specific and can be configured for whichever runtime is active.
#------------------------------------------------------------------------------#

set(UNIT_POLICY MPI)

if(FLECSI_RUNTIME_MODEL STREQUAL "serial")

set(UNIT_POLICY SERIAL)
# set(UNIT_POLICY SERIAL)
set(RUNTIME_DRIVER ../execution/serial/runtime_driver.cc)

elseif(FLECSI_RUNTIME_MODEL STREQUAL "legion")

set(UNIT_POLICY LEGION)
# set(UNIT_POLICY LEGION)
set(RUNTIME_DRIVER ../execution/legion/runtime_driver.cc)

elseif(FLECSI_RUNTIME_MODEL STREQUAL "mpi")

set(UNIT_POLICY MPI)
# set(UNIT_POLICY MPI)
set(RUNTIME_DRIVER ../execution/mpi/runtime_driver.cc)

elseif(FLECSI_RUNTIME_MODEL STREQUAL "hpx")
Expand Down Expand Up @@ -108,7 +110,7 @@ cinch_add_unit(dcrs
LIBRARIES
${CINCH_RUNTIME_LIBRARIES}
${COLORING_LIBRARIES}
POLICY MPI
POLICY ${UNIT_POLICY}
THREADS 5
)

Expand All @@ -117,8 +119,10 @@ cinch_add_devel_target(devel-dcrs
INPUTS
test/simple2d-8x8.msh
test/simple2d-16x16.msh
LIBRARIES ${COLORING_LIBRARIES}
POLICY MPI
LIBRARIES
${CINCH_RUNTIME_LIBRARIES}
${COLORING_LIBRARIES}
POLICY ${UNIT_POLICY}
THREADS 5
FOLDER "Tests/Coloring/Devel"
)
Expand All @@ -127,31 +131,33 @@ cinch_add_unit(boxcolor2d
SOURCES test/test_simple_box_colorer_2d.cc
INPUTS
LIBRARIES ${COLORING_LIBRARIES}
POLICY MPI
POLICY ${UNIT_POLICY}
THREADS 4
)
cinch_add_unit(boxcolor3d
SOURCES test/test_simple_box_colorer_3d.cc
INPUTS
LIBRARIES ${COLORING_LIBRARIES}
POLICY MPI
POLICY ${UNIT_POLICY}
THREADS 4
)
# Both of these tests depend on ParMETIS.
# This could change if we add more colorer types.
if(ENABLE_PARMETIS)

cinch_add_devel_target(coloring
SOURCES test/coloring.cc
INPUTS
test/simple2d-8x8.msh
test/simple2d-16x16.msh
test/simple2d-32x32.msh
test/simple2d-48x48.msh
LIBRARIES ${COLORING_LIBRARIES}
POLICY MPI
THREADS 5
FOLDER "Tests/Coloring/Devel"
)
cinch_add_devel_target(coloring
SOURCES test/coloring.cc
INPUTS
test/simple2d-8x8.msh
test/simple2d-16x16.msh
test/simple2d-32x32.msh
test/simple2d-48x48.msh
LIBRARIES
${CINCH_RUNTIME_LIBRARIES}
${COLORING_LIBRARIES}
POLICY ${UNIT_POLICY}
THREADS 5
FOLDER "Tests/Coloring/Devel"
)

endif()
endif(ENABLE_PARMETIS)
8 changes: 2 additions & 6 deletions flecsi/data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,15 @@ elseif(FLECSI_RUNTIME_MODEL STREQUAL "hpx")

set(data_HEADERS
${data_HEADERS}
hpx/color.h
hpx/data_client_handle_policy.h
hpx/data_handle_policy.h
hpx/data_policy.h
hpx/dense.h
hpx/global.h
hpx/meta_data.h
hpx/registration_wrapper.h
hpx/scoped.h
hpx/sparse.h
hpx/storage_policy.h
hpx/sparse_data_handle_policy.h
hpx/tuple.h
hpx/storage_policy.h
)

set(UNIT_POLICY HPX)
Expand Down Expand Up @@ -233,7 +230,6 @@ if(ENABLE_PARMETIS)
cinch_add_unit(client_registration
SOURCES
test/client_registration.cc
../utils/demangle.cc
${DRIVER_INITIALIZATION}
${RUNTIME_DRIVER}
DEFINES
Expand Down
9 changes: 9 additions & 0 deletions flecsi/data/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ struct data_client_policy_handler_u<topology::mesh_topology_u<POLICY_TYPE>> {
*ent.ghost_id_updated = false;
}
#endif
#if FLECSI_RUNTIME_MODEL == FLECSI_RUNTIME_MODEL_hpx
auto ritr = ism.find(ent.index_space);
clog_assert(ritr != ism.end(), "invalid index space " << ei.index_space);

// make client handle depend on only one of the fields
if(h.future == nullptr) {
h.future = &(ritr->second.future[ent.fid]);
}
#endif

++entity_index;
} // for
Expand Down
198 changes: 198 additions & 0 deletions flecsi/data/hpx/color.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
@@@@@@@@ @@ @@@@@@ @@@@@@@@ @@
/@@///// /@@ @@////@@ @@////// /@@
/@@ /@@ @@@@@ @@ // /@@ /@@
/@@@@@@@ /@@ @@///@@/@@ /@@@@@@@@@/@@
/@@//// /@@/@@@@@@@/@@ ////////@@/@@
/@@ /@@/@@//// //@@ @@ /@@/@@
/@@ @@@//@@@@@@ //@@@@@@ @@@@@@@@ /@@
// /// ////// ////// //////// //

Copyright (c) 2018, Los Alamos National Security, LLC
All rights reserved.
*/
#pragma once

/*! @file */

//----------------------------------------------------------------------------//
// POLICY_NAMESPACE must be defined before including storage_class.h!!!
// Using this approach allows us to have only one storage_class_u
// definition that can be used by all data policies -> code reuse...
#define POLICY_NAMESPACE hpx
#include <flecsi/data/storage_class.h>
#undef POLICY_NAMESPACE
//----------------------------------------------------------------------------//

#include <flecsi/data/common/privilege.h>
#include <flecsi/data/data_client.h>
#include <flecsi/data/global_data_handle.h>
#include <flecsi/data/storage.h>
#include <flecsi/execution/context.h>

#include <flecsi/utils/const_string.h>

namespace flecsi {
namespace data {
namespace hpx {

//----------------------------------------------------------------------------//
// Global handle.
//----------------------------------------------------------------------------//

/*!
The color_handle_u provide an access to color variables that have
been registered in data model

\tparam T The type of the data variable. If this type is not
consistent with the type used to register the data, bad things
can happen. However, it can be useful to reinterpret the type,
e.g., when writing raw bytes. This class is part of the
low-level \e flecsi interface, so it is assumed that you
know what you are doing...

@tparam PERMISSIONS The permissions to the handle.
*/

template<typename T, size_t PERMISSIONS>
struct color_handle_u : public global_data_handle_u<T, PERMISSIONS> {

/*!
Type definitions.
*/

using base_t = global_data_handle_u<T, PERMISSIONS>;

/*!
Constructor.
*/

color_handle_u() {
base_t::color = true;
}

/*!
Destructor.
*/

~color_handle_u() {}

/*
Copy constructor.
*/

template<size_t P2>
color_handle_u(const color_handle_u<T, P2> & a)
: base_t(reinterpret_cast<const base_t &>(a)), label_(a.label()),
size_(a.size()) {
static_assert(P2 == 0, "passing mapped handle to task args");
}

//--------------------------------------------------------------------------//
// Member data interface.
//--------------------------------------------------------------------------//

/*!
\brief Return a std::string containing the label of the data variable
reference by this handle.
*/

const std::string & label() const {
return label_;
} // label

/*!
\brief Return the index space size of the data variable
referenced by this handle.
*/

size_t size() const {
return size_;
} // size

/*!
\brief Test to see if this handle is empty

\return true if registered.
*/

operator bool() const {
return base_t::combined_data != nullptr;
} // operator bool

private:
std::string label_ = "";
size_t size_ = 1;
}; // struct color_handle_u

//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//
// Main type definition.
//+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=//

//----------------------------------------------------------------------------//
// Global storage type.
//----------------------------------------------------------------------------//

/*!
FIXME: Global storage type.
*/
template<>
struct storage_class_u<storage_label_type_t::color> {

/*!
Type definitions.
*/

template<typename T, size_t PERMISSIONS>
using handle_t = color_handle_u<T, PERMISSIONS>;

/*!
Data handles.
*/

template<typename DATA_CLIENT_TYPE,
typename DATA_TYPE,
size_t NAMESPACE,
size_t NAME,
size_t VERSION,
size_t PERMISSIONS>
static handle_t<DATA_TYPE, 0> get_handle(
const data_client_handle<DATA_CLIENT_TYPE, PERMISSIONS> & client_handle) {
handle_t<DATA_TYPE, 0> h;
auto & context = execution::context_t::instance();

auto & field_info = context.get_field_info_from_name(
typeid(typename DATA_CLIENT_TYPE::type_identifier_t).hash_code(),
utils::hash::field_hash<NAMESPACE, NAME>(VERSION));

auto & registered_field_data = context.registered_field_data();
auto fieldDataIter = registered_field_data.find(field_info.fid);
if(fieldDataIter == registered_field_data.end()) {
// TODO: deal with VERSION
context.register_field_data(field_info.fid, field_info.size);
}

auto data = registered_field_data[field_info.fid].data();

h.fid = field_info.fid;
h.index_space = field_info.index_space;
h.data_client_hash = field_info.data_client_hash;

h.combined_data = reinterpret_cast<DATA_TYPE *>(data);

h.color = true;
h.state = context.execution_state();

auto& registered_field_futures = context.registered_field_futures();
h.future = &registered_field_futures[field_info.fid];

h.ghost_is_readable = nullptr;

return h;
}

}; // struct storage_class_u

} // namespace hpx
} // namespace data
} // namespace flecsi
Loading