5 ms·
I was just taking a look and couldn't help but notice the switch statement for your operator[], which likely causes a lot of unnecessary bad speculation at runt
by amadio 2y ago
I was just taking a look and couldn't help but notice the switch statement for your operator[], which likely causes a lot of unnecessary bad speculation at runtime:
https://github.com/RandyGaul/cute_headers/blob/755849fc2819d4e61e7d999aa036d79706d832b0/cute_math.h#L99 https://github.com/RandyGaul/cute_headers/blob/755849fc2819d...
I fixed this exact problem in a highly used library in high energy physics:
https://gitlab.cern.ch/CLHEP/CLHEP/-/commit/5f20daf0cae911793d9aa5fc62987d6dc83647ab https://gitlab.cern.ch/CLHEP/CLHEP/-/commit/5f20daf0cae91179...
Many believe the C++ compiler will magically optimize the switch away, but in some cases, like the example above for CLHEP, it doesn't happen, so you end up with bad performance.
- amadio 2y agoSince you left this "optimize me" comment here: https://github.com/RandyGaul/cute_headers/blob/755849fc2819d4e61e7d999aa036d79706d832b0/cute_math.h#L667 https://github.com/RandyGaul/cute_headers/blob/755849fc2819d... See an optimized quaternion multiplication implementation in SSE by me here: https://stackoverflow.com/questions/18542894/how-to-multiply-two-quaternions-with-minimal-instructions/18542951 https://stackoverflow.com/questions/18542894/how-to-multiply...