4 ms·
I’d make it an inline function and call it multiple times per loop iteration. You should be able to pull some of the initializations out of the loop and fetch m
by emerged 4y ago
I’d make it an inline function and call it multiple times per loop iteration. You should be able to pull some of the initializations out of the loop and fetch multiple at once, pipelining using different registers. Optimizing compilers have gotten good enough to do the right things much of the time with intrinsics but it still may benefit from hand writing.
Sometimes you can even eek a touch more speed with prefetch, but it can be tricky to get that right.
Another thing that matters a ton is whether you’re microbenchmarking it accurately. It isn’t trivial to do so, as you should mimic real memory / cache behavior as opposed to repeatedly having it fetch memory which is already cached and give you misleading results.