News for hackers. Stuff that matters.
Re:D is being used for autonomous driving research – Audi an... by kazinator on Monday July 01, 2019 @04:12AM (#20323391)
On the other hand, there is exactly one copy of qsort in your entire program image, no matter how many different uses it is applied to. That's better from a caching POV than numerous expansions of templated sorting.

Caching is everything; something that does an indirect call, but through a hot cache, is usually better than something that avoids it, but thrashes the cache.

Caching is so important that byte code that fits into a L1 cache (together with the byte code dispatcher) can beat native code that doesn't fit.

Indirect calling itself isn't so bad when it isn't computed. The comparison function being called by qsort stays the same over the entire job. The source operand which provides the call address is known way in advance of the indirect call, making it possible to pipeline through that without stalls.

> good luck achieving in C what is possible to do in C++ with constexpr at compile time

You can always just type out all the code you want by hand, including all the cases, using a liberal sprinkling of copy and paste. You can open-code some quicksort by hand, or else piece it together out of some prolog/payload/epilog type macro fragments or whatever.

It's just not generic and reusable that way; but in many C programs, that doesn't matter at all.

At the end of the day, we are somehow still using LAPACK routines written in Fortran for number crunching.

There are no comments on this comment yet.