-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement parallelism using rayon #110
Conversation
73ec541
to
78e90c3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
=======================================
Coverage 96.82% 96.82%
=======================================
Files 2 2
Lines 126 126
=======================================
Hits 122 122
Misses 4 4 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving my comments here from slack per @nabobalis request 😄 Hope that helps!
seeds.slice(s![i, ..]), | ||
let all_lines: Vec<StreamlineResult> = seeds | ||
.axis_iter(Axis(0)) | ||
.into_par_iter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't need/want the work stealing that rayon does, its a little more leg work to implement, but batching the seeds and using scoped_threads would probably be faster since it doesn't have the communication overhead.
Thank you @Will-Shanks ! |
(result.status, result.line) | ||
}).unzip(); | ||
|
||
let extracted_lines_views: Vec<ArrayView2<f64>> = extracted_lines.iter().map(|arr| arr.view()).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Will-Shanks If you don't mind me continuing to pick your brains, I finally came back to this.
I think I understood what you said about combining the things into a single map, but I couldn't figure out a way around this extra loop to convert the arrays into views which stack needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After playing around with it I agree with you, I couldn't come up with anything better that the borrow checker approved of.
let extracted_lines_views: Vec<ArrayView2<f64>> =
- extracted_lines.iter().map(|arr| arr.view()).collect();
- let xs = stack(Axis(0), extracted_lines_views.as_slice()).unwrap();
- return (statuses, xs);
+ extracted_lines.par_iter().map(|arr| arr.view()).collect();
+ let xs = stack(Axis(0), &extracted_lines_views).unwrap();
+ (statuses, xs)
}
- if
view()
is lightweight (which I'm guessing it probably is) the iter/par_iter change probably isn't productive - I would hope
extracted_lines_views.as_slice()
and&extracted_lines_views
end up as the same machine code, but I think the latter should be preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cadair a small suggestion I would make is to run Of course this is mostly a personal preference so feel free to take it or leave it :) |
Are these possible to do with a pre-commit config? |
I don't have that setup, but I don't see why you couldn't. I'd probably only do that for |
I was planning on adding a formatter after this PR gets merged (and before we do the next release), thanks for the pointers on the other cargo commands they look really useful. |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
@Cadair do you have any notes on how you're generating those graphs? Y'all have got me curious enough now I'd like to try running it, but I can't figure out what I'm doing wrong. When I try and run one of the scripts in |
I am doing a plain |
I am going to merge this to unblock #137 and #135. @Will-Shanks I am very happy to continue to take suggestions as and when you have any though! |
This is really pushing my rust skills, but I think it works.
Without parallelism enabled:
This is rebased on #111 - See 73ec541 for the relevant diff