@@ -15,9 +15,8 @@ use ndarray::{
1515 s, Array1 , Array2 , Array3 , ArrayD , ArrayView1 , ArrayView4 , ArrayViewD , ArrayViewMutD , Axis ,
1616 Ix1 , Ix2 ,
1717} ;
18- use rayon:: prelude :: { IntoParallelIterator , ParallelIterator } ;
18+ use rayon:: iter :: { IndexedParallelIterator , IntoParallelRefMutIterator , ParallelIterator } ;
1919use std:: iter;
20- use std:: sync:: { Arc , Mutex } ;
2120
2221/// This structure captures the information needed to create an evolution kernel operator (EKO) for
2322/// a specific [`Grid`].
@@ -446,26 +445,29 @@ pub(crate) fn evolve_slice(
446445 for ( pids1, factor) in channel1. entry ( ) {
447446 // find the tuple of EKOs that evolve the current channel entry of the grid into
448447 // every channel of the FK-table
449- let tmp = channels0. iter ( ) . map ( |pids0| {
450- izip ! ( pids0, pids1, & pids01, & eko_slices)
451- . map ( |( & pid0, & pid1, pids, slices) | {
452- // for each convolution ...
453- pids. iter ( ) . zip ( slices) . find_map ( |( & ( p0, p1) , op) | {
454- // find the EKO that matches both the FK-table and the grid PID
455- ( ( p0 == pid0) && ( p1 == pid1) ) . then_some ( op)
448+ let tmp: Vec < _ > = channels0
449+ . iter ( )
450+ . map ( |pids0| {
451+ izip ! ( pids0, pids1, & pids01, & eko_slices)
452+ . map ( |( & pid0, & pid1, pids, slices) | {
453+ // for each convolution ...
454+ pids. iter ( ) . zip ( slices) . find_map ( |( & ( p0, p1) , op) | {
455+ // find the EKO that matches both the FK-table and the grid PID
456+ ( ( p0 == pid0) && ( p1 == pid1) ) . then_some ( op)
457+ } )
456458 } )
457- } )
458- // if an EKO isn't found, it's zero and therefore the whole FK-table
459- // channel contribution will be zero
460- . collect :: < Option < Box < [ _ ] > > > ( )
461- } ) ;
459+ // if an EKO isn't found, it's zero and therefore the whole FK-table
460+ // channel contribution will be zero
461+ . collect :: < Option < Box < [ _ ] > > > ( )
462+ } )
463+ . collect ( ) ;
462464
463- for ( fk_table , ops ) in tables. iter_mut ( ) . zip ( tmp) {
465+ tables. par_iter_mut ( ) . zip ( tmp) . for_each ( | ( fk_table , ops ) | {
464466 // if there's one zero EKO, the entire tuple is `None`
465467 if let Some ( ops) = ops {
466468 general_tensor_mul ( * factor, array. view ( ) , & ops, fk_table. view_mut ( ) ) ;
467469 }
468- }
470+ } ) ;
469471 }
470472 }
471473
0 commit comments