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

Function memAlloc

src/backend/opencl/memory.cpp:58–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57template<typename T>
58unique_ptr<cl::Buffer, function<void(cl::Buffer *)>> memAlloc(
59 const size_t &elements) {
60 // TODO: make memAlloc aware of array shapes
61 if (elements) {
62 dim4 dims(elements);
63 void *ptr = memoryManager().alloc(false, 1, dims.get(), sizeof(T));
64 auto buf = static_cast<cl_mem>(ptr);
65 cl::Buffer *bptr = new cl::Buffer(buf, true);
66 return unique_ptr<cl::Buffer, function<void(cl::Buffer *)>>(bptr,
67 bufferFree);
68 } else {
69 return unique_ptr<cl::Buffer, function<void(cl::Buffer *)>>(nullptr,
70 bufferFree);
71 }
72}
73
74void *memAllocUser(const size_t &bytes) {
75 dim4 dims(bytes);

Callers

nothing calls this directly

Calls 2

allocMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected