summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2011-03-12 13:07:30 +0000
committerAlberto Ruiz <aruiz@um.es>2011-03-12 13:07:30 +0000
commitf73c151f536aa81875285ccb38adc309d01b5915 (patch)
treed3d77eb5a658c9986fbd5fa0e638004b68b2cccf
parenteb5181b401743c34599073e8adb6bf34a897a3bc (diff)
fpudebug
-rw-r--r--hmatrix.cabal9
-rw-r--r--lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c19
2 files changed, 26 insertions, 2 deletions
diff --git a/hmatrix.cabal b/hmatrix.cabal
index 764198c..10c8173 100644
--- a/hmatrix.cabal
+++ b/hmatrix.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix 1Name: hmatrix
2Version: 0.11.0.3 2Version: 0.11.0.4
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -87,6 +87,10 @@ flag finit
87 description: Force FPU initialization in foreing calls 87 description: Force FPU initialization in foreing calls
88 default: False 88 default: False
89 89
90flag fpudebug
91 description: Check FPU stack
92 default: False
93
90library 94library
91 95
92 Build-Depends: base >= 4 && < 5, 96 Build-Depends: base >= 4 && < 5,
@@ -170,6 +174,9 @@ library
170 if flag(finit) 174 if flag(finit)
171 cpp-options: -DFINIT 175 cpp-options: -DFINIT
172 176
177 if flag(fpudebug)
178 cc-options: -DFPUDEBUG
179
173 if impl(ghc == 7.0.1) 180 if impl(ghc == 7.0.1)
174 cpp-options: -DNONORMVTEST 181 cpp-options: -DNONORMVTEST
175 182
diff --git a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
index f4ae0f6..77a8847 100644
--- a/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
+++ b/lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c
@@ -47,7 +47,24 @@
47//--------------------------------------- 47//---------------------------------------
48void asm_finit() { 48void asm_finit() {
49#ifdef i386 49#ifdef i386
50 asm("finit"); 50
51 #if FPUDEBUG
52 uint val=0;
53 asm("fstsw"
54 : "=a" (val)
55 : "a" (val)
56 );
57
58 val = (val%16384)/2048; // bits 13-11
59
60 if (val != 0) {
61 printf("Warning: FPU Stack: %d\n",val);
62 asm("finit");
63 }
64 #else
65 asm("finit");
66 #endif
67
51#endif 68#endif
52} 69}
53//--------------------------------------- 70//---------------------------------------