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
impl LlvmCompiler
Sourcepub fn new(
teenyc_path: impl Into<PathBuf>,
cache_dir: impl Into<PathBuf>,
) -> Result<Self>
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.
Sourcepub fn with_target_cpu(self, cpu: impl Into<String>) -> Self
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.
Sourcepub fn with_ptx_version(self, ptx_version: u32) -> Self
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.
Sourcepub fn with_log_level(self, log_level: LogLevel) -> Self
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
impl Clone for LlvmCompiler
Source§fn clone(&self) -> LlvmCompiler
fn clone(&self) -> LlvmCompiler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more