summaryrefslogtreecommitdiff
path: root/examples/benchmarks.hs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/benchmarks.hs')
-rw-r--r--examples/benchmarks.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/benchmarks.hs b/examples/benchmarks.hs
index f5ca550..e210280 100644
--- a/examples/benchmarks.hs
+++ b/examples/benchmarks.hs
@@ -32,12 +32,11 @@ v = flatten $ ident 500 :: Vector Double
32bench1 = do 32bench1 = do
33 time $ print$ vectorMax (w+w2) -- evaluate it 33 time $ print$ vectorMax (w+w2) -- evaluate it
34 putStrLn "Sum of a vector with 5M doubles:" 34 putStrLn "Sum of a vector with 5M doubles:"
35 print $ vectorMax v -- evaluate it 35 print$ vectorMax (w+w2) -- evaluate it
36-- time $ printf " BLAS: %.2f: " $ sumVB w 36 time $ printf " BLAS: %.2f: " $ sumVB w
37 time $ printf " Haskell: %.2f: " $ sumVH w 37 time $ printf "BLAS only dot: %.2f: " $ w <.> w2
38 time $ printf " BLAS: %.2f: " $ w <.> w2 38 time $ printf " Haskell: %.2f: " $ sumVH w
39 time $ printf " Haskell: %.2f: " $ sumVH w 39 time $ printf " innerH: %.2f: " $ innerH w w2
40 time $ printf " innerH: %.2f: " $ innerH w w2
41 time $ printf "foldVector: %.2f: " $ sumVector w 40 time $ printf "foldVector: %.2f: " $ sumVector w
42 let getPos k s = if k `mod` 500 < 200 && w@>k > 0 then k:s else s 41 let getPos k s = if k `mod` 500 < 200 && w@>k > 0 then k:s else s
43 putStrLn "foldLoop for element selection:" 42 putStrLn "foldLoop for element selection:"
@@ -46,10 +45,10 @@ bench1 = do
46 time $ print $ constant (1::Double) 5000001 @> 7 45 time $ print $ constant (1::Double) 5000001 @> 7
47 time $ print $ constant i 5000001 @> 7 46 time $ print $ constant i 5000001 @> 7
48 time $ print $ conj (constant i 5000001) @> 7 47 time $ print $ conj (constant i 5000001) @> 7
49 putStrLn "some zips:" 48 putStrLn "zips C vs H:"
50 time $ print $ (w / w2) @> 7 49 time $ print $ (w / w2) @> 7
51 time $ print $ (zipVector (/) w w2) @> 7 50 time $ print $ (zipVector (/) w w2) @> 7
52 putStrLn "some folds:" 51 putStrLn "folds C/BLAS vs H:"
53 let t = constant (1::Double) 5000002 52 let t = constant (1::Double) 5000002
54 print $ t @> 7 53 print $ t @> 7
55 time $ print $ foldVector max (t@>0) t 54 time $ print $ foldVector max (t@>0) t
@@ -57,6 +56,8 @@ bench1 = do
57 time $ print $ sqrt $ foldVector (\v s -> v*v+s) 0 t 56 time $ print $ sqrt $ foldVector (\v s -> v*v+s) 0 t
58 time $ print $ pnorm PNorm2 t 57 time $ print $ pnorm PNorm2 t
59 58
59sumVB v = constant 1 (dim v) <.> v
60
60sumVH v = go (d - 1) 0 61sumVH v = go (d - 1) 0
61 where 62 where
62 d = dim v 63 d = dim v