Disable cache per variable

Hey there.

I want to disable the caching mechanism for some of the data fields of my structures.
Something like that:

struct Foo {
float4 bar0;
float4 bar1;
float4 bar2;
float4 bar3;
disable_cache float4 bar4;

Is there a way to do that ?

It sounds like you’re asking for the “volatile” qualifier.


Does that help?

I was afraid that the compiler might turn off all kind of optimizations when using the volatile keyword. I need just the caching off.

What are you trying to achieve? Might memory fence functions be what you are after?

You can switch off L1 memory caching for a variable using inline ptx load/store instructions. To ensure visibility between threads though you should in addition memory fence instructions as stated by tera above.