monad-par 0.3.5 → 0.3.6
raw patch · 6 files changed
+36/−20 lines, 6 filesdep ~basedep ~mtlnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, mtl
API changes (from Hackage documentation)
Files
- Control/Monad/Par/IO.hs +1/−1
- Control/Monad/Par/Scheds/Direct.hs +5/−2
- Control/Monad/Par/Scheds/DirectInternal.hs +13/−7
- Control/Monad/Par/Scheds/TraceInternal.hs +11/−6
- monad-par.cabal +5/−3
- tests/TestHelpers.hs +1/−1
Control/Monad/Par/IO.hs view
@@ -27,7 +27,7 @@ -- | A run method which allows actual IO to occur on top of the Par -- monad. Of course this means that all the normal problems of--- parallel IO computations are present, including nondeterminsm.+-- parallel IO computations are present, including nondeterminism. -- -- A simple example program: --
Control/Monad/Par/Scheds/Direct.hs view
@@ -36,6 +36,9 @@ import Data.IORef (IORef,newIORef,readIORef,writeIORef,atomicModifyIORef) import Text.Printf (printf) import GHC.Conc (numCapabilities,yield)+import Control.Monad+import Control.Monad.IO.Class+import Control.Monad.Trans import "mtl" Control.Monad.Cont as C import qualified "mtl" Control.Monad.Reader as RD import qualified System.Random.MWC as Random@@ -228,7 +231,7 @@ tryWakeIdle :: HotVar [MVar Bool] -> IO () tryWakeIdle idle = do--- NOTE: I worry about having the idle var hammmered by all threads on their spawn-path:+-- NOTE: I worry about having the idle var hammered by all threads on their spawn-path: -- If any worker is idle, wake one up and give it work to do. idles <- readHotVar idle -- Optimistically do a normal read first. when (not (Prelude.null idles)) $ do@@ -658,7 +661,7 @@ -- | Attempt to steal work or, failing that, give up and go idle. -- -- The current policy is to do a burst of of N tries without--- yielding or pausing inbetween.+-- yielding or pausing in between. steal :: Sched -> IO () steal mysched@Sched{ idle, scheds, rng, no=my_no } = do when (dbglvl>=2)$ do tid <- myThreadId
Control/Monad/Par/Scheds/DirectInternal.hs view
@@ -1,15 +1,20 @@-{-# LANGUAGE PackageImports, CPP, GeneralizedNewtypeDeriving #-}+{-# LANGUAGE PackageImports, CPP, GeneralizedNewtypeDeriving,+ DeriveDataTypeable #-} --- | Type definiton and some helpers. This is used mainly by+-- | Type definition and some helpers. This is used mainly by -- Direct.hs but can also be used by other modules that want access to -- the internals of the scheduler (i.e. the private `Par` type constructor). module Control.Monad.Par.Scheds.DirectInternal where +#if !MIN_VERSION_base(4,6,0)+import Prelude hiding (catch)+#endif+ import Control.Applicative import "mtl" Control.Monad.Cont as C import qualified "mtl" Control.Monad.Reader as RD-import Control.Monad.IO.Class (liftIO)+import "mtl" Control.Monad.Trans (liftIO) import qualified System.Random.MWC as Random @@ -20,10 +25,10 @@ import Data.Word (Word64) import Data.Concurrent.Deque.Class (WSDeque) import Control.Monad.Fix (MonadFix (mfix))-#if MIN_VERSION_base(4,4,0)+#if MIN_VERSION_base(4,9,0) import GHC.IO.Unsafe (unsafeDupableInterleaveIO) #else-import GHC.IO.Unsafe (unsafeInterleaveIO)+import System.IO.Unsafe (unsafeInterleaveIO) #endif #ifdef USE_CHASELEV@@ -32,6 +37,7 @@ import Data.Concurrent.Deque.ChaseLev as R #endif +import Data.Typeable (Typeable) import Control.Exception (Exception, throwIO, BlockedIndefinitelyOnMVar (..), catch) @@ -70,12 +76,12 @@ flip RD.runReaderT sched $ runContT (unPar (f ans)) $ \a -> liftIO (putMVar mv a) >> ar a -#if !MIN_VERSION_base(4,4,0)+#if !MIN_VERSION_base(4,9,0) unsafeDupableInterleaveIO :: IO a -> IO a unsafeDupableInterleaveIO = unsafeInterleaveIO #endif -data FixParException = FixParException deriving Show+data FixParException = FixParException deriving (Show, Typeable) instance Exception FixParException type SessionID = Word64
Control/Monad/Par/Scheds/TraceInternal.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE RankNTypes, NamedFieldPuns, BangPatterns,- ExistentialQuantification, CPP #-}+ ExistentialQuantification, CPP, DeriveDataTypeable #-} {-# OPTIONS_GHC -Wall -fno-warn-name-shadowing -fno-warn-unused-do-bind #-} -- | This module exposes the internals of the @Par@ monad so that you@@ -17,15 +17,19 @@ pollIVar, yield, fixPar, FixParException (..) ) where +#if MIN_VERSION_base(4,6,0)+import Prelude hiding (mapM, sequence, head,tail)+#else+import Prelude hiding (mapM, sequence, head,tail,catch)+#endif import Control.Monad as M hiding (mapM, sequence, join)-import Prelude hiding (mapM, sequence, head,tail) import Data.IORef import System.IO.Unsafe-#if MIN_VERSION_base(4,4,0)+#if MIN_VERSION_base(4,9,0) import GHC.IO.Unsafe (unsafeDupableInterleaveIO) #else-import GHC.IO.Unsafe (unsafeInterleaveIO)+import System.IO.Unsafe (unsafeInterleaveIO) #endif import Control.Concurrent hiding (yield) import GHC.Conc (numCapabilities)@@ -33,6 +37,7 @@ import Control.Monad.Fix (MonadFix (mfix)) import Control.Exception (Exception, throwIO, BlockedIndefinitelyOnMVar (..), catch)+import Data.Typeable (Typeable) -- import Text.Printf #if !MIN_VERSION_base(4,8,0)@@ -105,7 +110,7 @@ r <- io loop (c r) -data FixParException = FixParException deriving Show+data FixParException = FixParException deriving (Show, Typeable) instance Exception FixParException -- | Process the next item on the work queue or, failing that, go into@@ -213,7 +218,7 @@ case f ans of Par q -> pure $ q $ \a -> LiftIO (putMVar mv a) (\ ~() -> c a)) id -#if !MIN_VERSION_base(4,4,0)+#if !MIN_VERSION_base(4,9,0) unsafeDupableInterleaveIO :: IO a -> IO a unsafeDupableInterleaveIO = unsafeInterleaveIO #endif
monad-par.cabal view
@@ -1,5 +1,5 @@ Name: monad-par-Version: 0.3.5+Version: 0.3.6 Synopsis: A library for parallel programming based on a monad @@ -61,7 +61,7 @@ Stability: Experimental Category: Control,Parallelism,Monads Build-type: Simple-Cabal-version: >=1.8+Cabal-version: >=1.10 extra-source-files: tests/AListTest.hs@@ -91,6 +91,7 @@ location: https://github.com/simonmar/monad-par Library+ Default-Language: Haskell98 Exposed-modules: -- The classic, simple monad-par interface: Control.Monad.Par@@ -160,12 +161,13 @@ Test-Suite test-monad-par+ Default-Language: Haskell98 type: exitcode-stdio-1.0 main-is: tests/AllTests.hs hs-source-dirs: tests/ ./ -- Run tests in parallel: ghc-options: -O2 -threaded -rtsopts -with-rtsopts=-N4 - build-depends: base >= 4 && < 5+ build-depends: base >= 4.3 && < 5 , abstract-par, monad-par-extras , array >= 0.3 , deepseq >= 1.2
tests/TestHelpers.hs view
@@ -27,7 +27,7 @@ loop !n !x = loop (n-1) (x + x * 0.5011) -- This version watches the clock so it uses a constant amount of time--- regadless of compile/interpret mode an opt lvl.+-- regardless of compile/interpret mode an opt lvl. waste_time :: Double -> IO Double waste_time seconds = do strt <- getCurrentTime