Skip to content

Commit

Permalink
Fixing task dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Jan 24, 2021
1 parent 21310fc commit f168f57
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 33 deletions.
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
2 changes: 1 addition & 1 deletion flecsi/data/hpx/data_client_handle_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct hpx_data_client_handle_policy_t {
data_client_handle_index_subspace_t
handle_index_subspaces[MAX_INDEX_SUBSPACES];

execution::hpx_future_u<void> future;
execution::hpx_future_u<void>* future = nullptr;

}; // struct data_client_handle_policy_t

Expand Down
2 changes: 1 addition & 1 deletion flecsi/data/hpx/data_handle_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct hpx_data_handle_policy_t {
size_t data_client_hash;
bool * ghost_is_readable;

execution::hpx_future_u<void> future;
execution::hpx_future_u<void>* future = nullptr;

}; // class mpi_data_handle_policy_t

Expand Down
4 changes: 4 additions & 0 deletions flecsi/data/hpx/dense.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ struct storage_class_u<storage_label_type_t::dense> {
hb.ghost_is_readable =
&(ism[field_info.index_space].ghost_is_readable[field_info.fid]);

#if FLECSI_RUNTIME_MODEL == FLECSI_RUNTIME_MODEL_hpx
hb.future = &(ism[field_info.index_space].future[field_info.fid]);
#endif

return h;
}

Expand Down
4 changes: 4 additions & 0 deletions flecsi/data/hpx/sparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ struct storage_class_u<ragged> {
hb.ghost_is_readable =
&(ism[field_info.index_space].ghost_is_readable[field_info.fid]);

#if FLECSI_RUNTIME_MODEL == FLECSI_RUNTIME_MODEL_hpx
hb.future = &(ism[field_info.index_space].future[field_info.fid]);
#endif

return h;
}

Expand Down
2 changes: 1 addition & 1 deletion flecsi/data/hpx/sparse_data_handle_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct hpx_sparse_data_handle_policy_t {
field_id_t fid;
bool * ghost_is_readable;

execution::hpx_future_u<void> future;
execution::hpx_future_u<void>* future = nullptr;

}; // class mpi_sparse_data_handle_policy_t

Expand Down
2 changes: 2 additions & 0 deletions flecsi/execution/hpx/context_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <flecsi/utils/mpi_type_traits.h>

#include <flecsi/utils/const_string.h>
#include <flecsi/execution/hpx/future.h>

