From 74b68a0541d86a1483131d72b0b4f01706a31821 Mon Sep 17 00:00:00 2001 From: ywwu928 <44017355+ywwu928@users.noreply.github.com> Date: Thu, 23 May 2024 20:51:41 -0500 Subject: [PATCH] copy GlobalRef first then manipulate on frequent access (#105) --- .../graphs/mirror_dist_local_csr.hpp | 75 +++++++++++-------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/include/pando-lib-galois/graphs/mirror_dist_local_csr.hpp b/include/pando-lib-galois/graphs/mirror_dist_local_csr.hpp index 34d801dd..404c0f2d 100644 --- a/include/pando-lib-galois/graphs/mirror_dist_local_csr.hpp +++ b/include/pando-lib-galois/graphs/mirror_dist_local_csr.hpp @@ -448,13 +448,14 @@ class MirrorDistLocalCSR { */ pando::Vector getLocalDirtyMasters() { pando::Vector dirtyMasterTopology; - pando::GlobalRef> masterBitSet = masterBitSets.getLocalRef(); + pando::Array masterBitSet = masterBitSets.getLocalRef(); for (std::uint64_t i = 0ul; i < lift(masterBitSet, size); i++) { - if (fmap(masterBitSet, operator[], i) == true) { + if (masterBitSet[i] == true) { VertexTopologyID masterTopologyID = getMasterTopologyIDFromIndex(i); dirtyMasterTopology.pushBack(masterTopologyID); } } + masterBitSets.getLocalRef() = masterBitSet; return dirtyMasterTopology; } @@ -464,13 +465,14 @@ class MirrorDistLocalCSR { */ pando::Vector getLocalDirtyMirrors() { pando::Vector dirtyMirrorTopology; - pando::GlobalRef> mirrorBitSet = mirrorBitSets.getLocalRef(); - for (std::uint64_t i = 0ul; i < lift(mirrorBitSet, size); i++) { - if (fmap(mirrorBitSet, operator[], i) == true) { + pando::Array mirrorBitSet = mirrorBitSets.getLocalRef(); + for (std::uint64_t i = 0ul; i < mirrorBitSet.size(); i++) { + if (mirrorBitSet[i] == true) { VertexTopologyID mirrorTopologyID = getMirrorTopologyIDFromIndex(i); dirtyMirrorTopology.pushBack(mirrorTopologyID); } } + mirrorBitSets.getLocalRef() = mirrorBitSet; return dirtyMirrorTopology; } @@ -480,20 +482,22 @@ class MirrorDistLocalCSR { */ pando::Vector getLocalDirtyVertices() { pando::Vector dirtyVertexTopology; - pando::GlobalRef> masterBitSet = masterBitSets.getLocalRef(); - for (std::uint64_t i = 0ul; i < lift(masterBitSet, size); i++) { - if (fmap(masterBitSet, operator[], i) == true) { + pando::Array masterBitSet = masterBitSets.getLocalRef(); + for (std::uint64_t i = 0ul; i < masterBitSet.size(); i++) { + if (masterBitSet[i] == true) { VertexTopologyID masterTopologyID = getMasterTopologyIDFromIndex(i); dirtyVertexTopology.pushBack(masterTopologyID); } } - pando::GlobalRef> mirrorBitSet = mirrorBitSets.getLocalRef(); - for (std::uint64_t i = 0ul; i < lift(mirrorBitSet, size); i++) { - if (fmap(mirrorBitSet, operator[], i) == true) { + masterBitSets.getLocalRef() = masterBitSet; + pando::Array mirrorBitSet = mirrorBitSets.getLocalRef(); + for (std::uint64_t i = 0ul; i < mirrorBitSet.size(); i++) { + if (mirrorBitSet[i] == true) { VertexTopologyID mirrorTopologyID = getMirrorTopologyIDFromIndex(i); dirtyVertexTopology.pushBack(mirrorTopologyID); } } + mirrorBitSets.getLocalRef() = mirrorBitSet; return dirtyVertexTopology; } @@ -575,13 +579,13 @@ class MirrorDistLocalCSR { PANDO_CHECK(galois::doAll( wgh, state, localMirrorToRemoteMasterOrderedTable, +[](decltype(state) state, - pando::GlobalRef> localMirrorToRemoteMasterOrderedMap) { + pando::Array localMirrorToRemoteMasterOrderedMap) { auto [thisMDLCSR, func, wgh] = state; - pando::GlobalRef> mirrorBitSet = thisMDLCSR.getLocalMirrorBitSet(); + pando::Array mirrorBitSet = thisMDLCSR.getLocalMirrorBitSet(); - for (std::uint64_t i = 0ul; i < lift(mirrorBitSet, size); i++) { - bool dirty = fmap(mirrorBitSet, operator[], i); + for (std::uint64_t i = 0ul; i < mirrorBitSet.size(); i++) { + bool dirty = mirrorBitSet[i]; if (dirty) { // obtain the local mirror vertex data VertexTopologyID mirrorTopologyID = thisMDLCSR.getMirrorTopologyIDFromIndex(i); @@ -589,7 +593,7 @@ class MirrorDistLocalCSR { VertexData mirrorData = thisMDLCSR.getData(mirrorTopologyID); // obtain the corresponding remote master information - MirrorToMasterMap map = fmap(localMirrorToRemoteMasterOrderedMap, operator[], i); + MirrorToMasterMap map = localMirrorToRemoteMasterOrderedMap[i]; VertexTopologyID masterTopologyID = map.getMaster(); // atomic function signature: func(VertexData mirror, pando::GlobalRef // master) apply the function @@ -615,6 +619,8 @@ class MirrorDistLocalCSR { // master data updated } } + + thisMDLCSR.getLocalMirrorBitSet() = mirrorBitSet; })); PANDO_CHECK(wg.wait()); wg.deinitialize(); @@ -632,23 +638,23 @@ class MirrorDistLocalCSR { PANDO_CHECK(galois::doAll( wgh, state, localMasterToRemoteMirrorTable, - +[](decltype(state) state, pando::GlobalRef>> - localMasterToRemoteMirrorMap) { + +[](decltype(state) state, + pando::Vector> localMasterToRemoteMirrorMap) { auto [thisMDLCSR, wgh] = state; - pando::GlobalRef> masterBitSet = thisMDLCSR.getLocalMasterBitSet(); + pando::Array masterBitSet = thisMDLCSR.getLocalMasterBitSet(); std::uint64_t numHosts = static_cast(pando::getPlaceDims().node.id); for (std::uint64_t nodeId = 0ul; nodeId < numHosts; nodeId++) { - pando::GlobalRef> mapVectorFromHost = - fmap(localMasterToRemoteMirrorMap, operator[], nodeId); - for (std::uint64_t i = 0ul; i < lift(mapVectorFromHost, size); i++) { - MirrorToMasterMap map = fmap(mapVectorFromHost, operator[], i); + pando::Vector mapVectorFromHost = + localMasterToRemoteMirrorMap[nodeId]; + for (std::uint64_t i = 0ul; i < mapVectorFromHost.size(); i++) { + MirrorToMasterMap map = mapVectorFromHost[i]; VertexTopologyID masterTopologyID = map.getMaster(); std::uint64_t index = thisMDLCSR.getIndex(masterTopologyID, thisMDLCSR.getLocalMasterRange()); - bool dirty = fmap(masterBitSet, operator[], index); + bool dirty = masterBitSet[index]; if (dirty) { // obtain the local master vertex data VertexData masterData = thisMDLCSR.getData(masterTopologyID); @@ -791,13 +797,16 @@ class MirrorDistLocalCSR { auto state = galois::make_tpl(masterRange, mirrorRange, mirrorBitSets); PANDO_CHECK(galois::doAll( wgh, state, masterBitSets, - +[](decltype(state) state, pando::GlobalRef> masterBitSet) { + +[](decltype(state) state, pando::GlobalRef> globalMasterBitSet) { auto [masterRange, mirrorRange, mirrorBitSets] = state; - pando::GlobalRef> mirrorBitSet = mirrorBitSets.getLocalRef(); + pando::Array mirrorBitSet = mirrorBitSets.getLocalRef(); + pando::Array masterBitSet = globalMasterBitSet; PANDO_CHECK(fmap(mirrorBitSet, initialize, lift(mirrorRange.getLocalRef(), size))); PANDO_CHECK(fmap(masterBitSet, initialize, lift(masterRange.getLocalRef(), size))); fmapVoid(mirrorBitSet, fill, false); fmapVoid(masterBitSet, fill, false); + mirrorBitSets.getLocalRef() = mirrorBitSet; + globalMasterBitSet = masterBitSet; })); PANDO_CHECK(wg.wait()); // wg.deinitialize(); @@ -813,14 +822,14 @@ class MirrorDistLocalCSR { // initialize localMirrorToRemoteMasterOrderedTable PANDO_CHECK_RETURN(localMasterToRemoteMirrorTable.initialize()); for (std::int64_t i = 0; i < dims.node.id; i++) { - pando::GlobalRef>> - localMasterToRemoteMirrorMap = localMasterToRemoteMirrorTable[i]; - PANDO_CHECK_RETURN(fmap(localMasterToRemoteMirrorMap, initialize, dims.node.id)); + pando::Vector> localMasterToRemoteMirrorMap; + PANDO_CHECK_RETURN(localMasterToRemoteMirrorMap.initialize(dims.node.id)); for (std::int64_t i = 0; i < dims.node.id; i++) { pando::GlobalRef> mapVectorFromHost = - fmap(localMasterToRemoteMirrorMap, operator[], i); + localMasterToRemoteMirrorMap[i]; PANDO_CHECK_RETURN(fmap(mapVectorFromHost, initialize, 0)); } + localMasterToRemoteMirrorTable[i] = localMasterToRemoteMirrorMap; } auto thisCSR = *this; @@ -833,10 +842,10 @@ class MirrorDistLocalCSR { galois::doAll( state, localMirrorToRemoteMasterOrderedTable, +[](decltype(state) state, - pando::GlobalRef> localMirrorToRemoteMasterOrderedMap) { + pando::Array localMirrorToRemoteMasterOrderedMap) { auto [object, localMasterToRemoteMirrorTable] = state; - for (std::uint64_t i = 0ul; i < lift(localMirrorToRemoteMasterOrderedMap, size); i++) { - MirrorToMasterMap m = fmap(localMirrorToRemoteMasterOrderedMap, operator[], i); + for (std::uint64_t i = 0ul; i < localMirrorToRemoteMasterOrderedMap.size(); i++) { + MirrorToMasterMap m = localMirrorToRemoteMasterOrderedMap[i]; VertexTopologyID masterTopologyID = m.getMaster(); VertexTokenID masterTokenID = object.getTokenID(masterTopologyID); std::uint64_t physicalHost = object.getPhysicalHostID(masterTokenID);