How I garantee that a array goes to cache?

Dear All

 There any way I can garantee that a certain array (when I copy from host to device) goes to cache and stays there? I know there are constant memory (read only memory). How I declare that memory and transfer a array from host to that memory?

Thanks

Luis Gonçalves

From the example in http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#device-memory

__constant__ float constData[256];
float data[256];
cudaMemcpyToSymbol(constData, data, sizeof(data));
cudaMemcpyFromSymbol(data, constData, sizeof(data));

There are some way to read and write to a array in the cache without have to actualize in the main “graphics memory” or the data in cache not to be replicated in the main “graphics memory”?

There are some arrays that I want to be transitory and I do not need to transfer to the host.

Thanks

Luis Gonçalves

Do you ask if there is a possibility to read/write from a kernel directly to some kind of global cache?
The answer to that question is no.

On a per block level you can use shared memory as a user-defined cache. If you want to share data with ALL threads you need to go through global memory. You cannot use caches because they are per SM.

Dear Luis,
There was some discussion of Tesla K20 non-use of L1 cache last week https://devtalk.nvidia.com/default/topic/794905/cuda-programming-and-performance/3gb-can-it-be-read-as-texture-/
The question of slow access to constant cause by serial (ie not parrallel) access to its
tiny cache has also come up before. It seems many parameters about caches depend on which GPU hardware
you are using.
Bill