Benchmark Log
PMMH Inference on HMM
This details the benchmarks for a program using monad-bayes to run PMMH inference on a HMM, whilst tactically adding various {-# INLINE #-} pragmas to functions of the monad-bayes library in response to analysing the Haskell core generated. Each benchmark is the average over 4 iterations.
Source Program
main = defaultMain [
bgroup "runPmmh" [ bench "(100, 100, 100)" $ whnfIO $ runPmmh (100, 100, 100)
]
]
runPmmh :: (Int, Int, Int) -> IO ()
runPmmh (n_mhsteps, n_timesteps, n_particles) = do
particleWeightings <- inferModel n_mhsteps n_timesteps n_particles
print particleWeightings
- Original Code

- Inline pragma added to
pmmhfunction

- Inline pragma added to
pushEvidencefunction

- Inline pragma added to
hoistfunction

- Inline pragma added to
mhTransfunctions

- Inline pragma added to Traced.Static
>>=of theTracedmonad

- Inlines to
prior,extractWeight,flatten&applyWeightofBayes.Weighted.

- Added inlines to
resampleGeneric,resampleSystematic,runWeighted,sir.

- Locally cloned
Control.Monad.Coroutinemodule and inlined the definition of>>.

- Adding an
INLINABLEpragma to>>=of theControl.Monad.Coroutinemodule.

- Added bang-patterns to
Paramsdatatype ofPmmhHmm.hs. AddedINLINABLEtoawaitofControl.Monad.Coroutine.SuspensionFunctors. Unpacked and added bang-patterns to all possible parameters of theTracedatatype ofBayes.Traced.Common.

-
INLINABLEpragmas were added torunPopulation,explicitPopulation,extractEvidence,proper,evidence, andcollapseofBayes.Population.Also, the arguments of the
Traceddatatype fromBayes.Traced.Staticwere made strict. This made things slower (so these changes were undone.)

- Implemented and integrated CPS version of
StateTmonad.
