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

elements function #1

Open
jacobwilliams opened this issue May 5, 2017 · 1 comment
Open

elements function #1

jacobwilliams opened this issue May 5, 2017 · 1 comment

Comments

@jacobwilliams
Copy link

Nice paper! FYI: I was experimenting with the elements example. I noticed that it is a good bit faster if you convert fromrv3 from a function to a subroutine. So:

pure subroutine fromrv3(r, v, mu, ele)
    double precision, dimension(:), intent(in) :: r
    double precision, dimension(:), intent(in) :: v
    double precision, intent(in) :: mu
    double precision, dimension(6),intent(out) :: ele
...
end subroutine fromrv3

On my PC with ifort 17.0.2.187 (-O3 flag), for times=1000000, the total/times result goes from about 2.65e-7 to about 1.73e-7.

@helgee
Copy link
Member

helgee commented May 8, 2017

Thanks, Jacob!

The function version is probably slower since it allocates an additional array on the stack (see here). Do you agree?

Since all other implementations also explicitly return the result and not mutate a parameter like the subroutine version, I prefer to keep the function version.

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

2 participants