-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
POC: Automatically parallelize map(f, arrays...)
#43910
base: avi/infer_effects
Are you sure you want to change the base?
Conversation
To get a better tradeoff, could we |
Well, not in general, a data race is not an effect. You are guaranteed that it won't have the write side of a data race, but it could have the read side. However, if you are only concerned about data races among the different execution of the functions (which seems like you might be for this case, since any other data race would have been there before), I do think you can conclude that the different function executions do not race with each other. |
Ooooh, this is interesting. That sounds like a very good idea! (We can perhaps even do something clever like exponentially increase base case size a la galloping search to get a good measurement or sth like that.)
Thanks! Yes, I should've phrased it carefully. I think a more accurate way to say what I wanted to say is that parallel |
e98e5a6
to
081bef4
Compare
081bef4
to
e591ba0
Compare
3281ce4
to
b30e99c
Compare
Was this closed intentionally or it's just an accident of merging #43852? |
Accidental due to the deletion of the base branch. @tkf looks like we can't reopen. Mind opening a new PR? |
This new reflection utility is similar to `Core.Compiler.return_type` but for the effect analysis. It comes with its own tfunc and similar compiler optimizations so that we can fold inferred effects at compiler time when possible (albeit it is as unreliable as `Core.Compiler.return_type`).
This new reflection utility is similar to `Core.Compiler.return_type` but for the effect analysis. It comes with its own tfunc and similar compiler optimizations so that we can fold inferred effects at compiler time when possible (albeit it is as unreliable as `Core.Compiler.return_type`).
0d2c6b8
to
1604714
Compare
1604714
to
f07dea9
Compare
Thanks to @Keno's work on purity modeling #43852, we can check the data-race-freedom (DRF) of user-defined function by asserting that it is
:effect_free
as defined in #43852 (presumably). This already covers a nontrivial interesting subset of DRF functions. (Edit: The direction of this PR seems to be OK but calling an:effect_free
method a "DRF function" is wrong: #43910 (comment)) This PR is a POC implementation of automatic parallelization ofmap(f, arrays...)
by detecting thatf
andgetindex
are effect-free. For example,map(sin, xs)
is parallelized for "well-behaving" array types likexs::Array
andxs::UnitRange
.A major obstacle for automatic parallelization is (apart from that we don't have JuliaFolds in
Base
) that, sincemap
on arrays is used everywhere, we can't add overhead to the workloads that are not "big enough." So, this PR currently uses a rather strict bound for parallelism (the length of the array has to be larger than2^18
ATM). However, it means that the automatic parallelization kicks in very rarely. For this reason, I'm not entirely sure if this is the right direction. Maybe it's much better to let the user declare that a certain call is "throughput oriented" so that we can increase the parallelism a bit more while still doing the automatic DRF check (so, the user doesn't have to be nervous about introducing data races).@Keno Is it correct to assume that
:effect_free
implies DRF (given that the caller does not "touch" (mutate) the returned object)?