13 #include <unordered_set>
15 namespace faiss {
namespace gpu {
20 typedef char value_type;
23 : start_((
char*) mem),
25 end_((
char*) mem + size) {
31 char* allocate(std::ptrdiff_t size) {
32 if (size <= (end_ - cur_)) {
35 FAISS_ASSERT(cur_ <= end_);
40 CUDA_VERIFY(cudaMalloc(&p, size));
41 mallocAllocs_.insert(p);
46 void deallocate(
char* p,
size_t size) {
49 auto it = mallocAllocs_.find(p);
50 if (it != mallocAllocs_.end()) {
51 CUDA_VERIFY(cudaFree(p));
52 mallocAllocs_.erase(it);
60 std::unordered_set<char*> mallocAllocs_;
Allocator for Thrust that comes out of a specified memory space.