diff --git a/libcusp/include/galois/graphs/DistributedLocalGraph.h b/libcusp/include/galois/graphs/DistributedLocalGraph.h index bed956848..0ff532a8f 100644 --- a/libcusp/include/galois/graphs/DistributedLocalGraph.h +++ b/libcusp/include/galois/graphs/DistributedLocalGraph.h @@ -99,14 +99,18 @@ class DistLocalGraph { // local graph // size() = Number of nodes created on this host (masters + mirrors) - uint32_t numOwned; //!< Number of nodes owned (masters) by this host. - //!< size() - numOwned = mirrors on this host - uint32_t beginMaster; //!< Local id of the beginning of master nodes. - //!< beginMaster + numOwned = local id of the end of - //!< master nodes + uint32_t numOwned; //!< Number of nodes owned (masters) by this host. + //!< size() - numOwned = mirrors on this host + uint32_t numOwnedInit; //!< Number of nodes owned (masters) by this host that + //!< was loaded initially (static graph) + uint32_t beginMaster; //!< Local id of the beginning of master nodes. + //!< beginMaster + numOwned = local id of the end of + //!< master nodes uint32_t numNodesWithEdges; //!< Number of nodes (masters + mirrors) that have //!< outgoing edges + std::vector + ownedNodesIndices; //!< Indices of owned nodes that are added dynamically //! Information that converts host to range of nodes that host reads std::vector> gid2host; //! Mirror nodes from different hosts. For reduce @@ -693,6 +697,8 @@ class DistLocalGraph { return specificRanges[0]; } + size_t getValue(uint32_t lid) { return ownedNodesIndices[lid]; } + /** * Returns a range object that encapsulates only master nodes in this * graph. @@ -716,6 +722,13 @@ class DistLocalGraph { return specificRanges[2]; } + void setNumOwnedInit(uint32_t num) { + numOwnedInit = num; + for (uint32_t i = 0; i < num; i++) { + ownedNodesIndices.push_back(i); + } + } + /** * Returns a vector object that contains the global IDs (in order) of * the master nodes in this graph. @@ -969,11 +982,11 @@ class DistLocalGraph { std::optional> dstData = std::nullopt) { if (isVertex) { - if (globalToLocalMap.find(src) == globalToLocalMap.end()) { - localToGlobalVector.push_back(src); - globalToLocalMap[src] = localToGlobalVector.size() - 1; - numNodes++; - } + assert(globalToLocalMap.find(src) == globalToLocalMap.end()); + localToGlobalVector.push_back(src); + globalToLocalMap[src] = localToGlobalVector.size() - 1; + numNodes++; + ownedNodesIndices.push_back(numNodes - 1); numOwned++; } else { assert(globalToLocalMap.find(src) != globalToLocalMap.end()); diff --git a/libwmd/include/galois/wmd/WMDPartitioner.h b/libwmd/include/galois/wmd/WMDPartitioner.h index c786aa932..e7914cc03 100644 --- a/libwmd/include/galois/wmd/WMDPartitioner.h +++ b/libwmd/include/galois/wmd/WMDPartitioner.h @@ -314,6 +314,7 @@ class WMDGraph : public DistLocalGraph { base_DistGraph::determineThreadRangesMaster(); base_DistGraph::determineThreadRangesWithEdges(); base_DistGraph::initializeSpecificRanges(); + base_DistGraph::setNumOwnedInit(base_DistGraph::numOwned); Tthread_ranges.stop(); Tgraph_construct.stop(); diff --git a/libwmd/test/wmd-graph-build.cpp b/libwmd/test/wmd-graph-build.cpp index 0a8e0a92c..9705092dc 100644 --- a/libwmd/test/wmd-graph-build.cpp +++ b/libwmd/test/wmd-graph-build.cpp @@ -209,7 +209,9 @@ int main(int argc, char* argv[]) { galois::do_all( galois::iterate(graph->masterNodesRange()), [&](size_t lid) { - auto token = graph->getData(lid).id; + size_t initLid = lid; + lid = graph->getValue(lid); + auto token = graph->getData(lid).id; std::vector edgeDst; auto end = graph->edge_end(lid); auto itr = graph->edge_begin(lid); @@ -222,7 +224,7 @@ int main(int argc, char* argv[]) { } assert(edgeDst == edgeDstDbg); std::sort(edgeDst.begin(), edgeDst.end()); - tokenAndEdges[lid] = std::make_pair(token, std::move(edgeDst)); + tokenAndEdges[initLid] = std::make_pair(token, std::move(edgeDst)); }, galois::steal()); // gather node info from other hosts