likwid icon indicating copy to clipboard operation
likwid copied to clipboard

WIP: Binary expression tree calculator

Open breiters opened this issue 1 year ago • 0 comments

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 with exit(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, metrictrees in the GroupInfo struct with one array of type struct metric. This would simplify the code, make it more clear, and less error-prone. Need some help / discussion here

breiters avatar Nov 18 '24 17:11 breiters