#[cfg(target_os = "linux")]
mod platform;
#[cfg(not(target_os = "linux"))]
#[path = "platform/stub/mod.rs"]
mod platform;
#[cfg(feature = "cutlass")]
pub use platform::{
BlockScaledFp4Plan, BlockScaledFp4Spec, BlockScaledFp4VectorPlan, BlockScaledFp4VectorSpec,
BlockScaledMxFp8Plan, BlockScaledMxFp8Spec, BlockwiseFp8VectorPlan, BlockwiseFp8VectorSpec,
DenseMatmulDataType, DenseMatmulPlan, DenseMatmulSpec, DenseVectorPlan, DenseVectorSpec,
FmhaBf16Plan, FmhaBf16Spec, IndexedGroupedFp4Plan, IndexedGroupedFp4Spec,
PairedVariableGroupedFp4Plan, ScaledFp8Plan, ScaledFp8ScaleType, ScaledFp8Spec,
ScaledFp8WeightScaleType, VariableGroupedBf16Plan, VariableGroupedBf16Spec,
VariableGroupedFp4Plan, VariableGroupedFp4Spec,
};
pub use platform::{
CaptureMode, CompileSpec, CompiledPtx, Context, DeviceBuffer, DeviceInfo, Driver, Event, Graph,
Kernel, KernelArgument, KernelNode, LaunchConfig, MemoryPool, MemoryPoolStats, Module,
PinnedBuffer, ProfilerRange, Stream, compiler_version,
};
#[cfg(feature = "cublaslt")]
pub use platform::{CublasBf16Plan, CublasBf16Spec, CublasLtBf16Plan, CublasLtBf16Spec};
#[cfg(all(target_os = "linux", feature = "cutlass"))]
unsafe extern "C" {
fn mircuda_cutlass_version() -> u32;
}
#[cfg(all(target_os = "linux", feature = "cutlass"))]
#[must_use]
pub fn cutlass_version() -> u32 {
unsafe { mircuda_cutlass_version() }
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("CUDA execution is unsupported on {0}")]
UnsupportedPlatform(&'static str),
#[cfg(target_os = "linux")]
#[error(transparent)]
Driver(#[from] cudarc::driver::DriverError),
#[cfg(target_os = "linux")]
#[error(transparent)]
Nvrtc(#[from] cudarc::nvrtc::CompileError),
#[cfg(target_os = "linux")]
#[error(transparent)]
NvrtcApi(#[from] cudarc::nvrtc::result::NvrtcError),
#[cfg(target_os = "linux")]
#[error(transparent)]
IntegerConversion(#[from] std::num::TryFromIntError),
#[error("CUDA module and stream belong to different contexts")]
ContextMismatch,
#[error("CUDA buffer must be used on its allocation stream")]
StreamMismatch,
#[error("CUDA stream capture produced an empty graph")]
EmptyGraph,
#[error("CUDA graph node does not belong to this graph")]
GraphNodeMismatch,
#[error("CUDA capture did not expose one active kernel dependency")]
MissingCapturedKernel,
#[error("NVRTC returned no loadable PTX image")]
MissingPtx,
#[error("PTX image is not a NUL-terminated driver module")]
InvalidPtx,
#[error("CUDA returned a null host allocation")]
NullAllocation,
#[cfg(target_os = "linux")]
#[error(transparent)]
Nul(#[from] std::ffi::NulError),
#[error("typed pinned-host view does not match its allocation size")]
InvalidHostView,
#[error("CUDA transfer byte lengths differ")]
TransferSizeMismatch,
#[error("CUDA device transfer range exceeds its allocation")]
InvalidTransferRange,
#[error("CUDA matrix buffers do not match the plan shape")]
InvalidMatmulBuffer,
#[error("CUTLASS plan failed with status {0}")]
Cutlass(i32),
#[error("cuBLASLt plan failed with status {0}")]
CublasLt(i32),
#[error("cuBLAS plan failed with status {0}")]
Cublas(i32),
}
pub type Result<T> = std::result::Result<T, Error>;