Skip to content

Commit

Permalink
Merge pull request #244 from fz707/2step
Browse files Browse the repository at this point in the history
[#243] 2-step constructor for abstract data-structure
  • Loading branch information
VitoCastellana authored Jul 11, 2023
2 parents 95e9382 + 608de56 commit 82859e1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/shad/data_structures/abstract_data_structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class AbstractDataStructure {
/// @brief Default constructor
AbstractDataStructure() = default;


/// @brief Create method.
///
/// Creates a global instance of DataStructure, and associates to it a unique
Expand All @@ -85,7 +86,9 @@ class AbstractDataStructure {
ObjectID id = catalogRef->GetNextID();
std::tuple<ObjectID, Args...> tuple(id, args...);
rt::executeOnAll(CreateFunWrapper<ObjectID, Args...>, tuple);
return catalogRef->GetPtr(id);
auto ret= catalogRef->GetPtr(id);
ret->DataStructurePointerCommunication();
return ret;
}

/// @brief Destroy method.
Expand Down Expand Up @@ -149,6 +152,7 @@ class AbstractDataStructure {
static void CreateFunWrapper(const std::tuple<Args...> &args) {
CreateFunInnerWrapper(std::move(args), std::index_sequence_for<Args...>());
}
void DataStructurePointerCommunication(){}

class Catalog {
public:
Expand Down Expand Up @@ -196,6 +200,7 @@ class AbstractDataStructure {
}

private:

Catalog() : register_(rt::numLocalities()), oidCache_(), registerLock_() {}

/// The Type storing the counter to obtain new DataStructure object IDs.
Expand Down
15 changes: 15 additions & 0 deletions include/shad/data_structures/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,18 @@ void PrintAllElements() {
}
}

constexpr void DataStructurePointerCommunication() {
rt::executeOnAll([](const ObjectID &oid) {
auto This = Array<T>::GetPtr(oid);
rt::executeOnAll([](const std::tuple<ObjectID, rt::Locality, T*> &args) {
auto This = Array<T>::GetPtr(std::get<0>(args));

This->ptrs_[(uint32_t)std::get<1>(args)] = std::get<2>(args);
},
std::make_tuple(This->GetGlobalID(), rt::thisLocality(), This->data_.data()));
}, GetGlobalID());
}

private:
ObjectID oid_;
size_t size_;
Expand Down Expand Up @@ -948,6 +960,9 @@ void PrintAllElements() {
}
};

template <>
constexpr void Array<bool>::DataStructurePointerCommunication() {}

static std::pair<rt::Locality, size_t> getTargetLocalityFromTargePosition(
const std::vector<std::pair<size_t, size_t>> &dataDistribution,
size_t position) {
Expand Down

0 comments on commit 82859e1

Please sign in to comment.