20 #ifndef GALOIS_GRAPHS_LC_LINEAR_GRAPH_H
21 #define GALOIS_GRAPHS_LC_LINEAR_GRAPH_H
23 #include <type_traits>
25 #include <boost/mpl/if.hpp>
27 #include "galois/config.h"
43 template <
typename NodeTy,
typename EdgeTy,
bool HasNoLockable =
false,
44 bool UseNumaAlloc =
false,
bool HasOutOfLineLockable =
false,
45 bool HasId =
false,
typename FileEdgeTy = EdgeTy>
47 :
private boost::noncopyable,
48 private internal::LocalIteratorFeature<UseNumaAlloc>,
49 private internal::OutOfLineLockableFeature<HasOutOfLineLockable &&
51 template <
typename Graph>
55 template <
bool _has_
id>
58 HasOutOfLineLockable, _has_id, FileEdgeTy>
62 template <
typename _node_data>
64 typedef LC_Linear_Graph<_node_data, EdgeTy, HasNoLockable, UseNumaAlloc,
65 HasOutOfLineLockable, HasId, FileEdgeTy>
69 template <
typename _edge_data>
71 typedef LC_Linear_Graph<NodeTy, _edge_data, HasNoLockable, UseNumaAlloc,
72 HasOutOfLineLockable, HasId, FileEdgeTy>
76 template <
typename _file_edge_data>
79 HasOutOfLineLockable, HasId, _file_edge_data>
83 template <
bool _has_no_lockable>
86 HasOutOfLineLockable, HasId, FileEdgeTy>
90 template <
bool _use_numa_alloc>
93 HasOutOfLineLockable, HasId, FileEdgeTy>
97 template <
bool _has_out_of_line_lockable>
100 _has_out_of_line_lockable,
101 _has_out_of_line_lockable || HasId, FileEdgeTy>
109 typedef internal::EdgeInfoBase<NodeInfo*, EdgeTy>
EdgeInfo;
111 typedef internal::NodeInfoBaseTypes<NodeTy,
112 !HasNoLockable && !HasOutOfLineLockable>
116 :
public internal::NodeInfoBase<NodeTy,
117 !HasNoLockable && !HasOutOfLineLockable>,
118 public internal::IntrusiveId<
119 typename boost::mpl::if_c<HasId, uint32_t, void>::type> {
126 return reinterpret_cast<EdgeInfo*
>(n);
138 while (reinterpret_cast<char*>(ni) < reinterpret_cast<char*>(ei))
164 template <
bool _A1 = HasNoLockable,
bool _A2 = HasOutOfLineLockable>
166 typename std::enable_if<!_A1 && !_A2>::type* = 0) {
170 template <
bool _A1 = HasOutOfLineLockable,
bool _A2 = HasNoLockable>
172 typename std::enable_if<_A1 && !_A2>::type* = 0) {
173 this->outOfLineAcquire(
getId(N), mflag);
176 template <
bool _A1 = HasOutOfLineLockable,
bool _A2 = HasNoLockable>
178 typename std::enable_if<_A2>::type* = 0) {}
184 template <
bool _A1 = EdgeInfo::has_value,
188 typename std::enable_if<!_A1 || _A2>::type* = 0) {
190 if (EdgeInfo::has_value)
194 template <
bool _A1 = EdgeInfo::has_value,
198 typename std::enable_if<_A1 && !_A2>::type* = 0) {
202 template <
bool _Enable = HasId>
207 template <
bool _Enable = HasId>
217 EdgeInfo* edgeBegin = n->edgeBegin();
220 if (EdgeInfo::has_value) {
221 while (edgeBegin != edgeEnd) {
222 edgeBegin->destroy();
265 for (
edge_iterator ii = N->edgeBegin(), ee = N->edgeEnd(); ii != ee;
270 return N->edgeBegin();
280 return internal::make_no_deref_range(
edge_begin(N, mflag),
286 return edges(N, mflag);
292 template <
typename CompTy>
294 const CompTy& comp = std::less<EdgeTy>(),
298 internal::EdgeSortCompWrapper<EdgeInfo, CompTy>(comp));
305 template <
typename CompTy>
309 std::sort(N->edgeBegin(), N->edgeEnd(), comp);
319 this->outOfLineAllocateLocal(
numNodes);
324 this->outOfLineAllocateInterleaved(
numNodes);
332 LC_Linear_Graph::size_of_out_of_line::value,
336 this->setLocalRange(*r.first, *r.second);
339 size_t id = *r.first;
342 curNode += bytes /
sizeof(
NodeInfo);
351 nodes[*ii] = curNode;
352 curNode = curNode->next();
360 LC_Linear_Graph::size_of_out_of_line::value,
LC_Linear_Graph< NodeTy, _edge_data, HasNoLockable, UseNumaAlloc, HasOutOfLineLockable, HasId, FileEdgeTy > type
Definition: LC_Linear_Graph.h:73
Definition: LC_Linear_Graph.h:63
Local computation graph (i.e., graph structure does not change).
Definition: LC_Linear_Graph.h:46
GraphNode getNode(size_t n, typename std::enable_if< _Enable >::type *=0)
Definition: LC_Linear_Graph.h:208
size_t size() const
Definition: LC_Linear_Graph.h:246
Definition: LC_Linear_Graph.h:91
LargeArray< NodeInfo * > Nodes
Definition: LC_Linear_Graph.h:110
void constructEdgesFrom(FileGraph &graph, unsigned tid, unsigned total, const ReadGraphAuxData &)
Definition: LC_Linear_Graph.h:356
void constructNodesFrom(FileGraph &graph, unsigned tid, unsigned total, const ReadGraphAuxData &)
Definition: LC_Linear_Graph.h:328
void sortEdgesByEdgeData(GraphNode N, const CompTy &comp=std::less< EdgeTy >(), MethodFlag mflag=MethodFlag::WRITE)
Sorts outgoing edges of a node.
Definition: LC_Linear_Graph.h:293
edge_iterator edge_begin(GraphNode N)
Returns the index to the beginning of global node N's outgoing edges in the outgoing edges array...
Definition: FileGraph.cpp:641
Contains FileGraph and FileGraphWriter class declarations.
Definition: LC_Linear_Graph.h:98
size_t size() const
Returns the number of nodes in the (sub)graph.
Definition: FileGraph.h:545
runtime::iterable< NoDerefIterator< edge_iterator > > out_edges(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_Linear_Graph.h:285
node_data_reference getData(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_Linear_Graph.h:230
size_t getId(GraphNode N, typename std::enable_if< _Enable >::type *=0)
Definition: LC_Linear_Graph.h:203
uint64_t numEdges
Definition: LC_Linear_Graph.h:161
edge_iterator edge_begin(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_Linear_Graph.h:262
edge_iterator edge_end(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_Linear_Graph.h:273
boost::counting_iterator< uint64_t > iterator
uint64 boost counting iterator
Definition: FileGraph.h:408
EdgeInfo * edge_iterator
Definition: LC_Linear_Graph.h:151
local_iterator local_end()
Definition: LC_Linear_Graph.h:254
EdgeInfo::reference edge_data_reference
Definition: LC_Linear_Graph.h:150
LargeArray< char > data
Definition: LC_Linear_Graph.h:159
LC_Linear_Graph< NodeTy, EdgeTy, _has_no_lockable, UseNumaAlloc, HasOutOfLineLockable, HasId, FileEdgeTy > type
Definition: LC_Linear_Graph.h:87
GraphNode getEdgeDst(edge_iterator it)
Gets the destination of some edge.
Definition: FileGraph.cpp:669
boost::counting_iterator< uint64_t > edge_iterator
Edge iterators (boost iterator)
Definition: FileGraph.h:248
Definition: Iterable.h:36
GraphNode getEdgeDst(edge_iterator ni) const
Definition: LC_Linear_Graph.h:244
local_iterator local_begin()
Definition: LC_Linear_Graph.h:253
iterator local_iterator
Definition: LC_Linear_Graph.h:154
size_t sizeEdges() const
Definition: LC_Linear_Graph.h:247
uint64_t numNodes
Definition: LC_Linear_Graph.h:160
bool shouldLock(const galois::MethodFlag g)
Helper function to decide if the conflict detection lock should be taken.
Definition: libgalois/include/galois/runtime/Context.h:189
void allocateLocal(size_type n)
Allocates using Thread Local memory policy.
Definition: LargeArray.h:220
internal::EdgeInfoBase< NodeInfo *, EdgeTy > EdgeInfo
Definition: LC_Linear_Graph.h:108
~LC_Linear_Graph()
Definition: LC_Linear_Graph.h:213
void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp)
Definition: ParallelSTL.h:247
internal::NodeInfoBaseTypes< NodeTy,!HasNoLockable &&!HasOutOfLineLockable > NodeInfoTypes
Definition: LC_Linear_Graph.h:113
Modify a LC_Graph to have in and out edges.
Definition: LC_InOut_Graph.h:39
LC_Linear_Graph< _node_data, EdgeTy, HasNoLockable, UseNumaAlloc, HasOutOfLineLockable, HasId, FileEdgeTy > type
Definition: LC_Linear_Graph.h:66
Definition: LC_Linear_Graph.h:77
EdgeTy & reference
Definition: LazyObject.h:96
void allocateInterleaved(size_type n)
[allocatefunctions] Allocates interleaved across NUMA (memory) nodes.
Definition: LargeArray.h:206
void acquireNode(GraphNode N, MethodFlag mflag, typename std::enable_if< _A1 &&!_A2 >::type *=0)
Definition: LC_Linear_Graph.h:171
Definition: LC_Linear_Graph.h:84
void allocateFrom(FileGraph &graph, const ReadGraphAuxData &)
Definition: LC_Linear_Graph.h:312
const_local_iterator local_end() const
Definition: LC_Linear_Graph.h:258
const_local_iterator local_begin() const
Definition: LC_Linear_Graph.h:255
const_iterator end() const
Definition: LC_Linear_Graph.h:251
pointer iterator
Definition: LargeArray.h:67
LC_Linear_Graph< NodeTy, EdgeTy, HasNoLockable, UseNumaAlloc, HasOutOfLineLockable, HasId, _file_edge_data > type
Definition: LC_Linear_Graph.h:80
iterator end()
Definition: LC_Linear_Graph.h:249
const_iterator const_local_iterator
Definition: LC_Linear_Graph.h:155
Definition: LC_Linear_Graph.h:56
const_iterator begin() const
Definition: LC_Linear_Graph.h:250
NodeInfo *const * const_iterator
Definition: LC_Linear_Graph.h:153
NodeInfo * GraphNode
Definition: LC_Linear_Graph.h:145
void acquire(Lockable *lockable, galois::MethodFlag m)
Master function which handles conflict detection used to acquire a lockable thing.
Definition: libgalois/include/galois/runtime/Context.h:218
MethodFlag
What should the runtime do when executing a method.
Definition: MethodFlags.h:34
Definition: LC_Linear_Graph.h:70
LC_Linear_Graph< NodeTy, EdgeTy, HasNoLockable, UseNumaAlloc, _has_out_of_line_lockable, _has_out_of_line_lockable||HasId, FileEdgeTy > type
Definition: LC_Linear_Graph.h:102
NodeInfoTypes::reference node_data_reference
Definition: LC_Linear_Graph.h:149
edge_data_reference getEdgeData(edge_iterator ni, MethodFlag GALOIS_UNUSED(mflag)=MethodFlag::UNPROTECTED) const
Definition: LC_Linear_Graph.h:238
iterator begin()
Definition: LC_Linear_Graph.h:248
edge_iterator raw_begin(GraphNode N)
Definition: LC_Linear_Graph.h:180
LC_Linear_Graph< NodeTy, EdgeTy, HasNoLockable, _use_numa_alloc, HasOutOfLineLockable, HasId, FileEdgeTy > type
Definition: LC_Linear_Graph.h:94
int ReadGraphAuxData
Definition: LC_Linear_Graph.h:156
read_with_aux_graph_tag read_tag
Definition: LC_Linear_Graph.h:105
EdgeTy & getEdgeData(GraphNode src, GraphNode dst)
Get edge data of an edge between 2 nodes.
Definition: FileGraph.h:241
Definition: LC_Linear_Graph.h:115
void constructAt(size_type n, Args &&...args)
Definition: LargeArray.h:260
GraphRange divideByNode(size_t nodeSize, size_t edgeSize, size_t id, size_t total)
Given a division and a total number of divisions, return a range for that particular division to work...
Definition: FileGraph.cpp:480
runtime::iterable< NoDerefIterator< edge_iterator > > edges(GraphNode N, MethodFlag mflag=MethodFlag::WRITE)
Definition: LC_Linear_Graph.h:279
edge_iterator edge_end(GraphNode N)
Returns the index to the end of global node N's outgoing edges in the outgoing edges array...
Definition: FileGraph.cpp:655
size_t sizeEdges() const
Returns the number of edges in the (sub)graph.
Definition: FileGraph.h:548
const_pointer data() const
Definition: LargeArray.h:292
void acquireNode(GraphNode N, MethodFlag mflag, typename std::enable_if<!_A1 &&!_A2 >::type *=0)
Definition: LC_Linear_Graph.h:165
iterator end()
Definition: LargeArray.h:201
edge_iterator raw_end(GraphNode N)
Definition: LC_Linear_Graph.h:182
LC_Linear_Graph< NodeTy, EdgeTy, HasNoLockable, UseNumaAlloc, HasOutOfLineLockable, _has_id, FileEdgeTy > type
Definition: LC_Linear_Graph.h:59
Graph that mmaps Galois gr files for access.
Definition: FileGraph.h:57
T value_type
Definition: Executor_ParaMeter.h:111
Nodes nodes
Definition: LC_Linear_Graph.h:162
void sortEdges(GraphNode N, const CompTy &comp, MethodFlag mflag=MethodFlag::WRITE)
Sorts outgoing edges of a node.
Definition: LC_Linear_Graph.h:306
void acquireNode(GraphNode, MethodFlag, typename std::enable_if< _A2 >::type *=0)
Definition: LC_Linear_Graph.h:177
NodeInfo ** iterator
Definition: LC_Linear_Graph.h:152
void constructEdgeValue(FileGraph &graph, typename FileGraph::edge_iterator nn, EdgeInfo *edge, typename std::enable_if<!_A1||_A2 >::type *=0)
Definition: LC_Linear_Graph.h:186
void construct(Args &&...args)
[allocatefunctions]
Definition: LargeArray.h:254
NodeTy node_data_type
Definition: LC_Linear_Graph.h:148
iterator begin()
Definition: LargeArray.h:199
EdgeTy edge_data_type
Definition: LC_Linear_Graph.h:146
FileEdgeTy file_edge_data_type
Definition: LC_Linear_Graph.h:147
void constructEdgeValue(FileGraph &, typename FileGraph::edge_iterator, EdgeInfo *edge, typename std::enable_if< _A1 &&!_A2 >::type *=0)
Definition: LC_Linear_Graph.h:196