summaryrefslogtreecommitdiff
path: root/examples/parallel.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-05-08 08:48:12 +0200
committerAlberto Ruiz <aruiz@um.es>2014-05-08 08:48:12 +0200
commit1925c123d7d8184a1d2ddc0a413e0fd2776e1083 (patch)
treefad79f909d9c3be53d68e6ebd67202650536d387 /examples/parallel.hs
parenteb3f702d065a4a967bb754977233e6eec408fd1f (diff)
empty hmatrix-base
Diffstat (limited to 'examples/parallel.hs')
-rw-r--r--examples/parallel.hs28
1 files changed, 0 insertions, 28 deletions
diff --git a/examples/parallel.hs b/examples/parallel.hs
deleted file mode 100644
index e875407..0000000
--- a/examples/parallel.hs
+++ /dev/null
@@ -1,28 +0,0 @@
1-- $ ghc --make -O -rtsopts -threaded parallel.hs
2-- $ ./parallel 3000 +RTS -N4 -s -A200M
3
4import System.Environment(getArgs)
5import Numeric.LinearAlgebra
6import Control.Parallel.Strategies
7import System.Time
8
9inParallel = parMap rwhnf id
10
11-- matrix product decomposed into p parallel subtasks
12parMul p x y = fromBlocks [ inParallel ( map (x <>) ys ) ]
13 where [ys] = toBlocksEvery (rows y) (cols y `div` p) y
14
15main = do
16 n <- (read . head) `fmap` getArgs
17 let m = ident n :: Matrix Double
18 time $ print $ maxElement $ takeDiag $ m <> m
19 time $ print $ maxElement $ takeDiag $ parMul 2 m m
20 time $ print $ maxElement $ takeDiag $ parMul 4 m m
21 time $ print $ maxElement $ takeDiag $ parMul 8 m m
22
23time act = do
24 t0 <- getClockTime
25 act
26 t1 <- getClockTime
27 print $ tdSec $ normalizeTimeDiff $ diffClockTimes t1 t0
28