[flang] Allow more concurrently open NEWUNIT= values, with recycling
authorPeter Klausler <pklausler@nvidia.com>
Wed, 16 Feb 2022 21:26:44 +0000 (13:26 -0800)
committerPeter Klausler <pklausler@nvidia.com>
Tue, 1 Mar 2022 00:13:22 +0000 (16:13 -0800)
commit73b193aec21d5203bde76c76bd0a29c6f77daf36
tree7f5b73b177b0c3f9c45f46fb111f34bf4c63c632
parent6d751c410d6f5400c2c26d47e5033679fbd736d6
[flang] Allow more concurrently open NEWUNIT= values, with recycling

Add a header-only implementation of Briggs & Torczon's fast small
integer set data structure to flang/include/flang/Common, and use
it in the runtime to manage a pool of Fortran unit numbers with
recycling.  This replaces the bit set previously used for that
purpose.  The set is initialized on demand with the negations of
all the NEWUNIT= unit numbers that can be returned to any kind
of integer variable.

For programs that require more concurrently open NEWUNIT= unit
numbers than the pool can hold, they are now allocated with a
non-recycling counter.  This allows as many open units as the
operating system provides.

Many of the top-line comments in flang/unittests/Runtime had the
wrong path name.  I noticed this while adding a unit test for the
fast integer set data structure, and cleaned them up.

Differential Revision: https://reviews.llvm.org/D120685
27 files changed:
flang/include/flang/Common/fast-int-set.h [new file with mode: 0644]
flang/runtime/io-api.cpp
flang/runtime/tools.h
flang/runtime/unit-map.cpp
flang/runtime/unit-map.h
flang/unittests/CMakeLists.txt
flang/unittests/Common/CMakeLists.txt [new file with mode: 0644]
flang/unittests/Common/FastIntSetTest.cpp [new file with mode: 0644]
flang/unittests/Runtime/BufferTest.cpp
flang/unittests/Runtime/CharacterTest.cpp
flang/unittests/Runtime/CommandTest.cpp
flang/unittests/Runtime/CrashHandlerFixture.cpp
flang/unittests/Runtime/CrashHandlerFixture.h
flang/unittests/Runtime/Format.cpp
flang/unittests/Runtime/Inquiry.cpp
flang/unittests/Runtime/ListInputTest.cpp
flang/unittests/Runtime/Matmul.cpp
flang/unittests/Runtime/MiscIntrinsic.cpp
flang/unittests/Runtime/Namelist.cpp
flang/unittests/Runtime/Numeric.cpp
flang/unittests/Runtime/NumericalFormatTest.cpp
flang/unittests/Runtime/Random.cpp
flang/unittests/Runtime/Reduction.cpp
flang/unittests/Runtime/RuntimeCrashTest.cpp
flang/unittests/Runtime/Time.cpp
flang/unittests/Runtime/Transformational.cpp
flang/unittests/Runtime/tools.h