Then my assumption is that “param” is actually stored in shared memory for the threads. Is that correct?
Secondly, I notice that it is not necessary for each thread to compute “sqrt” because they would all produce the same value. I thought it might be better to move this into shared memory, like so…
However, it won’t allow me to assign to the shared variable from outside of the kernel like this. Hmm. I suppose I could accomplish this by sending it as an additional parameter,
I double that… but I am unsure how the broadcast works. I tired using it but was never able to get any advantage from broadcast (maybe there was no broad cast happening) … hence am unsure how broadcast works. But theoretically it should work,
Then my assumption is that “param” is actually stored in shared memory for the threads. Is that correct?[/codebox]
in this code, compiler will choice register or local memory for storing this “foo” variable. this kernel is too simple and this variable is not take alot of memory so compiler will use register for storing this variable. You can check in visual profiler if thread use local memory or not.
Shared memory will be used if he defined that “foo” variable in shared memory. so I said that “foo” will strore in register.
[codebox]shared foo;
global mykernel( float param )
{
}
int main()
{
const float pi = 3.14;
foo = sqrt(param + pi);
mykernel<<>>(param);
}[/codebox]
shared float foo;
he wants to store this variable in shared memory. and this variable will be read by each threas on block, so in my experience bank conflicts will occurs.
Bank conflict will occurs if more than 2 threads in the same of a half-warp access the same bank.
Just to clarify…I agree that the local variable foo will be stored in registers/local memory. However, I believe the original question was regarding the function parameter named param. It is my understanding that this parameter will be passed via shared memory.