summaryrefslogtreecommitdiff
path: root/examples/parallel.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/parallel.hs')
-rw-r--r--examples/parallel.hs7
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
1import System(getArgs) 3import System(getArgs)
2import Numeric.LinearAlgebra 4import Numeric.LinearAlgebra
3import Control.Parallel.Strategies 5import Control.Parallel.Strategies
4import System.Time 6import System.Time
5 7
6inParallel = parMap rwhnf id 8inParallel = parMap rnf id
9-- rwhnf also works in this case
7 10
11-- matrix product decomposed into p parallel subtasks
8parMul p x y = fromBlocks [ inParallel ( map (x <>) ys ) ] 12parMul p x y = fromBlocks [ inParallel ( map (x <>) ys ) ]
9 where ys = splitColumns p y 13 where ys = splitColumns p y
10 14
11
12main = do 15main = 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