News for hackers. Stuff that matters.
Re:The Hunt for the Fastest Zero by JdeBP on Tuesday January 21, 2020 @08:15AM (#22106585)
Re:The Hunt for the Fastest Zero by CarloWood on Tuesday January 21, 2020 @05:32AM (#22105706)
I'd use std::memset and have something that works without needing a benchmark to detect obscure template quirks.
Re:The Hunt for the Fastest Zero by hikarudo on Tuesday January 21, 2020 @07:35AM (#22106343)
I agree. Why go through the extra loops? Keep it simple.
Re:The Hunt for the Fastest Zero by tipiak on Tuesday January 21, 2020 @08:46AM (#22106805)
std::memset only works for sequential and contiguous memory. std::fill works on pretty much anything that has std::begin() and std::end().

As the conclusion of the article says I would use the idiomatic way first, then and only if I have performance issues, actually force it to memset.

The only bad thing here is that, gcc only do the reasonable optimization on '-O3'.

Re:The Hunt for the Fastest Zero by NablaSquaredG on Tuesday January 21, 2020 @07:07AM (#22106191)
Well, if it's optimised out at "-O3", I usually don't care. If you have some numerical code you can optimise further (even though you're using "-O3" or "-ffast-math"), things become interesting!