Skip to content

[Flang] Compilation of DATA statement for large COMPLEX arrays needs a lot of time #66452

@yus3710-fj

Description

@yus3710-fj

This is an issue from Fujitsu testsuite.

#63610 about memory shortage has been fixed, but the compilation takes a long time.
(The compilation command is executed with ulimit -t 300 in Fujitsu testsuite.)

The following are the test program, the result of time command of flang-new and gfortran compilation.

! test.f90
complex(kind=8),dimension(1000)     :: a8
complex(kind=8),dimension(1000,1000)  :: b8
complex(kind=16),dimension(1000)    :: a16
complex(kind=16),dimension(1000,1000) :: b16

data a8/1000*(0.0,0.0)/,a16/1000*(0.0,0.0)/
data b8/1000000*(0.0,0.0)/,b16/1000000*(0.0,0.0)/

end
$ time flang-new -v test.f90 
flang-new version 18.0.0 (https://github.com/llvm/llvm-project.git 444abb396c340e52a8a4db5778b7d6b3b6195070)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /usr/lib/gcc/aarch64-redhat-linux/8
Selected GCC installation: /usr/lib/gcc/aarch64-redhat-linux/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +neon -target-feature +v8a -o /tmp/test-6590a6.o -x f95-cpp-input test.f90
 "/usr/bin/ld" -pie -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/Scrt1.o /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/crti.o /usr/lib/gcc/aarch64-redhat-linux/8/crtbeginS.o -L/path/to/install/lib/clang/18/lib/aarch64-unknown-linux-gnu -L/usr/lib/gcc/aarch64-redhat-linux/8 -L/usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/test-6590a6.o -L/path/to/install/lib -lFortran_main -lFortranRuntime -lFortranDecimal -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/aarch64-redhat-linux/8/crtendS.o /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/crtn.o

real    18m5.933s
user    18m5.553s
sys     0m0.239s
$ time gfortran -v test.f90 
Driving: gfortran -v test.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,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 --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC) 
 :

real    0m0.117s
user    0m0.091s
sys     0m0.004s

It seems that semantics takes a long time.

$ time flang-new -fc1 -fdebug-dump-parse-tree-no-sema test.f90 
Program -> ProgramUnit -> MainProgram
| SpecificationPart
:
| ExecutionPart -> Block
| EndProgramStmt -> 

real    0m0.781s
user    0m0.495s
sys     0m0.061s
$ time flang-new -fc1 -fdebug-dump-parse-tree test.f90 
Program -> ProgramUnit -> MainProgram
| SpecificationPart
:
| ExecutionPart -> Block
| EndProgramStmt -> 

real    18m8.254s
user    18m7.959s
sys     0m0.160s
$ time flang-new -fc1 -emit-fir test.f90 

real    17m37.932s
user    17m37.596s
sys     0m0.190s

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions