Skip to main content

vanity_core/gpu/
device.rs

1//! OpenCL device discovery (feature-gated).
2
3#[derive(Debug, Clone)]
4pub struct GpuDeviceInfo {
5    pub index: usize,
6    pub name: String,
7    pub vendor: String,
8    pub device_type: String,
9    pub compute_units: u32,
10    pub max_clock_mhz: u32,
11}
12
13/// True when the binary was built with `opencl` and at least one device enumerates.
14pub fn gpu_available() -> bool {
15    !list_gpu_devices().is_empty()
16}
17
18#[cfg(feature = "opencl")]
19pub fn list_gpu_devices() -> Vec<GpuDeviceInfo> {
20    crate::gpu::opencl_backend::enumerate_devices()
21}
22
23#[cfg(not(feature = "opencl"))]
24pub fn list_gpu_devices() -> Vec<GpuDeviceInfo> {
25    Vec::new()
26}