pub trait FaerParallelismExt {
// Required method
fn with_faer_parallelism(
&mut self,
callback: impl FnOnce(Par) -> Result<()> + Send,
) -> Result<()>;
}Expand description
Invoke a direct faer operation with the parallelism selected by a CPU session.
The faer::Par value is scoped to the callback and is derived from the
session’s managed thread budget and nesting policy. A non-CPU session, or a
CPU session built without cpu-faer, returns a typed unsupported error.
Par::Seq remains the portable choice for direct calls outside a session.
§Examples
use tenferro_cpu::{CpuBackend, FaerParallelismExt};
use tenferro_tensor::BackendSessionHost;
let mut backend = CpuBackend::with_threads(2)?;
backend.with_backend_session(|session| {
session.with_faer_parallelism(|parallel| {
let _ = parallel;
Ok(())
})
})?;Required Methods§
Sourcefn with_faer_parallelism(
&mut self,
callback: impl FnOnce(Par) -> Result<()> + Send,
) -> Result<()>
fn with_faer_parallelism( &mut self, callback: impl FnOnce(Par) -> Result<()> + Send, ) -> Result<()>
Run a scoped callback with this session’s faer parallelism policy.
§Errors
Returns tenferro_tensor::Error::Unsupported when the session is not
a CPU/faer execution session, or the callback’s own typed error.
§Examples
use tenferro_cpu::FaerParallelismExt;
session.with_faer_parallelism(|parallel| {
let _ = parallel;
Ok::<_, tenferro_tensor::Error>(())
})?;Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<S> FaerParallelismExt for Swhere
S: BackendSession + ?Sized,
Available on crate feature
cpu-faer only.