-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Type stability and array layout with pmap? #14265
Comments
I found this interesting and so took a look at it. I wanted to compare/contrast the implementation of
In contrast to function map_to!{T,F}(f::F, offs, dest::AbstractArray{T}, A::AbstractArray)
# map to dest array, checking the type of each result. if a result does not
# match, widen the result type and re-dispatch.
@inbounds for i = offs:length(A)
el = f(A[i])
S = typeof(el)
if S === T || S <: T
dest[i] = el::T
else
R = typejoin(T, S)
new = similar(dest, R)
copy!(new,1, dest,1, i-1)
new[i] = el
return map_to!(f, i+1, new, A)
end
end
return dest
end I am assuming that the continuous type widening approach was adopted for performance reasons against some "typical" cases? Anyway, since the function call part of mapping is done asynchronously in So the above is about how things are/could be implemented. However I am not sure to what extent the current implementations of these things reflects the intended semantics. Is there anything written about how |
I think I was being a bit gun shy in asking for so much clarification in the previous comment. The referenced PR rectifies the problem in the original issue. However it would be kind of nice to see something about intended semantics for map in general (for example mapping of string enforces string returns types, which is maybe part of a larger pattern?). |
Closed by #19447 |
I understand that it might be hard for
pmap
to keep track of the array layout, but the promotion toAny
is kind of annoying.The text was updated successfully, but these errors were encountered: