11 #ifndef CACHED_ALLOC_HPP
12 #define CACHED_ALLOC_HPP
16 #ifdef THRUST_BACKEND_CUDA
18 #include <cuda_runtime.h>
19 #include <thrust/system/cuda/vector.h>
20 #include <thrust/system/cuda/execution_policy.h>
21 #include <thrust/host_vector.h>
22 #include <thrust/generate.h>
23 #include <thrust/pair.h>
51 typedef char value_type;
53 CachedAllocator() : maxBuffers(10) {}
54 ~CachedAllocator() { clear(); }
56 char* allocate(
size_t n);
57 void deallocate(
char* ptr,
size_t n);
61 typedef std::pair<size_t, char*> FreeBlockPair;
62 typedef std::list<FreeBlockPair> FreeBlockList;
63 typedef std::map<char*, size_t> AllocatedBlockMap;
66 FreeBlockList freeBlocks;
67 AllocatedBlockMap allocatedBlocks;
70 extern CachedAllocator cachedAlloc;