[R-sig-Fedora] R with external BLAS fails regression test

2014-07-07 Thread Martyn Plummer
Dear Tom,

The change in the Fedora RPM from using R's internal BLAS to external
BLAS means the Fedora R binary now fails one of R's regression tests,
specifically: tests/reg-BLAS.R. You can run this code by hand to verify
the issue.

As noted in the R administration and Installation Manual, R relies on
ISO/IEC 60559 compliance of an external BLAS. This can be broken if for
example the code assumes that terms with a zero factor are always zero
and do not need to be computed - whereas x*0 can be NaN. This is checked
in the test suite.

The version of BLAS that comes with R contains patched versions of
DGBMV, DGEMM, and DGEMV.  The patch has been in place since 2010.
Presumably R blas and reference BLAS have been divergent ever since.

I guess this should be reported upstream as a BLAS bug. Recalling the
previous thread on openblas, I note that openblas does pass the
regression test.

Martyn

CC: Lejeczek, who reported the bug, and R-SIG-Fedora for information.
---
This message and its attachments are strictly confidenti...{{dropped:8}}

___
R-SIG-Fedora mailing list
R-SIG-Fedora@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-fedora


Re: [R-sig-Fedora] R with external BLAS fails regression test

2014-07-07 Thread Tom Callaway
On 07/07/2014 08:15 AM, Martyn Plummer wrote:
 Dear Tom,
 
 The change in the Fedora RPM from using R's internal BLAS to external
 BLAS means the Fedora R binary now fails one of R's regression tests,
 specifically: tests/reg-BLAS.R. You can run this code by hand to verify
 the issue.
 
 As noted in the R administration and Installation Manual, R relies on
 ISO/IEC 60559 compliance of an external BLAS. This can be broken if for
 example the code assumes that terms with a zero factor are always zero
 and do not need to be computed - whereas x*0 can be NaN. This is checked
 in the test suite.
 
 The version of BLAS that comes with R contains patched versions of
 DGBMV, DGEMM, and DGEMV.  The patch has been in place since 2010.
 Presumably R blas and reference BLAS have been divergent ever since.
 
 I guess this should be reported upstream as a BLAS bug. Recalling the
 previous thread on openblas, I note that openblas does pass the
 regression test.

Seems like it. In the interim, is there a patch handy, or do I need to
try to untangle it from the R code?

~tom

