Hi FX,

Am 17.12.21 um 00:34 schrieb FX via Fortran:
unrelated PS: I’ve been thinking aloud and benchmarking faster integer I/O for 
libgfortran at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98076
Comments are welcome on the proposed design, I think the current proposal is a 
low-hanging fruit (not risky, much faster).

Quick test integrating the idea into libgfortran, here are the timings to make 
a formatted write of 10 million integers into a string:

- very small value (1), negligible speedup (2.273s to 2.248s)
- small value (1042), speedup of 28% (3.224s to 2.350s)
- huge(0_8), speed up of 50% (5.914s to 2.560s)
- huge(0_16), speed up of 83% (19.46s to 3.31s)

Conclusion: this looks quite interesting! I’m not sure what use cases people 
have for writing lots of formatted integers, but this doesn’t sound too bad.

yes, it does!

Further thought: fast 64-bit itoa() implementations, under the MIT license 
(https://github.com/jeaiii/itoa) promise a speed-up of 2 to 10 times compared 
to naive implementation. That could bring us down further, but we probably 
cannot incorporate that, right?

Two questions:

1. This is easy, am I missing something? Some reason why it was never tried 
before?

I can't really answer that, but it appears that having __int128 support
requires a 64bit platform.  How common was that in 2004 when itoa was
added to libgfortran?  Do people who care about performance write lots
of formatted integers?  ;-)

2. Why is gfc_xtoa() in runtime/error.c? We should probably move it.

Based on the logs itoa was moved around between files, but xtoa
wasn't.  gfc_xtoa is only used in one file: write.c.

Cheers,
FX


Harald

Reply via email to