| 1 | {-# LANGUAGE PArr, ParallelListComp #-} |
|---|
| 2 | {-# OPTIONS -fvectorise #-} |
|---|
| 3 | |
|---|
| 4 | module MinimalParTree (sumTreeWrapper) where |
|---|
| 5 | |
|---|
| 6 | import qualified Prelude |
|---|
| 7 | import Data.Array.Parallel.Prelude |
|---|
| 8 | import Data.Array.Parallel.Prelude.Int |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | data Tree a = Node a [: Tree a :] |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | testTree :: Int -> Tree Int |
|---|
| 15 | testTree elem = Node elem emptyP |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | sumTree :: Tree Int -> Int |
|---|
| 19 | sumTree (Node x ns) = x + sumP (mapP sumTree ns) |
|---|
| 20 | |
|---|
| 21 | {-# NOINLINE sumTreeWrapper #-} |
|---|
| 22 | sumTreeWrapper :: Int -> Int |
|---|
| 23 | sumTreeWrapper elem = |
|---|
| 24 | sumTree (testTree elem) |
|---|