-
Notifications
You must be signed in to change notification settings - Fork 152
fixed MMatrix boundschecks, faster getindex #484
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
Conversation
…getindex temporary stack copies
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.
Should the thrown bounds errors be BoundsError(v, i)
etc?
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.
Cool! Thanks :)
Are the matrix and vector versions strictly necessary anymore? Perhaps we can delete those methods.
Yes (also for The boundschecks for cartesian index access are still broken, though. |
src/MArray.jl
Outdated
@propagate_inbounds function getindex(v::MArray, i::Int) | ||
T = eltype(v) | ||
if isbitstype(T) | ||
@boundscheck if i < 1 || i > length(v) |
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.
Any reason not to write this as @boundscheck checkbounds(v, i)
?
Ok, this is fast. How do I fix the following?
|
OK what's there looks great now :) For Cartesian indexing it's the |
Ok, I think this can be merged (from my perspective). Can we run a benchmark to see whether the pointer access or the boundscheck confuse the optimizer? As far as I can see all cartesian accesses were effectively |
Let's roll with this. |
As remarked on JuliaLang/julia#29000, accessing an
MArray
,MMatrix
,MVector
sometimes pulls a stack copy. This patch avoids the stack copy, by using the pointer forgetindex
as well, not just forsetindex
.