axiolid_backend_gpu/executor.rs
1//! Open graph-compiler seam implemented by concrete GPU API crates.
2
3use axiolid_contracts::{ExecutionOptions, GeomResult};
4use axiolid_mesh::TriMesh;
5use axiolid_model::{GeometryGraph, NodeId};
6
7use crate::GpuDeviceDescriptor;
8
9/// Concrete GPU graph compiler supplied by an API-specific crate.
10///
11/// A CUDA executor for a workstation, a Metal executor for Apple silicon, and
12/// a WebGPU executor for integrated graphics can implement this batch contract
13/// without leaking vendor types into portable operation contracts.
14pub trait GpuGraphExecutor: core::fmt::Debug + Send + Sync {
15 /// Hardware/API facts.
16 fn device(&self) -> &GpuDeviceDescriptor;
17
18 /// Validate algorithm-specific precision, determinism, and resource policy
19 /// before any work is submitted to the device.
20 fn validate_options(&self, options: &ExecutionOptions) -> GeomResult<()>;
21
22 /// Compile graph roots as one batch to amortize upload and synchronization.
23 ///
24 /// Return exactly one mesh per root, in input order. Honor every forwarded
25 /// execution policy or return a typed `GeomError`; never silently reduce
26 /// precision or determinism.
27 fn compile_mesh_batch(
28 &self,
29 graph: &GeometryGraph,
30 roots: &[NodeId],
31 options: &ExecutionOptions,
32 ) -> GeomResult<Vec<TriMesh>>;
33}