[flang-commits] [PATCH] D113697: [flang] Runtime performance improvements to real formatted input

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Nov 11 10:49:08 PST 2021


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
klausler requested review of this revision.

Profiling a basic internal real input read benchmark shows some
hot spots in the code used to prepare input for decimal-to-binary
conversion, which is of course where the time should be spent.
The library that implements decimal to/from binary conversions has
been optimized, but not the code in the Fortran runtime that calls it,
and there are some obvious light changes worth making here.

Move some member functions from *.cpp files into the class definitions
of Descriptor and IoStatementState to enable inlining and specialization.

Make GetNextInputBytes() the new basic input API within the
runtime, replacing GetCurrentChar() -- which is rewritten in terms of
GetNextInputBytes -- so that input routines can have the
ability to acquire more than one input character at a time
and amortize overhead.

These changes speed up the time to read 1M random reals
using internal I/O from a character array from 1.29s to 0.54s
on my machine, which on par with Intel Fortran and much faster than
GNU Fortran.


https://reviews.llvm.org/D113697

Files:
  flang/include/flang/Decimal/decimal.h
  flang/include/flang/Runtime/descriptor.h
  flang/lib/Decimal/big-radix-floating-point.h
  flang/lib/Decimal/decimal-to-binary.cpp
  flang/runtime/descriptor.cpp
  flang/runtime/edit-input.cpp
  flang/runtime/internal-unit.cpp
  flang/runtime/internal-unit.h
  flang/runtime/io-stmt.cpp
  flang/runtime/io-stmt.h
  flang/runtime/unit.cpp
  flang/runtime/unit.h
  flang/unittests/Runtime/NumericalFormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113697.386588.patch
Type: text/x-patch
Size: 31593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211111/c9da15b2/attachment-0001.bin>


More information about the flang-commits mailing list