openvm_recursion_circuit/cuda/
mod.rs

1use openvm_cuda_common::{
2    copy::MemCopyH2D, d_buffer::DeviceBuffer, error::MemCopyError, stream::GpuDeviceCtx,
3};
4
5use crate::{
6    cuda::{preflight::PreflightGpu, proof::ProofGpu, vk::VerifyingKeyGpu},
7    system::GlobalTraceGenCtx,
8};
9
10pub mod abi;
11pub mod preflight;
12pub mod proof;
13pub mod types;
14pub mod vk;
15
16pub struct GlobalCtxGpu;
17
18impl GlobalTraceGenCtx for GlobalCtxGpu {
19    type ChildVerifyingKey = VerifyingKeyGpu;
20    type MultiProof = [ProofGpu];
21    type PreflightRecords = [PreflightGpu];
22}
23
24pub fn to_device_or_nullptr_on<T>(
25    h2d: &[T],
26    device_ctx: &GpuDeviceCtx,
27) -> Result<DeviceBuffer<T>, MemCopyError> {
28    if h2d.is_empty() {
29        Ok(DeviceBuffer::new())
30    } else {
31        h2d.to_device_on(device_ctx)
32    }
33}