Re:C and C++ Prioritize Performance over Correctness
by 8n4vidtmkvmk on Friday August 18, 2023 @04:53PM
(#37181967)
If the assembly is that important I'd find a way to put it into my unit tests. Create a "golden" for the assembly and it should trigger a diff if it changes.
Re:C and C++ Prioritize Performance over Correctness
by jacquesm on Friday August 18, 2023 @05:00PM
(#37182039)
The easy way to achieve that is to freeze the assembly once it is generated and to keep the C inlined around as documentation, as well as a way to regenerate the whole thing should it come to that (and then, indeed you'll need to audit the diff to make sure the code generator didn't just optimize away your carefully unrolled loops).
Re:C and C++ Prioritize Performance over Correctness
by asvitkine on Friday August 18, 2023 @05:30PM
(#37182400)
Is there any tooling for that or are you talking hypothetically?
Re:C and C++ Prioritize Performance over Correctness
by jacquesm on Friday August 18, 2023 @05:44PM
(#37182560)
Just standard unix tooling, what else do you need? It's as powerful a set of text manipulation tools as you could wish for.
Re:C and C++ Prioritize Performance over Correctness
by oasisaimlessly on Saturday August 19, 2023 @02:39AM
(#37186180)
For hot functions that were carefully optimized, I have test harnesses that run them and measure their cycle counts, which are asserted to be equal to the cycle count after hand-optimization (+/- some small margin if there is non-determinism). This is sensitive to regressions while having a very low false-positive rate due to being (approximately) deterministic.
Do you repeat this exercise when you upgrade or change compilers?