aivika-distributed 1.4 → 1.5
raw patch · 13 files changed
+64/−51 lines, 13 filesdep +vectordep ~aivikadep ~aivika-transformersdep ~distributed-processPVP ok
version bump matches the API change (PVP)
Dependencies added: vector
Dependency ranges changed: aivika, aivika-transformers, distributed-process, mwc-random
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- Simulation/Aivika/Distributed/Optimistic/DIO.hs +1/−1
- Simulation/Aivika/Distributed/Optimistic/Generator.hs +1/−1
- Simulation/Aivika/Distributed/Optimistic/Internal/AcknowledgementMessageQueue.hs +1/−0
- Simulation/Aivika/Distributed/Optimistic/Internal/Channel.hs +1/−0
- Simulation/Aivika/Distributed/Optimistic/Internal/DIO.hs +1/−4
- Simulation/Aivika/Distributed/Optimistic/Internal/Event.hs +9/−7
- Simulation/Aivika/Distributed/Optimistic/Internal/InputMessageQueue.hs +2/−0
- Simulation/Aivika/Distributed/Optimistic/Internal/OutputMessageQueue.hs +1/−0
- Simulation/Aivika/Distributed/Optimistic/Internal/TransientMessageQueue.hs +1/−0
- Simulation/Aivika/Distributed/Optimistic/Internal/UndoableLog.hs +17/−16
- Simulation/Aivika/Distributed/Optimistic/Message.hs +3/−0
- aivika-distributed.cabal +21/−22
CHANGELOG.md view
@@ -1,4 +1,9 @@ +Version 1.5+-----++* Updated dependencies and fixed warnings.+ Version 1.4 -----
Simulation/Aivika/Distributed/Optimistic/DIO.hs view
@@ -1,5 +1,5 @@ -{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, OverlappingInstances #-}+{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} -- | -- Module : Simulation.Aivika.Distributed.Optimistic.DIO
Simulation/Aivika/Distributed/Optimistic/Generator.hs view
@@ -71,7 +71,7 @@ case tp of SimpleGenerator -> do let g = MWC.uniform <$>- MWC.withSystemRandom (return :: MWC.GenIO -> IO MWC.GenIO)+ MWC.createSystemRandom g' <- liftIOUnsafe g newRandomGenerator01 (liftIOUnsafe g') SimpleGeneratorWithSeed x ->
Simulation/Aivika/Distributed/Optimistic/Internal/AcknowledgementMessageQueue.hs view
@@ -51,6 +51,7 @@ -- | Return the acknowledgement message queue size. acknowledgementMessageQueueSize :: AcknowledgementMessageQueue -> IO Int+{-# INLINE acknowledgementMessageQueueSize #-} acknowledgementMessageQueueSize = vectorCount . acknowledgementMessages -- | Return a complement.
Simulation/Aivika/Distributed/Optimistic/Internal/Channel.hs view
@@ -42,6 +42,7 @@ -- | Test quickly whether the channel is empty. channelEmpty :: Channel a -> IO Bool+{-# INLINE channelEmpty #-} channelEmpty ch = readIORef (channelListEmptyIO ch)
Simulation/Aivika/Distributed/Optimistic/Internal/DIO.hs view
@@ -151,9 +151,6 @@ instance Monad DIO where - {-# INLINE return #-}- return = DIO . const . return- {-# INLINE (>>=) #-} (DIO m) >>= k = DIO $ \ps -> m ps >>= \a ->@@ -162,7 +159,7 @@ instance Applicative DIO where {-# INLINE pure #-}- pure = return+ pure = DIO . const . pure {-# INLINE (<*>) #-} (<*>) = ap
Simulation/Aivika/Distributed/Optimistic/Internal/Event.hs view
@@ -1,5 +1,5 @@ -{-# LANGUAGE TypeFamilies, FlexibleInstances, OverlappingInstances #-}+{-# LANGUAGE TypeFamilies, FlexibleInstances #-} -- | -- Module : Simulation.Aivika.Distributed.Optimistic.Internal.Event@@ -30,7 +30,7 @@ import Control.Exception import qualified Control.Distributed.Process as DP -import qualified Simulation.Aivika.PriorityQueue.Pure as PQ+import qualified Simulation.Aivika.PriorityQueue.EventQueue.Pure as PQ import Simulation.Aivika.Trans import Simulation.Aivika.Trans.Internal.Types@@ -115,11 +115,11 @@ queueProcessMonitorNotificationSource = s, queueIsLeaving = leaving } - enqueueEvent t (Event m) =+ enqueueEventWithPriority t priority (Event m) = Event $ \p -> let pq = queuePQ $ runEventQueue $ pointRun p in invokeEvent p $- R.modifyRef pq $ \x -> PQ.enqueue x t m+ R.modifyRef pq $ \x -> PQ.enqueue x t priority m runEventWith processing (Event e) = Dynamics $ \p ->@@ -217,7 +217,7 @@ else do -- proceed with processing the events f <- invokeEvent p1 $ fmap PQ.queueNull $ R.readRef pq unless f $- do (t2, c2) <- invokeEvent p1 $ fmap PQ.queueFront $ R.readRef pq+ do (t2, priority2, c2) <- invokeEvent p1 $ fmap PQ.queueFront $ R.readRef pq let t = queueTime q t' <- liftIOUnsafe $ readIORef t when (t2 < t') $ @@ -232,6 +232,7 @@ dt = spcDT sc n2 = fromIntegral $ floor ((t2 - t0) / dt) p2 = p { pointTime = t2,+ pointPriority = priority2, pointIteration = n2, pointPhase = -1 } ---@@ -853,6 +854,7 @@ Event $ \p -> do let q = runEventQueue $ pointRun p t = pointTime p+ priority = pointPriority p --- logDIO INFO $ "t = " ++ show (pointTime p) ++@@ -883,8 +885,8 @@ let f = PQ.queueNull pq if f then await loop'- else do let (t2, _) = PQ.queueFront pq- if t < t2+ else do let (t2, priority2, _) = PQ.queueFront pq+ if (t < t2) || (t == t2 && priority > priority2) then await loop' else invokeEvent p $ enqueueEvent t $
Simulation/Aivika/Distributed/Optimistic/Internal/InputMessageQueue.hs view
@@ -100,10 +100,12 @@ -- | Return the input message queue size. inputMessageQueueSize :: InputMessageQueue -> IO Int+{-# INLINE inputMessageQueueSize #-} inputMessageQueueSize = vectorCount . inputMessages -- | Return the reversion count. inputMessageQueueVersion :: InputMessageQueue -> IO Int+{-# INLINE inputMessageQueueVersion #-} inputMessageQueueVersion = readIORef . inputMessageVersionRef -- | Return a complement.
Simulation/Aivika/Distributed/Optimistic/Internal/OutputMessageQueue.hs view
@@ -58,6 +58,7 @@ -- | Return the output message queue size. outputMessageQueueSize :: OutputMessageQueue -> IO Int+{-# INLINE outputMessageQueueSize #-} outputMessageQueueSize = DLL.listCount . outputMessages -- | Send the message.
Simulation/Aivika/Distributed/Optimistic/Internal/TransientMessageQueue.hs view
@@ -107,6 +107,7 @@ -- | Get the transient message queue size. transientMessageQueueSize :: TransientMessageQueue -> IO Int+{-# INLINE transientMessageQueueSize #-} transientMessageQueueSize q = fmap M.size $ readIORef (queueTransientMessages q)
Simulation/Aivika/Distributed/Optimistic/Internal/UndoableLog.hs view
@@ -18,7 +18,8 @@ logSize) where import Data.IORef-import Data.Array.IO.Safe+import qualified Data.Vector.Mutable as V+import qualified Data.Vector.Unboxed.Mutable as UV import Control.Monad import Control.Monad.Trans@@ -43,9 +44,9 @@ -- ^ the start item index in the chunk. chunkItemEnd :: IORef Int, -- ^ the end item index in the chunk.- chunkItemTimes :: IOUArray Int Double,+ chunkItemTimes :: UV.IOVector Double, -- ^ the times at which the operations had occurred.- chunkItemUndo :: IOArray Int (DIO ())+ chunkItemUndo :: V.IOVector (DIO ()) -- ^ the undo operations. } @@ -74,7 +75,7 @@ DLL.listAddLast (logItemChunks log) ch else do ch <- DLL.listLast (logItemChunks log) e <- readIORef (chunkItemEnd ch)- t0 <- readArray (chunkItemTimes ch) (e - 1)+ t0 <- UV.read (chunkItemTimes ch) (e - 1) when (t < t0) $ error $ "The logging data are not sorted by time (" ++@@ -84,8 +85,8 @@ then do ch <- newItemChunk t h DLL.listAddLast (logItemChunks log) ch else do let e' = e + 1- writeArray (chunkItemTimes ch) e t- writeArray (chunkItemUndo ch) e h+ UV.write (chunkItemTimes ch) e t+ V.write (chunkItemUndo ch) e h e' `seq` writeIORef (chunkItemEnd ch) e' -- | Rollback the log till the specified time either including that one or not.@@ -106,10 +107,10 @@ then do liftIOUnsafe $ DLL.listRemoveLast (logItemChunks log) loop else do let e' = e - 1- t0 <- e' `seq` liftIOUnsafe $ readArray (chunkItemTimes ch) e'+ t0 <- e' `seq` liftIOUnsafe $ UV.read (chunkItemTimes ch) e' when ((t < t0) || (including && t == t0)) $- do h <- liftIOUnsafe $ readArray (chunkItemUndo ch) e'- liftIOUnsafe $ writeArray (chunkItemUndo ch) e' undefined+ do h <- liftIOUnsafe $ V.read (chunkItemUndo ch) e'+ liftIOUnsafe $ V.write (chunkItemUndo ch) e' undefined liftIOUnsafe $ writeIORef (chunkItemEnd ch) e' h inner e'@@ -123,17 +124,17 @@ unless f $ do ch <- DLL.listFirst (logItemChunks log) e <- readIORef (chunkItemEnd ch)- t0 <- readArray (chunkItemTimes ch) (e - 1)+ t0 <- UV.read (chunkItemTimes ch) (e - 1) if t0 < t then do DLL.listRemoveFirst (logItemChunks log) reduceLog log t else do let loop s = if s == e then error "The log is corrupted: reduceLog"- else do t0 <- readArray (chunkItemTimes ch) s+ else do t0 <- UV.read (chunkItemTimes ch) s when (t0 < t) $ do let s' = s + 1- writeArray (chunkItemUndo ch) s undefined+ V.write (chunkItemUndo ch) s undefined s' `seq` writeIORef (chunkItemStart ch) s' loop s' s <- readIORef (chunkItemStart ch)@@ -157,12 +158,12 @@ newItemChunk :: Double -> DIO () -> IO UndoableItemChunk {-# INLINABLE newItemChunk #-} newItemChunk t h =- do times <- newArray_ (0, chunkItemCapacity - 1)- undo <- newArray_ (0, chunkItemCapacity - 1)+ do times <- UV.new chunkItemCapacity+ undo <- V.new chunkItemCapacity start <- newIORef 0 end <- newIORef 1- writeArray times 0 t- writeArray undo 0 h+ UV.write times 0 t+ V.write undo 0 h return UndoableItemChunk { chunkItemStart = start, chunkItemEnd = end, chunkItemTimes = times,
Simulation/Aivika/Distributed/Optimistic/Message.hs view
@@ -39,12 +39,14 @@ -- | Send a message to the specified remote process with the current receive time. sendMessage :: forall a. Serializable a => ProcessId -> a -> Event DIO ()+{-# INLINABLE sendMessage #-} sendMessage pid a = do t <- liftDynamics time enqueueMessage pid t a -- | Send a message to the specified remote process with the given receive time. enqueueMessage :: forall a. Serializable a => ProcessId -> Double -> a -> Event DIO ()+{-# INLINABLE enqueueMessage #-} enqueueMessage pid t a = Event $ \p -> do let queue = queueOutputMessages $@@ -68,6 +70,7 @@ -- | The signal triggered when the remote message of the specified type has come. messageReceived :: forall a. Serializable a => Signal DIO a+{-# INLINABLE messageReceived #-} messageReceived = Signal { handleSignal = \h -> Event $ \p ->
aivika-distributed.cabal view
@@ -1,5 +1,5 @@ name: aivika-distributed-version: 1.4+version: 1.5 synopsis: Parallel distributed discrete event simulation module for the Aivika library description: This package extends the aivika-transformers [1] package and allows running parallel distributed simulations.@@ -23,7 +23,6 @@ There are additional packages that allow you to run the distributed simulation experiments by using the Monte-Carlo method. They allow you to save the simulation results in SQL databases and then generate a report or a set of reports consisting of HTML pages with charts, histograms, links to CSV tables, summary statistics etc.- Please consult the AivikaSoft [3] website for more details. . Regarding the speed of simulation, the recent rough estimation is as follows. This estimation may change from version to version. For example, in version 1.0 the rollback log was rewritten, which had a significant effect.@@ -51,16 +50,14 @@ . \[2] <http://hackage.haskell.org/package/aivika> .- \[3] <http://www.aivikasoft.com>- . category: Simulation license: BSD3 license-file: LICENSE-copyright: (c) 2015-2018. David Sorokin <david.sorokin@gmail.com>+copyright: (c) 2015-2024. David Sorokin <davsor@mail.ru> author: David Sorokin-maintainer: David Sorokin <david.sorokin@gmail.com>-homepage: http://www.aivikasoft.com-cabal-version: >= 1.6+maintainer: David Sorokin <davsor@mail.ru>+homepage: https://gitflic.ru/project/dsorokin/aivika-distributed+cabal-version: >= 1.10 build-type: Simple tested-with: GHC == 7.10.1 @@ -123,28 +120,30 @@ array >= 0.3.0.0, stm >= 2.4.2, random >= 1.0.0.3,- mwc-random >= 0.13.0.0,+ mwc-random >= 0.13.1.0, binary >= 0.6.4.0, time >= 1.5.0.1, containers >= 0.4.0.0, exceptions >= 0.8.0.2,- distributed-process >= 0.6.1,- aivika >= 5.3.1,- aivika-transformers >= 5.3.1+ distributed-process >= 0.7.6,+ vector >= 0.10.0.1,+ aivika >= 6.0.0,+ aivika-transformers >= 6.0.0 - extensions: MultiParamTypeClasses,- FlexibleInstances,- FlexibleContexts,- TypeFamilies,- RankNTypes,- DeriveGeneric,- DeriveDataTypeable,- OverlappingInstances,- MonoLocalBinds+ other-extensions: MultiParamTypeClasses,+ FlexibleInstances,+ FlexibleContexts,+ TypeFamilies,+ RankNTypes,+ DeriveGeneric,+ DeriveDataTypeable,+ MonoLocalBinds ghc-options: -O2 + default-language: Haskell2010+ source-repository head type: git- location: https://github.com/dsorokin/aivika-distributed+ location: https://gitflic.ru/project/dsorokin/aivika-distributed