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

@inbounds #11

Open
henry2004y opened this issue Jan 7, 2022 · 0 comments
Open

@inbounds #11

henry2004y opened this issue Jan 7, 2022 · 0 comments

Comments

@henry2004y
Copy link
Owner

@inbounds has no effect when applied to an entire function as of Julia 1.7.1. See this issue.

As I have many kernel loops, @inbounds appears frequently. It would be great if I can eliminate some of them. One idea is that I should avoid using explicit indexing range and try to use foreach and in if possible. For handling boundary cells, something like foreach(vector)[3:end-2] can help.

A quick test shows that the code is 4x slower without @inbounds:

Without @inbounds:
17.096 ms (1186 allocations: 689.38 KiB)
With @inbounds:
4.407 ms (1184 allocations: 689.34 KiB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant