Skip to content

Commit bd29284

Browse files
authored
changes to support edits (#56)
* changes to support edits * fixing pre-commit issue * fixing pre-commit * fixing minor bug
1 parent 5835f9b commit bd29284

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

libcusp/include/galois/graphs/DistributedLocalGraph.h

+29-10
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@ class DistLocalGraph {
754754
*/
755755
inline void determineThreadRangesMaster() {
756756
// make sure this hasn't been called before
757-
assert(masterRanges.size() == 0);
757+
if (masterRanges.size() != 0)
758+
masterRanges.clear();
758759

759760
// first check if we even need to do any work; if already calculated,
760761
// use already calculated vector
@@ -780,7 +781,8 @@ class DistLocalGraph {
780781
*/
781782
inline void determineThreadRangesWithEdges() {
782783
// make sure not called before
783-
assert(withEdgeRanges.size() == 0);
784+
if (withEdgeRanges.size() != 0)
785+
withEdgeRanges.clear();
784786

785787
// first check if we even need to do any work; if already calculated,
786788
// use already calculated vector
@@ -802,7 +804,8 @@ class DistLocalGraph {
802804
* over the graph in different ways.
803805
*/
804806
void initializeSpecificRanges() {
805-
assert(specificRanges.size() == 0);
807+
if (specificRanges.size() != 0)
808+
specificRanges.clear();
806809

807810
// TODO/FIXME assertion likely not safe if a host gets no nodes
808811
// make sure the thread ranges have already been calculated
@@ -949,20 +952,27 @@ class DistLocalGraph {
949952
host, galois::runtime::evilPhase, std::move(b));
950953
}
951954

955+
void updateRanges() {
956+
determineThreadRanges();
957+
determineThreadRangesMaster();
958+
determineThreadRangesWithEdges();
959+
initializeSpecificRanges();
960+
}
961+
952962
// Assumptions:
953963
// 1. A vertex is added before any edges are added to it
954964
// 2. No support for deleting edges/vertices yet
955965
// 3. Only works for OEC
956966
void
957967
updateVariables(bool isVertex, uint64_t src,
958-
std::optional<std::vector<uint64_t>> dsts = std::nullopt) {
968+
std::optional<std::vector<uint64_t>> dsts = std::nullopt,
969+
std::optional<std::vector<NodeTy>> dstData = std::nullopt) {
959970

960971
if (isVertex) {
961972
if (globalToLocalMap.find(src) == globalToLocalMap.end()) {
962973
localToGlobalVector.push_back(src);
963974
globalToLocalMap[src] = localToGlobalVector.size() - 1;
964975
numNodes++;
965-
} else {
966976
}
967977
numOwned++;
968978
} else {
@@ -971,14 +981,24 @@ class DistLocalGraph {
971981
if (edge_begin(srcLID) == edge_end(srcLID)) {
972982
numNodesWithEdges++;
973983
}
984+
uint32_t i = 0;
974985
for (auto token : dsts.value()) {
975986
if (globalToLocalMap.find(token) == globalToLocalMap.end()) {
976987
localToGlobalVector.push_back(token);
977988
globalToLocalMap[token] = localToGlobalVector.size() - 1;
978989
numNodes++;
990+
numNodesWithEdges++;
991+
std::vector<NodeTy> data;
992+
data.push_back(dstData.value()[i]);
993+
graph->addVertices(data);
979994
}
995+
i++;
980996
if (!isOwned(token)) {
981997
mirrorNodes[getHostID(token)].push_back(token);
998+
} else {
999+
if (edge_begin(getLID(token)) == edge_end(getLID(token))) {
1000+
numNodesWithEdges++;
1001+
}
9821002
}
9831003
}
9841004
numEdges += dsts.value().size();
@@ -990,7 +1010,7 @@ class DistLocalGraph {
9901010
uint64_t belongsTo = getHostID(token);
9911011
if (belongsTo == id) {
9921012
updateVariables(true, token);
993-
// graph->addVertexTopologyOnly();
1013+
graph->addVertexTopologyOnly();
9941014
} else {
9951015
sendModifyRequest(belongsTo, ADD_VERTEX_TOPOLOGY_ONLY, token);
9961016
}
@@ -1025,18 +1045,17 @@ class DistLocalGraph {
10251045
}
10261046

10271047
void addEdges(uint64_t src, std::vector<uint64_t> dsts,
1028-
std::vector<EdgeTy> data) {
1048+
std::vector<EdgeTy> data, std::vector<NodeTy> dstData) {
10291049
uint64_t belongsTo = getHostID(src);
10301050
if (belongsTo == id) {
1031-
updateVariables(false, src, dsts);
1051+
updateVariables(false, src, dsts, dstData);
10321052
std::vector<uint64_t> lids;
10331053
for (uint32_t i = 0; i < dsts.size(); i++) {
10341054
lids.push_back(getLID(dsts[i]));
10351055
}
10361056
graph->addEdges(getLID(src), lids, data);
1037-
10381057
} else {
1039-
sendModifyRequest(belongsTo, ADD_EDGES, src, dsts, data);
1058+
sendModifyRequest(belongsTo, ADD_EDGES, src, dsts, data, dstData);
10401059
}
10411060
}
10421061

libgalois/include/galois/runtime/GraphUpdateManager.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class graphUpdateManager {
5858
stopCheck = true;
5959
while (!checkThread.joinable())
6060
;
61+
graph->updateRanges();
6162
checkThread.join();
6263
return stopIngest;
6364
}
@@ -85,7 +86,8 @@ class graphUpdateManager {
8586
dsts.push_back(edge.dst);
8687
std::vector<E> data;
8788
data.push_back(edge);
88-
graph->addEdges(edge.src, dsts, data);
89+
std::vector<N> dstData = fileParser->GetDstData(value.edges);
90+
graph->addEdges(edge.src, dsts, data, dstData);
8991
}
9092
}
9193
}
@@ -110,6 +112,7 @@ class graphUpdateManager {
110112
galois::runtime::getHostBarrier().wait();
111113
std::this_thread::sleep_for(
112114
std::chrono::milliseconds(periodForCheck));
115+
graph->updateRanges();
113116
lineNumber = 0;
114117
}
115118
}
@@ -141,7 +144,9 @@ class graphUpdateManager {
141144
galois::runtime::gDeserialize(m->second, edge_dsts);
142145
std::vector<E> edge_data;
143146
galois::runtime::gDeserialize(m->second, edge_data);
144-
graph->addEdges(src_node, edge_dsts, edge_data);
147+
std::vector<N> dst_data;
148+
galois::runtime::gDeserialize(m->second, dst_data);
149+
graph->addEdges(src_node, edge_dsts, edge_data, dst_data);
145150
}
146151
}
147152
std::this_thread::sleep_for(

libwmd/include/galois/wmd/schema.h

+8
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class FileParser {
7777
virtual ~FileParser() {}
7878
virtual ParsedGraphStructure<V, E> ParseLine(char* line,
7979
uint64_t lineLength) = 0;
80+
virtual std::vector<V> GetDstData(std::vector<E>& edges) = 0;
8081
static std::vector<std::string> SplitLine(const char* line,
8182
uint64_t lineLength, char delim,
8283
uint64_t numTokens) {
@@ -171,6 +172,13 @@ class WMDParser : public FileParser<V, E> {
171172
return ParsedGraphStructure<V, E>(edges);
172173
}
173174
}
175+
std::vector<V> GetDstData(std::vector<E>& edges) override {
176+
std::vector<V> dstData;
177+
for (auto& edge : edges) {
178+
dstData.emplace_back(edge.dst, 0, edge.dst_type);
179+
}
180+
return dstData;
181+
}
174182

175183
private:
176184
uint64_t csvFields_;

0 commit comments

Comments
 (0)