Skip to main content

root_batch_backend_for

Function root_batch_backend_for 

Source
pub fn root_batch_backend_for(
    requested: ComputeBackend,
    n: usize,
) -> ComputeBackend
Expand description

The ComputeBackend the iterative solvers would actually use for n problems if asked for requested — without running anything.

Applies exactly the same reduction the kernels do (feature availability, no GPU kernel here, and the ROOT_BATCH_MIN_PROBLEMS size floor), so what it reports is what would run. Useful for logging and for benchmark harnesses.

§Arguments

§Returns

Either ComputeBackend::Serial or ComputeBackend::CpuMulti; never ComputeBackend::Gpu, because no GPU kernel exists here yet.

§Example

use outram_foam_basic_lib::compute::ComputeBackend;
use outram_foam_basic_lib::math::parallel::{root_batch_backend_for, ROOT_BATCH_MIN_PROBLEMS};

// Too small to thread, whatever was asked for.
assert_eq!(root_batch_backend_for(ComputeBackend::CpuMulti, 8), ComputeBackend::Serial);

// Big enough; the answer now depends only on whether `parallel` is compiled in.
let picked = root_batch_backend_for(ComputeBackend::CpuMulti, ROOT_BATCH_MIN_PROBLEMS);
assert!(picked.is_available());