diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/parallel.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/parallel.hs b/examples/parallel.hs index 8f67863..7256fb6 100644 --- a/examples/parallel.hs +++ b/examples/parallel.hs | |||
@@ -5,11 +5,9 @@ import System.Time | |||
5 | 5 | ||
6 | inParallel = parMap rwhnf id | 6 | inParallel = parMap rwhnf id |
7 | 7 | ||
8 | parMul x y = fromBlocks [[ay],[by]] | 8 | parMul x y = fromBlocks [inParallel[x <> y1, x <> y2]] |
9 | where p = rows x `div` 2 | 9 | where p = cols y `div` 2 |
10 | a = takeRows p x | 10 | (y1,y2) = splitColumnsAt p y |
11 | b = dropRows p x | ||
12 | [ay,by] = inParallel [a<>y,b<>y] | ||
13 | 11 | ||
14 | main = do | 12 | main = do |
15 | n <- (read . head) `fmap` getArgs | 13 | n <- (read . head) `fmap` getArgs |
@@ -20,6 +18,9 @@ main = do | |||
20 | a = (2><3) [1..6::Double] | 18 | a = (2><3) [1..6::Double] |
21 | b = (3><4) [1..12::Double] | 19 | b = (3><4) [1..12::Double] |
22 | 20 | ||
21 | splitRowsAt p m = (takeRows p m, dropRows p m) | ||
22 | splitColumnsAt p m = (takeColumns p m, dropColumns p m) | ||
23 | |||
23 | time act = do | 24 | time act = do |
24 | t0 <- getClockTime | 25 | t0 <- getClockTime |
25 | act | 26 | act |