MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / suggested_launch_configuration

Method suggested_launch_configuration

crates/cust/src/function.rs:380–405  ·  view source on GitHub ↗

Returns a reasonable block and grid size to achieve the maximum capacity for the launch (the max number of active warps with the fewest blocks per multiprocessor). # Params `dynamic_smem_size` is the amount of dynamic shared memory required by this function. We currently do not expose a way of determining this dynamically based on block size due to safety concerns. `block_size_limit` is the max

(
        &self,
        dynamic_smem_size: usize,
        block_size_limit: BlockSize,
    )

Source from the content-addressed store, hash-verified

378 ///
379 /// Note: all panics by `dynamic_smem_size` will be ignored and the function will instead use `0`.
380 pub fn suggested_launch_configuration(
381 &self,
382 dynamic_smem_size: usize,
383 block_size_limit: BlockSize,
384 ) -> CudaResult<(u32, u32)> {
385 let mut min_grid_size = MaybeUninit::uninit();
386 let mut block_size = MaybeUninit::uninit();
387
388 let total_block_size_limit = block_size_limit.x * block_size_limit.y * block_size_limit.z;
389
390 unsafe {
391 cuda::cuOccupancyMaxPotentialBlockSize(
392 min_grid_size.as_mut_ptr(),
393 block_size.as_mut_ptr(),
394 self.to_raw(),
395 None,
396 dynamic_smem_size,
397 total_block_size_limit as i32,
398 )
399 .to_result()?;
400 Ok((
401 min_grid_size.assume_init() as u32,
402 block_size.assume_init() as u32,
403 ))
404 }
405 }
406}
407
408/// Launch a kernel function asynchronously.

Callers 1

mainFunction · 0.80

Calls 3

to_resultMethod · 0.45
as_mut_ptrMethod · 0.45
to_rawMethod · 0.45

Tested by

no test coverage detected