zer_compute/kernels/hello_backend.rs
1//! `HelloBackend` kernel, trivial diagnostic that proves a GPU kernel/shader
2//! was actually invoked on the device.
3//!
4//! Each backend writes a **different** magic token into a 4-byte output buffer.
5//! The token value is baked into each backend's kernel/shader source, only
6//! that specific kernel running on the device can produce the correct non-zero
7//! value. A zero token means the kernel never executed.
8//!
9//! The per-backend magic values are intentionally private to their respective
10//! launch modules so that a buggy Rust stub cannot accidentally return the
11//! "right" answer without the kernel having run.
12//!
13//! See `examples/hello_backend.rs` for the canonical usage.
14
15use crate::kernel::Kernel;
16
17/// Marker for the diagnostic hello kernel.
18pub struct HelloBackend;
19
20/// No input needed, the kernel only writes a constant.
21pub struct HelloBackendInput;
22
23/// Output of the hello kernel.
24pub struct HelloBackendOutput {
25 /// Magic token written by the kernel. Non-zero proves the kernel
26 /// executed; zero means the kernel never ran or the output buffer was
27 /// not written. The exact value is private to each backend's launch
28 /// module and should not be compared against a Rust-side constant.
29 pub token: u32,
30}
31
32impl Kernel for HelloBackend {
33 type Input<'a> = HelloBackendInput;
34 type Output = HelloBackendOutput;
35}