Skip to main content

OccupancyFromPtx

Struct OccupancyFromPtx 

Source
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

Source

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).

Source

pub fn kernels(&self) -> &[PtxKernel]

All kernels discovered in the PTX, in source order.

Source

pub fn kernel(&self, name: &str) -> Option<&PtxKernel>

Look up a kernel by its entry name.

Source

pub fn register_usage(&self, name: &str) -> Option<PtxRegisterUsage>

Register usage for the named kernel, or None if it is absent.

Source

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.

Source

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

Source§

fn clone(&self) -> OccupancyFromPtx

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OccupancyFromPtx

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OccupancyFromPtx

Source§

fn default() -> OccupancyFromPtx

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more