少于 1 分钟阅读

CUDA L1 Cache/shared memory 配置函数

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

CUDA function cache configurations

function

Sets the preferred cache configuration for a device function.

1
2
3
    __host__ cudaError_t cudaFuncSetCacheConfig ( const void* func, cudaFuncCache cacheConfig )

parameter

  1. kernel 函数名
  2. enum cudaFuncCache

Values

1
2
3
4
    cudaFuncCachePreferNone = 0
    //Default function cache configuration, no preference

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

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

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

example

1
2
3
4
5
6
7
8
    // cache config function
        cudaFuncSetCacheConfig(Kernel,cudaFuncCachePreferL1);

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