Skip to main content

LlvmCompiler

Struct LlvmCompiler 

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

Compiles kernels by shelling out to the custom teenyc compiler (-Zcodegen-backend=mlir) at runtime. See crate::compiler::find_teenyc for how its path is resolved, and the crate docs for the cargo-teeny setup this requires.

Implementations§

Source§

impl LlvmCompiler

Source

pub fn new( teenyc_path: impl Into<PathBuf>, cache_dir: impl Into<PathBuf>, ) -> Result<Self>

Creates a compiler that invokes the teenyc binary at teenyc_path, caching compiled kernels under cache_dir (created if it doesn’t exist).

ptx_version defaults from $TEENYC_PTX_VERSION if set (parse failures are ignored, falling back to None/teenyc’s own default). This matters beyond the compile itself: Compiler::compile’s cache-key hash folds in ptx_version, so a JIT/runtime call site that never explicitly calls Self::with_ptx_version — e.g. a deployed binary just looking up an AOT-precompiled kernel cache, with no live teenyc to fall back to — must still agree with whatever override cargo teeny package --options ptx-version=NN used at AOT time, or every lookup misses. Reading the env var here means one .env entry (see TEENYC_PTX_VERSION in the deployed package’s env) keeps both sides in sync without every call site having to thread the value through by hand.

log_level similarly defaults from $TEENYC_LOG_LEVEL if set (parse failures are ignored, falling back to None) — this lets any call site, including ones that don’t (or can’t, e.g. a fixed helper like crate::compiler::driver::cuda::compile_kernel) call Self::with_log_level directly, turn on pipeline-stage logging via the environment.

Source

pub fn with_target_cpu(self, cpu: impl Into<String>) -> Self

Sets the target GPU architecture (e.g. sm_90) passed to teenyc as -Ctarget-cpu.

Source

pub fn with_ptx_version(self, ptx_version: u32) -> Self

Override the PTX ISA version teenyc stamps into the generated PTX (encoded as major*10 + minor, e.g. 82 for 8.2), via TEENYC_PTX_VERSION. Without this, teenyc picks a conservative default from the target capability — set this when the deployment target’s exact CUDA version is known and needs a precise match.

Source

pub fn with_log_level(self, log_level: LogLevel) -> Self

Sets teenyc’s diagnostic verbosity (see LogLevel). Left unset (the default), teenyc uses its own default (roughly warn) and no pipeline-stage IR is captured.

Trait Implementations§

Source§

impl Clone for LlvmCompiler

Source§

fn clone(&self) -> LlvmCompiler

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 Compiler for LlvmCompiler

Source§

fn compile( &self, kernel: &impl Kernel, _target: &impl Target, force: bool, ) -> Result<String>

Compiles kernel for target, returning the path to the compiled artifact. force recompiles even if a cached artifact exists.
Source§

impl Debug for LlvmCompiler

Source§

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

Formats the value using the given formatter. 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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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