Commits

Aleksey Khudyakov committed 9c96a8b

Test for optmization routines

Comments (0)

Files changed (6)

test/optimization/fuse-mapM.hs

+import qualified Data.Vector.Fixed         as F
+import           Data.Vector.Fixed.Unboxed (Vec3)
+
+main :: IO ()
+main = do 
+  F.mapM_ print (F.mk3 1 2 3 :: Vec3 Double)

test/optimization/fuse-mk.hs

+import qualified Data.Vector.Fixed         as F
+import qualified Data.Vector.Fixed.Cont    as C
+import           Data.Vector.Fixed.Unboxed (Vec)
+import Data.Vector.Fixed (S,Z)
+
+fini :: C.ContVec (S (S (S Z))) Double -> Double
+fini = C.runContVec C.sum
+{-# NOINLINE fini #-}
+
+gen :: C.ContVec (S (S (S Z))) Double
+gen = C.generate fromIntegral
+{-# NOINLINE gen #-}
+
+main :: IO ()
+main = do 
+  -- print $ F.sum $ (F.mk3 1 2 3 :: Vec3 Double)
+  print $ fini (C.cvec (C.vector gen :: Vec (S (S (S Z))) Double))

test/optimization/fuse-simple.hs

+import qualified Data.Vector.Fixed         as F
+import           Data.Vector.Fixed.Unboxed (Vec3)
+
+main :: IO ()
+main =
+  print $ F.sum (F.generate fromIntegral :: Vec3 Double)

test/optimization/fuse-simplehs

Empty file added.

test/optimization/fuse-zipWith.hs

+import qualified Data.Vector.Fixed         as F
+import           Data.Vector.Fixed.Unboxed (Vec3)
+
+main :: IO ()
+main = do
+  let v = F.generate ((*2).fromIntegral) :: Vec3 Double
+      u = F.replicate 12
+  print $ F.sum $ F.zipWith (*) v u

test/optimization/run.sh

+#!/bin/sh
+
+run() {
+    touch "$1"
+    ghc -O2 -ddump-simpl -dsuppress-coercions "$1" > "$1.hcr"
+    # ---
+    printf "%-20s" "$1"
+    grep -c writeDoubleArray "$1.hcr"
+}
+
+run fuse-simple.hs
+run fuse-zipWith.hs
+run fuse-mk.hs
+run fuse-mapM.hs