Skip to main content

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/// Re-export of the `glamx` math library.
27pub use glamx;
28
29#[cfg(target_arch = "nvptx64")]
30pub use cuda_std;
31
32#[cfg(not(any(target_arch = "spirv", target_arch = "nvptx64")))]
33pub use std::println;
34#[cfg(any(target_arch = "spirv", target_arch = "nvptx64"))]
35#[macro_export]
36macro_rules! println {
37    () => {};
38    ($($arg:tt)*) => {};
39}