linksplatform / doublets-rs

The Unlicense
5 stars 2 forks source link

Use `rayon` and `bump-herd` to crazy fast parallel search #9

Open uselessgoddess opened 2 years ago

uselessgoddess commented 2 years ago

You can start with this example

fn par_each_impl(..., root: T) {
    if magic_appropriate_to_join(...) {
        rayon::join(
            || par_each_impl(..., left(root)),
            || par_each_impl(..., right(root)),
        )
    } else {
        seq_each_impl(..., root)
    }
}
uselessgoddess commented 2 years ago

par_each_iter_impl might look something like this:

fn par_each_iter_impl(..., buf) {
    if magic_appropriate_to_join(...) {
        let mid-cnt = count(left(...)); // mid-cnt + right-cnt == cnt
        rayon::join(
            || par_each_impl(..., buf[..mid-cnt]),
            || par_each_impl(..., buf[mid-cnt..]),
        )
    } else {
        seq_each_iter_impl(..., buf)
    }
}

fn par_each_iter(...) {
    let mut buf = with_capacity(count(...));
    par_each_impl_iter(buf[...])
}