Skip to content

Commit 8f70c8c

Browse files
author
Fardin Zaman
committed
[pnnl#243] 2-step constructor for abstract data-structure
1 parent a64955e commit 8f70c8c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

include/shad/data_structures/abstract_data_structure.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class AbstractDataStructure {
6464
/// @brief Default constructor
6565
AbstractDataStructure() = default;
6666

67+
6768
/// @brief Create method.
6869
///
6970
/// Creates a global instance of DataStructure, and associates to it a unique
@@ -85,7 +86,9 @@ class AbstractDataStructure {
8586
ObjectID id = catalogRef->GetNextID();
8687
std::tuple<ObjectID, Args...> tuple(id, args...);
8788
rt::executeOnAll(CreateFunWrapper<ObjectID, Args...>, tuple);
88-
return catalogRef->GetPtr(id);
89+
auto ret= catalogRef->GetPtr(id);
90+
ret->DataStructurePointerCommunication();
91+
return ret;
8992
}
9093

9194
/// @brief Destroy method.
@@ -150,6 +153,8 @@ class AbstractDataStructure {
150153
CreateFunInnerWrapper(std::move(args), std::index_sequence_for<Args...>());
151154
}
152155

156+
void DataStructurePointerCommunication(){}
157+
153158
class Catalog {
154159
public:
155160
void Insert(const ObjectID &oid, const SharedPtr ce) {
@@ -196,6 +201,7 @@ class AbstractDataStructure {
196201
}
197202

198203
private:
204+
199205
Catalog() : register_(rt::numLocalities()), oidCache_(), registerLock_() {}
200206

201207
/// The Type storing the counter to obtain new DataStructure object IDs.

include/shad/data_structures/array.h

+15
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,18 @@ void PrintAllElements() {
701701
}
702702
}
703703

704+
constexpr void DataStructurePointerCommunication() {
705+
rt::executeOnAll([](const ObjectID &oid) {
706+
auto This = Array<T>::GetPtr(oid);
707+
rt::executeOnAll([](const std::tuple<ObjectID, rt::Locality, T*> &args) {
708+
auto This = Array<T>::GetPtr(std::get<0>(args));
709+
710+
This->ptrs_[(uint32_t)std::get<1>(args)] = std::get<2>(args);
711+
},
712+
std::make_tuple(This->GetGlobalID(), rt::thisLocality(), This->data_.data()));
713+
}, GetGlobalID());
714+
}
715+
704716
private:
705717
ObjectID oid_;
706718
size_t size_;
@@ -948,6 +960,9 @@ void PrintAllElements() {
948960
}
949961
};
950962

963+
template <>
964+
constexpr void Array<bool>::DataStructurePointerCommunication() {}
965+
951966
static std::pair<rt::Locality, size_t> getTargetLocalityFromTargePosition(
952967
const std::vector<std::pair<size_t, size_t>> &dataDistribution,
953968
size_t position) {

0 commit comments

Comments
 (0)