[flang-commits] [flang] Move deallocation of I/O resources under STOP to a critical section (PR #74181)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Dec 6 08:19:12 PST 2023


klausler wrote:

> > I don't understand why this lock is needed here. CloseAllExternalUnits ends up calling ExternalFileUnit::CloseAll, which already has a critical section in it.
> 
> It seems like `ExternalFileUnit::CloseAll` is closing up the I/O buffers while other threads in the parallel region are still operating upon them. The `ExternalFileUnit::CloseAll` critical section is for the collection of buckets to be freed. I was wondering if increasing the scope of the critical section could help, and hence went this way in this patch.
> 
> Could I do this better? Ideally, we would want all threads to flush their contents before closing the I/O buffers.

The lock you're introducing here is going to help only if all threads execute a `STOP` statement, right?  If one or more threads do not `STOP`, they'll need to be terminated by some other means.  Perhaps you need some kind of interrupt with a barrier.

https://github.com/llvm/llvm-project/pull/74181


More information about the flang-commits mailing list