pub struct Function<'a> { /* private fields */ }
Expand description
Handle to a global kernel function.
Implementations§
source§impl<'a> Function<'a>
impl<'a> Function<'a>
sourcepub fn get_attribute(&self, attr: FunctionAttribute) -> CudaResult<i32>
pub fn get_attribute(&self, attr: FunctionAttribute) -> CudaResult<i32>
Returns information about a function.
Examples:
use rustacuda::function::FunctionAttribute;
let function = module.get_function(&name).unwrap();
let shared_memory = function.get_attribute(FunctionAttribute::SharedMemorySizeBytes).unwrap();
println!("This function uses {} bytes of shared memory", shared_memory);
sourcepub fn set_cache_config(&mut self, config: CacheConfig) -> CudaResult<()>
pub fn set_cache_config(&mut self, config: CacheConfig) -> CudaResult<()>
Sets the preferred cache configuration for this function.
On devices where L1 cache and shared memory use the same hardware resources, this sets the preferred cache configuration for this function. This is only a preference. The driver will use the requested configuration if possible, but is free to choose a different configuration if required to execute the function. This setting will override the context-wide setting.
This setting does nothing on devices where the size of the L1 cache and shared memory are fixed.
Example:
use rustacuda::context::CacheConfig;
let mut function = module.get_function(&name).unwrap();
function.set_cache_config(CacheConfig::PreferL1).unwrap();
Sets the preferred shared memory configuration for this function.
On devices with configurable shared memory banks, this function will set this function’s shared memory bank size which is used for subsequent launches of this function. If not set, the context-wide setting will be used instead.
Example:
use rustacuda::context::SharedMemoryConfig;
let mut function = module.get_function(&name).unwrap();
function.set_shared_memory_config(SharedMemoryConfig::EightByteBankSize).unwrap();