20 #ifndef GALOIS_WORKLIST_CHUNK_H
21 #define GALOIS_WORKLIST_CHUNK_H
23 #include "galois/config.h"
39 template <
bool,
template <
typename>
class PS,
typename TQ>
42 TQ&
get(
int i) {
return *queues.getRemote(i); }
43 TQ&
get() {
return *queues.getLocal(); }
48 template <
template <
typename>
class PS,
typename TQ>
49 struct squeue<false, PS, TQ> {
51 TQ&
get(int) {
return queue; }
52 TQ&
get() {
return queue; }
53 int myEffectiveID() {
return 0; }
54 int size() {
return 0; }
58 template <
typename T,
template <
typename,
bool>
class QT,
bool Distributed,
59 bool IsStack,
int ChunkSize,
bool Concurrent>
61 template <
typename _T>
63 ChunkMaster<_T, QT, Distributed, IsStack, ChunkSize, Concurrent>;
65 template <
int _chunk_size>
66 using with_chunk_size =
67 ChunkMaster<T, QT, Distributed, IsStack, _chunk_size, Concurrent>;
69 template <
bool _Concurrent>
71 ChunkMaster<T, QT, Distributed, IsStack, ChunkSize, _Concurrent>;
74 class Chunk :
public FixedSizeRing<T, ChunkSize>,
75 public QT<Chunk, Concurrent>::ListNode {};
77 runtime::FixedSizeAllocator<Chunk>
alloc;
82 p() : cur(0), next(0) {}
85 typedef QT<Chunk, Concurrent> LevelItem;
87 squeue<Concurrent, substrate::PerThreadStorage, p> data;
88 squeue<Distributed, substrate::PerSocketStorage, LevelItem> Q;
91 Chunk* ptr =
alloc.allocate(1);
96 void delChunk(Chunk* ptr) {
98 alloc.deallocate(ptr, 1);
101 void pushChunk(Chunk* C) {
102 LevelItem& I = Q.get();
106 Chunk* popChunkByID(
unsigned int i) {
107 LevelItem& I = Q.get(i);
112 int id = Q.myEffectiveID();
113 Chunk* r = popChunkByID(
id);
117 for (
int i =
id + 1; i < (int)Q.size(); ++i) {
123 for (
int i = 0; i < id; ++i) {
132 template <
typename... Args>
133 T* emplacei(p& n, Args&&... args) {
135 if (n.next && (retval = n.next->emplace_back(std::forward<Args>(args)...)))
140 retval = n.next->emplace_back(std::forward<Args>(args)...);
148 ChunkMaster() =
default;
149 ChunkMaster(
const ChunkMaster&) =
delete;
150 ChunkMaster& operator=(
const ChunkMaster&) =
delete;
166 template <
typename... Args>
169 return emplacei(n, std::forward<Args>(args)...);
180 if (n.next && !n.next->empty())
181 return &n.next->back();
185 if (n.next && !n.next->empty())
186 return &n.next->back();
189 if (n.cur && !n.cur->empty())
190 return &n.cur->front();
198 if (n.cur && !n.cur->empty())
199 return &n.cur->front();
225 template <
typename Iter>
226 void push(Iter b, Iter e) {
232 template <
typename RangeTy>
233 void push_initial(
const RangeTy& range) {
234 auto rp = range.local_pair();
235 push(rp.first, rp.second);
242 if (n.next && (retval = n.next->extract_back()))
248 return n.next->extract_back();
251 if (n.cur && (retval = n.cur->extract_front()))
261 return n.cur->extract_front();
274 template <
int ChunkSize = 64,
typename T =
int,
bool Concurrent = true>
275 using ChunkFIFO = internal::ChunkMaster<T, ConExtLinkedQueue,
false,
false,
276 ChunkSize, Concurrent>;
284 template <
int ChunkSize = 64, typename T =
int,
bool Concurrent = true>
286 ChunkSize, Concurrent>;
294 template <
int ChunkSize = 64, typename T =
int,
bool Concurrent = true>
296 false, ChunkSize, Concurrent>;
304 template <
int ChunkSize = 64, typename T =
int,
bool Concurrent = true>
306 true, ChunkSize, Concurrent>;
315 template <
int ChunkSize = 64, typename T =
int,
bool Concurrent = true>
317 true, ChunkSize, Concurrent>;
Definition: WorkListHelpers.h:67
Definition: WorkListHelpers.h:115
internal::ChunkMaster< T, ConExtLinkedQueue, false, false, ChunkSize, Concurrent > ChunkFIFO
Chunk FIFO.
Definition: Chunk.h:276
internal::ChunkMaster< T, ConExtLinkedQueue, true, true, ChunkSize, Concurrent > PerSocketChunkBag
Distributed chunked bag.
Definition: Chunk.h:317
Galois version of boost::optional.
Definition: optional.h:34
internal::ChunkMaster< T, ConExtLinkedStack, true, true, ChunkSize, Concurrent > PerSocketChunkLIFO
Distributed chunked LIFO.
Definition: Chunk.h:306
static unsigned getTID()
Definition: ThreadPool.h:204
unsigned int activeThreads
Definition: Threads.cpp:26
#define GALOIS_WLCOMPILECHECK(name)
Definition: WLCompileCheck.h:26
internal::ChunkMaster< T, ConExtLinkedStack, false, true, ChunkSize, Concurrent > ChunkLIFO
Chunk LIFO.
Definition: Chunk.h:286
void * alloc()
Definition: PerThreadStorage.cpp:42
T value_type
Definition: Executor_ParaMeter.h:111
internal::ChunkMaster< T, ConExtLinkedQueue, true, false, ChunkSize, Concurrent > PerSocketChunkFIFO
Distributed chunked FIFO.
Definition: Chunk.h:296