diff options
Diffstat (limited to 'examples/parallel.hs')
-rw-r--r-- | examples/parallel.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/parallel.hs b/examples/parallel.hs index 566b729..e875407 100644 --- a/examples/parallel.hs +++ b/examples/parallel.hs | |||
@@ -1,4 +1,5 @@ | |||
1 | -- $ runhaskell parallel.hs 2000 | 1 | -- $ ghc --make -O -rtsopts -threaded parallel.hs |
2 | -- $ ./parallel 3000 +RTS -N4 -s -A200M | ||
2 | 3 | ||
3 | import System.Environment(getArgs) | 4 | import System.Environment(getArgs) |
4 | import Numeric.LinearAlgebra | 5 | import Numeric.LinearAlgebra |
@@ -7,7 +8,6 @@ import System.Time | |||
7 | 8 | ||
8 | inParallel = parMap rwhnf id | 9 | inParallel = parMap rwhnf id |
9 | 10 | ||
10 | |||
11 | -- matrix product decomposed into p parallel subtasks | 11 | -- matrix product decomposed into p parallel subtasks |
12 | parMul p x y = fromBlocks [ inParallel ( map (x <>) ys ) ] | 12 | parMul p x y = fromBlocks [ inParallel ( map (x <>) ys ) ] |
13 | where [ys] = toBlocksEvery (rows y) (cols y `div` p) y | 13 | where [ys] = toBlocksEvery (rows y) (cols y `div` p) y |
@@ -25,3 +25,4 @@ time act = do | |||
25 | act | 25 | act |
26 | t1 <- getClockTime | 26 | t1 <- getClockTime |
27 | print $ tdSec $ normalizeTimeDiff $ diffClockTimes t1 t0 | 27 | print $ tdSec $ normalizeTimeDiff $ diffClockTimes t1 t0 |
28 | |||