khal_std/lib.rs
1//! GPU standard library for khal compute shaders.
2//!
3//! Provides cross-platform primitives (synchronization, atomics, indexing, iteration)
4//! that compile to SPIR-V, CUDA PTX, and native CPU targets.
5
6#![cfg_attr(any(target_arch = "spirv", target_arch = "nvptx64"), no_std)]
7#![cfg_attr(target_arch = "nvptx64", feature(link_llvm_intrinsics))]
8
9/// Architecture-specific runtime support (CPU coroutines, CUDA intrinsics).
10pub mod arch;
11/// Floating-point conversion utilities (f16, packing/unpacking).
12pub mod float;
13/// Indexing utilities with optional bounds-check removal.
14pub mod index;
15/// GPU-compatible iterators.
16pub mod iter;
17/// Re-exports of `spirv_std_macros` and `khal_derive::spirv_bindgen`.
18pub mod macros;
19/// Memory scope and semantics constants for SPIR-V and CUDA.
20pub mod memory;
21/// Numeric trait re-exports (`Float`) across backends.
22pub mod num_traits;
23/// Synchronization primitives (barriers, atomics).
24pub mod sync;
25
26/// Build-script helpers for shader crates. Host-only.
27#[cfg(not(any(target_arch = "spirv", target_arch = "nvptx64")))]
28pub mod build_script;
29#[cfg(not(any(target_arch = "spirv", target_arch = "nvptx64")))]
30pub use build_script::*;
31
32/// Re-export of the `glamx` math library.
33pub use glamx;
34
35#[cfg(target_arch = "nvptx64")]
36pub use cuda_std;
37
38#[cfg(not(any(target_arch = "spirv", target_arch = "nvptx64")))]
39pub use std::println;
40#[cfg(any(target_arch = "spirv", target_arch = "nvptx64"))]
41#[macro_export]
42macro_rules! println {
43 () => {};
44 ($($arg:tt)*) => {};
45}