min_cl/
lib.rs

1pub mod api;
2mod cl_device;
3mod measure_perf;
4pub use cl_device::*;
5
6pub type Error = Box<dyn std::error::Error + Send + Sync>;
7
8use std::{sync::RwLock, time::Duration};
9
10pub static DEVICES: RwLock<Option<Vec<(Duration, usize, usize, CLDevice)>>> = RwLock::new(None);
11
12pub fn init_devices() {
13    if DEVICES.read().unwrap().is_none() {
14        *DEVICES.write().unwrap() =
15            Some(measured_devices().expect("Could not gather OpenCL devices"));
16    }
17}
18
19#[cfg(test)]
20mod tests {
21    use crate::{init_devices, DEVICES};
22
23    #[test]
24    fn test_devices() {
25        init_devices();
26        println!("{:?}", DEVICES.read())
27    }
28}