15 #include <unordered_set>
17 namespace faiss {
namespace gpu {
22 typedef char value_type;
25 : start_((
char*) mem),
27 end_((
char*) mem + size) {
33 char* allocate(std::ptrdiff_t size) {
34 if (size <= (end_ - cur_)) {
37 FAISS_ASSERT(cur_ <= end_);
42 CUDA_VERIFY(cudaMalloc(&p, size));
43 mallocAllocs_.insert(p);
48 void deallocate(
char* p,
size_t size) {
51 auto it = mallocAllocs_.find(p);
52 if (it != mallocAllocs_.end()) {
53 CUDA_VERIFY(cudaFree(p));
54 mallocAllocs_.erase(it);
62 std::unordered_set<char*> mallocAllocs_;
Allocator for Thrust that comes out of a specified memory space.