likwid
likwid copied to clipboard
WIP: Binary expression tree calculator
This replaces the stack-based calculator with a binary expression tree (as discussed at SC'23).
- The tree is constructed only once per metric at the point of time when a perfgroup is read. It can then be evaluated arbitrarily often with varying counter values.
- According to my (very basic) measurements, it speeds up formula evaluation by a factor of x5 - x15 (depending on the formula) on my laptop: (e.g. 1833 cycles (tree-based) vs. 25909 cycles (stack-based) to evaluate the (Zen2) formula:
Memory data volume [GBytes] 1.0E-09*(DFC0+DFC1)*(4.0/(num_numadomains/num_sockets))*64.0) - Currently, only addition, subtraction, multiplication, and division are implemented. Can be extended (if required at all)
TODOs:
- [ ] Implement proper error handling (currently marked as comment with
TODO, or implemented withexit(EXIT_FAILURE)) Need some help / discussion here - [ ] Test correctness (currently both, the stack-based method and the expression tree method, are applied and the program exits if the results don't match)
- [ ] Remove stack-based code if the code changes are accepted
- [x] Write interface documentation for expression tree interfaces
- [ ] Adopt LIKWID code style? Need some help / discussion here
- [ ] Move finding of counter index in index list to tree building phase (iff possible) Need some help / discussion here
- [ ] Possibly replace the three arrays
metricnames,metricformulas,metrictreesin theGroupInfostruct with one array of typestruct metric. This would simplify the code, make it more clear, and less error-prone. Need some help / discussion here