Assess potential speedups from vectorization
- Dominant language
- Fortran
- Stars
- 352
- Forks
- 361
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
I strongly suspect that little, if any, CTSM code is currently being vectorized, due to a combination of (1) our use of pointers (#235), (2) our indirect indexing via filters (#236), (3) the complex logic in many of our loops, and (4) the fact that many of our loops call other subroutines (including endrun). We should assess whether we could get a significant performance benefit if our code was more vector-friendly. Here are some steps we could take:
- [ ] For one or more simple loops, without any conditionals or function / subroutine calls: assess whether they're being vectorized.
* Can check whether the loop is vectorized via intel's vectorization report that you can produce during compilation.
* If our loops are NOT being vectorized, assess whether this is due to:
* Our use of filters (#236)
* Our use of pointers: does switching to allocatables help? (#235) (first just try this for the small set of variables used in the trial loop(s))
- [ ] For one or more loops that are getting vectorized: Assess whether we're getting much performance benefit from the vectorization. It would be good to check this both for single loops and for nested loops (with an outer loop over level, for example): Vectorization may have little performance benefit for non-nested loops, because data elements aren't reused, so CPU time is swamped by memory access time.
* For a loop that is vectorized: can check performance improvement by comparing the vectorized version with a non-vectorized version (which can be forced with an in-code directive to the intel compiler: `!dir$ novector`.
* If we're not getting much benefit from vectorization based on some sample loops (e.g., because we're much more memory-bound than cpu-bound), then we could give up on trying to make our code more vectorizable
- [ ] If we ARE getting significant speedups from vectorization for fairly simple loops, then look into:
* Are conditionals inside loops preventing vectorization?
* Are function / subroutine calls inside loops preventing vectorization? I expect this to be the case for calls to other modules, but what about calls to routines in the same module, which could potentially be inlined?
Contributor guide
Assessment
This issue has not been assessed yet.