Skip to content

Commit

Permalink
changing masterRanges() (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
divija95 authored Aug 21, 2024
1 parent 74f886f commit cf65e84
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
33 changes: 23 additions & 10 deletions libcusp/include/galois/graphs/DistributedLocalGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>
ownedNodesIndices; //!< Indices of owned nodes that are added dynamically
//! Information that converts host to range of nodes that host reads
std::vector<std::pair<uint64_t, uint64_t>> gid2host;
//! Mirror nodes from different hosts. For reduce
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -969,11 +982,11 @@ class DistLocalGraph {
std::optional<std::vector<NodeTy>> 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());
Expand Down
1 change: 1 addition & 0 deletions libwmd/include/galois/wmd/WMDPartitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ class WMDGraph : public DistLocalGraph<NodeTy, EdgeTy> {
base_DistGraph::determineThreadRangesMaster();
base_DistGraph::determineThreadRangesWithEdges();
base_DistGraph::initializeSpecificRanges();
base_DistGraph::setNumOwnedInit(base_DistGraph::numOwned);
Tthread_ranges.stop();

Tgraph_construct.stop();
Expand Down
6 changes: 4 additions & 2 deletions libwmd/test/wmd-graph-build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t> edgeDst;
auto end = graph->edge_end(lid);
auto itr = graph->edge_begin(lid);
Expand All @@ -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
Expand Down

0 comments on commit cf65e84

Please sign in to comment.