Skip to main content

cudaFuncSetCacheConfig

Function cudaFuncSetCacheConfig 

Source
pub unsafe extern "C" fn cudaFuncSetCacheConfig(
    func: *const c_void,
    cacheConfig: cudaFuncCache,
) -> cudaError_t
Expand description

Sets the preferred cache configuration for a device function.

On devices where the L1 cache and shared memory use the same hardware resources, this sets through cacheConfig the preferred cache configuration for the function specified via func. This is only a preference. The runtime will use the requested configuration if possible, but it is free to choose a different configuration if required to execute func.

func is a device function symbol and must be declared as a __global__ function. If the specified function does not exist, then cudaErrorInvalidDeviceFunction is returned. For templated functions, pass the function symbol as follows: func_name<template_arg_0,…,template_arg_N>

This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.

Launching a kernel with a different preference than the most recent preference setting may insert a device-side synchronization point.

The supported cache configurations are:

Note that this function may also return error codes from previous, asynchronous launches.

Note: Use of a string naming a function as the func parameter was deprecated in CUDA 4.1 and removed in CUDA 5.0.

Note that this function may also return cudaError_t::CUDA_ERROR_NOT_INITIALIZED, cudaErrorInsufficientDriver or cudaError_t::CUDA_ERROR_NO_DEVICE if this call tries to initialize internal CUDA RT state.

Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.

Note: This API does not accept a cudaKernel_t casted as void*. If cache config modification is required for a cudaKernel_t (or a global function), it can be replaced with a call to cudaFuncSetAttributes with the attribute cudaFuncAttribute::CU_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT to specify a more granular L1 cache and shared memory split configuration.

§Parameters

  • func: Device function symbol.
  • cacheConfig: Requested cache configuration.

§Return value

See also: cudaFuncSetCacheConfig (C++ API), cudaFuncGetAttributes (C API), cudaLaunchKernel (C API), cuFuncSetCacheConfig.