20 #ifndef GALOIS_WORKLIST_PERTHREADCHUNK_H
21 #define GALOIS_WORKLIST_PERTHREADCHUNK_H
50 t->
next = head.getValue();
53 head.unlock_and_set(C);
59 bool empty()
const {
return !tail; }
69 assert(!head.getValue());
71 head.unlock_and_set(obj);
89 head.unlock_and_clear();
91 head.unlock_and_set(h->
next);
106 victim.head.unlock_and_clear();
138 victim.head.unlock();
161 tail->
next = head.getValue();
162 head.unlock_and_set(C);
166 bool empty()
const {
return !head.getValue(); }
171 oldhead = head.getValue();
173 }
while (!head.CAS(oldhead, obj));
186 setval = retval->
next;
189 head.unlock_and_set(setval);
200 victim.head.unlock_and_clear();
231 victim.head.unlock();
244 template <
typename InnerWL>
250 std::pair<InnerWL, unsigned>& me = *local.
getLocal();
252 unsigned id = tp.getTID();
257 for (
unsigned eid =
id + 1; eid < num; ++eid) {
258 if (tp.getSocket(eid) == pkg) {
264 for (
unsigned eid = 0; eid < id; ++eid) {
265 if (tp.getSocket(eid) == pkg) {
274 unsigned eid = (
id + me.second) % num;
276 if (
id != eid && tp.isLeader(eid)) {
295 template <
bool IsLocallyLIFO,
int ChunkSize,
typename Container,
typename T>
297 template <
typename _T>
300 template <
bool _concurrent>
303 template <
int _chunk_size>
321 void delChunk(Chunk* ptr) {
326 void swapInPush(std::pair<Chunk*, Chunk*>& d) {
328 std::swap(d.first, d.second);
331 Chunk*& getPushChunk(std::pair<Chunk*, Chunk*>& d) {
338 Chunk*& getPopChunk(std::pair<Chunk*, Chunk*>& d) {
return d.first; }
340 bool doPush(Chunk* c,
const T& val) {
return c->push_back(val); }
344 return c->extract_front();
346 return c->extract_back();
349 void push_internal(std::pair<Chunk*, Chunk*>&, Chunk*& n,
const T& val) {
351 if (n && doPush(n, val))
355 worklist.push(static_cast<ChunkHeader*>(n));
368 std::pair<Chunk*, Chunk*>& tld = *data.
getLocal();
369 Chunk*& n = getPushChunk(tld);
370 push_internal(tld, n, val);
373 template <
typename Iter>
375 std::pair<Chunk*, Chunk*>& tld = *data.
getLocal();
376 Chunk*& n = getPushChunk(tld);
378 push_internal(tld, n, *b++);
381 template <
typename RangeTy>
383 auto rp = range.local_pair();
384 push(rp.first, rp.second);
388 std::pair<Chunk*, Chunk*>& tld = *data.
getLocal();
389 Chunk*& n = getPopChunk(tld);
392 if (n && (retval = doPop(n)))
398 n =
static_cast<Chunk*
>(worklist.pop());
399 if (n && (retval = doPop(n)))
409 template <
int ChunkSize = 64,
typename T =
int>
411 PerThreadChunkMaster<true, ChunkSize, StealingQueue<PerThreadChunkStack>,
415 template <
int ChunkSize = 64, typename T =
int>
void push_initial(const RangeTy &range)
Definition: PerThreadChunk.h:382
PerThreadChunkMaster< true, ChunkSize, StealingQueue< PerThreadChunkStack >, T > PerThreadChunkLIFO
Definition: PerThreadChunk.h:412
PtrLock is a spinlock and a pointer.
Definition: PtrLock.h:42
ThreadPool & getThreadPool(void)
return a reference to system thread pool
Definition: ThreadPool.cpp:259
unsigned int getActiveThreads() noexcept
Returns the number of threads in use.
Definition: Threads.cpp:37
T * getLocal()
Definition: PerThreadStorage.h:128
#define GALOIS_ATTRIBUTE_NOINLINE
Definition: CompilerSpecific.h:46
void push(Iter b, Iter e)
Definition: PerThreadChunk.h:374
void push(ChunkHeader *obj)
Definition: PerThreadChunk.h:168
bool empty() const
Definition: PerThreadChunk.h:59
ChunkHeader * stealHalfAndPop(PerThreadChunkStack &victim)
Definition: PerThreadChunk.h:212
void construct(U *p, Args &&...args) const
Definition: runtime/Mem.h:766
Galois version of boost::optional.
Definition: optional.h:34
bool empty() const
Definition: PerThreadChunk.h:166
Ordered collection of bounded size.
Definition: FixedSizeRing.h:207
pointer allocate(size_type size)
Definition: runtime/Mem.h:754
Definition: PerThreadStorage.h:88
ChunkHeader * pop()
Definition: PerThreadChunk.h:288
Definition: PerThreadChunk.h:245
T value_type
Definition: PerThreadChunk.h:363
void destroy(pointer ptr) const
Definition: runtime/Mem.h:770
#define GALOIS_WLCOMPILECHECK(name)
Definition: WLCompileCheck.h:26
static unsigned getSocket()
Definition: ThreadPool.h:207
static bool isLeader()
Definition: ThreadPool.h:205
ChunkHeader * stealAllAndPop(PerThreadChunkStack &victim)
Definition: PerThreadChunk.h:193
Definition: PerThreadChunk.h:151
void push(ChunkHeader *c)
Definition: PerThreadChunk.h:286
void deallocate(pointer ptr, size_type GALOIS_USED_ONLY_IN_DEBUG(len))
Definition: runtime/Mem.h:760
void push(ChunkHeader *obj)
Definition: PerThreadChunk.h:61
PerThreadChunkQueue()
Definition: PerThreadChunk.h:57
PerThreadChunkMaster()
Definition: PerThreadChunk.h:365
Definition: PerThreadChunk.h:39
ChunkHeader * pop()
Definition: PerThreadChunk.h:176
galois::optional< value_type > pop()
Definition: PerThreadChunk.h:387
T * getRemote(unsigned int thread)
Definition: PerThreadStorage.h:149
ChunkHeader * pop()
Definition: PerThreadChunk.h:75
ChunkHeader * stealHalfAndPop(PerThreadChunkQueue &victim)
Definition: PerThreadChunk.h:118
void push(value_type val)
Definition: PerThreadChunk.h:367
ChunkHeader * stealAllAndPop(PerThreadChunkQueue &victim)
Definition: PerThreadChunk.h:97
Definition: PerThreadChunk.h:296