Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28383 Discussions

Multithread deadlock in OPEN and INQUIRE

mahlumg
Beginner
424 Views

We are working on adding some multithreading to a segment of our product which involves managing several files in the background. While working on this we found that occasionally, the program would end up deadlocked with one thread sitting in OPEN and another in INQUIRE.

 

I attached a small sample program that replicates our problem. Two threads are created on the C++ side and for simplicity, each thread will then loop though a list of file names. In the loops are the calls to a Fortran wrapper subroutine around the OPEN and INQUIRE calls, one loop for each. Without any modifications, this program seems to lock up immediately as OPEN and INQUIRE try to run on the first file listed. However, to test if it is only locking when using the same file, lines are added to delay the execution of  either or both threads. When doing this one can see that a deadlock can occur regardless of what file OPEN or INQUIRE are using so long as they are attempting to execute at the same time.

0 Kudos
5 Replies
Barbara_P_Intel
Moderator
380 Views

I'll take a look. What compiler versions are you using? What version of VS?

Thank you.

 

0 Kudos
mahlumg
Beginner
355 Views

I am currently using Intel Fortran XE 2019 Update 5 (2019.5.281) on VS 2017 (15.9.17)

0 Kudos
Barbara_P_Intel
Moderator
349 Views

Please update to the current compiler release. It's part of oneAPI 2022.2. I know that there are bug fixes regarding I/O since PSXE 2019.

If you are a registered user with Intel Registration Center (IRC), you should have received an email in the last 24 hours announcing its availability.

Otherwise, you can download it from here. The Fortran compiler is part of the oneAPI HPC Toolkit.

I suggest updating to VS2019, too.

 

 

0 Kudos
mahlumg
Beginner
320 Views

I'm trying to install the latest VS and oneAPI, but I ran into an issue. However, in the meantime, I downloaded the latest Fortran runtimes, and the program worked using those (20.0.1.0) instead of what I had prior (19.0.1.0)

0 Kudos
Barbara_P_Intel
Moderator
314 Views

Great that you have your application running okay!

Please don't use the LATEST version of VS 2022, version 17.2. You will NOT be able to use Fortran projects. See this article or the pinned topic on this forum for details.

 

 

0 Kudos
Reply