diff options
Diffstat (limited to 'examples/parallel.hs')
-rw-r--r-- | examples/parallel.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/parallel.hs b/examples/parallel.hs index dfbfd88..8653bc3 100644 --- a/examples/parallel.hs +++ b/examples/parallel.hs | |||
@@ -1,14 +1,17 @@ | |||
1 | -- $ runhaskell parallel.hs 2000 | ||
2 | |||
1 | import System(getArgs) | 3 | import System(getArgs) |
2 | import Numeric.LinearAlgebra | 4 | import Numeric.LinearAlgebra |
3 | import Control.Parallel.Strategies | 5 | import Control.Parallel.Strategies |
4 | import System.Time | 6 | import System.Time |
5 | 7 | ||
6 | inParallel = parMap rwhnf id | 8 | inParallel = parMap rnf id |
9 | -- rwhnf also works in this case | ||
7 | 10 | ||
11 | -- matrix product decomposed into p parallel subtasks | ||
8 | parMul p x y = fromBlocks [ inParallel ( map (x <>) ys ) ] | 12 | parMul p x y = fromBlocks [ inParallel ( map (x <>) ys ) ] |
9 | where ys = splitColumns p y | 13 | where ys = splitColumns p y |
10 | 14 | ||
11 | |||
12 | main = do | 15 | main = do |
13 | n <- (read . head) `fmap` getArgs | 16 | n <- (read . head) `fmap` getArgs |
14 | let m = ident n :: Matrix Double | 17 | let m = ident n :: Matrix Double |