20 #ifndef GALOIS_RUNTIME_PAGEPOOL_H
21 #define GALOIS_RUNTIME_PAGEPOOL_H
27 #include <unordered_map>
30 #include "galois/config.h"
66 template <
typename _UNUSED =
void>
67 class PageAllocState {
68 std::deque<std::atomic<int>> counts;
69 std::vector<HeadPtrStorage> pool;
70 std::unordered_map<void*, int> ownerMap;
78 std::lock_guard<galois::substrate::SimpleLock> lg(mapLock);
90 int count(
int tid)
const {
return counts[tid]; }
92 int countAll()
const {
98 HeadPtr& hp = pool[tid].data;
101 FreeNode* h = hp.getValue();
103 hp.unlock_and_set(h->next);
108 return allocFromOS();
111 void pageFree(
void* ptr) {
114 assert(ownerMap.count(ptr));
115 int i = ownerMap[ptr];
117 HeadPtr& hp = pool[i].data;
119 FreeNode* nh =
reinterpret_cast<FreeNode*
>(ptr);
120 nh->next = hp.getValue();
121 hp.unlock_and_set(nh);
128 void setPagePoolState(PageAllocState<>* pa);
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
Definition: CacheLineStorage.h:32
unsigned getMaxThreads() const
return the number of threads supported by the thread pool on the current machine
Definition: ThreadPool.h:178
void pagePoolPreAlloc(unsigned)
Definition: PagePool.cpp:43
size_t pagePoolSize()
Definition: PagePool.cpp:50
static unsigned getTID()
Definition: ThreadPool.h:204
void pagePoolFree(void *)
Definition: PagePool.cpp:48
void pagePreAlloc(int numpages)
Preallocate numpages large pages for each thread.
void * allocPages(unsigned num, bool preFault)
Definition: PageAlloc.cpp:71
int numPagePoolAllocForThread(unsigned tid)
Returns total large pages allocated for thread by Galois memory management subsystem.
Definition: PagePool.cpp:37
void * pagePoolAlloc()
Low level page pool (individual pages, use largeMalloc for large blocks)
Definition: PagePool.cpp:41
SimpleLock is a spinlock.
Definition: SimpleLock.h:36
T accumulate(InputIterator first, InputIterator last, const T &identity, const BinaryOperation &binary_op)
Definition: ParallelSTL.h:268
int numPagePoolAllocTotal()
Returns total large pages allocated by Galois memory management subsystem.
Definition: PagePool.cpp:35