| 67 | // Allocate size bytes on GPU, returning pointer in ptrPtr. |
| 68 | template<typename T> |
| 69 | static 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. |
nothing calls this directly
no test coverage detected