mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 15:56:40 +00:00

Make some minor tweaks (inlining, caching) to the formatting input path to improve integer input in a SPEC code. (None of the I/O library has been tuned yet for performance, and there are some easy optimizations for common cases.) Input integer values are now calculated with native C/C++ 128-bit integers. A benchmark that only reads about 5M lines of three integer values each speeds up from over 8 seconds to under 3 in my environment with these changeds. If this works out, the code here can be used to optimize the formatted input paths for real and character data, too. Fixes https://github.com/llvm/llvm-project/issues/134026.
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
//===-- lib/runtime/connection.cpp ------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "flang-rt/runtime/connection.h"
|
|
#include "flang-rt/runtime/environment.h"
|
|
#include "flang-rt/runtime/io-stmt.h"
|
|
|
|
namespace Fortran::runtime::io {
|
|
RT_OFFLOAD_API_GROUP_BEGIN
|
|
|
|
SavedPosition::SavedPosition(IoStatementState &io) : io_{io} {
|
|
ConnectionState &conn{io_.GetConnectionState()};
|
|
saved_ = conn;
|
|
conn.pinnedFrame = true;
|
|
}
|
|
|
|
SavedPosition::~SavedPosition() {
|
|
if (!cancelled_) {
|
|
ConnectionState &conn{io_.GetConnectionState()};
|
|
while (conn.currentRecordNumber > saved_.currentRecordNumber) {
|
|
io_.BackspaceRecord();
|
|
}
|
|
conn.leftTabLimit = saved_.leftTabLimit;
|
|
conn.furthestPositionInRecord = saved_.furthestPositionInRecord;
|
|
conn.positionInRecord = saved_.positionInRecord;
|
|
conn.pinnedFrame = saved_.pinnedFrame;
|
|
}
|
|
}
|
|
|
|
RT_OFFLOAD_API_GROUP_END
|
|
} // namespace Fortran::runtime::io
|