Skip to main content

ensemble_backend_for

Function ensemble_backend_for 

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

The ComputeBackend the ODE ensemble would actually use for n lanes if asked for requested — without running anything.

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

§Arguments

  • requested — the backend a caller would pass to integrate_ensemble.
  • n — the number of independent lanes, dimensionless.

§Returns

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

§Example

use outram_foam_basic_lib::compute::ComputeBackend;
use outram_foam_basic_lib::ode::parallel::{ensemble_backend_for, ODE_ENSEMBLE_MIN_LANES};

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

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