[Haskell-cafe] Processor availability
How might I go about finding out how many processors are available in a concurrent GHC program? I have some code I'd like to parallelize, but I don't want to spawn a separate (even lightweight) thread for each of thousands of minor tasks. Louis Wasserman wasserman.lo...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Processor availability
wasserman.louis: How might I go about finding out how many processors are available in a concurrent GHC program? I have some code I'd like to parallelize, but I don't want to spawn a separate (even lightweight) thread for each of thousands of minor tasks. Louis Wasserman [1]wasserman.lo...@gmail.com You set the number of OS threads with +RTS -N at runtime. This value is accessible from Haskell via: GHC.Conc: -- | the value passed to the @+RTS -N@ flag. This is the number of -- Haskell threads that can run truly simultaneously at any given -- time, and is typically set to the number of physical CPU cores on -- the machine. numCapabilities :: Int -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Processor availability
2009/1/22 Louis Wasserman wasserman.lo...@gmail.com: How might I go about finding out how many processors are available in a concurrent GHC program? I have some code I'd like to parallelize, but I don't want to spawn a separate (even lightweight) thread for each of thousands of minor tasks. Use a thread pool and feed it tasks. Control.Concurrent.Chan makes a good queue. Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Processor availability
2009/1/22 Louis Wasserman wasserman.lo...@gmail.com How might I go about finding out how many processors are available in a concurrent GHC program? I have some code I'd like to parallelize, but I don't want to spawn a separate (even lightweight) thread for each of thousands of minor tasks. Consider using Contorl.Parallel.Strategies which allows you to spark of lightweight jobs that get run on a pool of threads. -- Sebastian Sylvan +44(0)7857-300802 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe