3 ms·
The article compares padded length 15 output for both cases; removing leading zeroes would have cost for both AVX-512 and regular code.
by dzaima 5y ago
The article compares padded length 15 output for both cases; removing leading zeroes would have cost for both AVX-512 and regular code.
- jeffbee 5y agoYeah, that's the "this approach" to which I refer though. This is a micro-optimization of an approach that I'm not sure has many beneficial applications.
- dzaima 5y agoAh. The article, as I see it, is primarily about AVX-512 vs scalar code, not the 15 digits though. The fixed-length restriction is purely to simplify the challenge. To remove leading zeroes, you'd need to use one of bsf/lzcnt/pcmpistri, and a masked store, which has some cost, but still stays branchless and will probably easily be compensated by the smaller cache/storage/network usage & shorter decoding.
- celrod 5y agoAVX512 has a compressed store which might be a bit easier than a normal masked store?
- dzaima 5y agocompress has less throughput, and probably a decent bit more latency. It would save offsetting the result pointer by the leading zero count, but I don't think that'd be enough to compensate for the slower compress. I don't know where regular masked store is done in the pipeline though, so maybe it has its own latency comparable to that of compress, but I doubt it.
- celrod 5y agoYeah, 2p5 (two uops on port 5) for a compressed store vs 1p05 (1 uop on either port 0 or port 5) for a masked move. For throughput's sake, shifting the pointer is better.