Can you dynamically allocate constant arrays? Host treating const, global, texture arrays equally?

Hi there. Since constant arrays are really just device memory loaded into the constant cache via a special load instruction, I was wondering if it is possible for the host to dynamically allocate constant arrays for use by a kernel? If so, what syntax would be used? Currently, the only examples I see of constant memory have it statically declared. I’d like to do something like this:

constant float myArray[d]; // d is only known at runtime

Thanks. :)

  • Jeff

Hi there. Since constant arrays are really just device memory loaded into the constant cache via a special load instruction, I was wondering if it is possible for the host to dynamically allocate constant arrays for use by a kernel? If so, what syntax would be used? Currently, the only examples I see of constant memory have it statically declared. I’d like to do something like this:

constant float myArray[d]; // d is only known at runtime

Thanks. :)

  • Jeff

AFAIK, no. There’s 64 kb of it, so I believe it to be different from (global) device memory.

What you can do is declare a static array (of ints or bytes or whatever is ok for your addressing needs) and give your constant data a place within that array, dynamically.

Then you use copy to symbol with offset and pass the adresses to your kernel.

AFAIK, no. There’s 64 kb of it, so I believe it to be different from (global) device memory.

What you can do is declare a static array (of ints or bytes or whatever is ok for your addressing needs) and give your constant data a place within that array, dynamically.

Then you use copy to symbol with offset and pass the adresses to your kernel.