| 258 | } |
| 259 | |
| 260 | af_err af_alloc_device_v2(void **ptr, const dim_t bytes) { |
| 261 | try { |
| 262 | AF_CHECK(af_init()); |
| 263 | #ifdef AF_OPENCL |
| 264 | auto *buf = static_cast<cl::Buffer *>(memAllocUser(bytes)); |
| 265 | *ptr = buf->operator()(); |
| 266 | |
| 267 | // Calling retain to offset the decrement the reference count by the |
| 268 | // destructor of cl::Buffer |
| 269 | clRetainMemObject(cl_mem(*ptr)); |
| 270 | delete buf; |
| 271 | #else |
| 272 | *ptr = static_cast<void *>(memAllocUser(bytes)); |
| 273 | #endif |
| 274 | } |
| 275 | CATCHALL; |
| 276 | return AF_SUCCESS; |
| 277 | } |
| 278 | |
| 279 | af_err af_alloc_pinned(void **ptr, const dim_t bytes) { |
| 280 | try { |
no test coverage detected