1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use super::error::{GPUError, GPUResult};
use crate::multicore::Worker;
use ff::{PrimeField, ScalarEngine};
use groupy::CurveAffine;
use std::marker::PhantomData;
use std::sync::Arc;
// This module is compiled instead of `fft.rs` and `multiexp.rs` if `gpu` feature is disabled.
pub struct FFTKernel<E>(PhantomData<E>)
where
E: ScalarEngine;
impl<E> FFTKernel<E>
where
E: ScalarEngine,
{
pub fn create(_: bool) -> GPUResult<FFTKernel<E>> {
return Err(GPUError::GPUDisabled);
}
pub fn radix_fft(&mut self, _: &mut [E::Fr], _: &E::Fr, _: u32) -> GPUResult<()> {
return Err(GPUError::GPUDisabled);
}
}
pub struct MultiexpKernel<E>(PhantomData<E>)
where
E: ScalarEngine;
impl<E> MultiexpKernel<E>
where
E: ScalarEngine,
{
pub fn create(_: bool) -> GPUResult<MultiexpKernel<E>> {
return Err(GPUError::GPUDisabled);
}
pub fn multiexp<G>(
&mut self,
_: &Worker,
_: Arc<Vec<G>>,
_: Arc<Vec<<<G::Engine as ScalarEngine>::Fr as PrimeField>::Repr>>,
_: usize,
_: usize,
) -> GPUResult<<G as CurveAffine>::Projective>
where
G: CurveAffine,
{
return Err(GPUError::GPUDisabled);
}
}
use crate::bls::Engine;
macro_rules! locked_kernel {
($class:ident) => {
pub struct $class<E>(PhantomData<E>);
impl<E> $class<E>
where
E: Engine,
{
pub fn new(_: usize, _: bool) -> $class<E> {
$class::<E>(PhantomData)
}
pub fn with<F, R, K>(&mut self, _: F) -> GPUResult<R>
where
F: FnMut(&mut K) -> GPUResult<R>,
{
return Err(GPUError::GPUDisabled);
}
}
};
}
locked_kernel!(LockedFFTKernel);
locked_kernel!(LockedMultiexpKernel);