Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parBuffer doesn't use all cores when told to. #67

Open
noahmartinwilliams opened this issue Nov 21, 2023 · 0 comments
Open

parBuffer doesn't use all cores when told to. #67

noahmartinwilliams opened this issue Nov 21, 2023 · 0 comments

Comments

@noahmartinwilliams
Copy link

I tried compiling the following code with ghc-9.2.8:

module Main (main) where

import Control.Parallel.Strategies
import GHC.Conc
import System.IO
import Text.Printf

sigmoid :: Double -> Double
sigmoid x = 1.0 / (1.0 + (exp (-x)))

genStuff :: [String]
genStuff = do
    let ints = [0..]
        doubles = map (\x -> fromIntegral x :: Double) ints
        sigmoids = map (\x -> sigmoid x) doubles
        strs = map (\x -> (printf "%.5F" x) ++ "\n") sigmoids
    strs

main :: IO ()
main = do
    hSetBuffering stdout LineBuffering
    let stuff = genStuff `using` parBuffer numCapabilities rdeepseq
    putStr (foldr (++) "" (take 100000 stuff))

And I compiled it with -threaded -rtsopts -eventlog and used threadscope to look at the results, and got this:

threadscope-parbuffer-test

I'm pretty sure that it should be using all of the cores consistently, shouldn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant