You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to split an MxN array into k^2 chunks of size (M/k)x(N/k) and then process these in parallel. I'm aware of exact_chunks, but it doesn't natively support par_iter, right? What is the idiomatic way to do this?
We should add a ParallelIterator implementation for Parallel<ExactChunks/Mut>.
In the meantime, a workaround is to Zip's parallel methods:
use ndarray::prelude::*;use ndarray::Zip;fnmain(){letmut a = Array2::<u8>::zeros([6,6]);Zip::from(a.exact_chunks_mut([3,3])).par_for_each(|mut chunk| chunk.diag_mut().fill(1));assert_eq!(
a,
array![[1,0,0,1,0,0],[0,1,0,0,1,0],[0,0,1,0,0,1],[1,0,0,1,0,0],[0,1,0,0,1,0],[0,0,1,0,0,1],],);}
Activity
jturner314 commentedon Aug 1, 2022
We should add a
ParallelIteratorimplementation forParallel<ExactChunks/Mut>.In the meantime, a workaround is to
Zip's parallel methods:The
par_azip!macro may be a bit more convenient.Regardless, make sure to enable to
rayonfeature.