CONQUEST-release
CONQUEST-release copied to clipboard
pao_elem_derivative_2 is called on scalars inside a loop
The second hotspot shown in profiling in #197 is
https://github.com/OrderN/CONQUEST-release/blob/4162a3c6d799960ba88bc6e92944f4e54794362e/src/PAO_grid_transform_module.f90#L394-L400
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.