//! # Raw FFI Bindings for CUDA Libraries
//!
//! This crate provides raw, unsafe FFI (Foreign Function Interface) bindings to various
//! NVIDIA CUDA libraries like CUDA Driver, Runtime, CUBLAS, NCCL, etc.
//!
//! ## Code Generation
//!
//! The modules within this crate are not hand-written. They are automatically generated
//! by a `build.rs` script using `bindgen` during the compilation process. The source
//! headers are typically located from the CUDA Toolkit installation path.
//!
//! ## Safety
//!
//! All functions and types exposed by this crate are essentially direct translations
//! from C headers and are therefore `unsafe`. The caller is responsible for upholding
//! all safety invariants required by the underlying C APIs.
//!
//! The numerous `#![allow(...)]` attributes are applied on a per-module basis to suppress
//! warnings originating from the auto-generated code, which does not follow standard
//! Rust style conventions. These lints do not affect any hand-written code in this crate.
macro_rules! cuda_module {
($name:ident, $desc:literal) => {
#[allow(
non_upper_case_globals,
non_camel_case_types,
non_snake_case,
unsafe_op_in_unsafe_fn,
dead_code,
clippy::all
)]
#[doc = $desc]
pub mod $name {
#![doc = concat!("Auto-generated bindings for ", $desc)]
include!(concat!(env!("OUT_DIR"), "/", stringify!($name), ".rs"));
}
};
}
// --- Core Execution APIs (Low-level to High-level) ---
#[cfg(feature = "driver")]
cuda_module!(driver, "CUDA Driver API");
#[cfg(feature = "runtime")]
cuda_module!(runtime, "CUDA Runtime API");
// --- System Utilities ---
#[cfg(feature = "nvml")]
cuda_module!(nvml, "NVIDIA Management Library");
// --- Application-Specific Libraries ---
#[cfg(feature = "cublas")]
cuda_module!(cublas, "cuBLAS - CUDA Basic Linear Algebra Subprograms");
#[cfg(feature = "cublaslt")]
cuda_module!(cublaslt, "cuBLASLt - CUDA BLAS Lightweight operations");
#[cfg(feature = "nccl")]
cuda_module!(nccl, "NCCL - NVIDIA Collective Communications Library");