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

Method nativeAlloc

src/backend/opencl/memory.cpp:205–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205void *Allocator::nativeAlloc(const size_t bytes) {
206 cl_int err = CL_SUCCESS;
207 auto ptr = static_cast<void *>(clCreateBuffer(
208 getContext()(), CL_MEM_READ_WRITE, // NOLINT(hicpp-signed-bitwise)
209 bytes, nullptr, &err));
210
211 if (err != CL_SUCCESS) {
212 auto str = fmt::format("Failed to allocate device memory of size {}",
213 bytesToString(bytes));
214 AF_ERROR(str, AF_ERR_NO_MEM);
215 }
216
217 AF_TRACE("nativeAlloc: {} {}", bytesToString(bytes), ptr);
218 return ptr;
219}
220
221void Allocator::nativeFree(void *ptr) {
222 cl_mem buffer = static_cast<cl_mem>(ptr);

Callers

nothing calls this directly

Calls 4

bytesToStringFunction · 0.85
getActiveDeviceIdFunction · 0.70
getContextFunction · 0.50
getQueueFunction · 0.50

Tested by

no test coverage detected