CUDA L1 Cache/shared memory 配置函数

用于NVIDIA 的 Fermi、 Kepler 以及最新Volta (我猜测未来)架构 缓存配置函数

CUDA function cache configurations

function

Sets the preferred cache configuration for a device function.


__host__ ​cudaError_t cudaFuncSetCacheConfig ( const void* func, cudaFuncCache cacheConfig ) 

parameter

  1. kernel 函数名
  2. enum cudaFuncCache

Values


cudaFuncCachePreferNone = 0
//Default function cache configuration, no preference

cudaFuncCachePreferShared = 1
//Prefer larger shared memory and smaller L1 cache

cudaFuncCachePreferL1 = 2
//Prefer larger L1 cache and smaller shared memory

cudaFuncCachePreferEqual = 3
//Prefer equal size L1 cache and shared memory

example


// cache config function
    cudaFuncSetCacheConfig(Kernel,cudaFuncCachePreferL1);

.....
  Kernel<<< grid, threads, 0 >>>;