-
-
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
More thorough aliasing detection in nonscalar copy, broadcast and assignment #25890
Commits on Feb 14, 2018
-
More thorough aliasing detection in nonscalar copy, broadcast and ass…
…ignment. This commit puts together the beginnings of an "interface" for detecting and avoiding aliasing between arrays before performing some mutating operation on one of them. `A′ = unalias(dest, A)` is the main entry point; it checks to see if `dest` and `A` might alias one another, and then either returns `A` or a copy of `A`. When it returns a copy of `A`, it absolutely must preserve the same type. As such, this function is designed to be specialized on `A`, typically like: Base.unalias(dest, A::T) = mightalias(dest, A) ? typeof(A)(unalias(dest, A.a), unalias(dest, A.b), ...) : A `mightalias(A, B)` is a quick and rough check to see if two arrays alias eachother. Instead of requiring every array to know about every other array type, it simply asks both arrays for their `dataids` and then looks for an empty intersection between every pair. Finally, `dataids(A)` returns a tuple of ranges that describe something about the region of memory the array occupies. It could be simply `(objectid(A):objectid(A),)` or for an array with multiple fields, `(dataids(A.a)..., dataids(A.b)..., ...)`.
Configuration menu - View commit details
-
Copy full SHA for f24bc59 - Browse repository at this point
Copy the full SHA f24bc59View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1e8ac8f - Browse repository at this point
Copy the full SHA 1e8ac8fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 901514b - Browse repository at this point
Copy the full SHA 901514bView commit details -
Add support for dealiasing Adjoint and Transpose
And fixup the assumption that `broadcast!(f, C, A)` is safe
Configuration menu - View commit details
-
Copy full SHA for 534bf91 - Browse repository at this point
Copy the full SHA 534bf91View commit details -
Refactor API to use
map(x->unalias(dest, x), xs)
instead of...a builtin mapper method. Using varargs would require de-structuring the one arg case: `(a,) = unalias(dest, a)`.
Configuration menu - View commit details
-
Copy full SHA for 0fde137 - Browse repository at this point
Copy the full SHA 0fde137View commit details -
Configuration menu - View commit details
-
Copy full SHA for fa809cb - Browse repository at this point
Copy the full SHA fa809cbView commit details -
Configuration menu - View commit details
-
Copy full SHA for eeebbe7 - Browse repository at this point
Copy the full SHA eeebbe7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2254dc5 - Browse repository at this point
Copy the full SHA 2254dc5View commit details -
Add default StridedArray dataids definition and constrain StridedSubA…
…rray... to only look at the linear data segment of its parent that it can reach
Configuration menu - View commit details
-
Copy full SHA for d97d0c3 - Browse repository at this point
Copy the full SHA d97d0c3View commit details
Commits on Feb 15, 2018
-
More refined aliasing detection for views into the same parent
And a more accurate StridedArray dataids definition.
Configuration menu - View commit details
-
Copy full SHA for 5410652 - Browse repository at this point
Copy the full SHA 5410652View commit details -
Configuration menu - View commit details
-
Copy full SHA for c451ecc - Browse repository at this point
Copy the full SHA c451eccView commit details
Commits on Feb 20, 2018
-
Major simplification: do not worry about array extents
By defining `mightalias(::SubArray, ::SubArray)` we cover the vast majority of cases where extents are important. SubArrays are the basically only array in the standard library that "restrict" views into parents; all other wrappers largely re-shuffle the data. `dataids(::AbstractArray)` now just returns a tuple of `UInt`s that describe the identities of the mutable "blocks" that the array references. By default, this is just `(objectid(A),)`, allowing all custom arrays to detect situations with two `===` arrays. Anything more complicated requires them to define their component parts with a custom `dataids` method definition.
Configuration menu - View commit details
-
Copy full SHA for dd1588e - Browse repository at this point
Copy the full SHA dd1588eView commit details
Commits on Feb 21, 2018
-
Configuration menu - View commit details
-
Copy full SHA for e16c03e - Browse repository at this point
Copy the full SHA e16c03eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2ba5688 - Browse repository at this point
Copy the full SHA 2ba5688View commit details
Commits on Feb 22, 2018
-
Use
copy
with a method type assertion instead ofdeepcopy
This will do what we want in almost all cases. We only hit this method if `A` is aliasing a mutable array... which means that `A` is mutable as well, and thus in many cases it has defined an appropriate `similar(A)` method that returns the same type.
Configuration menu - View commit details
-
Copy full SHA for 636453d - Browse repository at this point
Copy the full SHA 636453dView commit details
Commits on Feb 23, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 5caac48 - Browse repository at this point
Copy the full SHA 5caac48View commit details
Commits on Feb 26, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 1ffc135 - Browse repository at this point
Copy the full SHA 1ffc135View commit details