Skip to main content

Linker

Struct Linker 

Source
pub struct Linker { /* private fields */ }
Expand description

RAII wrapper around the CUDA link state (CUlinkState).

The linker accumulates PTX, cubin, and fatbin inputs via the add_* methods and then produces a single linked binary via complete.

On macOS, a synthetic implementation stores the inputs in memory and produces a synthetic cubin on completion.

§Drop behaviour

Dropping the linker calls cuLinkDestroy on platforms with a real CUDA driver. If complete() was already called, Drop is still safe because the cubin data has been copied into the LinkedModule.

Implementations§

Source§

impl Linker

Source

pub fn new(options: LinkerOptions) -> CudaResult<Self>

Creates a new linker with the given options.

On platforms with a real CUDA driver, this calls cuLinkCreate. On macOS, a synthetic linker is created for testing purposes.

§Errors

Returns a CudaError if cuLinkCreate fails (e.g. no active CUDA context).

Source

pub fn add_ptx(&mut self, ptx: &str, name: &str) -> CudaResult<()>

Adds PTX source code to the linker.

The PTX is compiled and linked when complete is called.

§Arguments
  • ptx — PTX source code (must not contain interior null bytes).
  • name — A descriptive name for this input (used in error messages).
§Errors
Source

pub fn add_cubin(&mut self, data: &[u8], name: &str) -> CudaResult<()>

Adds compiled cubin data to the linker.

§Arguments
  • data — Raw cubin binary data.
  • name — A descriptive name for this input.
§Errors
Source

pub fn add_fatbin(&mut self, data: &[u8], name: &str) -> CudaResult<()>

Adds a fat binary to the linker.

§Arguments
  • data — Raw fatbin binary data.
  • name — A descriptive name for this input.
§Errors
Source

pub fn add_object(&mut self, data: &[u8], name: &str) -> CudaResult<()>

Adds a relocatable device object to the linker.

§Arguments
  • data — Raw object binary data.
  • name — A descriptive name for this input.
§Errors
Source

pub fn add_library(&mut self, data: &[u8], name: &str) -> CudaResult<()>

Adds a device code library to the linker.

§Arguments
  • data — Raw library binary data.
  • name — A descriptive name for this input.
§Errors
Source

pub fn input_count(&self) -> usize

Returns the number of inputs added to the linker.

Source

pub fn input_names(&self) -> &[String]

Returns the names of all inputs added so far.

Source

pub fn options(&self) -> &LinkerOptions

Returns a reference to the linker options.

Source

pub fn complete(self) -> CudaResult<LinkedModule>

Completes the link, producing a LinkedModule.

This consumes the linker. The resulting cubin data is copied into the LinkedModule before the underlying CUlinkState is destroyed (by Drop).

§Errors

Trait Implementations§

Source§

impl Debug for Linker

Source§

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

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

impl Drop for Linker

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Linker

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> 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, 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