Skip to main content

zer_compute/
error.rs

1use zer_core::error::ZerError;
2
3/// GPU-specific error type. Variants are forwarded to `ZerError::Gpu` at the
4/// trait boundary so callers that only depend on `zer-core` don't need to
5/// know about the GPU backend.
6#[derive(Debug, thiserror::Error)]
7pub enum GpuError {
8    #[error("CUDA error: {0}")]
9    Cuda(String),
10
11    #[error("Vulkan error: {0}")]
12    Vulkan(String),
13
14    #[error("shader not compiled: {0}. Rebuild with the appropriate feature flag.")]
15    ShaderNotFound(String),
16
17    #[error("kernel launch failed: {0}")]
18    LaunchFailed(String),
19
20    #[error("device memory allocation failed: requested {requested_bytes} bytes, {detail}")]
21    AllocationFailed {
22        requested_bytes: u64,
23        detail: String,
24    },
25
26    #[error("host↔device transfer failed: {0}")]
27    TransferFailed(String),
28
29    #[error("schema mismatch in GPU kernel: expected {expected} fields, got {got}")]
30    SchemaMismatch { expected: usize, got: usize },
31
32    #[error("backend not available: {0}")]
33    BackendUnavailable(String),
34}
35
36impl From<GpuError> for ZerError {
37    fn from(e: GpuError) -> Self {
38        ZerError::Gpu(e.to_string())
39    }
40}