1use std::str::FromStr;
3
4pub fn get_num_threads() -> usize {
5 match std::env::var("RAYON_NUM_THREADS")
7 .ok()
8 .and_then(|s| usize::from_str(&s).ok())
9 {
10 Some(x) if x > 0 => x,
11 Some(_) | None => num_cpus::get(),
12 }
13}
14
15pub fn has_accelerate() -> bool {
16 cfg!(feature = "accelerate")
17}
18
19pub fn has_mkl() -> bool {
20 cfg!(feature = "mkl")
21}
22
23pub fn cuda_is_available() -> bool {
24 cfg!(feature = "cuda")
25}
26
27pub fn metal_is_available() -> bool {
28 cfg!(feature = "metal")
29}
30
31pub fn with_avx() -> bool {
32 cfg!(target_feature = "avx2")
33}
34
35pub fn with_neon() -> bool {
36 cfg!(target_feature = "neon")
37}
38
39pub fn with_simd128() -> bool {
40 cfg!(target_feature = "simd128")
41}
42
43pub fn with_f16c() -> bool {
44 cfg!(target_feature = "f16c")
45}