diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-03-05 15:56:40 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-03-05 15:56:40 +0000 |
commit | 80be521adb679b3a41034269c35f0de4db698fab (patch) | |
tree | e9847d124453c7df4ea8cb27c4ef4fc150c93727 | |
parent | 4761a5f2e70a2d82c90f1d7896ab4b3638c507a1 (diff) |
add Intel's MKL support
-rw-r--r-- | README | 41 | ||||
-rw-r--r-- | hmatrix.cabal | 25 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests/Properties.hs | 6 |
3 files changed, 50 insertions, 22 deletions
@@ -4,20 +4,21 @@ | |||
4 | 4 | ||
5 | REQUIREMENTS ---------------------------- | 5 | REQUIREMENTS ---------------------------- |
6 | 6 | ||
7 | Development packages of: | 7 | 1) GNU Scientific Library (http://www.gnu.org/software/gsl). |
8 | In Ubuntu we need the package "libgsl0-dev". | ||
8 | 9 | ||
9 | 1) GNU Scientific Library (http://www.gnu.org/software/gsl) | 10 | 2) BLAS/LAPACK (http://www.netlib.org/lapack). |
11 | An optimized implementation is recommended. I have tested: | ||
10 | 12 | ||
11 | 2) BLAS and LAPACK (http://www.netlib.org/lapack) | 13 | - Intel's MKL (http://www.intel.com/cd/software/products). |
14 | There is a free noncommercial download of MKL for Linux. | ||
12 | 15 | ||
13 | 3) ATLAS (recommended) (http://math-atlas.sourceforge.net/) | 16 | - ATLAS (http://math-atlas.sourceforge.net). |
14 | 17 | In Ubuntu the required packages are "refblas3-dev", "lapack3-dev", | |
15 | For example, in Ubuntu Linux we need: | 18 | and "atlas3-base-dev" (or a version tuned for your machine). |
16 | 19 | Please note that ATLAS currently requires compilation -fviaC in 32bit | |
17 | - libgsl0-dev | 20 | machines. Otherwise many functions fail, producing strange NaN's. |
18 | - refblas3-dev | 21 | Even with -fvia-C we may get wrong behavior in some cases. |
19 | - lapack3-dev | ||
20 | - atlas3-base-dev (or a version specifically tuned for your machine) | ||
21 | 22 | ||
22 | For ghc-6.8.x you may also need: | 23 | For ghc-6.8.x you may also need: |
23 | 24 | ||
@@ -46,6 +47,19 @@ Manual: | |||
46 | $ runhaskell Setup.lhs haddock | 47 | $ runhaskell Setup.lhs haddock |
47 | $ runhaskell Setup.lhs install | 48 | $ runhaskell Setup.lhs install |
48 | 49 | ||
50 | Using Intel's MKL: | ||
51 | |||
52 | - add/modify environment variables (e.g. in your .bashrc): | ||
53 | export LD_LIBRARY_PATH=/path/to/mkl/lib/arch | ||
54 | export LIBRARY_PATH=/path/to/mkl/lib/arch | ||
55 | where arch = "32" or "em64t" | ||
56 | |||
57 | - add the "-fmkl" flag in the cabal configuration command: | ||
58 | $ runhaskell Setup.lhs configure --prefix=$HOME --user -fmkl | ||
59 | $ runhaskell Setup.lhs build | ||
60 | $ runhaskell Setup.lhs install | ||
61 | |||
62 | |||
49 | See below for installation on Windows. | 63 | See below for installation on Windows. |
50 | 64 | ||
51 | TESTS --------------------------------------------- | 65 | TESTS --------------------------------------------- |
@@ -88,7 +102,7 @@ KNOWN PROBLEMS / BUGS ------------------------------- | |||
88 | NaN's results on certain blas/lapack calls. In these machines | 102 | NaN's results on certain blas/lapack calls. In these machines |
89 | the library is automatically compiled -fvia-C, which apparently | 103 | the library is automatically compiled -fvia-C, which apparently |
90 | solves the problem. | 104 | solves the problem. |
91 | On 64-bit the default and faster -fasm seems to work well. | 105 | On 64-bit, or using MKL, the default and faster -fasm seems to work well. |
92 | 106 | ||
93 | - On 64-bit machines the example "minimize.hs", when run from ghci, | 107 | - On 64-bit machines the example "minimize.hs", when run from ghci, |
94 | produces a segmentation fault. It happens in the call to | 108 | produces a segmentation fault. It happens in the call to |
@@ -110,6 +124,9 @@ KNOWN PROBLEMS / BUGS ------------------------------- | |||
110 | A similar problem was reported at: | 124 | A similar problem was reported at: |
111 | http://article.gmane.org/gmane.linux.debian.devel.bugs.general/323065 | 125 | http://article.gmane.org/gmane.linux.debian.devel.bugs.general/323065 |
112 | 126 | ||
127 | - On distributions with old GSL versions you should comment out a couple of functions | ||
128 | in the export lists of Ellint.hs and Debye.hs | ||
129 | |||
113 | CHANGES --------------------------------------------------------- | 130 | CHANGES --------------------------------------------------------- |
114 | 131 | ||
115 | This is a new version of the library previously known as GSLHaskell. | 132 | This is a new version of the library previously known as GSLHaskell. |
diff --git a/hmatrix.cabal b/hmatrix.cabal index 89ddb8a..263064e 100644 --- a/hmatrix.cabal +++ b/hmatrix.cabal | |||
@@ -1,5 +1,5 @@ | |||
1 | Name: hmatrix | 1 | Name: hmatrix |
2 | Version: 0.2.1.0 | 2 | Version: 0.2.1.1 |
3 | License: GPL | 3 | License: GPL |
4 | License-file: LICENSE | 4 | License-file: LICENSE |
5 | Author: Alberto Ruiz | 5 | Author: Alberto Ruiz |
@@ -21,19 +21,19 @@ build-type: Simple | |||
21 | flag splitBase | 21 | flag splitBase |
22 | description: Choose the new smaller, split-up base package. | 22 | description: Choose the new smaller, split-up base package. |
23 | 23 | ||
24 | flag mkl | ||
25 | description: Link with Intel's MKL optimized libraries. | ||
26 | default: False | ||
27 | |||
24 | library | 28 | library |
25 | if flag(splitBase) | 29 | if flag(splitBase) |
26 | build-depends: base >= 3, array, QuickCheck, HUnit, storable-complex | 30 | build-depends: base >= 3, array, QuickCheck, HUnit, storable-complex |
27 | else | 31 | else |
28 | build-depends: base < 3, QuickCheck, HUnit, storable-complex | 32 | build-depends: base < 3, QuickCheck, HUnit, storable-complex |
29 | 33 | ||
30 | if os(windows) | 34 | if !flag(mkl) |
31 | ghc-options: | 35 | if !os(x86_64) |
32 | else | 36 | ghc-options: -fvia-C |
33 | if arch(x86_64) | ||
34 | ghc-options: | ||
35 | else | ||
36 | ghc-options: -fvia-C | ||
37 | 37 | ||
38 | Build-Depends: haskell98 | 38 | Build-Depends: haskell98 |
39 | Extensions: ForeignFunctionInterface | 39 | Extensions: ForeignFunctionInterface |
@@ -95,6 +95,13 @@ library | |||
95 | C-sources: lib/Data/Packed/Internal/auxi.c, | 95 | C-sources: lib/Data/Packed/Internal/auxi.c, |
96 | lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c, | 96 | lib/Numeric/LinearAlgebra/LAPACK/lapack-aux.c, |
97 | lib/Numeric/GSL/gsl-aux.c | 97 | lib/Numeric/GSL/gsl-aux.c |
98 | extra-libraries: gsl blas lapack | 98 | if flag(mkl) |
99 | if arch(x86_64) | ||
100 | extra-libraries: gsl mkl_lapack mkl_intel_lp64 mkl_sequential mkl_core | ||
101 | else | ||
102 | extra-libraries: gsl mkl_lapack mkl_intel mkl_sequential mkl_core | ||
103 | else | ||
104 | extra-libraries: gsl blas lapack | ||
105 | |||
99 | cc-options: -O4 | 106 | cc-options: -O4 |
100 | ghc-prof-options: -auto-all | 107 | ghc-prof-options: -auto-all |
diff --git a/lib/Numeric/LinearAlgebra/Tests/Properties.hs b/lib/Numeric/LinearAlgebra/Tests/Properties.hs index 566d038..55e9a1b 100644 --- a/lib/Numeric/LinearAlgebra/Tests/Properties.hs +++ b/lib/Numeric/LinearAlgebra/Tests/Properties.hs | |||
@@ -40,6 +40,9 @@ module Numeric.LinearAlgebra.Tests.Properties ( | |||
40 | import Numeric.LinearAlgebra | 40 | import Numeric.LinearAlgebra |
41 | import Numeric.LinearAlgebra.Tests.Instances(Sq(..),Her(..),Rot(..)) | 41 | import Numeric.LinearAlgebra.Tests.Instances(Sq(..),Her(..),Rot(..)) |
42 | import Test.QuickCheck | 42 | import Test.QuickCheck |
43 | import Debug.Trace | ||
44 | |||
45 | debug x = trace (show x) x | ||
43 | 46 | ||
44 | -- relative error | 47 | -- relative error |
45 | dist :: (Normed t, Num t) => t -> t -> Double | 48 | dist :: (Normed t, Num t) => t -> t -> Double |
@@ -89,8 +92,9 @@ ones (r,c) = zeros (r,c) + 1 | |||
89 | 92 | ||
90 | ----------------------------------------------------- | 93 | ----------------------------------------------------- |
91 | 94 | ||
92 | luProp m = m |~| p <> l <> u && det p == s | 95 | luProp m = m |~| p <> l <> u && f (det p) |~| f s |
93 | where (l,u,p,s) = lu m | 96 | where (l,u,p,s) = lu m |
97 | f x = fromList [x] | ||
94 | 98 | ||
95 | invProp m = m <> inv m |~| ident (rows m) | 99 | invProp m = m <> inv m |~| ident (rows m) |
96 | 100 | ||