delete on_release;
}
-static THAllocator CPU_fixed_allocator =
+static Allocator CPU_fixed_allocator =
{ cpu_fixed_malloc, cpu_fixed_realloc, cpu_fixed_free };
}
#define TH_ALLOCATOR_MAPPED_FROMFD 32
#define TH_ALLOCATOR_MAPPED_UNLINK 64
-using THAllocator = at::Allocator;
-
/* default malloc/free allocator. malloc and realloc raise an error (using
* THError) on allocation failure.
*/
-TH_API THAllocator* getTHDefaultAllocator(void);
+TH_API c10::Allocator* getTHDefaultAllocator(void);
// Sentinel value/type to help distinguish the file descriptor constructor from
// the non-file descriptor constructor
TH_API THStorage* THStorage_(newWithMapping)(const char *filename, ptrdiff_t size, int flags);
TH_API THStorage* THStorage_(newWithAllocator)(ptrdiff_t size,
- THAllocator* allocator);
+ c10::Allocator* allocator);
TH_API THStorage* THStorage_(newWithDataAndAllocator)(
at::DataPtr&& data, ptrdiff_t size, at::Allocator* allocator);
#include <THC/THCGeneral.h>
-THC_API THCDeviceAllocator* THCCachingAllocator_get(void);
+THC_API c10::Allocator* THCCachingAllocator_get(void);
THC_API void THCCachingAllocator_emptyCache(void);
THC_API void THCCachingAllocator_cacheInfo(int dev_id, size_t* cachedAndFree, size_t* largestBlock);
THC_API void* THCCachingAllocator_getBaseAllocation(void *ptr, size_t *size);
// Note that this allocator does not split larger allocations into smaller
// blocks, unlike the caching device allocator.
//
-THC_API THAllocator* getTHCCachingHostAllocator(void);
+THC_API c10::Allocator* getTHCCachingHostAllocator(void);
// Records an event in the specified stream. The allocation 'ptr' will not be
// re-used until the event has occurred.
return state->rngState;
}
-THAllocator* THCState_getCudaHostAllocator(THCState* state)
+c10::Allocator* THCState_getCudaHostAllocator(THCState* state)
{
return state->cudaHostAllocator;
}
void* THCudaMalloc(THCState *state, size_t size)
{
THCudaCheck(cudaGetLastError());
- THCDeviceAllocator* allocator = state->cudaDeviceAllocator;
+ c10::Allocator* allocator = state->cudaDeviceAllocator;
return allocator->raw_allocate(size);
}
at::DataPtr THCudaHostAlloc(THCState *state, size_t size)
{
THCudaCheck(cudaGetLastError());
- THAllocator* allocator = state->cudaHostAllocator;
+ c10::Allocator* allocator = state->cudaHostAllocator;
return allocator->allocate(size);
}
cudaError_t THCudaMemGetInfo(THCState *state, size_t* freeBytes, size_t* totalBytes, size_t* largestBlock)
{
size_t cachedBytes = 0;
- THCDeviceAllocator* allocator = state->cudaDeviceAllocator;
+ c10::Allocator* allocator = state->cudaDeviceAllocator;
*largestBlock = 0;
/* get info from CUDA first */
typedef struct THCState THCState;
struct THCState;
-typedef THAllocator THCDeviceAllocator;
-
typedef struct _THCCudaResourcesPerDevice {
/* cuBLAS handle is lazily initialized */
cublasHandle_t blasHandle;
THC_API int THCState_getPeerToPeerAccess(THCState* state, int dev, int devToAccess);
THC_API struct THCRNGState* THCState_getRngState(THCState* state);
-THC_API THAllocator* THCState_getCudaHostAllocator(THCState* state);
+THC_API c10::Allocator* THCState_getCudaHostAllocator(THCState* state);
THC_API void THCMagma_init(THCState *state);
PyObject * THCPModule_cudaHostAllocator(PyObject *_unused)
{
HANDLE_TH_ERRORS
- THAllocator* allocator = THCState_getCudaHostAllocator(state);
+ c10::Allocator* allocator = THCState_getCudaHostAllocator(state);
return PyLong_FromVoidPtr(allocator);
END_HANDLE_TH_ERRORS
}
THPStoragePtr self((THPStorage *)type->tp_alloc(type, 0));
THPUtils_assert(self, "failed to allocate a " THPStorageStr " object");
- THAllocator* allocator = nullptr;
+ c10::Allocator* allocator = nullptr;
// Internally we allow constructing with a keywoard only argument cdata
if (kwargs != nullptr) {
PyObject *allocator_ptr = PyDict_GetItemString(kwargs, "allocator");
if (allocator_ptr) {
THPUtils_assert(THPUtils_checkLong(allocator_ptr), "invalid allocator");
- allocator = (THAllocator*) PyLong_AsVoidPtr(allocator_ptr);
+ allocator = static_cast<c10::Allocator*>(PyLong_AsVoidPtr(allocator_ptr));
PyDict_DelItemString(kwargs, "allocator");
}