==
¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸(((º OSAS @ Red Hat
University Outreach || Fedora Special Projects || Fedora Legal
attachment: tcallawa.vcf___
R-SIG-Fedora mailing list
R-SIG-Fedora@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-fedora


Re: [R-sig-Fedora] R with external BLAS fails regression test

2014-07-07 Thread Martyn Plummer

On Mon, 2014-07-07 at 10:09 -0400, Tom Callaway wrote:
 On 07/07/2014 08:15 AM, Martyn Plummer wrote:
  Dear Tom,
  
  The change in the Fedora RPM from using R's internal BLAS to external
  BLAS means the Fedora R binary now fails one of R's regression tests,
  specifically: tests/reg-BLAS.R. You can run this code by hand to verify
  the issue.
  
  As noted in the R administration and Installation Manual, R relies on
  ISO/IEC 60559 compliance of an external BLAS. This can be broken if for
  example the code assumes that terms with a zero factor are always zero
  and do not need to be computed - whereas x*0 can be NaN. This is checked
  in the test suite.
  
  The version of BLAS that comes with R contains patched versions of
  DGBMV, DGEMM, and DGEMV.  The patch has been in place since 2010.
  Presumably R blas and reference BLAS have been divergent ever since.
  
  I guess this should be reported upstream as a BLAS bug. Recalling the
  previous thread on openblas, I note that openblas does pass the
  regression test.
 
 Seems like it. In the interim, is there a patch handy, or do I need to
 try to untangle it from the R code?

I have reconstructed a patch (attached) that you can apply directly to
the BLAS source code from Netlib.

Martyn

 ~tom
 
 ==
 ¸.·´¯`·.´¯`·.¸¸.·´¯`·.¸(((º OSAS @ Red Hat
 University Outreach || Fedora Special Projects || Fedora Legal



---
This message and its attachments are strictly confidential. If you are
not the intended recipient of this message, please immediately notify
the sender and delete it. Since its integrity cannot be guaranteed,
its content cannot involve the sender's responsibility. Any misuse,
any disclosure or publication of its content, either whole or partial,
is prohibited, exception made of formally approved use
---
diff -uNr BLAS/dgbmv.f BLAS-patched/dgbmv.f
--- BLAS/dgbmv.f	2011-04-19 21:07:23.0 +0200
+++ BLAS-patched/dgbmv.f	2014-07-07 16:39:26.509772771 +0200
@@ -240,18 +240,18 @@
   JX = KX
   IF (INCY.EQ.1) THEN
   DO 60 J = 1,N
-  IF (X(JX).NE.ZERO) THEN
+c  IF (X(JX).NE.ZERO) THEN
   TEMP = ALPHA*X(JX)
   K = KUP1 - J
   DO 50 I = MAX(1,J-KU),MIN(M,J+KL)
   Y(I) = Y(I) + TEMP*A(K+I,J)
50 CONTINUE
-  END IF
+c  END IF
   JX = JX + INCX
60 CONTINUE
   ELSE
   DO 80 J = 1,N
-  IF (X(JX).NE.ZERO) THEN
+c  IF (X(JX).NE.ZERO) THEN
   TEMP = ALPHA*X(JX)
   IY = KY
   K = KUP1 - J
@@ -259,7 +259,7 @@
   Y(IY) = Y(IY) + TEMP*A(K+I,J)
   IY = IY + INCY
70 CONTINUE
-  END IF
+c  END IF
   JX = JX + INCX
   IF (J.GT.KU) KY = KY + INCY
80 CONTINUE
diff -uNr BLAS/dgemm.f BLAS-patched/dgemm.f
--- BLAS/dgemm.f	2011-04-19 21:07:23.0 +0200
+++ BLAS-patched/dgemm.f	2014-07-07 16:41:46.510379952 +0200
@@ -239,12 +239,12 @@
60 CONTINUE
   END IF
   DO 80 L = 1,K
-  IF (B(L,J).NE.ZERO) THEN
+c  IF (B(L,J).NE.ZERO) THEN
   TEMP = ALPHA*B(L,J)
   DO 70 I = 1,M
   C(I,J) = C(I,J) + TEMP*A(I,L)
70 CONTINUE
-  END IF
+c  END IF
80 CONTINUE
90 CONTINUE
   ELSE
@@ -281,12 +281,12 @@
   140 CONTINUE
   END IF
   DO 160 L = 1,K
-  IF (B(J,L).NE.ZERO) THEN
+c  IF (B(J,L).NE.ZERO) THEN
   TEMP = ALPHA*B(J,L)
   DO 150 I = 1,M
   C(I,J) = C(I,J) + TEMP*A(I,L)
   150 CONTINUE
-  END IF
+c  END IF
   160 CONTINUE
   170 CONTINUE
   ELSE
diff -uNr BLAS/dgemv.f BLAS-patched/dgemv.f
--- BLAS/dgemv.f	2011-04-19 21:07:23.0 +0200
+++ BLAS-patched/dgemv.f	2014-07-07 16:40:29.334045215 +0200
@@ -209,24 +209,24 @@
   JX = KX
   IF (INCY.EQ.1) THEN
   DO 60 J = 1,N
-  IF (X(JX).NE.ZERO) THEN
+c  IF (X(JX).NE.ZERO) THEN
   TEMP = ALPHA*X(JX)
   DO 50 I = 1,M
   Y(I) = Y(I) + TEMP*A(I,J)
50 CONTINUE
-  END IF
+c  END IF
   JX = JX + INCX
60 CONTINUE