Re: [julia-users] @inbounds is broken?

2014-08-29 Thread John Myles White
In theory, the compiler could potentially pull the bounds check out of the loop since the loop parameters are run-time constants, which means that the bounds check doesn't actually need to happen on each access. -- John On Aug 29, 2014, at 1:21 PM, Ed Scheinerman wrote: > The compiler can't

Re: [julia-users] @inbounds is broken?

2014-08-29 Thread Ed Scheinerman
The compiler can't know how far I will traverse the array. That's passed in as an argument. I've run this short of the end (and past the end) and timings are always the same. On Friday, August 29, 2014, Johan Sigfrids wrote: > I believe that for simple cases the compiler is smart enough to remov

Re: [julia-users] @inbounds is broken?

2014-08-29 Thread Johan Sigfrids
I believe that for simple cases the compiler is smart enough to remove bound checking on its own. In that case adding @inbounds won't help. On Friday, August 29, 2014 8:03:35 PM UTC+3, Ed Scheinerman wrote: > > I'd like to use @inbounds also to speed up code that I'm 100% sure has > proper array

Re: [julia-users] @inbounds is broken?

2014-08-29 Thread Ed Scheinerman
I'd like to use @inbounds also to speed up code that I'm 100% sure has proper array indices. But I tried the following experiment and found no significant difference using or omitting @inbounds before the array access. What am I doing wrong? Or is bounds checking so super efficient that I shoul

Re: [julia-users] @inbounds is broken?

2014-08-04 Thread Jacob Quinn
Steve, `@inbounds` is certainly tricky because of the lack of documentation, which I think is slightly on purpose as this is meant to be for more advanced usage. The main insight to using `@inbounds` correctly is realizing that `@inbounds expression` returns the value `nothing`. That's why your f

[julia-users] @inbounds is broken?

2014-08-04 Thread vavasis
Dear Julia users, The usage of the @inbounds macro is not explained the manual, and its syntax appears to be strange. Consider the three functions at the end of this posting. Only the third one works -- why? In general, I think @inbounds is broken. Besides the weird syntax, it has two other