[commit: ghc] ghc-lwc2: Added missing file -- sieve-vanilla-TMVar (4dbe94d)

Sivaramakrishnan Krishnamoorthy Chandrasekaran t-sichan at microsoft.com
Tue Apr 30 22:20:09 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : ghc-lwc2

https://github.com/ghc/ghc/commit/4dbe94d9a59e45e17e2d58967cece904f6cfac1f

>---------------------------------------------------------------

commit 4dbe94d9a59e45e17e2d58967cece904f6cfac1f
Author: KC Sivaramakrishnan <chandras at cs.purdue.edu>
Date:   Tue Apr 30 16:19:07 2013 -0400

    Added missing file -- sieve-vanilla-TMVar

>---------------------------------------------------------------

 .../Sieve/{sieve-TMVar.hs => sieve-vanilla-TMVar.hs}  | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/tests/Benchmarks/Sieve/sieve-TMVar.hs b/tests/Benchmarks/Sieve/sieve-vanilla-TMVar.hs
similarity index 82%
copy from tests/Benchmarks/Sieve/sieve-TMVar.hs
copy to tests/Benchmarks/Sieve/sieve-vanilla-TMVar.hs
index bfbed63..8263ada 100644
--- a/tests/Benchmarks/Sieve/sieve-TMVar.hs
+++ b/tests/Benchmarks/Sieve/sieve-vanilla-TMVar.hs
@@ -1,16 +1,10 @@
 import Control.Monad
+import Control.Monad.STM
+import Control.Concurrent.STM.TMVar
+import Control.Concurrent
 import Control.Exception
-import LwConc.Substrate
-import ConcurrentList
-import LwConc.PTM.TMVar
 import System.Environment
 import Data.IORef
-import Debug.Trace
-
-initSched = uninterruptibleMask_ $ do
-  newSched
-  n <- getNumCapabilities
-  replicateM_ (n-1) newCapability
 
 -- Map over [2..] (2 until infinity), putting the value in mOut. The putting operation will block until
 -- mOut is empty. mOut will become empty when some other thread executes takeTMVar (getting its value).
@@ -30,12 +24,10 @@ primeFilter mIn mOut prime = do
 -- calling the result out.
 -- Fold over the elements of out, with the function linkFilter, having mIn as the first value.
 main = do
-  initSched
   numArg:_ <- getArgs
-  let n = read numArg
-  mIn <- newEmptyTMVarIO
+  mIn <- atomically $ newEmptyTMVar
   forkIO $ generate mIn
-  out <- replicateM n newEmptyTMVarIO
+  out <- replicateM (read numArg) (atomically newEmptyTMVar)
   foldM_ linkFilter mIn out
 
 -- Take a value from mIn, and call it prime. Then show that prime. Make a new thread that
@@ -45,6 +37,5 @@ linkFilter :: TMVar Int -> TMVar Int -> IO (TMVar Int)
 linkFilter mIn mOut = do
   prime <- atomically $ takeTMVar mIn
   putStrLn $ show prime
-  -- debugPrint $ show prime
   forkIO $ primeFilter mIn mOut prime
   return mOut





More information about the ghc-commits mailing list