haskell / haskell/parallel

parBuffer doesn't use all cores when told to.

Open
#67 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
98
Forks
24
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/haskell/parallel/assets/357229/4369067a-362d-4a8d-b62d-ed011306ad9f)

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.