Skip to content

Commit

Permalink
p
Browse files Browse the repository at this point in the history
  • Loading branch information
JossWhittle committed Aug 29, 2016
1 parent f031b5c commit e6f0393
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
10 changes: 3 additions & 7 deletions MEL/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,15 @@ struct DiGraphNode {

template<typename MSG>
inline void DeepCopy(MSG &msg) {
std::cout << "Object Deep Copy" << std::endl;

msg & edges;
for (auto &e : edges) msg.packSharedPtr(e);
};
};

template<typename T, typename MSG>
inline void MyDeepCopy(DiGraphNode<T> &obj, MSG &msg) {
std::cout << "My Deep Copy" << std::endl;

inline void DiGraphNode_DeepCopy(DiGraphNode<T> &obj, MSG &msg) {
msg & obj.edges;
for (auto &e : obj.edges) msg.packSharedPtr<DiGraphNode<T>, MyDeepCopy>(e);
for (auto &e : obj.edges) msg.packSharedPtr<DiGraphNode<T>, DiGraphNode_DeepCopy>(e);
};

inline DiGraphNode<int>* MakeBTreeGraph(const int numNodes) {
Expand Down Expand Up @@ -191,7 +187,7 @@ int main(int argc, char *argv[]) {
auto startTime = MEL::Wtime(); // Start the clock!

// Deep copy the graph to all nodes
MEL::Deep::Bcast<DiGraphNode<int>*, MEL::Deep::PointerHashMap, MyDeepCopy, MyDeepCopy>(graph, 0, comm);
MEL::Deep::Bcast<decltype(graph), MEL::Deep::PointerHashMap, DiGraphNode_DeepCopy, DiGraphNode_DeepCopy>(graph, 0, comm);

MEL::Barrier(comm);
auto endTime = MEL::Wtime(); // Stop the clock!
Expand Down
20 changes: 10 additions & 10 deletions MEL_deepcopy_experimental.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferWrite)
inline enable_if_deep_not_pointer_not_stl<T> BufferedSend(T &obj, const int dst, const int tag, const Comm &comm, const int bufferSize) {
inline enable_if_not_pointer_not_stl<T> BufferedSend(T &obj, const int dst, const int tag, const Comm &comm, const int bufferSize) {
char *buffer = MEL::MemAlloc<char>(bufferSize);
Message<TransportBufferWrite, HASH_MAP> msg(buffer, bufferSize);
msg.packRootVar<T, F>(obj);
Expand All @@ -994,7 +994,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferWrite)
inline enable_if_deep_not_pointer_not_stl<T> BufferedSend(T &obj, const int dst, const int tag, const Comm &comm) {
inline enable_if_not_pointer_not_stl<T> BufferedSend(T &obj, const int dst, const int tag, const Comm &comm) {
MEL::Deep::BufferedSend<T, HASH_MAP, F>(obj, dst, tag, comm, MEL::Deep::BufferSize<T, HASH_MAP, F>(obj));
};

Expand Down Expand Up @@ -1167,7 +1167,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferRead)
inline enable_if_deep_not_pointer_not_stl<T> BufferedRecv(T &obj, const int src, const int tag, const Comm &comm) {
inline enable_if_not_pointer_not_stl<T> BufferedRecv(T &obj, const int src, const int tag, const Comm &comm) {
int bufferSize;
char *buffer = nullptr;
MEL::Deep::Recv(buffer, bufferSize, src, tag, comm);
Expand Down Expand Up @@ -1468,7 +1468,7 @@ namespace MEL {
};

TEMPLATE_T_F2(TransportBufferWrite, TransportBufferRead)
inline enable_if_deep_not_pointer_not_stl<T> BufferedBcast(T &obj, const int root, const Comm &comm, const int bufferSize) {
inline enable_if_not_pointer_not_stl<T> BufferedBcast(T &obj, const int root, const Comm &comm, const int bufferSize) {
if (MEL::CommRank(comm) == root) {
char *buffer = MEL::MemAlloc<char>(bufferSize);
Message<TransportBufferWrite, HASH_MAP> msg(buffer, bufferSize);
Expand Down Expand Up @@ -1501,7 +1501,7 @@ namespace MEL {
};

TEMPLATE_T_F2(TransportBufferWrite, TransportBufferRead)
inline enable_if_deep_not_pointer_not_stl<T> BufferedBcast(T &obj, const int root, const Comm &comm) {
inline enable_if_not_pointer_not_stl<T> BufferedBcast(T &obj, const int root, const Comm &comm) {
if (MEL::CommRank(comm) == root) {
MEL::Deep::BufferedBcast<T, HASH_MAP, F1>(obj, root, comm, MEL::Deep::BufferSize<T, HASH_MAP, F1>(obj));
}
Expand Down Expand Up @@ -1896,7 +1896,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferWrite)
inline enable_if_deep_not_pointer_not_stl<T> BufferedFileWrite(T &obj, MEL::File &file) {
inline enable_if_not_pointer_not_stl<T> BufferedFileWrite(T &obj, MEL::File &file) {
MEL::Deep::BufferedFileWrite<T, HASH_MAP, F>(obj, file, MEL::Deep::BufferSize<T, HASH_MAP, F>(obj));
};

Expand Down Expand Up @@ -2069,7 +2069,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferRead)
inline enable_if_deep_not_pointer_not_stl<T> BufferedFileRead(T &obj, MEL::File &file) {
inline enable_if_not_pointer_not_stl<T> BufferedFileRead(T &obj, MEL::File &file) {
int bufferSize;
char *buffer = nullptr;
MEL::Deep::FileRead(buffer, bufferSize, file);
Expand Down Expand Up @@ -2300,7 +2300,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferWrite)
inline enable_if_deep_not_pointer_not_stl<T> BufferedFileWrite(T &obj, std::ofstream &file, const int bufferSize) {
inline enable_if_not_pointer_not_stl<T> BufferedFileWrite(T &obj, std::ofstream &file, const int bufferSize) {
char *buffer = MEL::MemAlloc<char>(bufferSize);
Message<TransportBufferWrite, HASH_MAP> msg(buffer, bufferSize);
msg.packRootVar<T, F>(obj);
Expand All @@ -2316,7 +2316,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferWrite)
inline enable_if_deep_not_pointer_not_stl<T> BufferedFileWrite(T &obj, std::ofstream &file) {
inline enable_if_not_pointer_not_stl<T> BufferedFileWrite(T &obj, std::ofstream &file) {
MEL::Deep::BufferedFileWrite<T, HASH_MAP, F>(obj, file, MEL::Deep::BufferSize<T, HASH_MAP, F>(obj));
};

Expand Down Expand Up @@ -2489,7 +2489,7 @@ namespace MEL {
};

TEMPLATE_T_F(TransportBufferRead)
inline enable_if_deep_not_pointer_not_stl<T> BufferedFileRead(T &obj, std::ifstream &file) {
inline enable_if_not_pointer_not_stl<T> BufferedFileRead(T &obj, std::ifstream &file) {
int bufferSize;
char *buffer = nullptr;
MEL::Deep::FileRead(buffer, bufferSize, file);
Expand Down

0 comments on commit e6f0393

Please sign in to comment.