MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / magma_malloc

Function magma_malloc

src/backend/opencl/magma/magma_data.h:69–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67// Allocate size bytes on GPU, returning pointer in ptrPtr.
68template<typename T>
69static magma_int_t magma_malloc(magma_ptr* ptrPtr, int num) {
70 size_t size = num * sizeof(T);
71 // malloc and free sometimes don't work for size=0, so allocate some minimal
72 // size
73 if (size == 0) size = sizeof(T);
74 cl::Buffer* buf = arrayfire::opencl::bufferAlloc(size);
75 *ptrPtr = static_cast<magma_ptr>(buf->get());
76 delete (buf);
77
78 if (ptrPtr == nullptr) { return MAGMA_ERR_DEVICE_ALLOC; };
79 return MAGMA_SUCCESS;
80}
81
82// --------------------
83// Free GPU memory allocated by magma_malloc.

Callers

nothing calls this directly

Calls 2

bufferAllocFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected