pub struct OccupancyFromPtx { /* private fields */ }Expand description
Parses register usage out of a PTX string and wires it into the CPU-side occupancy model.
Construct with OccupancyFromPtx::parse, then either inspect per-kernel
register counts via OccupancyFromPtx::kernel or compute an occupancy
estimate directly with OccupancyFromPtx::estimate_for.
Implementations§
Source§impl OccupancyFromPtx
impl OccupancyFromPtx
Sourcepub fn parse(ptx: &str) -> CudaResult<Self>
pub fn parse(ptx: &str) -> CudaResult<Self>
Parse all kernels and their .reg directives out of a PTX module.
Register declarations are attributed to the most recently seen
.entry. Directives that appear before any .entry (module-scope
.reg, which PTX permits for globals) are ignored for occupancy
purposes because they do not occupy per-thread registers.
§Errors
Returns CudaError::InvalidValue if the PTX contains no .entry
directive at all (there is nothing whose occupancy could be modelled).
Sourcepub fn register_usage(&self, name: &str) -> Option<PtxRegisterUsage>
pub fn register_usage(&self, name: &str) -> Option<PtxRegisterUsage>
Register usage for the named kernel, or None if it is absent.
Sourcepub fn estimate_for(
&self,
kernel_name: &str,
sm_major: u32,
sm_minor: u32,
block_size: u32,
shared_memory: u32,
) -> CudaResult<OccupancyEstimate>
pub fn estimate_for( &self, kernel_name: &str, sm_major: u32, sm_minor: u32, block_size: u32, shared_memory: u32, ) -> CudaResult<OccupancyEstimate>
Estimate occupancy for one kernel on a synthetic device of the given compute capability, using the register count parsed from the PTX.
This is the offline equivalent of
cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags: the parsed
.reg count is substituted for the figure ptxas would otherwise
supply.
§Parameters
kernel_name— entry name to model.sm_major/sm_minor— target compute capability (e.g.9, 0).block_size— threads per block.shared_memory— dynamic shared memory per block in bytes.
§Errors
Returns CudaError::NotFound if kernel_name is not present.
Sourcepub fn estimate_with_info(
&self,
kernel_name: &str,
info: DeviceOccupancyInfo,
block_size: u32,
shared_memory: u32,
) -> CudaResult<OccupancyEstimate>
pub fn estimate_with_info( &self, kernel_name: &str, info: DeviceOccupancyInfo, block_size: u32, shared_memory: u32, ) -> CudaResult<OccupancyEstimate>
Estimate occupancy for one kernel against an explicit device
description, for callers that already hold a DeviceOccupancyInfo.
§Errors
Returns CudaError::NotFound if kernel_name is not present.
Trait Implementations§
Source§impl Clone for OccupancyFromPtx
impl Clone for OccupancyFromPtx
Source§fn clone(&self) -> OccupancyFromPtx
fn clone(&self) -> OccupancyFromPtx
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more