Rework threading to be done at a higher level, simplifying array argument passing
- Dominant language
- Fortran
- Stars
- 352
- Forks
- 361
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Currently we do threading by breaking each individual array into "clumps" of indices. This implementation is fragile (for example, doing whole-array assignments breaks threading, and lower bounds of array arguments need to be carefully maintained, since often we pass just the section of the array for the given thread). This also leads to extra verbosity when passing arguments - both in the caller and callee (again, to maintain appropriate array bounds).
@mvertens and I would like to rework threading to be done at a higher level: Rather than dividing each array into clumps, we would instead have one object (i.e., one instance of each derived type) per clump. That is, a given instance would hold the data for a single clump (which typically equates to a single thread), and there would be no need to subdivide individual arrays.
See https://github.com/billsacks/prototypes-clm-threading_at_high_level for a prototype and more detailed thoughts.
### Implementation checklist
- [x] Rework processor-level bounds to start at 1 for each processor (done in ctsm5.1.dev047)
- [ ] Rework handling of clumps to be done at a higher level, as shown in Bill's prototype
- [ ] Move all remaining module-level variables into derived types, with instances of those types. One example I see of this is harvest(:) in dynHarvestMod.
### Testing checklist
- [ ] Test performance for a case without i/o - should be no worse than before
- [ ] Test performance of i/o
- [ ] Test a case where nclumps_per_proc is greater than nthreads - compare with baseline. Point is: Make sure we haven't baked in any assumptions that nclumps = nthreads.
Contributor guide
Assessment
This issue has not been assessed yet.