Allocate __private memory inside a kernel


I need to do something like this inside a kernel:

__private mytype* next_item = (mytype*)malloc(sizeof(mytype));

However, I’m getting this error out of the clGetProgramBuildInfo call:

kernel referenced an external function malloc, that could not be found.

(interestingly, I only get this on my MacBook Pro, but not my newer iMac, which gives me a frustratingly blank error log…)

Do I need to use a special on-chip memory allocation system? If so, where is this documented? googling “opencl malloc” doesn’t give you too many useful results.



apologies, I was under the impression that you could use __private memory on-device within one processing unit.

I shall duly rewrite my kernel code to stop it using any kind of dynamic array :confused: