[commit: ghc] ghc-lwc2: Simplifications of the benchmarks (45a77b6)
Sivaramakrishnan Krishnamoorthy Chandrasekaran
t-sichan at microsoft.com
Sat Apr 27 04:22:53 CEST 2013
Repository : http://darcs.haskell.org/ghc.git/
On branch : ghc-lwc2
https://github.com/ghc/ghc/commit/45a77b65a72caec59a9259139180f61e7895e298
>---------------------------------------------------------------
commit 45a77b65a72caec59a9259139180f61e7895e298
Author: KC Sivaramakrishnan <chandras at cs.purdue.edu>
Date: Thu Apr 25 13:32:01 2013 -0400
Simplifications of the benchmarks
>---------------------------------------------------------------
tests/Benchmarks/ChameneosRedux/MVarList.hs | 2 +-
tests/Benchmarks/ChameneosRedux/Makefile | 2 +-
tests/Benchmarks/Sieve/sieve-lwc.hs | 12 +++++-------
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/tests/Benchmarks/ChameneosRedux/MVarList.hs b/tests/Benchmarks/ChameneosRedux/MVarList.hs
index e738bf5..60c8bc6 100644
--- a/tests/Benchmarks/ChameneosRedux/MVarList.hs
+++ b/tests/Benchmarks/ChameneosRedux/MVarList.hs
@@ -59,7 +59,7 @@ import GHC.IORef
-- x:tl -> (Queue tl back, Just x)
-- NOTE KC: Even a list seems to work just as well as a queue.
-newtype Queue a = Queue [a]
+data Queue a = Queue [a]
_INL_(emptyQueue)
emptyQueue :: Queue a
diff --git a/tests/Benchmarks/ChameneosRedux/Makefile b/tests/Benchmarks/ChameneosRedux/Makefile
index 3601228..267677a 100644
--- a/tests/Benchmarks/ChameneosRedux/Makefile
+++ b/tests/Benchmarks/ChameneosRedux/Makefile
@@ -5,7 +5,7 @@ include ../../config.mk
TOP := ../../../
GHC_OPTS_EXTRA=-O2 -threaded -XBangPatterns -XCPP -XGeneralizedNewtypeDeriving -funbox-strict-fields -optc-O3
-PROFILE_FLAGS := -DPROFILE_ENABLED -prof -auto-all -fprof-auto
+PROFILE_FLAGS := -DPROFILE_ENABLED -prof -fprof-auto -auto -auto-all
#Uncomment the following line to enable profiled compilation
#GHC_OPTS_EXTRA += $(PROFILE_FLAGS)
diff --git a/tests/Benchmarks/Sieve/sieve-lwc.hs b/tests/Benchmarks/Sieve/sieve-lwc.hs
index 2935752..bf8ccae 100644
--- a/tests/Benchmarks/Sieve/sieve-lwc.hs
+++ b/tests/Benchmarks/Sieve/sieve-lwc.hs
@@ -18,9 +18,8 @@ generate mOut = mapM_ (putMVar mOut) [2..]
-- Take a value from mIn, divide it by a prime, if the remainder is not 0, put the value in mOut.
primeFilter :: MVar Int -> MVar Int -> Int -> IO ()
primeFilter mIn mOut prime = do
- hole <- newIORef 0
forever $ do
- i <- takeMVarWithHole mIn hole
+ i <- takeMVar mIn
when (i `mod` prime /= 0) (putMVar mOut i)
-- Take the first commandline argument and call it numArg.
@@ -34,15 +33,14 @@ main = do
mIn <- newEmptyMVar
forkIO $ generate mIn
out <- replicateM (read numArg) newEmptyMVar
- hole <- newIORef 0
- foldM_ (linkFilter hole) mIn out
+ foldM_ linkFilter mIn out
-- Take a value from mIn, and call it prime. Then show that prime. Make a new thread that
-- runs primeFilter with mIn, mOut and the prime. When this function is used as a fold
-- function, mOut becomes the mIn of the next iteration.
-linkFilter :: IORef Int -> MVar Int -> MVar Int -> IO (MVar Int)
-linkFilter hole mIn mOut = do
- prime <- takeMVarWithHole mIn hole
+linkFilter :: MVar Int -> MVar Int -> IO (MVar Int)
+linkFilter mIn mOut = do
+ prime <- takeMVar mIn
putStrLn $ show prime
forkIO $ primeFilter mIn mOut prime
return mOut
More information about the ghc-commits
mailing list