Remove non-global Threadpool
This commit is contained in:
@@ -243,90 +243,6 @@ pub fn integrate_embedded_rk<BTableau: EmbeddedButcherTableau, F: Integrable, RH
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rayon")]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
/// Integrates a multigrid problem, much the same as [`integrate`],
|
||||
/// using a `rayon` threadpool for parallelisation.
|
||||
///
|
||||
/// note that `rhs` accepts the full system state, and is responsible
|
||||
/// for computing the full state difference.
|
||||
/// `rhs` can be a mutable closure, so buffers can be used
|
||||
/// and mutated inside the closure.
|
||||
///
|
||||
/// This function requires the `rayon` feature, and is not callable in
|
||||
/// a `wasm` context.
|
||||
pub fn integrate_multigrid<BTableau: ButcherTableau, F: Integrable, RHS>(
|
||||
mut rhs: RHS,
|
||||
prev: &[F::State],
|
||||
fut: &mut [F::State],
|
||||
time: &mut Float,
|
||||
dt: Float,
|
||||
k: &mut [&mut [F::Diff]],
|
||||
|
||||
pool: &rayon::ThreadPool,
|
||||
) where
|
||||
RHS: FnMut(&mut [F::Diff], &[F::State], Float),
|
||||
F::State: Send + Sync,
|
||||
F::Diff: Send + Sync,
|
||||
{
|
||||
for i in 0.. {
|
||||
let simtime;
|
||||
match i {
|
||||
0 => {
|
||||
pool.scope(|s| {
|
||||
assert!(k.len() >= BTableau::S);
|
||||
for (prev, fut) in prev.iter().zip(fut.iter_mut()) {
|
||||
s.spawn(move |_| {
|
||||
F::assign(fut, prev);
|
||||
});
|
||||
}
|
||||
});
|
||||
simtime = *time;
|
||||
}
|
||||
i if i < BTableau::S => {
|
||||
pool.scope(|s| {
|
||||
for (ig, (prev, fut)) in prev.iter().zip(fut.iter_mut()).enumerate() {
|
||||
let k = &k;
|
||||
s.spawn(move |_| {
|
||||
F::assign(fut, prev);
|
||||
for (ik, &a) in BTableau::A[i - 1].iter().enumerate() {
|
||||
if a == 0.0 {
|
||||
continue;
|
||||
}
|
||||
F::scaled_add(fut, &k[ik][ig], a * dt);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
simtime = *time + dt * BTableau::C[i - 1];
|
||||
}
|
||||
_ if i == BTableau::S => {
|
||||
pool.scope(|s| {
|
||||
for (ig, (prev, fut)) in prev.iter().zip(fut.iter_mut()).enumerate() {
|
||||
let k = &k;
|
||||
s.spawn(move |_| {
|
||||
F::assign(fut, prev);
|
||||
for (ik, &b) in BTableau::B.iter().enumerate() {
|
||||
if b == 0.0 {
|
||||
continue;
|
||||
}
|
||||
F::scaled_add(fut, &k[ik][ig], b * dt);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
*time += dt;
|
||||
return;
|
||||
}
|
||||
_ => {
|
||||
unreachable!();
|
||||
}
|
||||
};
|
||||
|
||||
rhs(&mut k[i], &fut, simtime);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Solving a second order PDE
|
||||
fn ballistic() {
|
||||
|
||||
Reference in New Issue
Block a user