Skip to main content

Program

Struct Program 

Source
pub struct Program { /* private fields */ }

Implementations§

Source§

impl Program

Source

pub fn from_source(source: &str) -> Self

Creates a lazy NVRTC program from CUDA source text.

The raw NVRTC handle is created when the program is compiled or otherwise materialized.

Source

pub fn with_name(self, name: &str) -> Self

Source

pub fn with_header(self, header: Header<'_>) -> Self

Source

pub fn with_headers(self, headers: &[Header<'_>]) -> Self

Source

pub unsafe fn from_raw(handle: nvrtcProgram) -> Result<Self>

Takes ownership of a raw NVRTC program handle.

§Safety

handle must be a valid nvrtcProgram that is not owned by any other wrapper. The returned wrapper destroys it with nvrtcDestroyProgram.

Source

pub fn compile(&self, options: &[&str]) -> Result<()>

Source

pub fn compile_with_options(&self, options: &CompileOptions<'_>) -> Result<()>

Source

pub fn compile_with_options_and_cancel_flag( &self, options: &CompileOptions<'_>, cancel: &AtomicBool, ) -> Result<()>

Registers a flow callback that can cancel compilation.

The callback function must satisfy the following constraints:

(1) It must return 1 to cancel compilation or 0 to continue. Other return values are reserved for future use.

(2) It must return consistent values. Once it returns 1 at one point, it must return 1 in all following invocations during the current nvrtcCompileProgram call in progress.

(3) It must be thread-safe.

(4) It must not invoke any NVRTC, libNVVM, or PTX APIs.

Source

pub fn add_name_expression(&self, name_expression: &str) -> Result<()>

Registers a name expression for a __global__, __device__, or __constant__ symbol.

The identical name expression string must be provided to Program::lowered_name after compilation.

§Errors

Returns an error if name_expression contains an interior NUL byte, if the program handle is invalid, or if NVRTC rejects the expression.

Source

pub fn lowered_name(&self, name_expression: &str) -> Result<String>

Returns the lowered (mangled) name for a registered name expression.

The identical name expression must have been previously provided to Program::add_name_expression.

§Errors

Returns an error if name_expression contains an interior NUL byte, if the program handle is invalid, or if NVRTC cannot return the lowered name.

Source

pub fn ptx(&self) -> Result<Vec<u8>>

Source

pub fn ptx_image(&self) -> Result<ModuleImage<'static>>

Source

pub fn ptx_string(&self) -> Result<String>

Source

pub fn cubin(&self) -> Result<Vec<u8>>

Source

pub fn cubin_image(&self) -> Result<ModuleImage<'static>>

Source

pub fn lto_ir(&self) -> Result<Vec<u8>>

Source

pub fn lto_ir_image(&self) -> Result<ModuleImage<'static>>

Source

pub fn optix_ir(&self) -> Result<Vec<u8>>

Source

pub fn optix_ir_image(&self) -> Result<ModuleImage<'static>>

Source

pub fn log(&self) -> Result<String>

Source

pub fn pch_create_status(&self) -> Result<Status>

Returns the PCH creation status.

Status::Success indicates that the PCH was successfully created. Status::NoPchCreateAttempted indicates that no PCH creation was attempted, either because PCH was not requested during the preceding compile call, or automatic PCH processing was requested, and the compiler chose not to create a PCH file. Status::PchCreateHeapExhausted indicates that a PCH file could potentially have been created, but the compiler ran out space in the PCH heap. In this scenario, use Program::pch_heap_size_required to query the required heap size, reallocate the heap with set_pch_heap_size, and retry PCH creation with sys::nvrtcCompileProgram on a new NVRTC program instance. Status::PchCreate indicates that an error condition prevented the PCH file from being created.

§Errors

Returns an error if the program handle is invalid.

Source

pub fn pch_heap_size_required(&self) -> Result<usize>

Returns the PCH heap size required to compile the given program.

§Errors

Returns an error if the program handle is invalid or if the returned size is not valid because Program::pch_create_status did not return Status::Success or Status::PchCreateHeapExhausted.

Source

pub fn materialize_raw(&self) -> Result<nvrtcProgram>

Returns the raw NVRTC program handle, creating it first if needed.

If the program has not been materialized yet, this creates the raw handle first.

§Errors

Returns an error if NVRTC cannot create the program handle.

Source

pub const fn as_raw_if_materialized(&self) -> Option<nvrtcProgram>

Returns the raw NVRTC program handle only if it has already been materialized.

Source

pub fn into_raw(self) -> Result<nvrtcProgram>

Transfers ownership of the raw NVRTC program handle to the caller.

If the program has not been materialized yet, this creates the raw handle first. The caller becomes responsible for destroying the returned handle with nvrtcDestroyProgram.

Source§

impl Program

Trait Implementations§

Source§

impl Debug for Program

Source§

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

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

impl Drop for Program

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.