[Flang] Execution does not terminate when an array name enclosed in square brackets is used in where construct
Version of flang : 21.0.0(9fe6f6a0d430b872750354c20f3e4a651bd1f135)/AArch64
When array-constructor (an array name enclosed in square brackets) is used in where construct, execution does not terminate after more than 20 minutes.
Gfortran and ifx execute in less than a second.
The above program is sngtar12_2.f90
According to the Fortran standard 2023: 7.8 Construction of array values, it seems correct to use array names enclosed in square brackets.
Execution terminates in the following cases:
- Do not use where construct
The above program is sngtar12_21.f90 - Do not use square brackets
The above program is sngtar12_23.f90
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
sngtar12_2.f90:
program main
integer a(6000*400), b(6000*400)
a=1
where(a>0)
b=[a]
b=[a**1]
end where
if(b(6000*400)/=1) print *,'err1'
print *,'pass'
end program
$ flang sngtar12_2.f90; time ./a.out -> Killed because execution does not terminate after more than 20 minutes
C-c C-c
real 24m34.953s
user 24m9.212s
sys 0m25.710s
$
$ gfortran sngtar12_2.f90; time ./a.out
pass
real 0m0.056s
user 0m0.033s
sys 0m0.023s
$
$ ifx sngtar12_2.f90; time ./a.out
pass
real 0m0.255s
user 0m0.002s
sys 0m0.005s
$
sngtar12_21.f90:
program main
integer a(6000*400), b(6000*400)
a=1
! where(a>0)
b=[a]
b=[a**1]
! end where
if(b(6000*400)/=1) print *,'err1'
print *,'pass'
end program
$ flang sngtar12_21.f90; time ./a.out
pass
real 0m0.146s
user 0m0.128s
sys 0m0.011s
$
sngtar12_23.f90:
program main
integer a(6000*400), b(6000*400)
a=1
where(a>0)
b=a
b=a**1
end where
if(b(6000*400)/=1) print *,'err1'
print *,'pass'
end program
$ flang sngtar12_23.f90; time ./a.out
pass
real 0m0.240s
user 0m0.185s
sys 0m0.001s
$
To clarify, compilation is fine:
$ time flang sngtar12_2.f90
real 0m0.335s
user 0m0.324s
sys 0m0.050s
It's the execution that runs for a long time.
This seems to be working now:
$ cat sandbox/test.f90
program main
integer a(6000*400), b(6000*400)
a=1
where(a>0)
b=[a]
b=[a**1]
end where
if(b(6000*400)/=1) print *,'err1'
print *,'pass'
end program
$ ./build/bin/flang sandbox/test.f90 -o sandbox/test
$ time ./sandbox/test
pass
real 0m0.243s
user 0m0.044s
sys 0m0.007s
@ohno-fj could you please check with the latest Flang and close it that's the case?
@ceseo thank you for your comment. I have confirmed that the program terminates normally with the latest Flang. I close this issue.
The following is the confirmation log.
$ flang sngtar12_2.f90; time ./a.out
pass
real 0m0.352s
user 0m0.321s
sys 0m0.030s
$