namespace flecsi {
namespace execution {
Expand Down Expand Up @@ -197,6 +198,7 @@ struct hpx_context_policy_t {

struct index_space_data_t {
std::map<field_id_t, bool> ghost_is_readable;
std::map<field_id_t, execution::hpx_future_u<void>> future;
};

struct index_subspace_data_t {
Expand Down
50 changes: 28 additions & 22 deletions flecsi/execution/hpx/task_add_dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,33 @@ struct task_add_dependencies_t
GHOST_PERMISSIONS> &) {

// Skip Read Only handles
if constexpr((SHARED_PERMISSIONS == ro) || (GHOST_PERMISSIONS == rw) ||
(GHOST_PERMISSIONS == wo)) {
return;
}
else {
a.future = future;
if constexpr((EXCLUSIVE_PERMISSIONS != ro && EXCLUSIVE_PERMISSIONS != na) ||
(SHARED_PERMISSIONS != ro && SHARED_PERMISSIONS != na) ||
(GHOST_PERMISSIONS != ro && GHOST_PERMISSIONS != na)) {
*a.future = future;
has_dependencies = true;
}
} // handle

template<typename Global, typename T, size_t PERMISSIONS>
void handle(Global & a, global_accessor_u<T, PERMISSIONS> &) {
// Skip Read Only handles
if constexpr(PERMISSIONS != ro) {
a.future = future;
has_dependencies = true;
if constexpr(PERMISSIONS != ro && PERMISSIONS != na) {
if(a.future != nullptr) {
*a.future = future;
has_dependencies = true;
}
}
} // handle

template<typename Local, typename T, size_t PERMISSIONS>
void handle(Local & a, color_accessor_u<T, PERMISSIONS> &) {
// Skip Read Only handles
if constexpr(PERMISSIONS != ro && PERMISSIONS != na) {
if(a.future != nullptr) {
*a.future = future;
has_dependencies = true;
}
}
} // handle

Expand All @@ -122,12 +133,10 @@ struct task_add_dependencies_t
GHOST_PERMISSIONS> &) {

// Skip Read Only handles
if constexpr((SHARED_PERMISSIONS == ro) || (GHOST_PERMISSIONS == rw) ||
(GHOST_PERMISSIONS == wo)) {
return;
}
else {
a.future = future;
if constexpr((EXCLUSIVE_PERMISSIONS != ro && EXCLUSIVE_PERMISSIONS != na) ||
(SHARED_PERMISSIONS != ro && SHARED_PERMISSIONS != na) ||
(GHOST_PERMISSIONS != ro && GHOST_PERMISSIONS != na)) {
*a.future = future;
has_dependencies = true;
}
} // handle
Expand All @@ -147,25 +156,22 @@ struct task_add_dependencies_t

template<typename Ragged, typename T2>
void handle(Ragged & r1, ragged_mutator<T2> & r2) {
r1.future = future;
*r1.future = future;
has_dependencies = true;
}

template<typename Sparse, typename T2>
void handle(Sparse & m1, sparse_mutator<T2> & m2) {
m1.future = future;
*m1.future = future;
has_dependencies = true;
}

template<typename Client, typename T, size_t PERMISSIONS>
void handle(Client & h, data_client_handle_u<T, PERMISSIONS> &) {

// Skip Read Only handles
if constexpr(PERMISSIONS == ro) {
return;
}
else {
h.future = future;
if constexpr(PERMISSIONS != ro && PERMISSIONS != na) {
*h.future = future;
has_dependencies = true;
}
}
Expand Down
30 changes: 22 additions & 8 deletions flecsi/execution/hpx/task_collect_dependencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,29 @@ struct task_collect_dependencies_t
GHOST_PERMISSIONS> & a) {
auto & h = a.handle;

if(h.future.valid()) {
dependencies_.push_back(h.future);
clog_assert(h.future != nullptr, "invalid future handle");
if(h.future->valid()) {
dependencies_.push_back(*h.future);
}
} // handle

template<typename T, size_t PERMISSIONS>
void handle(global_accessor_u<T, PERMISSIONS> & a) {
auto & h = a.handle;

if(h.future.valid()) {
dependencies_.push_back(h.future);
// clog_assert(h.future != nullptr, "invalid future handle");
if(h.future != nullptr && h.future->valid()) {
dependencies_.push_back(*h.future);
}
} // handle

template<typename T, size_t PERMISSIONS>
void handle(color_accessor_u<T, PERMISSIONS> & a) {
auto & h = a.handle;

// clog_assert(h.future != nullptr, "invalid future handle");
if(h.future != nullptr && h.future->valid()) {
dependencies_.push_back(*h.future);
}
} // handle

Expand All @@ -112,8 +124,9 @@ struct task_collect_dependencies_t
GHOST_PERMISSIONS> & a) {
auto & h = a.handle;

if(h.future.valid()) {
dependencies_.push_back(h.future);
clog_assert(h.future != nullptr, "invalid future handle");
if(h.future->valid()) {
dependencies_.push_back(*h.future);
}
} // handle

Expand Down Expand Up @@ -141,8 +154,9 @@ struct task_collect_dependencies_t
template<typename T, size_t PERMISSIONS>
void handle(data_client_handle_u<T, PERMISSIONS> h) {

if(h.future.valid()) {
dependencies_.push_back(h.future);
clog_assert(h.future != nullptr, "invalid future handle");
if(h.future->valid()) {
dependencies_.push_back(*h.future);
}
}

Expand Down

0 comments on commit f168f57

Please sign in to comment.