Reputation: 178
Is there a way to reallocate local memory in one same kernel
EX)
__local float arr[size 1] //maximum size
..
arr usage
..
free arr
__local float arr2[size 2] //smaller than size1
arr2 usage
if i want use different purpose, should i reuse arr
with different indexes?
Upvotes: 0
Views: 101
Reputation: 6343
It's C99, so You could make a union of the structure or arrays you want to use sequentially. They would share the memory.
Upvotes: 0
Reputation: 8484
No, you cannot dynamically reallocate memory in OpenCL.
You can define one or more __local
arrays depending on their size of course as the local memory is limited.
You can also reuse previously defined array for other purpose.
If you need different array size per kernel call then you can pass local array as a kernel parameter and decide on the host which size should that be per each call.
Upvotes: 2