Skip to content

Commit

Permalink
Simplifications of the benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
kayceesrk committed Apr 25, 2013
1 parent 6828d71 commit 45a77b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/Benchmarks/ChameneosRedux/MVarList.hs
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Benchmarks/ChameneosRedux/Makefile
Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions tests/Benchmarks/Sieve/sieve-lwc.hs
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit 45a77b6

Please sign in to comment.