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

Possible compiler bug? The maximum allowed number of `use` statements in a submodule

DataScientist
Valued Contributor I
409 Views

Over the past years, particularly most recently, with Intel Fortran classic compilers 2021 and 2022 on Linux (WSL), I have repeatedly encountered strange lengthy compilations of some submodules followed by either nonsensical syntax errors about various parts of the code or an ICE. 

This happens only for submodules that contain thousands of preprocessor fences and macros with hundreds of procedures, each of which `use` multiple other modules.

Although the GNU Fortran compiler can readily compile these files, the Intel ifort spends considerable time compiling the submodule before a random failure or an ICE.

After exhaustive investigations, I have narrowed the possible causes of the problem to the number of times `use` statements appear in the body of the submodule procedures.

In one instance, I was able to estimate the maximum number of use statements that `ifort` could handle, which appeared to be around 250-350 — activating any further submodule procedures led to random compiler syntax errors.

So, frequent `use` statements appear to put a hefty load on the compiler. Why? I am not sure, but I am hoping someone from the Intel compiler developer team could shed light on this matter and offer remedies.

Unfortunately, the instances where the problems occur are embedded in a large codebase, and I have not yet had time to generate a minimal example that reproduces the problem. But I have seen this pattern with the Intel compiler tens of times with different submodules, and I am confident about the presence of the problem. Luckily, now I know how to resolve the problem (by simply moving all use statements out of procedures and placing them in the submodule header so that each `use` statement appears uniquely within the entire module. But this reduces the locality of the statements and is undesirable.)

We'd appreciate any thought and hints as to the potential root cause of such a problem with Intel `ifort`. Specifically, what does `ifort` do when encountering a `use` statement? I must add that each module being `use`d within the submodule is massive, with thousands of lines with hundreds of procedures.

Thank you for the great Intel Fortran compilers IFORT and IFX.

0 Kudos
4 Replies
andrew_4619
Honored Contributor II
393 Views

Just for clarity the use statements are local in the contained routines in the submodule be the limit is the accumulated sum of the use statements not the use statements in a specific routine? 

 

I ask because this pattern of usage of 'use' is one that I also employ, I just did an check and the worst three submodules in my application have 481, 322 and 256 occurrences of USE (predominantly USE ONLY:) and I do not have any problems however I am using Windows so maybe Linux is also a factor.

 

DataScientist
Valued Contributor I
370 Views

Thanks for sharing the experience. All instances are similarly `use, only:`, and it seems like the overall count of `use` statements within a submodule matter and is problematic. But I do not have a test case with hundreds of `use` statements within a single procedure to confirm it.

All cases observed are in the Microsoft WSL environment because this is where all testings are done before moving the tests to other platforms. So it may also exist in non-Linux environments.

0 Kudos
Ron_Green
Moderator
354 Views

I know we have a number of fixes for submodules coming in the 2023.0.0 release.  Since the reproducer is probably hard to package and send to us, perhaps try the 2023.0.0 compiler first.  The linux packages for 2023 are ready, WIndows packages are taking a little longer.  We should announce the 2023 compiler "shortly".  Watch the top of the Forum for the Announcement from Barbara in the coming days.

I also worry about the WSL aspect of this issue.  We do not test on WSL.  Could we be running into memory limits in WSL, or stack limits?  Did you 'ulimit -s unlimited' before the compilation?

 

ron

DataScientist
Valued Contributor I
339 Views

Impressive. Thank you. I will test this report back here.

Happy new year to all.

0 Kudos
Reply