-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
`@inbounds expr` allows bounds checks to be omitted for code syntactically inside the argument expression. adds @inbounds to matmul, comprehensions, and vectorized binary operators.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,18 @@ function precompile(f, args::Tuple) | |
end | ||
end | ||
|
||
macro boundscheck(yesno,blk) | ||
quote | ||
$(Expr(:boundscheck,yesno)) | ||
$(esc(blk)) | ||
$(Expr(:boundscheck,0)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Keno
Member
|
||
end | ||
end | ||
|
||
macro inbounds(blk) | ||
:(@boundscheck false $(esc(blk))) | ||
end | ||
|
||
# NOTE: Base shares Array with Core so we can add definitions to it | ||
|
||
Array{T,N}(::Type{T}, d::NTuple{N,Int}) = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1215,4 +1215,6 @@ export | |
@show, | ||
@printf, | ||
@sprintf, | ||
@deprecate | ||
@deprecate, | ||
@boundscheck, | ||
@inbounds |
4 comments
on commit 66ab577
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.
Hooray!
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.
I also suspect we should have a special startup mode (via a command-line flag) that defines
macro boundscheck(yesno, blk)
blk
end
That way we can guard against overly-hasty usages of @inbounds
and rapidly find the problem point.
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.
Is it possible to have the @inbounds
apply to a whole module?
Totally agree that a command line flag when starting julia that can force all checks to be carried out is a useful debugging tool.
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.
Perhaps alternatively/additionally, when Julia is compiled in debug mode, these shouldn't work either.
I'm almost certainly misunderstanding, but doesn't this turn off bounds checking after running the user's block? Shouldn't it turn it on?