14 #include "DeviceMemory.h"
17 #include <unordered_map>
19 namespace faiss {
namespace gpu {
37 size_t size)
override;
40 std::string
toString()
const override;
50 inline Range(
char* s,
char* e, cudaStream_t str) :
51 start_(s), end_(e), stream_(str) {
62 Stack(
int device,
size_t size);
65 Stack(
int device,
void* p,
size_t size,
bool isOwner);
74 char*
getAlloc(
size_t size, cudaStream_t stream);
77 void returnAlloc(
char* p,
size_t size, cudaStream_t stream);
bool isOwner_
Do we own our region of memory?
DeviceMemoryReservation getMemory(cudaStream_t stream, size_t size) override
size_t getHighWaterCudaMalloc() const
Returns the high-water mark of cudaMalloc activity.
size_t size_
Total size end_ - start_.
std::list< Range > lastUsers_
Stack(int device, size_t size)
Constructor that allocates memory via cudaMalloc.
size_t mallocCurrent_
How much cudaMalloc memory is currently outstanding?
Stack stack_
Memory stack.
void returnAlloc(char *p, size_t size, cudaStream_t stream)
Returns an allocation.
char * head_
Stack head within [start, end)
size_t getSizeAvailable() const override
Returns the current size available without calling cudaMalloc.
size_t getSizeAvailable() const
size_t highWaterMemoryUsed_
int device_
Device this allocation is on.
std::string toString() const override
Returns a string containing our current memory manager state.
Manages temporary memory allocations on a GPU device.
std::string toString() const
Returns the stack state.
size_t getHighWaterCudaMalloc() const override
char * getAlloc(size_t size, cudaStream_t stream)
int getDevice() const override
Returns the device we are managing memory for.
StackDeviceMemory(int device, size_t allocPerDevice)
Allocate a new region of memory that we manage.