diff options
| author | Simon Marlow <marlowsd@gmail.com> | 2012-02-13 11:17:50 +0000 |
|---|---|---|
| committer | Simon Marlow <marlowsd@gmail.com> | 2012-02-13 12:26:10 +0000 |
| commit | 67f4ab7e6b7705a9d617c6109a8c5434ede13cae (patch) | |
| tree | 8f1ed63f526c3a88a4f234c9a3d5b5ac2a9eb0c6 /compiler/codeGen/CgParallel.hs | |
| parent | 86ebfef9a5acc60b7a2ce3c8f025e6e707f17f87 (diff) | |
| download | haskell-67f4ab7e6b7705a9d617c6109a8c5434ede13cae.tar.gz | |
Allocate pinned object blocks from the nursery, not the global
allocator.
Prompted by a benchmark posted to parallel-haskell@haskell.org by
Andreas Voellmy <andreas.voellmy@gmail.com>. This program exhibits
contention for the block allocator when run with -N2 and greater
without the fix:
{-# LANGUAGE MagicHash, UnboxedTuples, BangPatterns #-}
module Main where
import Control.Monad
import Control.Concurrent
import System.Environment
import GHC.IO
import GHC.Exts
import GHC.Conc
main = do
[m] <- fmap (fmap read) getArgs
n <- getNumCapabilities
ms <- replicateM n newEmptyMVar
sequence [ forkIO $ busyWorkerB (m `quot` n) >> putMVar mv () | mv <- ms ]
mapM takeMVar ms
busyWorkerB :: Int -> IO ()
busyWorkerB n_loops = go 0
where go !n | n >= n_loops = return ()
| otherwise =
do p <- (IO $ \s ->
case newPinnedByteArray# 1024# s of
{ (# s', mbarr# #) ->
(# s', () #)
}
)
go (n+1)
Diffstat (limited to 'compiler/codeGen/CgParallel.hs')
0 files changed, 0 insertions, 0 deletions
