Commit ddc87ccb authored by batterseapower's avatar batterseapower

Tweaks to benchmarks, more benchmarks

parent 6f57cbc9
......@@ -7,4 +7,5 @@ FAST_OPTS = 27 16 8
NORM_OPTS = 24 16 8
SLOW_OPTS = 33 17 8
SRC_SUPERCOMP_HC_OPTS =
# Goes off to infinity with +VE information even if rollback is off
SRC_SUPERCOMP_HC_OPTS = -fsupercompiler-no-positive-information
TOP = ../..
include $(TOP)/mk/boilerplate.mk
SUBDIRS = SumSquare
SUBDIRS = SumSquare SumSquare-Explicit
# Worthless benchmark, runs too fast:
# SumSquare-LazySum
......
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 = strictSum go0
where
-- TQ translation of [ k * m | k <- enumFromTo 1 n, m <- enumFromTo 1 k ]
go0 = go1 [] (enumFromTo 1 n)
go1 tl [] = tl
go1 tl (k:ks) = go2 (go1 tl ks) (enumFromTo 1 k)
where
go2 tl [] = tl
go2 tl (m:ms) = (k*m) : go2 tl ms
TOP = ../../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
SRCS = Main.hs
SRC_SUPERCOMP_HC_OPTS =
......@@ -6,7 +6,12 @@ main :: IO ()
main = do
[n_str] <- getArgs
let n = read n_str
print (length (root (replicate n 'x') (replicate n 'y') (replicate n 'z')))
print (length (root (my_replicate n 'x') (my_replicate n 'y') (my_replicate n 'z')))
-- Prevent benchmark results being skewed because rewrite rules have access to more information than the SC does:
my_replicate :: Int -> a -> [a]
my_replicate 0 x = []
my_replicate n x = x : my_replicate (n - 1) x
{-# SUPERCOMPILE root #-}
root xs ys zs = (xs ++ ys) ++ zs
......@@ -7,7 +7,12 @@ import Prelude hiding (sum)
main :: IO ()
main = do
[n] <- fmap (map read) getArgs
print (root (replicate n 1) (replicate n 2))
print (root (my_replicate n 1) (my_replicate n 2))
-- Prevent benchmark results being skewed because rewrite rules have access to more information than the SC does:
my_replicate :: Int -> a -> [a]
my_replicate 0 x = []
my_replicate n x = x : my_replicate (n - 1) x
{-# SUPERCOMPILE root #-}
root :: [Int] -> [Int] -> Int
......
......@@ -5,7 +5,12 @@ import System.Environment
main :: IO ()
main = do
[n] <- fmap (map read) getArgs
print (root [1..n])
print (root (my_enum 1 n))
-- Prevent benchmark results being skewed because rewrite rules have access to more information than the SC does:
my_enum :: Int -> Int -> [Int]
my_enum n m | n > m = []
| otherwise = n : my_enum (n+1) m
{-# SUPERCOMPILE root #-}
root :: [a] -> Int
......
......@@ -7,6 +7,12 @@ main = do
[n] <- fmap (map read) getArgs
print (length (root (flip (:)) [] 1 n))
-- Prevent benchmark results being skewed because rewrite rules have access to more information than the SC does:
my_length :: [a] -> Int
my_length = go 0
where go n [] = n
go n (_:xs) = n `seq` go (n+1) xs
-- Example from Section 5 of "Shortcut Fusion for Accumulating Parameters & Zip-like Functions"
-- Optimal output should be isomorphic to:
--
......
TOP = ../..
include $(TOP)/mk/boilerplate.mk
SUBDIRS = AccumulatingParam-Peano AccumulatingParam Ackermann AckermannPeano-1 AckermannPeano-2 EvenDouble EvenDoubleGenerator Generalisation KMP LetRec MapMapFusion ReverseReverse
SUBDIRS = AccumulatingParam-Peano AccumulatingParam Ackermann AckermannPeano-1 AckermannPeano-2 EvenDouble EvenDoubleGenerator Generalisation KMP LetRec MapMapFusion ReverseReverse queens-explicit
# Covered by Peter somewhat already:
# AppendAssociativity
# Covered by other benchmarks:
......
......@@ -7,7 +7,12 @@ import System.Environment
main :: IO ()
main = do
[n] <- fmap (map read) getArgs
print (root [1..(n :: Int)])
print (root (my_enum 1 n))
-- Prevent benchmark results being skewed because rewrite rules have access to more information than the SC does:
my_enum :: Int -> Int -> [Int]
my_enum n m | n > m = []
| otherwise = n : my_enum (n+1) m
{-
map f xs = case xs of
......
-- !!! count the number of solutions to the "n queens" problem.
-- (grabbed from LML dist)
import System.Environment
main = do
[arg] <- getArgs
print $ nsoln $ read arg
nsoln nq = length (gen nq)
where
safe :: Int -> Int -> [Int] -> Bool
safe x d [] = True
safe x d (q:l) = x /= q && x /= q+d && x /= q-d && safe x (d+1) l
gen :: Int -> [[Int]]
gen 0 = [[]]
gen n = -- [ (q:b) | b <- gen (n-1), q <- [1..nq], safe q 1 b]
go1 [] (gen (n - 1))
where
go1 tl [] = tl
go1 tl (b:bs) = go2 (go1 tl bs) [1..nq]
where
go2 tl [] = tl
go2 tl (q:qs) = go3 (go2 tl qs)
where go3 tl = if safe q 1 b then (q:b):tl else tl
TOP = ../../..
include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
SRCS = Main.hs
FAST_OPTS = 10
NORM_OPTS = 10
SLOW_OPTS = 12
SRC_SUPERCOMP_HC_OPTS =
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