public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/114626] New: Very long time for compilation the attached program, depends on value of a parameter
@ 2024-04-07  8:46 arjen.markus895 at gmail dot com
  2024-04-07 18:30 ` [Bug fortran/114626] " anlauf at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: arjen.markus895 at gmail dot com @ 2024-04-07  8:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114626

            Bug ID: 114626
           Summary: Very long time for compilation the attached program,
                    depends on value of a parameter
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arjen.markus895 at gmail dot com
  Target Milestone: ---

Created attachment 57894
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57894&action=edit
Source of the program causing the very long compile time

The attached program causes the gfortran compiler to take a very long time if
the parameter max_ij is set to 100. It may not even finish. If the parameter is
set to 13 (to at least give one result), it takes a few seconds but at least
finishes in a reasonable time.

This is with default compile options. I have not tried specific options.

(Note: it is a silly program, meant for demonstration only.)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/114626] Very long time for compilation the attached program, depends on value of a parameter
  2024-04-07  8:46 [Bug fortran/114626] New: Very long time for compilation the attached program, depends on value of a parameter arjen.markus895 at gmail dot com
@ 2024-04-07 18:30 ` anlauf at gcc dot gnu.org
  2024-04-08  6:22 ` arjen.markus895 at gmail dot com
  2024-04-08 20:39 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-04-07 18:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114626

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97571
           Priority|P3                          |P4

--- Comment #1 from anlauf at gcc dot gnu.org ---
Note that

pack( [ (k, k = 1,max_sum)], &
[ ( count( [((i**3+j**3, i = 1,j), j = 1,max_ij)] == k ) > 1, k = 1,max_sum )]
)

is a constant expression that the frontend tries to simplify at compile time.
I assume that most of the time goes into handling of the array constructors.

There's no limit implemented that checks the complexity of such expressions
and to give up if that limit is reached.

An expression like the above could occur in a parameter definition, and a
limit then might terminate the compilation with an error.

Fortunately, you've already found a workaround.

For a related PR see pr97571.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/114626] Very long time for compilation the attached program, depends on value of a parameter
  2024-04-07  8:46 [Bug fortran/114626] New: Very long time for compilation the attached program, depends on value of a parameter arjen.markus895 at gmail dot com
  2024-04-07 18:30 ` [Bug fortran/114626] " anlauf at gcc dot gnu.org
@ 2024-04-08  6:22 ` arjen.markus895 at gmail dot com
  2024-04-08 20:39 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: arjen.markus895 at gmail dot com @ 2024-04-08  6:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114626

--- Comment #2 from Arjen Markus <arjen.markus895 at gmail dot com> ---
Thanks for the explanation - that is clear enough.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/114626] Very long time for compilation the attached program, depends on value of a parameter
  2024-04-07  8:46 [Bug fortran/114626] New: Very long time for compilation the attached program, depends on value of a parameter arjen.markus895 at gmail dot com
  2024-04-07 18:30 ` [Bug fortran/114626] " anlauf at gcc dot gnu.org
  2024-04-08  6:22 ` arjen.markus895 at gmail dot com
@ 2024-04-08 20:39 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-04-08 20:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114626

--- Comment #3 from anlauf at gcc dot gnu.org ---
Another option is to not declare max_sum as parameter but as variable.
With

    integer              :: max_sum = 2 * max_ij ** 3

the code compiles almost instantly, but it has noticeable runtime.

(But it performs much better here than with Intel... :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-08 20:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-07  8:46 [Bug fortran/114626] New: Very long time for compilation the attached program, depends on value of a parameter arjen.markus895 at gmail dot com
2024-04-07 18:30 ` [Bug fortran/114626] " anlauf at gcc dot gnu.org
2024-04-08  6:22 ` arjen.markus895 at gmail dot com
2024-04-08 20:39 ` anlauf at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).