-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
vlib: add an arrays.parallel
module, containing parallel.run/3
and parallel.amap/3
implementations
#22090
Conversation
Why is this failing on |
Not sure about the exact reason (yet), but |
Good Idea, will do that |
@spytheman thanks for the review. The review comments are good. |
The windows tcc CI failure is unrelated to this PR. The other (the ubuntu musc one) is (it happens for the new test). Not sure why yet. |
Co-authored-by: Delyan Angelov <delian66@gmail.com>
Per the code comments, moving the run and amap implementation to arrays.parallel Ensuring ordering in amap() implementation Enhancing tests to not be module specific per code comments
Per the code comments, moving the run and amap implementation to arrays.parallel Ensuring ordering in amap() implementation Enhancing tests to not be module specific per code comments
c4425b0
to
be24c3a
Compare
(rebased over current master, to pickup the windows CI fix, and add some changes to make it easier to diagnose the rest of the CI failures) |
The macos failures happen very seldom locally (~20% of the time).
The input has 9 elements, the output has 8 (the 25 for 5*5 is missing). |
…bility of the caller). Fix races (<< is not thread safe) on macos, cleanup and comment more
arrays.parallel
module, containing parallel.run/3
and parallel.amap/3
implementations
The race was for the Instead of using << in the workers, the fix (among other things), pre-allocates the result task array in |
…onal workers parameter
Would be nice to detect this in runtime in debug mode or with a separate flag. |
Yes, although I have no idea how will it work. V currently does not track what array is used by which threads. |
Thank you! I was busy with work for a couple days. Appreciate the changes! |
arrays.run_parallel
arrays.map_parallel
Description
When we want to run functions on input array in parallel, a simple for loop does not suffice.
This implementation uses channels and waitgroups to let the user run a lambda function to run tasks in parallel.
It also allows the user to specify the max workers to achieve parallelism