use super::job::Job;
fn lens_job(job: &Job) -> cyber_lens_gpu::mine::Job {
cyber_lens_gpu::mine::Job {
init: job.init,
blocks: job.blocks,
tail_lane: job.tail_lane,
tail: job.tail,
target: job.target,
}
}
const DISPATCH: u32 = 1 << 22;
#[cfg(all(feature = "metal", target_os = "macos"))]
pub struct Metal {
inner: cyber_lens_gpu::metal::Metal,
}
#[cfg(all(feature = "metal", target_os = "macos"))]
impl Metal {
pub fn new() -> Result<Self, String> {
cyber_lens_gpu::metal::Metal::new().map(|inner| Metal { inner })
}
}
#[cfg(all(feature = "metal", target_os = "macos"))]
impl super::Backend for Metal {
fn name(&self) -> String {
format!("metal ({})", self.inner.device())
}
fn search(&self, job: &Job, base: u128, count: u32) -> Result<Option<u32>, String> {
self.inner.mine(&lens_job(job), base, count)
}
fn dispatch(&self) -> u32 {
DISPATCH
}
}
#[cfg(feature = "webgpu")]
pub struct WebGpu {
inner: cyber_lens_gpu::webgpu::WebGpu,
}
#[cfg(feature = "webgpu")]
impl WebGpu {
pub fn new() -> Result<Self, String> {
cyber_lens_gpu::webgpu::WebGpu::new().map(|inner| WebGpu { inner })
}
}
#[cfg(feature = "webgpu")]
impl super::Backend for WebGpu {
fn name(&self) -> String {
format!("webgpu ({})", self.inner.adapter())
}
fn search(&self, job: &Job, base: u128, count: u32) -> Result<Option<u32>, String> {
self.inner.mine(&lens_job(job), base, count)
}
fn dispatch(&self) -> u32 {
DISPATCH
}
}