Allocator with python functions to perform memory allocation.
This allocator keeps functions corresponding to malloc and free, delegating the actual allocation to external sources while only handling the timing of the resource allocation and deallocation.
malloc should follow the signature
malloc(int, int) -> intreturning the pointer to the allocated memory given the param object, the number of bytes to allocate and the device id on which the allocation should take place.
Similarly, free should follow the signature
free(int, int)with no return, taking the pointer to the allocated memory and the device id on which the memory was allocated.
If the external memory management supports asynchronous operations, the current CuPy stream can be retrieved inside
cupy.cuda.get_current_stream(). To use external streams, wrap them with
malloc_func (function) – malloc function to be called.
free_func (function) – free function to be called.
malloc(self, size_t size) → MemoryPointer¶