Skip to content
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

Improve performance annotation docs #17722

Closed
wants to merge 7 commits into from
Closed

Conversation

lopezm94
Copy link

@lopezm94 lopezm94 commented Jul 30, 2016

Continuation of pull request #17700

@kshyatt kshyatt added docs This change adds or pertains to documentation performance Must go faster labels Jul 30, 2016
@@ -1114,6 +1114,54 @@ properties:
LLVM auto-vectorization may kick in automatically, leading to no further
speedup with :obj:`@simd`.

While :obj:`@simd` needs to be placed in front of a loop, that is not the case
for :obj:`@inbounds`. It can be placed in front of any expression as long as it
is inside a function, the only place where it could be outside of a function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run on sentence here. Turn the comma into a period, I think.

@lopezm94
Copy link
Author

Should I improve anything else?

in getindex(::Array{Int64,1}, ::Int64) at ./array.jl:309
in eval(::Module, ::Any) at ./boot.jl:225
in macro expansion at ./REPL.jl:92 [inlined]
in (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you run this on 0.5? the backtraces should look different now

@lopezm94
Copy link
Author

lopezm94 commented Jul 31, 2016

Nope, completely forgot about that after switching branch. Will do that right away

Previous error message was 0.4
@lopezm94
Copy link
Author

Backtrace modified

for :obj:`@inbounds`. It can be placed in front of any expression as long as it
is inside a function. The only place where it can be outside of a function
definition is in front of a loop.
::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This double-colon is malformed RST I think, see the sphinx errors

/home/Tony/julia/doc/manual/performance-tips.rst:1122: ERROR: Unexpected indentation.
/home/Tony/julia/doc/manual/performance-tips.rst:1146: ERROR: Unexpected indentation.

@lopezm94
Copy link
Author

lopezm94 commented Aug 1, 2016

I can only imagine putting one more newline between :: and the code, I'm clueless about the error. Building the documentations locally with make -C doc html and make -C doc latex I don't get any error. If I may ask, how should I build the documentation?

@tkelman
Copy link
Contributor

tkelman commented Aug 1, 2016

You have to scroll up to the start of the output, there are a lot of harmless warnings and the actual malformed rst errors are buried at the start of those.

@lopezm94
Copy link
Author

lopezm94 commented Aug 2, 2016

It is now fixed, thanks for the help.

@kshyatt
Copy link
Contributor

kshyatt commented Aug 2, 2016

This will fix #13234 as well, right?

@lopezm94
Copy link
Author

lopezm94 commented Aug 2, 2016

Yes, I mention it doesn't work on whole functions and a workaround must be done.

@tkelman
Copy link
Contributor

tkelman commented Aug 3, 2016

@eschnett @blakejohnson does this look all good to you?

While :obj:`@simd` needs to be placed in front of a loop, that is not the case
for :obj:`@inbounds`. It can be placed in front of any expression as long as it
is inside a function. The only place where it can be outside of a function
definition is in front of a loop.
Copy link
Contributor

@eschnett eschnett Aug 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information (outside functions only in front of loops) is news to me. Does this mean that a stand-alone statement

@inbounds a[1] = 0

is malformed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not. It just may or may not disable boundscheck depending on many other compiler heuristics.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, The only place where it can be outside of a function definition is in front of a loop is very misleading....

Copy link
Author

@lopezm94 lopezm94 Aug 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should it say? What does malformed mean in programming btw?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it is also just not true. At global scope it is perfectly fine to write:

x = 1
@inbounds x

But whereas without @inbounds this would print 1, with @inbounds it doesn't print anything. However, I think the inbounds meta information is ignored outside of a function.

I would simplify the description to say that @inbounds can be written in front of any expression, and in some expressions this may be useful to limit the scope of what you are declaring to be "in bounds".

@lopezm94
Copy link
Author

lopezm94 commented Aug 5, 2016

Would this be alright?

While :obj:`@simd` needs to be placed in front of a loop, that is not the case
for :obj:`@inbounds`. It can be placed in front of any expression, however
in some expressions it may be useful to limit the scope of what you are
declaring to be "in bounds". Not using the macro carefully can lead to
unexpected errors, it will generally work when used inside of a function
definition.

@blakejohnson
Copy link
Contributor

How about "it will generally have an effect when used inside a function definition"?

is inside a function. The only place where it can be outside of a function
definition is in front of a loop.
for :obj:`@inbounds`. It can be placed in front of any expression, however
the compiler isn't always capable of recognizing where to remove bounds check,
Copy link
Contributor

@tkelman tkelman Aug 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a run-on. Just end this sentence here ("where to remove bounds checks.") and have "Limiting" start a new one.

@lopezm94
Copy link
Author

What is the backport pending label for?

@lopezm94
Copy link
Author

lopezm94 commented Dec 7, 2016

#17702

@blakejohnson blakejohnson self-assigned this Mar 3, 2017
@blakejohnson
Copy link
Contributor

@lopezm94 could you give me commit access to your branch, following the instructions here:

https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/

I'd like to make a more more edits and then get this merged.

@lopezm94
Copy link
Author

lopezm94 commented Mar 6, 2017

Permission given just now @blakejohnson

@ViralBShah
Copy link
Member

I wonder if we want to use some of this stuff, or close this. @chriselrod Could you help decide, if you have a moment?

@chriselrod
Copy link
Contributor

chriselrod commented Apr 30, 2020

Looking over the PR, it looks like it's mostly about where you can apply the macros?
I think details like "placing @inbounds in front of a function definition or in global scope won't work" are better suited for docs on the individual macros themselves.

It can be placed in front of any expression, however
the compiler isn't always capable of recognizing where to remove bounds check. Limiting the scope of what you are declaring to be "in bounds" can help the
compiler to apply the optimizations.

While I think it's better to limit the scope of @inbounds for other reasons, is this really true, other than the global scope / outside of functions example?

@fredrikekre
Copy link
Member

I think the docstrings cover this, and if not we should add it there instead. This PR is for the old docsystem and lots have changed so I will just close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants