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

pao_elem_derivative_2 is called on scalars inside a loop #198

Open
tkoskela opened this issue Jun 15, 2023 · 1 comment
Open

pao_elem_derivative_2 is called on scalars inside a loop #198

tkoskela opened this issue Jun 15, 2023 · 1 comment
Assignees
Labels
area: main-source Relating to the src/ directory (main Conquest source code) improves: speed Speed-up of code

Comments

@tkoskela
Copy link
Contributor

The second hotspot shown in profiling in #197 is

do m1=-l1,l1
call pao_elem_derivative_2(direction,the_species,l1,acz,m1,x,y,z,val)
if(position+(count1-1)*n_pts_in_block > gridfunctions(pao_fns)%size) &
call cq_abort('single_pao_to_grad: position error ', &
position, gridfunctions(pao_fns)%size)
gridfunctions(pao_fns)%griddata(position+(count1-1)*n_pts_in_block) = val
count1 = count1+1

Disregarding the if statement, which we can remove, It looks like the main issue is pao_elem_derivative_2 (and all functions it calls) are called on scalar arguments, but the call is being made from inside a loop nest. To speed this up, the loop nest should be moved to the bottom of the call chain, which would allow vectorization and get rid of a lot of function calling overheads.

@tkoskela tkoskela added area: main-source Relating to the src/ directory (main Conquest source code) improves: speed Speed-up of code project: eCSE8 labels Jun 15, 2023
@tkoskela tkoskela self-assigned this Jun 15, 2023
@davidbowler
Copy link
Contributor

This will take a very great deal of work: the code is deeply nested and forked based on lots of different variables; simply moving the nest down is not obviously possible. Really we'd need a full refactoring of the code; probably a good thing, but will require careful maths/physics preparation before coding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: main-source Relating to the src/ directory (main Conquest source code) improves: speed Speed-up of code
Projects
None yet
Development

No branches or pull requests

2 participants