Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DistributedGraph.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
27 #ifndef _GALOIS_DIST_HGRAPH_H_
28 #define _GALOIS_DIST_HGRAPH_H_
29 
30 #include <unordered_map>
31 #include <fstream>
32 
37 #include "galois/DynamicBitset.h"
38 
39 /*
40  * Headers for boost serialization
41  */
42 
43 namespace galois {
44 namespace graphs {
55 };
56 
63 template <typename NodeTy, typename EdgeTy>
64 class DistGraph {
65 private:
67  constexpr static const char* const GRNAME = "dGraph";
68 
70 
71 protected:
74 
76  bool transposed;
77 
78  // global graph variables
79  uint64_t numGlobalNodes;
80  uint64_t numGlobalEdges;
81  uint32_t numNodes;
82  uint64_t numEdges;
83 
84  const unsigned id;
85  const uint32_t numHosts;
86 
87  // local graph
88  // size() = Number of nodes created on this host (masters + mirrors)
89  uint32_t numOwned;
90  uint32_t beginMaster;
92  uint32_t numNodesWithEdges;
95 
98  std::vector<std::pair<uint64_t, uint64_t>> gid2host;
100  std::vector<std::vector<size_t>> mirrorNodes;
101 
103  std::vector<uint64_t> localToGlobalVector;
105  std::unordered_map<uint64_t, uint32_t> globalToLocalMap;
106 
107 private:
108  // vector for determining range objects for master nodes + nodes
109  // with edges (which includes masters)
111  std::vector<uint32_t> allNodesRanges;
113  std::vector<uint32_t> masterRanges;
116  std::vector<uint32_t> withEdgeRanges;
118  std::vector<uint32_t> allNodesRangesIn;
120  std::vector<uint32_t> masterRangesIn;
121 
122  using NodeRangeType =
124 
127  std::vector<NodeRangeType> specificRanges;
129  std::vector<NodeRangeType> specificRangesIn;
130 
131 protected:
133  void inline increment_evilPhase() {
136  static_cast<uint32_t>(
137  std::numeric_limits<int16_t>::max())) { // limit defined by MPI or
138  // LCI
140  }
141  }
142 
144  unsigned inline evilPhasePlus1() {
145  unsigned result = galois::runtime::evilPhase + 1;
146 
147  // limit defined by MPI or LCI
148  if (result >= uint32_t{std::numeric_limits<int16_t>::max()}) {
149  return 1;
150  }
151  return result;
152  }
153 
155  template <typename GraphNode, typename ET>
156  struct IdLess {
157  bool
160  return e1.dst < e2.dst;
161  }
162  };
163 
164 private:
179  void computeMastersBlockedNodes(galois::graphs::OfflineGraph& g,
180  const std::vector<unsigned>& scalefactor,
181  unsigned DecomposeFactor = 1) {
182  uint64_t numNodes_to_divide = g.size();
183  if (scalefactor.empty() || (numHosts * DecomposeFactor == 1)) {
184  for (unsigned i = 0; i < numHosts * DecomposeFactor; ++i)
185  gid2host.push_back(galois::block_range(uint64_t{0}, numNodes_to_divide,
186  i, numHosts * DecomposeFactor));
187  return;
188  }
189 
190  // TODO: not compatible with DecomposeFactor.
191  assert(scalefactor.size() == numHosts);
192 
193  unsigned numBlocks = 0;
194 
195  for (unsigned i = 0; i < numHosts; ++i) {
196  numBlocks += scalefactor[i];
197  }
198 
199  std::vector<std::pair<uint64_t, uint64_t>> blocks;
200  for (unsigned i = 0; i < numBlocks; ++i) {
201  blocks.push_back(
202  galois::block_range(uint64_t{0}, numNodes_to_divide, i, numBlocks));
203  }
204 
205  std::vector<unsigned> prefixSums;
206  prefixSums.push_back(0);
207 
208  for (unsigned i = 1; i < numHosts; ++i) {
209  prefixSums.push_back(prefixSums[i - 1] + scalefactor[i - 1]);
210  }
211 
212  for (unsigned i = 0; i < numHosts; ++i) {
213  unsigned firstBlock = prefixSums[i];
214  unsigned lastBlock = prefixSums[i] + scalefactor[i] - 1;
215  gid2host.push_back(
216  std::make_pair(blocks[firstBlock].first, blocks[lastBlock].second));
217  }
218  }
219 
235  void computeMastersBalancedEdges(galois::graphs::OfflineGraph& g,
236  const std::vector<unsigned>& scalefactor,
237  uint32_t edgeWeight,
238  unsigned DecomposeFactor = 1) {
239  if (edgeWeight == 0) {
240  edgeWeight = 1;
241  }
242 
244 
245  gid2host.resize(numHosts * DecomposeFactor);
246  for (unsigned d = 0; d < DecomposeFactor; ++d) {
247  auto r = g.divideByNode(0, edgeWeight, (id + d * numHosts),
248  numHosts * DecomposeFactor, scalefactor);
249  gid2host[id + d * numHosts].first = *(r.first.first);
250  gid2host[id + d * numHosts].second = *(r.first.second);
251  }
252 
253  for (unsigned h = 0; h < numHosts; ++h) {
254  if (h == id) {
255  continue;
256  }
258  for (unsigned d = 0; d < DecomposeFactor; ++d) {
259  galois::runtime::gSerialize(b, gid2host[id + d * numHosts]);
260  }
261  net.sendTagged(h, galois::runtime::evilPhase, b);
262  }
263  net.flush();
264  unsigned received = 1;
265  while (received < numHosts) {
266  decltype(net.recieveTagged(galois::runtime::evilPhase, nullptr)) p;
267  do {
268  p = net.recieveTagged(galois::runtime::evilPhase, nullptr);
269  } while (!p);
270  assert(p->first != id);
271  auto& b = p->second;
272  for (unsigned d = 0; d < DecomposeFactor; ++d) {
273  galois::runtime::gDeserialize(b, gid2host[p->first + d * numHosts]);
274  }
275  ++received;
276  }
277  increment_evilPhase();
278 
279 #ifndef NDEBUG
280  for (unsigned h = 0; h < numHosts; h++) {
281  if (h == 0) {
282  assert(gid2host[h].first == 0);
283  } else if (h == numHosts - 1) {
284  assert(gid2host[h].first == gid2host[h - 1].second);
285  assert(gid2host[h].second == g.size());
286  } else {
287  assert(gid2host[h].first == gid2host[h - 1].second);
288  assert(gid2host[h].second == gid2host[h + 1].first);
289  }
290  }
291 #endif
292  }
293 
311  void computeMastersBalancedNodesAndEdges(
312  galois::graphs::OfflineGraph& g, const std::vector<unsigned>& scalefactor,
313  uint32_t nodeWeight, uint32_t edgeWeight, unsigned) {
314  if (nodeWeight == 0) {
315  nodeWeight = g.sizeEdges() / g.size(); // average degree
316  }
317  if (edgeWeight == 0) {
318  edgeWeight = 1;
319  }
320 
322  gid2host.resize(numHosts);
323  auto r = g.divideByNode(nodeWeight, edgeWeight, id, numHosts, scalefactor);
324  gid2host[id].first = *r.first.first;
325  gid2host[id].second = *r.first.second;
326  for (unsigned h = 0; h < numHosts; ++h) {
327  if (h == id)
328  continue;
330  galois::runtime::gSerialize(b, gid2host[id]);
331  net.sendTagged(h, galois::runtime::evilPhase, b);
332  }
333  net.flush();
334  unsigned received = 1;
335  while (received < numHosts) {
336  decltype(net.recieveTagged(galois::runtime::evilPhase, nullptr)) p;
337  do {
338  p = net.recieveTagged(galois::runtime::evilPhase, nullptr);
339  } while (!p);
340  assert(p->first != id);
341  auto& b = p->second;
342  galois::runtime::gDeserialize(b, gid2host[p->first]);
343  ++received;
344  }
345  increment_evilPhase();
346  }
347 
348 protected:
364  uint64_t computeMasters(MASTERS_DISTRIBUTION masters_distribution,
366  const std::vector<unsigned>& scalefactor,
367  uint32_t nodeWeight = 0, uint32_t edgeWeight = 0,
368  unsigned DecomposeFactor = 1) {
369  galois::Timer timer;
370  timer.start();
372 
373  uint64_t numNodes_to_divide = g.size();
374 
375  // compute masters for all nodes
376  switch (masters_distribution) {
377  case BALANCED_MASTERS:
378  computeMastersBlockedNodes(g, scalefactor, DecomposeFactor);
379  break;
381  computeMastersBalancedNodesAndEdges(g, scalefactor, nodeWeight,
382  edgeWeight, DecomposeFactor);
383  break;
385  default:
386  computeMastersBalancedEdges(g, scalefactor, edgeWeight, DecomposeFactor);
387  break;
388  }
389 
390  timer.stop();
391 
392  galois::runtime::reportStatCond_Tmax<MORE_DIST_STATS>(
393  GRNAME, "MasterDistTime", timer.get());
394 
396  "[", id, "] Master distribution time : ", timer.get_usec() / 1000000.0f,
397  " seconds to read ", g.num_bytes_read(), " bytes in ", g.num_seeks(),
398  " seeks (", g.num_bytes_read() / (float)timer.get_usec(), " MBPS)\n");
399  return numNodes_to_divide;
400  }
401 
404  void readersFromFile(galois::graphs::OfflineGraph& g, std::string filename) {
405  // read file lines
406  std::ifstream mappings(filename);
407  std::string curLine;
408 
409  unsigned timesToRead = id + 1;
410 
411  for (unsigned i = 0; i < timesToRead; i++) {
412  std::getline(mappings, curLine);
413  }
414 
415  std::vector<char> modifyLine(curLine.begin(), curLine.end());
416  char* tokenizedString = modifyLine.data();
417  char* token;
418  token = strtok(tokenizedString, " ");
419 
420  // loop 6 more times
421  for (unsigned i = 0; i < 6; i++) {
422  token = strtok(NULL, " ");
423  }
424  std::string left(token);
425 
426  // 3 more times for right
427  for (unsigned i = 0; i < 3; i++) {
428  token = strtok(NULL, " ");
429  }
430  std::string right(token);
431 
432  gid2host.resize(numHosts);
433  gid2host[id].first = std::stoul(left);
434  gid2host[id].second = std::stoul(right) + 1;
435  galois::gPrint("[", id, "] Left: ", gid2host[id].first,
436  ", Right: ", gid2host[id].second, "\n");
437 
439  // send/recv from other hosts
442 
443  for (unsigned h = 0; h < numHosts; ++h) {
444  if (h == id)
445  continue;
447  galois::runtime::gSerialize(b, gid2host[id]);
448  net.sendTagged(h, galois::runtime::evilPhase, b);
449  }
450  net.flush();
451  unsigned received = 1;
452  while (received < numHosts) {
453  decltype(net.recieveTagged(galois::runtime::evilPhase, nullptr)) p;
454  do {
455  p = net.recieveTagged(galois::runtime::evilPhase, nullptr);
456  } while (!p);
457  assert(p->first != id);
458  auto& b = p->second;
459  galois::runtime::gDeserialize(b, gid2host[p->first]);
460  ++received;
461  }
462  increment_evilPhase();
463 
464  // sanity checking assignment
465  for (unsigned h = 0; h < numHosts; h++) {
466  if (h == 0) {
467  GALOIS_ASSERT(gid2host[h].first == 0);
468  } else if (h == numHosts - 1) {
469  GALOIS_ASSERT(gid2host[h].first == gid2host[h - 1].second,
470  gid2host[h].first, " ", gid2host[h - 1].second);
471  GALOIS_ASSERT(gid2host[h].second == g.size(), gid2host[h].second, " ",
472  g.size());
473  } else {
474  GALOIS_ASSERT(gid2host[h].first == gid2host[h - 1].second,
475  gid2host[h].first, " ", gid2host[h - 1].second);
476  GALOIS_ASSERT(gid2host[h].second == gid2host[h + 1].first,
477  gid2host[h].second, " ", gid2host[h + 1].first);
478  }
479  }
480  }
481 
482  uint32_t G2L(uint64_t gid) const {
483  assert(isLocal(gid));
484  return globalToLocalMap.at(gid);
485  }
486 
487  uint64_t L2G(uint32_t lid) const { return localToGlobalVector[lid]; }
488 
489 public:
491  using GraphNode = typename GraphTy::GraphNode;
493  using EdgeType = EdgeTy;
495  using iterator = typename GraphTy::iterator;
500 
507  DistGraph(unsigned host, unsigned numHosts)
508  : transposed(false), id(host), numHosts(numHosts) {
509  mirrorNodes.resize(numHosts);
510  numGlobalNodes = 0;
511  numGlobalEdges = 0;
512  }
513 
520  std::vector<std::pair<uint32_t, uint32_t>> getMirrorRanges() const {
521  std::vector<std::pair<uint32_t, uint32_t>> mirrorRangesVector;
522  // order of nodes locally is masters, outgoing mirrors, incoming mirrors,
523  // so just get from numOwned to end
524  if (numOwned != numNodes) {
525  assert(numOwned < numNodes);
526  mirrorRangesVector.push_back(std::make_pair(numOwned, numNodes));
527  }
528  return mirrorRangesVector;
529  }
530 
531  std::vector<std::vector<size_t>>& getMirrorNodes() { return mirrorNodes; }
532 
535  virtual unsigned getHostID(uint64_t) const = 0;
538  virtual bool isOwned(uint64_t) const = 0;
541  virtual bool isLocal(uint64_t) const = 0;
546  virtual bool is_vertex_cut() const = 0;
550  virtual std::pair<unsigned, unsigned> cartesianGrid() const {
551  return std::make_pair(0u, 0u);
552  }
553 
554  bool isTransposed() { return transposed; }
555 
562  inline uint64_t getGID(const uint32_t nodeID) const { return L2G(nodeID); }
563 
570  inline uint32_t getLID(const uint64_t nodeID) const { return G2L(nodeID); }
571 
579  inline NodeTy&
582  auto& r = graph.getData(N, mflag);
583  return r;
584  }
585 
593  inline typename GraphTy::edge_data_reference
596  auto& r = graph.getEdgeData(ni, mflag);
597  return r;
598  }
599 
606  GraphNode getEdgeDst(edge_iterator ni) { return graph.getEdgeDst(ni); }
607 
615  return graph.edge_begin(N, galois::MethodFlag::UNPROTECTED);
616  }
617 
626  return graph.edge_end(N, galois::MethodFlag::UNPROTECTED);
627  }
628 
637  return galois::graphs::internal::make_no_deref_range(edge_begin(N),
638  edge_end(N));
639  }
640 
646  inline size_t size() const { return graph.size(); }
647 
653  inline size_t sizeEdges() const { return graph.sizeEdges(); }
654 
660  inline size_t numMasters() const { return numOwned; }
661 
669  inline size_t getNumNodesWithEdges() const { return numNodesWithEdges; }
670 
676  inline size_t globalSize() const { return numGlobalNodes; }
677 
683  inline size_t globalSizeEdges() const { return numGlobalEdges; }
684 
690  inline const NodeRangeType& allNodesRange() const {
691  assert(specificRanges.size() == 3);
692  return specificRanges[0];
693  }
694 
701  inline const NodeRangeType& masterNodesRange() const {
702  assert(specificRanges.size() == 3);
703  return specificRanges[1];
704  }
705 
713  inline const NodeRangeType& allNodesWithEdgesRange() const {
714  assert(specificRanges.size() == 3);
715  return specificRanges[2];
716  }
717 
718 protected:
725  inline void determineThreadRanges() {
727  galois::runtime::activeThreads, graph.getEdgePrefixSum());
728  }
729 
737  // make sure this hasn't been called before
738  assert(masterRanges.size() == 0);
739 
740  // first check if we even need to do any work; if already calculated,
741  // use already calculated vector
742  if (beginMaster == 0 && (beginMaster + numOwned) == size()) {
743  masterRanges = allNodesRanges;
744  } else if (beginMaster == 0 &&
745  (beginMaster + numOwned) == numNodesWithEdges &&
746  withEdgeRanges.size() != 0) {
747  masterRanges = withEdgeRanges;
748  } else {
749  galois::gDebug("Manually det. master thread ranges");
751  graph, galois::runtime::activeThreads, beginMaster,
752  beginMaster + numOwned, 0);
753  }
754  }
755 
763  // make sure not called before
764  assert(withEdgeRanges.size() == 0);
765 
766  // first check if we even need to do any work; if already calculated,
767  // use already calculated vector
768  if (numNodesWithEdges == size()) {
769  withEdgeRanges = allNodesRanges;
770  } else if (beginMaster == 0 &&
771  (beginMaster + numOwned) == numNodesWithEdges &&
772  masterRanges.size() != 0) {
773  withEdgeRanges = masterRanges;
774  } else {
775  galois::gDebug("Manually det. with edges thread ranges");
777  graph, galois::runtime::activeThreads, 0, numNodesWithEdges, 0);
778  }
779  }
780 
786  assert(specificRanges.size() == 0);
787 
788  // TODO/FIXME assertion likely not safe if a host gets no nodes
789  // make sure the thread ranges have already been calculated
790  // for the 3 ranges
791  assert(allNodesRanges.size() != 0);
792  assert(masterRanges.size() != 0);
793  assert(withEdgeRanges.size() != 0);
794 
795  // 0 is all nodes
796  specificRanges.push_back(galois::runtime::makeSpecificRange(
797  boost::counting_iterator<size_t>(0),
798  boost::counting_iterator<size_t>(size()), allNodesRanges.data()));
799 
800  // 1 is master nodes
801  specificRanges.push_back(galois::runtime::makeSpecificRange(
802  boost::counting_iterator<size_t>(beginMaster),
803  boost::counting_iterator<size_t>(beginMaster + numOwned),
804  masterRanges.data()));
805 
806  // 2 is with edge nodes
807  specificRanges.push_back(galois::runtime::makeSpecificRange(
808  boost::counting_iterator<size_t>(0),
809  boost::counting_iterator<size_t>(numNodesWithEdges),
810  withEdgeRanges.data()));
811 
812  assert(specificRanges.size() == 3);
813  }
814 
819  void edgesEqualMasters() { specificRanges[2] = specificRanges[1]; }
820 
821 public:
827  void save_local_graph_to_file(std::string) { GALOIS_DIE("not implemented"); }
828 
834  void read_local_graph_from_file(std::string) {
835  GALOIS_DIE("not implemented");
836  }
837 
841  void deallocate() {
842  galois::gDebug("Deallocating CSR in DistGraph");
843  graph.deallocate();
844  }
845 
851  using GN = typename GraphTy::GraphNode;
853  galois::iterate(graph),
854  [&](GN n) { graph.sortEdges(n, IdLess<GN, EdgeTy>()); },
855  galois::no_stats(), galois::loopname("CSREdgeSort"), galois::steal());
856  }
857 };
858 
859 template <typename NodeTy, typename EdgeTy>
860 constexpr const char* const galois::graphs::DistGraph<NodeTy, EdgeTy>::GRNAME;
861 } // end namespace graphs
862 } // end namespace galois
863 
864 #endif //_GALOIS_DIST_HGRAPH_H
size_t sizeEdges() const
Gets number of edges on this (local) graph.
Definition: DistributedGraph.h:653
void deallocate()
Deallocates underlying LC CSR Graph.
Definition: DistributedGraph.h:841
Definition: Traits.h:247
uint64_t get() const
Definition: Timer.cpp:29
uint64_t numGlobalEdges
Total edges in the global unpartitioned graph.
Definition: DistributedGraph.h:80
uint32_t getHostID()
Gets this host&#39;s ID.
Definition: Network.cpp:41
void increment_evilPhase()
Increments evilPhase, a phase counter used by communication.
Definition: DistributedGraph.h:133
A simple timer.
Definition: Timer.h:31
void start()
Definition: Timer.cpp:25
std::pair< IterTy, IterTy > block_range(IterTy b, IterTy e, unsigned id, unsigned num)
Returns a continuous block from the range based on the number of divisions and the id of the block re...
Definition: gstl.h:244
uint64_t getGID(const uint32_t nodeID) const
Converts a local node id into a global node id.
Definition: DistributedGraph.h:562
uint64_t numGlobalNodes
Total nodes in the global unpartitioned graph.
Definition: DistributedGraph.h:79
const uint32_t numHosts
Total number of machines.
Definition: DistributedGraph.h:85
typename GraphTy::edge_iterator edge_iterator
iterator type over edges
Definition: DistributedGraph.h:499
uint32_t getLID(const uint64_t nodeID) const
Converts a global node id into a local node id.
Definition: DistributedGraph.h:570
used to sort edges in the sort edges function
Definition: DistributedGraph.h:156
auto divideByNode(size_t nodeWeight, size_t edgeWeight, size_t id, size_t total, std::vector< unsigned > scaleFactor=std::vector< unsigned >()) -> GraphRange
Returns 2 ranges (one for nodes, one for edges) for a particular division.
Definition: OfflineGraph.h:324
size_t numMasters() const
Gets number of nodes on this (local) graph.
Definition: DistributedGraph.h:660
Buffer for serialization of data.
Definition: Serialize.h:56
GraphNode getEdgeDst(edge_iterator ni)
Gets edge destination of edge ni.
Definition: DistributedGraph.h:606
uint64_t num_bytes_read()
Definition: OfflineGraph.h:258
void gDebug(Args &&...GALOIS_USED_ONLY_IN_DEBUG(args))
Prints a debug string from a sequence of things; prints nothing if NDEBUG is defined.
Definition: gIO.h:72
Definition: Iterable.h:36
Contains the DynamicBitSet class and most of its implementation.
typename GraphTy::iterator iterator
iterator type over nodes
Definition: DistributedGraph.h:495
void sortEdgesByDestination()
Sort the underlying LC_CSR_Graph by ID (destinations) It sorts edges of the nodes by destination...
Definition: DistributedGraph.h:850
size_t size() const
Gets number of nodes on this (local) graph.
Definition: DistributedGraph.h:646
void gDeserialize(DeSerializeBuffer &buf, T1 &&t1, Args &&...args)
Deserialize data in a buffer into a series of objects.
Definition: Serialize.h:1032
SpecificRange< IterTy > makeSpecificRange(IterTy begin, IterTy end, const uint32_t *thread_ranges)
Creates a SpecificRange object.
Definition: Range.h:219
const char * loopname
Definition: Executor_ParaMeter.h:145
#define GALOIS_DIE(...)
Definition: gIO.h:96
void read_local_graph_from_file(std::string)
Read the local LC_CSR graph from the file on a disk.
Definition: DistributedGraph.h:834
uint64_t numEdges
Num edges in this graph in total.
Definition: DistributedGraph.h:82
std::vector< std::vector< size_t > > & getMirrorNodes()
Definition: DistributedGraph.h:531
iterator const_iterator
Definition: LC_CSR_Graph.h:155
uint32_t G2L(uint64_t gid) const
Definition: DistributedGraph.h:482
const NodeRangeType & allNodesRange() const
Returns a range object that encapsulates all nodes of the graph.
Definition: DistributedGraph.h:690
std::vector< uint32_t > determineUnitRangesFromGraph(GraphTy &graph, uint32_t unitsToSplit, uint32_t nodeAlpha=0)
Determines node division ranges for all nodes in a graph and returns it in an offset vector...
Definition: GraphHelpers.h:403
size_t globalSizeEdges() const
Gets number of edges on the global unpartitioned graph.
Definition: DistributedGraph.h:683
void determineThreadRanges()
Uses a pre-computed prefix sum to determine division of nodes among threads.
Definition: DistributedGraph.h:725
std::vector< std::pair< uint32_t, uint32_t > > getMirrorRanges() const
Return a vector of pairs denoting mirror node ranges.
Definition: DistributedGraph.h:520
edge_iterator edge_begin(GraphNode N)
Gets the first edge of some node.
Definition: DistributedGraph.h:614
bool isTransposed()
Definition: DistributedGraph.h:554
#define GALOIS_ASSERT(cond,...)
Like assert but unconditionally executed.
Definition: gIO.h:102
void edgesEqualMasters()
Specific range editor: makes the range for edges equivalent to the range for masters.
Definition: DistributedGraph.h:819
typename GraphTy::const_iterator const_iterator
constant iterator type over nodes
Definition: DistributedGraph.h:497
std::vector< std::vector< size_t > > mirrorNodes
Mirror nodes from different hosts. For reduce.
Definition: DistributedGraph.h:100
EdgeTy EdgeType
Expose EdgeTy to other classes.
Definition: DistributedGraph.h:493
std::vector< std::pair< uint64_t, uint64_t > > gid2host
Information that converts host to range of nodes that host reads.
Definition: DistributedGraph.h:98
const NodeRangeType & masterNodesRange() const
Returns a range object that encapsulates only master nodes in this graph.
Definition: DistributedGraph.h:701
const Ty max(std::atomic< Ty > &a, const Ty &b)
Definition: AtomicHelpers.h:40
virtual std::pair< unsigned, unsigned > cartesianGrid() const
Returns Cartesian split (if it exists, else returns pair of 0s.
Definition: DistributedGraph.h:550
size_t getNumNodesWithEdges() const
Gets number of nodes with edges (may include nodes without edges) on this (local) graph...
Definition: DistributedGraph.h:669
galois::runtime::iterable< galois::NoDerefIterator< edge_iterator > > edges(GraphNode N)
Returns an iterable object over the edges of a particular node in the graph.
Definition: DistributedGraph.h:636
Definition: OfflineGraph.h:63
Contains declaration of DistStatManager, which reports runtime statistics of a distributed applicatio...
MASTERS_DISTRIBUTION
Enums specifying how masters are to be distributed among hosts.
Definition: DistributedGraph.h:48
bool transposed
Marks if the graph is transposed or not.
Definition: DistributedGraph.h:76
typename GraphTy::GraphNode GraphNode
Type representing a node in this graph.
Definition: DistributedGraph.h:491
void determineThreadRangesMaster()
Determines the thread ranges for master nodes only and saves them to the object.
Definition: DistributedGraph.h:736
void gPrint(Args &&...args)
Prints a sequence of things.
Definition: gIO.h:47
Proxy object for internal EdgeSortReference.
Definition: Details.h:56
edge_iterator edge_end(GraphNode N)
Gets the end edge boundary of some node.
Definition: DistributedGraph.h:625
unsigned evilPhasePlus1()
Returns evilPhase + 1, handling loop around as necessary.
Definition: DistributedGraph.h:144
unsigned int activeThreads
Definition: Threads.cpp:26
Definition: Traits.h:206
NetworkInterface & getSystemNetworkInterface()
Get the network interface.
Definition: Network.cpp:131
MethodFlag
What should the runtime do when executing a method.
Definition: MethodFlags.h:34
GraphNode dst
Definition: Details.h:63
boost::counting_iterator< typename EdgeIndData::value_type > edge_iterator
Definition: LC_CSR_Graph.h:153
SpecificRange is a range type where a threads range is specified by an an int array that tells you wh...
Definition: Range.h:122
size_t globalSize() const
Gets number of nodes on the global unpartitioned graph.
Definition: DistributedGraph.h:676
uint32_t numNodes
Num nodes in this graph in total.
Definition: DistributedGraph.h:81
balance nodes and edges
Definition: DistributedGraph.h:54
void save_local_graph_to_file(std::string)
Write the local LC_CSR graph to the file on a disk.
Definition: DistributedGraph.h:827
bool operator()(const galois::graphs::EdgeSortValue< GraphNode, ET > &e1, const galois::graphs::EdgeSortValue< GraphNode, ET > &e2) const
Definition: DistributedGraph.h:158
uint32_t numOwned
Number of nodes owned (masters) by this host.
Definition: DistributedGraph.h:89
void do_all(const RangeFunc &rangeMaker, FunctionTy &&fn, const Args &...args)
Standard do-all loop.
Definition: Loops.h:71
uint32_t numNodesWithEdges
Number of nodes (masters + mirrors) that have outgoing edges.
Definition: DistributedGraph.h:94
uint64_t L2G(uint32_t lid) const
Definition: DistributedGraph.h:487
uint64_t computeMasters(MASTERS_DISTRIBUTION masters_distribution, galois::graphs::OfflineGraph &g, const std::vector< unsigned > &scalefactor, uint32_t nodeWeight=0, uint32_t edgeWeight=0, unsigned DecomposeFactor=1)
Wrapper call that will call into more specific compute masters functions that compute masters based o...
Definition: DistributedGraph.h:364
void initializeSpecificRanges()
Initializes the 3 range objects that a user can access to iterate over the graph in different ways...
Definition: DistributedGraph.h:785
void reset_seek_counters()
Definition: OfflineGraph.h:264
const NodeRangeType & allNodesWithEdgesRange() const
Returns a range object that encapsulates master nodes and nodes with edges in this graph...
Definition: DistributedGraph.h:713
size_t size() const
Definition: OfflineGraph.h:271
void readersFromFile(galois::graphs::OfflineGraph &g, std::string filename)
reader assignment from a file corresponds to master assignment if using an edge cut ...
Definition: DistributedGraph.h:404
std::unordered_map< uint64_t, uint32_t > globalToLocalMap
LID = globalToLocalMap[GID].
Definition: DistributedGraph.h:105
void stop()
Definition: Timer.cpp:27
uint32_t evilPhase
Variable that keeps track of which network send/recv phase a program is currently on...
Definition: Network.cpp:36
Base DistGraph class that all distributed graphs extend from.
Definition: DistributedGraph.h:64
auto iterate(C &cont)
Definition: Range.h:323
DistGraph(unsigned host, unsigned numHosts)
Constructor for DistGraph.
Definition: DistributedGraph.h:507
NodeTy & getData(GraphNode N, galois::MethodFlag mflag=galois::MethodFlag::UNPROTECTED)
Get data of a node.
Definition: DistributedGraph.h:580
uint64_t num_seeks()
Definition: OfflineGraph.h:252
std::vector< uint64_t > localToGlobalVector
GID = localToGlobalVector[LID].
Definition: DistributedGraph.h:103
const unsigned id
ID of the machine.
Definition: DistributedGraph.h:84
Contains the implementation of BufferedGraph.
size_t sizeEdges() const
Definition: OfflineGraph.h:272
std::vector< uint32_t > determineUnitRangesFromPrefixSum(uint32_t unitsToSplit, VectorTy &edgePrefixSum, uint32_t nodeAlpha=0)
Uses the divideByNode function (which is binary search based) to divide nodes among units using a pro...
Definition: GraphHelpers.h:484
balance nodes
Definition: DistributedGraph.h:50
uint32_t GraphNode
Definition: LC_CSR_Graph.h:146
GraphTy graph
The internal graph used by DistGraph to represent the graph.
Definition: DistributedGraph.h:73
uint64_t get_usec() const
Definition: Timer.cpp:34
boost::counting_iterator< typename EdgeDst::value_type > iterator
Definition: LC_CSR_Graph.h:154
void determineThreadRangesWithEdges()
Determines the thread ranges for nodes with edges only and saves them to the object.
Definition: DistributedGraph.h:762
GraphTy::edge_data_reference getEdgeData(edge_iterator ni, galois::MethodFlag mflag=galois::MethodFlag::UNPROTECTED)
Get the edge data for a particular edge in the graph.
Definition: DistributedGraph.h:594
uint32_t beginMaster
Local id of the beginning of master nodes.
Definition: DistributedGraph.h:91
balance edges
Definition: DistributedGraph.h:52