volatile sdata volatile shared memory, self managed

I want to use warp-level synchronization accessing shared memory, but to manage the shared memory by myself, i.e. using extern sdata. The guide instructs using volatile variables, but how do I apply it on sdata?

[codebox]extern shared unsigned int sdata;[/codebox]

Thanks!

You can do it like this:

[font=“Courier New”]extern shared unsigned int sdata;

volatile unsigned int *vsdata = sdata;[/font]

The benefit of having a separate pointer (“vsdata” in this case) that is declared as volatile is that you can use the non-volatile references for performance in the portions of the kernel that are not doing any warp-level reduction and still be able to reference the data as volatile within the reduction code where it’s needed.

–Cliff

Thanks Cliff!