Skip to content

Commit 9840f50

Browse files
authored
Merge pull request #1033 from ACSimon33/eigenvalue_fma_error
Prevent compilers from using FMA instructions
2 parents 694e337 + 349b76a commit 9840f50

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

SRC/dlanv2.f

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ SUBROUTINE DLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
144144
* ..
145145
* .. Local Scalars ..
146146
DOUBLE PRECISION AA, BB, BCMAX, BCMIS, CC, CS1, DD, EPS, P, SAB,
147-
$ SAC, SCALE, SIGMA, SN1, TAU, TEMP, Z, SAFMIN,
147+
$ SAC, SCALE, SIGMA, SN1, TAU, TEMP, Z, SAFMIN,
148148
$ SAFMN2, SAFMX2
149149
INTEGER COUNT
150150
* ..
@@ -248,10 +248,14 @@ SUBROUTINE DLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
248248
*
249249
* Compute [ A B ] = [ CS SN ] [ AA BB ]
250250
* [ C D ] [-SN CS ] [ CC DD ]
251+
*
252+
* Note: Some of the multiplications are wrapped in parentheses to
253+
* prevent compilers from using FMA instructions. See
254+
* https://github.com/Reference-LAPACK/lapack/issues/1031.
251255
*
252256
A = AA*CS + CC*SN
253-
B = BB*CS + DD*SN
254-
C = -AA*SN + CC*CS
257+
B = ( BB*CS ) + ( DD*SN )
258+
C = -( AA*SN ) + ( CC*CS )
255259
D = -BB*SN + DD*CS
256260
*
257261
TEMP = HALF*( A+D )

SRC/slanv2.f

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ SUBROUTINE SLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
144144
* ..
145145
* .. Local Scalars ..
146146
REAL AA, BB, BCMAX, BCMIS, CC, CS1, DD, EPS, P, SAB,
147-
$ SAC, SCALE, SIGMA, SN1, TAU, TEMP, Z, SAFMIN,
147+
$ SAC, SCALE, SIGMA, SN1, TAU, TEMP, Z, SAFMIN,
148148
$ SAFMN2, SAFMX2
149149
INTEGER COUNT
150150
* ..
@@ -248,10 +248,14 @@ SUBROUTINE SLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )
248248
*
249249
* Compute [ A B ] = [ CS SN ] [ AA BB ]
250250
* [ C D ] [-SN CS ] [ CC DD ]
251+
*
252+
* Note: Some of the multiplications are wrapped in parentheses to
253+
* prevent compilers from using FMA instructions. See
254+
* https://github.com/Reference-LAPACK/lapack/issues/1031.
251255
*
252256
A = AA*CS + CC*SN
253-
B = BB*CS + DD*SN
254-
C = -AA*SN + CC*CS
257+
B = ( BB*CS ) + ( DD*SN )
258+
C = -( AA*SN ) + ( CC*CS )
255259
D = -BB*SN + DD*CS
256260
*
257261
TEMP = HALF*( A+D )

0 commit comments

Comments
 (0)