Skip to main content

bellperson/gpu/
error.rs

1use bellpepper_core::SynthesisError;
2use ec_gpu_gen::EcError;
3
4#[derive(thiserror::Error, Debug)]
5pub enum GpuError {
6    #[error("GPUError: {0}")]
7    Simple(&'static str),
8    #[cfg(any(feature = "cuda", feature = "opencl"))]
9    #[error("No kernel is initialized!")]
10    KernelUninitialized,
11    #[error("EC GPU error: {0}")]
12    EcGpu(#[from] EcError),
13    #[error("GPU accelerator is disabled!")]
14    GpuDisabled,
15}
16
17pub type GpuResult<T> = std::result::Result<T, GpuError>;
18
19impl From<GpuError> for SynthesisError {
20    fn from(e: GpuError) -> Self {
21        // inspired by the commenct on MalformedProofs
22        SynthesisError::MalformedProofs(format!("Encountered a GPU Error: {}", e))
23    }
24}