-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: .tuples()
#971
Comments
The ugly part of For your particular case with slice-able data, you could also use |
FWIW, it's not necessarily true that this task will benefit from pixel-level parallelization, especially since there's little real CPU work, just data movement. If you have many images to convert, it may work better to parallelize that coarsely with each image working serially, but ultimately you're going to be limited by I/O and memory bandwidth. |
I tend to agree with that last statement; it seems to be mostly memory IO limited (rather than CPU), so it might be a pointless optimisation. FWIW, the original code can also be re-written as: let mut image_data = vec![0u8; mmap.len() * 3 / 4];
mmap.iter()
.tuples()
.zip(image_data.iter_mut().tuples())
.for_each(|((b, g, r, _), (r2, g2, b2))| (*r2, *g2, *b2) = (*r, *g, *b)); Clearly it's just copying data around. I'd still be curious to benchmark with parallelisation, but performance has improved to the point where this is no longer the slowest thing. I couldn't get Shall I still leave this issue open for further discussion on |
Here's a playground with
Yes, we can leave that request open. |
I see
tuples()
listed in Probably applicable but did not yet open issuesI'd find this very useful. I'm re-encoding images from LE-XRBG to BE-RGB:
This can clearly be parallelised quite a bit, but I don't see any obvious way of writing it without
tuples()
.The text was updated successfully, but these errors were encountered: