14 #include <unordered_set>
16 namespace faiss {
namespace gpu {
21 typedef char value_type;
24 : start_((
char*) mem),
26 end_((
char*) mem + size) {
32 char* allocate(std::ptrdiff_t size) {
33 if (size <= (end_ - cur_)) {
36 FAISS_ASSERT(cur_ <= end_);
41 CUDA_VERIFY(cudaMalloc(&p, size));
42 mallocAllocs_.insert(p);
47 void deallocate(
char* p,
size_t size) {
50 auto it = mallocAllocs_.find(p);
51 if (it != mallocAllocs_.end()) {
52 CUDA_VERIFY(cudaFree(p));
53 mallocAllocs_.erase(it);
61 std::unordered_set<char*> mallocAllocs_;
Allocator for Thrust that comes out of a specified memory space.