This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/86463] New: Slow compile with -ggdb and optimizations


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

            Bug ID: 86463
           Summary: Slow compile with -ggdb and optimizations
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: robert.j.farmer37 at gmail dot com
  Target Milestone: ---

Created attachment 44377
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44377&action=edit
Gzipped test case

So the problem i have is that i have a large file with many variable
assignments that takes a long time. Perhaps not unexpected as the file is large
(~5000 variable assignments) but if the file is split into smaller chunks, then
the performance shows a non-linear scaling with file size.

Attached is a tarball that contains:
largeFile.f90 the file to test, it includes one of the following files:
all_vars.inc which does variable assignments for all 5000 variables
top_vars.inc and bottom_vars.inc comment out half the variables from
all_vars.inc (to test scaling behavior)
and finally
definitions.inc provides the variable types

When compiling largeFile.f90 with both -ggdb and either -O1, -O2, -O3 and
including all_vars.inc i get the following timings:

time gfortran -ggdb -O0 -c largeFile.f90  0m0.376s
time gfortran -ggdb -O1 -c largeFile.f90 >8m (Gave up)
time gfortran -ggdb -O2 -c largeFile.f90 2m13.525s
time gfortran -ggdb -O3 -c largeFile.f90 2m31.139s

So -O1 shows very bad performance while -O2 and -O3 show ~2m to compile the
file

time gfortran -O0 -c largeFile.f90 0m0.326s
time gfortran -O1 -c largeFile.f90 0m2.618s
time gfortran -O2 -c largeFile.f90 0m4.276s
time gfortran -O3 -c largeFile.f90 0m22.745s

Shows its related to using the -ggdb flag

If i include only the top_vars.inc (in largeFile.f90) i get 35s and just
including bottom_vars.inc i get 11s (with -ggdb -O2) so that is a total of 46s
for the combination of the split files while the whole file takes 2m13s (using
all_vars.inc). So splitting the file into two chunks halves the total runtime.

This is tested with gfortran 8.1.1 but 7.2.0 also shows the problem.

While looking at other bugs, 59868 suggested -fno-var-tracking which does work
here and brings the time down to ~1s with:
gfortran -fno-var-tracking -ggdb -O2 -c largeFile.f90


gfortran -v -save-temps -ggdb -O2 -c largeFile.f90 
Using built-in specs.
COLLECT_GCC=/usr/bin/gfortran
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-libmpx
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.1.1 20180502 (Red Hat 8.1.1-1) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-ggdb' '-O2' '-c' '-mtune=generic'
'-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/8/f951 largeFile.f90 -quiet -dumpbase
largeFile.f90 -mtune=generic -march=x86-64 -auxbase largeFile -ggdb -O2
-version -fintrinsic-modules-path /usr/lib/gcc/x86_64-redhat-linux/8/finclude
-o largeFile.s
GNU Fortran (GCC) version 8.1.1 20180502 (Red Hat 8.1.1-1)
(x86_64-redhat-linux)
        compiled by GNU C version 8.1.1 20180502 (Red Hat 8.1.1-1), GMP version
6.1.2, MPFR version 3.1.6-p2, MPC version 1.0.2, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU Fortran2008 (GCC) version 8.1.1 20180502 (Red Hat 8.1.1-1)
(x86_64-redhat-linux)
        compiled by GNU C version 8.1.1 20180502 (Red Hat 8.1.1-1), GMP version
6.1.2, MPFR version 3.1.6-p2, MPC version 1.0.2, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-ggdb' '-O2' '-c' '-mtune=generic'
'-march=x86-64'
 as -v --64 -o largeFile.o largeFile.s
GNU assembler version 2.29.1 (x86_64-redhat-linux) using BFD version version
2.29.1-23.fc28
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/8/:/usr/libexec/gcc/x86_64-redhat-linux/8/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/8/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/8/:/usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-ggdb' '-O2' '-c' '-mtune=generic'
'-march=x86-64'

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]