3 ms·
I'd be curious about use cases where this does or does not make sense. On the one hand, you saved a few nanoseconds on the integer-to-string encoder. But on the
by jeffbee 5y ago
I'd be curious about use cases where this does or does not make sense. On the one hand, you saved a few nanoseconds on the integer-to-string encoder. But on the other hand you're committed to storing and transferring up to 15 leading zeros, and there must be some cost on the decoder to consuming the leading zeros. So this clearly makes sense on a write-once-read-never application but there must also be a point at which the full lifecycle cost crosses over and this approach is worse.
- aqrit 5y agorelated to IEEE 754 double-precision floating-point round-trips?
- dzaima 5y agoThe 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.