use crate::algorithm::Algorithm;
use crate::gpu::config::GpuConfigState;
pub const GPU_ALGOS: &[Algorithm] = &[Algorithm::Sha256, Algorithm::Md5];
pub fn should_use_gpu(file_size_mb: u64, algos: &[Algorithm], state: &GpuConfigState) -> bool {
let (single_mb, multi_mb) = match state {
GpuConfigState::UseThresholds {
single_mb,
multi_mb,
} => (*single_mb as u64, *multi_mb as u64),
_ => return false,
};
let gpu_algo_count = algos.iter().filter(|a| GPU_ALGOS.contains(a)).count();
if gpu_algo_count == 0 {
return false;
}
if gpu_algo_count >= 2 {
file_size_mb >= multi_mb
} else {
file_size_mb >= single_mb
}
}