Commit 87c35a01 authored by batterseapower's avatar batterseapower

Make subset of supercompile-folder benchmarks compile and run correctly, fix...

Make subset of supercompile-folder benchmarks compile and run correctly, fix SC opts for other benchmarks
parent b65222fb
......@@ -22,7 +22,7 @@ neg_powers =
pascal:: [[Integer]]
pascal = [1,2,1] : map (\line -> zipWith (+) (line++[0]) (0:line)) pascal
{-# SUPERCOMPILE bernoulli #-}
{- {-# SUPERCOMPILE bernoulli #-} -}
bernoulli 0 = 1
bernoulli 1 = -(1%2)
bernoulli n | odd n = 0
......@@ -34,6 +34,7 @@ bernoulli n =
| (k,combs)<- zip [2..n] pascal]
where powers = (neg_powers!!(n-1))
{-# SUPERCOMPILE main #-}
main = do
[arg] <- getArgs
let n = (read arg)::Int
......
......@@ -6,3 +6,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 450
NORM_OPTS = 1000
SLOW_OPTS = 1400
SRC_SUPERCOMP_HC_OPTS =
......@@ -6,3 +6,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 450
NORM_OPTS = 2000
SLOW_OPTS = 2700
SRC_SUPERCOMP_HC_OPTS =
......@@ -6,3 +6,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 8
NORM_OPTS = 8
SLOW_OPTS = 9
SRC_SUPERCOMP_HC_OPTS =
......@@ -2,3 +2,6 @@ TOP = ../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/target.mk
# Seems to loop with this:
#SRC_SUPERCOMP_HC_OPTS =
......@@ -9,3 +9,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 5000
NORM_OPTS = 50000
SLOW_OPTS = 100000
SRC_SUPERCOMP_HC_OPTS =
......@@ -12,3 +12,6 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 17
NORM_OPTS = 17
SLOW_OPTS = 19
# Seems to loop like this:
#SRC_SUPERCOMP_HC_OPTS =
......@@ -9,3 +9,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 1500
NORM_OPTS = 1500
SLOW_OPTS = 5500
SRC_SUPERCOMP_HC_OPTS =
......@@ -8,3 +8,5 @@ SRCS = Main.hs
FAST_OPTS = 10
NORM_OPTS = 10
SLOW_OPTS = 12
SRC_SUPERCOMP_HC_OPTS =
......@@ -6,3 +6,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 30
NORM_OPTS = 30
SLOW_OPTS = 35
SRC_SUPERCOMP_HC_OPTS =
......@@ -6,3 +6,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 27 16 8
NORM_OPTS = 24 16 8
SLOW_OPTS = 33 17 8
SRC_SUPERCOMP_HC_OPTS =
......@@ -6,3 +6,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 20000
NORM_OPTS = 100000
SLOW_OPTS = 230000
SRC_SUPERCOMP_HC_OPTS =
......@@ -10,3 +10,6 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 8000
NORM_OPTS = 20000
SLOW_OPTS = 30000
# Seems to loop like this:
#SRC_SUPERCOMP_HC_OPTS =
......@@ -5,3 +5,5 @@ include $(TOP)/mk/target.mk
FAST_OPTS = 10000
NORM_OPTS = 10000
SLOW_OPTS = 80000
SRC_SUPERCOMP_HC_OPTS =
\ No newline at end of file
......@@ -44,7 +44,7 @@ ifneq "$(HC_FAIL)" "YES"
ifneq "$(NoFibWithGHCi)" "YES"
$(NOFIB_PROG_WAY) : $(OBJS)
@echo ==nofib$(_way)== $(NOFIB_PROG): time to link $(NOFIB_PROG) follows...
@$(TIME) $(HC) $(HC_OPTS) -o $@ $^ $(LIBS)
$(TIME) $(HC) $(HC_OPTS) -o $@ $^ $(LIBS)
endif
endif
......
TOP = ..
include $(TOP)/mk/boilerplate.mk
SUBDIRS = compile-time contracts ilya jason neil peter toys trivial
#SUBDIRS = compile-time contracts ilya jason neil peter toys
# The ilya tests are for program equivalence
SUBDIRS = neil peter toys
include $(TOP)/mk/target.mk
......@@ -3,9 +3,8 @@ module Main where
main :: IO ()
main = print (f 10)
lazySum :: [Int] -> Int
lazySum = foldl (+) 0
{-# SUPERCOMPILE f #-}
f :: Int -> Int
f n = lazySum [ k * m | k <- enumFromTo'Int 1 n, m <- enumFromTo'Int 1 k ]
f n = lazySum [ k * m | k <- enumFromTo 1 n, m <- enumFromTo 1 k ]
module Main where
import Data.List (foldl')
main :: IO ()
main = print (f 10000)
strictSum = foldl' (+) 0
-- Result at Integer type: 1250416704167500
{-# SUPERCOMPILE f #-}
f :: Int -> Int
f n = sum'Int [ k * m | k <- enumFromTo'Int 1 n, m <- enumFromTo'Int 1 k ]
f n = strictSum [ k * m | k <- enumFromTo 1 n, m <- enumFromTo 1 k ]
......@@ -4,7 +4,7 @@ import System.Environment
main :: IO ()
main = do
n_str <- getArgs
[n_str] <- getArgs
let n = read n_str
print (length (root (replicate n 'x') (replicate n 'y') (replicate n 'z')))
......
......@@ -5,6 +5,8 @@ include $(TOP)/mk/target.mk
SRCS = Main.hs
SRC_RUNTEST_OPTS += +RTS -K32M -RTS
FAST_OPTS = 1000000
NORM_OPTS = 1000000
SLOW_OPTS = 1000000
\ No newline at end of file
module Main where
import System.Enivronment
import System.Environment
main :: IO ()
main = do
n <- fmap (map read) getArgs
[n] <- fmap (map read) getArgs
print (root (replicate n 1) (replicate n 2))
{-# SUPERCOMPILE root #-}
......
module Main where
import Prelude hiding (flip)
import System.Environment
main :: IO ()
......
module Main where
main :: IO ()
main = print (root [1, 2, 3])
main = print (root [1, 2, 3 :: Int])
{-# SUPERCOMPILE root #-}
root :: [a] -> [(Either a a, Either a a)]
root xs = zip (map (\x -> Left x) xs) (map (\x -> Right x) xs)
[(Left 1, Right 1), (Left 2, Right 2), (Left 3, Right 3)]
[(Left 1,Right 1),(Left 2,Right 2),(Left 3,Right 3)]
module Main where
main :: IO ()
main = print (root (Node (Node Empty 1 Empty) 2 (Node Empty 3 Empty)) (Node (Node Empty 4 Empty) 5 (Node Empty 6 Empty)))
main = print (root (Node (Node Empty (1 :: Int) Empty) 2 (Node Empty 3 Empty)) (Node (Node Empty 4 Empty) 5 (Node Empty 6 Empty)))
mapT f xs = case xs of Empty -> Empty
Node l a r -> Node (mapT f l) (f a) (mapT f r)
......@@ -11,6 +11,7 @@ zipT xs ys = case xs of Empty -> Empty
Node l' a' r' -> Node (zipT l l') (a, a') (zipT r r')
{-# SUPERCOMPILE root #-}
root :: Tree a -> Tree b -> Tree (Either a b, Either a b) -- NB: not fully polymorphic
root xt yt = zipT (mapT (\x -> Left x) xt) (mapT (\x -> Right x) yt)
data Tree a = Empty | Node (Tree a) a (Tree a)
......
Node (Node Empty (Left 1, Right 4) Empty) (Left 2, Right 5) (Node Empty (Left 3, Right 6) Empty)
Node (Node Empty (Left 1,Right 4) Empty) (Left 2,Right 5) (Node Empty (Left 3,Right 6) Empty)
......@@ -27,12 +27,23 @@ main = do
-- If we generalise away the (c n a) and (S a) then we'll get a nice tieback to what we started
-- with that and hence build something equivalent to the input code.
{-# SUPERCOMPILE root #-}
root :: (Nat -> b -> b) -> b -> Nat -> Nat -> b
root :: (b -> Nat -> b) -> b -> Nat -> Nat -> b
root c n a b = foldl c n (enumFromTo a b)
data Nat = S Nat | Z
deriving (Eq, Show)
instance Enum Nat where
succ = S
pred (S x) = x
toEnum x | x < 0 = error "toEnum @Nat"
| otherwise = go x
where go x = if x == 0
then Z
else S (go (x - 1))
fromEnum Z = 0
fromEnum (S n) = 1 + fromEnum n
peanoGt :: Nat -> Nat -> Bool
peanoGt Z _ = False
peanoGt (S _) Z = True
......
......@@ -23,5 +23,5 @@ main = print (root (+) 0 1 10)
-- If we generalise away the (c n a) and (a + 1) then we'll get a nice tieback to what we started
-- with that and hence build something equivalent to the input code.
{-# SUPERCOMPILE root #-}
root :: (Int -> b -> b) -> b -> Int -> Int -> b
root :: (b -> Int -> b) -> b -> Int -> Int -> b
root c n a b = foldl c n (enumFromTo a b)
......@@ -3,9 +3,7 @@ module Main where
import System.Environment
main :: IO ()
main = do
[x_str] <- getArgs
print (root (read x_str))
main = print (root 0)
ack :: Int -> Int -> Int
ack m n = case m of 0 -> n + 1
......
......@@ -4,7 +4,3 @@ include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/target.mk
SRCS = Main.hs
FAST_OPTS = 0
NORM_OPTS = 0
SLOW_OPTS = 0
\ No newline at end of file
......@@ -8,7 +8,7 @@ ack m n = case m of S m -> case n of S n -> ack m (ack (S m) n)
Z -> S n
{-# SUPERCOMPILE root #-}
root :: Nat -> Nat -> Nat
root :: Nat -> Nat
root x = ack (S Z) x
-- Optimal output:
......
module Main where
main :: IO ()
main = print root
main = print (root Z)
ack m n = case m of S m -> case n of S n -> ack m (ack (S m) n)
Z -> ack m (S Z)
Z -> S n
......
module Main where
import Prelude hiding (even)
main :: IO ()
main = print (root (S Z))
......
module Main where
import Prelude hiding (even)
main :: IO ()
main = print (root (S Z))
......
module Main where
import Prelude hiding (foldl)
main :: IO ()
main = print (root [1, 2, 3])
......
module Main where
import Prelude hiding (length, foldl')
import Prelude hiding (length)
main :: IO ()
main = print (length "Hello World")
foldl' c n xs = case xs of [] -> n; (x:xs) -> let n' = c n x in case n' of _ -> foldl' c n' xs
foldl' c n xs = case xs of [] -> n; (x:xs) -> let n' = c n x in n' `seq` foldl' c n' xs
{-# SUPERCOMPILE length #-}
length :: [a] -> Int
length xs = foldl' (\len _ -> len + 1) 0 xs
module Main where
import Prelude hiding (foldl', length)
import Prelude hiding (length)
main :: IO ()
main = print (length "Hello")
foldl' c n xs = case xs of [] -> n; (x:xs) -> let n' = c n x in case n' of _ -> foldl' c n' xs
foldl' c n xs = case xs of [] -> n; (x:xs) -> let n' = c n x in n' `seq` foldl' c n' xs
{-# SUPERCOMPILE length #-}
length xs = foldl' (\len _ -> S len) Z xs
......
([2, 2, 2, 2], [2, 2, 2, 2])
([2,2,2,2],[2,2,2,2])
......@@ -3,7 +3,7 @@ module Main where
import Prelude hiding (map)
main :: IO ()
main = print (root [1, 2, 3])
main = print (root [1, 2, 3 :: Int] :: [Either (Either Int Int) Int])
map f xs = case xs of
[] -> []
......
[Left (Right 1), Left (Right 2), Left (Right 3)]
[Left (Right 1),Left (Right 2),Left (Right 3)]
module Main where
import Prelude hiding (foldl')
main :: IO ()
main = print (root [1, 2, 3])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment