eclipse0922
eclipse0922

Reputation: 178

opencl- Is there a way to reallocate local memory?

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

Answers (2)

Dithermaster
Dithermaster

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

doqtor
doqtor

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

Related Questions