Problem with constant value

Hello everybody, sorry for my english. I’m spanish.

Well, I have a problem inside a kernel. Imagine the following kernel:

__global__ test (... float *res, int size1, int size2 ...)

int tam= size1 + size2;

float vector[tam];

...

// Make things with vector and store the result in res for example

...

I want to create a vector of size tam (sum of different sizes that change) but I get the following error: expression must have a constant value.

I can’t use constant or const before its declaration, so which is the best thing to do it?

Thanks a lot!

Greetings

you can’t dynamically allocate memory for registers in a kernel, or shared mem (actualy you can for shared if you do it before launching). you need to have a ruff idea of how big tam is and pre define it. also notice that such an allocation will go to local memory and not registers (which is actually global memory).