Author 
SQRT instruction hangs freeAXP 
rspalding
Member
Posts: 8
Location: Southern NJ
Joined: 19.08.08 
Posted on September 01 2020 11:47 


I happened to run an ancient FORTRAN program (a bruteforce prime number generator written long ago, by Eric Postpischl  whose name appears in the VMS source listings).
On an real DS10 it runs correctly when compiled with /ARCH=HOST.
The same code causes freeAXP to hang.
This on v3.x as well as the current v4.0.0.649
If I omit the /ARCH=HOST option from the compile, the resulting code calls MATH$SQRT_F and the program runs to normal completion.
I repeated the test on both v3 and v4 freeAXP, running both HP v8.4 as well as VSI V8.42L1 and V8.42L2. All fail, apparently identically.
The freeAXP crash dump shows the SQRTF instruction as the last instruction executed.
Methinks there's a bug involving FSQRT. Of course, the problem might also be in the compiler's handling of /ARCH=HOST, where it is led erroneously to assume that FSQRT is supported by the freeAXP 'hardware'. 

Author 
RE: SQRT instruction hangs freeAXP 
Bruce Claremont
Moderator
Posts: 623
Joined: 07.01.10 
Posted on September 02 2020 02:27 


We'll have a look. Can you provide the program source code? 

Author 
RE: SQRT instruction hangs freeAXP 
rspalding
Member
Posts: 8
Location: Southern NJ
Joined: 19.08.08 
Posted on September 02 2020 05:28 


Apologies to Mr. Postpischl, for my edits.
Code:
INTEGER PRIME
READ (5,*) N
C3 FORMAT (I10)
PRIME=1
DO 1 I=1, N
7 IF (PRIME .GE. 2 147 483 647) GO TO 999
PRIME= PRIME+ 1
J = IFIX( SQRT( FLOAT (PRIME))+ 0.999 )
J = MIN( J, PRIME1)
IF (J .LT. 2) GOTO 7
DO 6 K= 2, J
IF ((PRIME  (( PRIME/ K )* K)) .EQ. 0) GO TO 7
6 CONTINUE
WRITE (6, *) PRIME
1 CONTINUE
C14 FORMAT (1X, I10)
999 STOP
END 

Author 
RE: SQRT instruction hangs freeAXP 
rspalding
Member
Posts: 8
Location: Southern NJ
Joined: 19.08.08 
Posted on September 02 2020 05:40 


Sadly, somehow all the leading whitespace was deleted during posting.
Please apply the usual cardoriented rules for FORTRAN66:
15 line number, 6 continuation flag, 7+ code, IIRC.
Perhaps the current compilers no longer care. 

Author 
RE: SQRT instruction hangs freeAXP 
rspalding
Member
Posts: 8
Location: Southern NJ
Joined: 19.08.08 
Posted on September 02 2020 06:21 


I just tried to create a simpler reproducer  and thought I had failed.
The following code runs several iterations without a hang  but prints the wrong result (SQRT(2.0) != 2.75)
HOWEVER, on the 4th or 5th repetition of the loop, I do get the freeAXP hang.
This code runs correctly on a real iron (DS10).
1 READ (5,*) X
WRITE (6,*) SQRT(X)
GOTO 1
END


Author 
RE: SQRT instruction hangs freeAXP 
Bruce Claremont
Moderator
Posts: 623
Joined: 07.01.10 
Posted on September 03 2020 02:15 


Thanks for the source code. We've reproduced all of your results. Head scratched has ensued. I'll keep you posted.
Edited by Bruce Claremont on September 04 2020 02:52 

Author 
RE: SQRT instruction hangs freeAXP 
Bruce Claremont
Moderator
Posts: 623
Joined: 07.01.10 
Posted on September 06 2020 06:28 


A simple test run on a genuine AlphaServer 400 under OpenVMS 7.32. FreeAXP emulates an AlphaServer 400. The test demonstrated things are working properly on the real hardware.
Using Digital Fortran 77 V7.11073313
$ ty sqrt.for
WRITE (6,*) 'Enter X:'
READ (5,*) X
1 WRITE (6,*) X,'>',SQRT(X)
C GOTO 1
END
$
$ for sqrt
$ link sqrt
$ r sqrt
Enter X:
2.0
2.000000 > 1.414214
$
$ for/arch=host sqrt
$ link sqrt
$ r sqrt
Enter X:
2.0
2.000000 > 1.414214
$
Edited by Bruce Claremont on September 06 2020 06:44 

Author 
RE: SQRT instruction hangs freeAXP 
Bruce Claremont
Moderator
Posts: 623
Joined: 07.01.10 
Posted on September 06 2020 06:32 


Prime program tested on genuine AlphaServer 400. Everything works as expected.
Using Digital Fortran 77 V7.11073313.
$ ty prime.for
INTEGER PRIME
READ (5,*) N
C3 FORMAT (I10)
PRIME=1
DO 1 I=1, N
7 IF (PRIME .GE. 2 147 483 647) GO TO 999
PRIME= PRIME+ 1
J = IFIX( SQRT( FLOAT (PRIME))+ 0.999 )
J = MIN( J, PRIME1)
IF (J .LT. 2) GOTO 7
DO 6 K= 2, J
IF ((PRIME  (( PRIME/ K )* K)) .EQ. 0) GO TO 7
6 CONTINUE
WRITE (6, *) PRIME
1 CONTINUE
C14 FORMAT (1X, I10)
999 STOP
END
$
$ for prime
$ link prime
$ r prime
10
3
5
7
11
13
17
19
23
29
31
$
$ for/arch=host prime
$ link prime
$ r prime
10
3
5
7
11
13
17
19
23
29
31
$
Edited by Bruce Claremont on September 06 2020 06:43 

Author 
RE: SQRT instruction hangs freeAXP 
Bruce Claremont
Moderator
Posts: 623
Joined: 07.01.10 
Posted on September 06 2020 06:49 


Which FORTRAN compiler are you using? Under Digital Fortran 77 V7.11073313, everything works as it should under FreeAXP. Under HP Fortran V8.010465548F7C and HP Fortran V8.01104669, we reproduce the reported problems.
Edited by Bruce Claremont on September 06 2020 07:38 

Author 
RE: SQRT instruction hangs freeAXP 
Bruce Claremont
Moderator
Posts: 623
Joined: 07.01.10 
Posted on September 06 2020 08:18 


The problem occurs when EV6 elements are included in the /ARCH compiler qualifier. I'm guessing the inclusion of EV5 and EV6 instructions in Avanti are leading /ARCH=HOST to default to EV67. This is causing a problem when using the HP V8.n compilers.
The workaround is to avoid using /ARCH=HOST, EV6, or EV67 with the HP V8.n compilers. The compile and run samples below demonstrate the issue. All compiles were run under VMS 7.32 and HP Fortran V8.2104679.
BURN34> for sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 1.414214
BURN34>
BURN34> for/arch=host sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 2.750000
BURN34>
BURN34> for/arch=ev4 sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 1.414214
BURN34>
BURN34> for/arch=ev5 sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 1.414214
BURN34>
BURN34> for/arch=ev56 sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 1.414214
BURN34>
BURN34> for/arch=ev6 sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 2.750000
BURN34>
BURN34> for/arch=ev67 sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 2.750000
BURN34>
BURN34> for/arch=pca56 sqrt
BURN34> link sqrt
BURN34> r sqrt
Enter X:
2.0
2.000000 > 1.414214
BURN34>

