
Recursion, both direct and indirect, prevents accurate stack size calculation at link time for GPU device code. Restructure these recursive (often mutually so) routines in the Fortran runtime with new implementations based on an iterative work queue with suspendable/resumable work tickets: Assign, Initialize, initializeClone, Finalize, and Destroy. Default derived type I/O is also recursive, but already disabled. It can be added to this new framework later if the overall approach succeeds. Note that derived type FINAL subroutine calls, defined assignments, and defined I/O procedures all perform callbacks into user code, which may well reenter the runtime library. This kind of recursion is not handled by this change, although it may be possible to do so in the future using thread-local work queues. (Relanding this patch after reverting initial attempt due to some test failures that needed some time to analyze and fix.) Fixes https://github.com/llvm/llvm-project/issues/142481.
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
//===-- lib/runtime/descriptor-io.h -----------------------------*- 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
|
|
#define FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
|
|
|
|
#include "flang-rt/runtime/connection.h"
|
|
|
|
namespace Fortran::runtime {
|
|
class Descriptor;
|
|
} // namespace Fortran::runtime
|
|
|
|
namespace Fortran::runtime::io {
|
|
class IoStatementState;
|
|
struct NonTbpDefinedIoTable;
|
|
} // namespace Fortran::runtime::io
|
|
|
|
namespace Fortran::runtime::io::descr {
|
|
|
|
template <Direction DIR>
|
|
RT_API_ATTRS bool DescriptorIO(IoStatementState &, const Descriptor &,
|
|
const NonTbpDefinedIoTable * = nullptr);
|
|
|
|
extern template RT_API_ATTRS bool DescriptorIO<Direction::Output>(
|
|
IoStatementState &, const Descriptor &, const NonTbpDefinedIoTable *);
|
|
extern template RT_API_ATTRS bool DescriptorIO<Direction::Input>(
|
|
IoStatementState &, const Descriptor &, const NonTbpDefinedIoTable *);
|
|
|
|
} // namespace Fortran::runtime::io::descr
|
|
#endif // FLANG_RT_RUNTIME_DESCRIPTOR_IO_H_
|