Hi. I’m a newb in programming. So may be the solution is quite simple…
I want to find out if there is some way to share variables within a thread? For example I have some code that is used several times in a kernel, like:
__global__ void procedure ()
{
//define some variables...
for (...)
{
switch(a)
{
case 1:
//do A
for (...)
{
//do B
}
;
break;
case 2:
//do B
break;
case 3:
//do A
break;
}
}
}
Where A and B are about 5 - 10 lines of code and use some common variables, that are loaded at the beginning. The most simple way is to make a function that will do A and a function that will do B. But they need to have about 10 common variables and some more that need to be stored till the next call to A or B. So maybe there is some way to share these variables within a thread (all threads are independent, so the variables have to be shared only within a thread and they shouldn’t be placed in global memory for quicker access). Or maybe there’s a way to make some sort of a substitute variable, use it where i want A and B, so that compiler would insert A code and B code instead of these variables, when compiling?
Thanks.