poc_kokkos_rs/functor/mod.rs
1mod for_kernel;
2mod policies;
3mod reduce_kernel;
4mod scan_kernel;
5
6pub use for_kernel::{ForFunctor, parallel_for};
7pub(crate) use policies::ExecutionPolicy;
8pub use policies::{
9 ExecutionSpace, MDRange, PerTeam, PerThread, Range, Schedule, TeamHandle, TeamPolicy,
10 TeamThreadMDRange, TeamThreadRange, TeamVectorMDRange, TeamVectorRange, ThreadVectorMDRange,
11 ThreadVectorRange,
12};
13
14// internal routines
15
16// / Builds a N-depth nested loop executing a kernel using the N resulting indices.
17// / Technically, this should be replaced by a tiling function, for both serial and parallel
18// / implementations.
19// fn recursive_loop<const N: usize>(ranges: &[usize; N], mut kernel: impl Fn([usize; N])) {
20// // handles recursions
21// fn inner<const N: usize>(
22// current_depth: usize,
23// ranges: &[usize; N],
24// kernel: &mut impl Fn([usize; N]),
25// indices: &mut [usize; N],
26// ) {
27// if current_depth == N {
28// // all loops unraveled
29// // call the kernel
30// kernel(*indices)
31// } else {
32// // loop on next dimension; update indices
33// // can we avoid a clone by passing a slice starting one element
34// // after the unraveled range ?
35// ranges[current_depth].clone().for_each(|i_current| {
36// indices[current_depth] = i_current;
37// inner(current_depth + 1, ranges, kernel, indices);
38// });
39// }
40// }
41
42// let mut indices = [0; N];
43// inner(0, ranges, &mut kernel, &mut indices);
44// }