
Hello all, I'm googling around haskell.org to get some deeper knowledge about Control.Parallel.Strategies than it is presented on http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Parallel-... BTW, could someone point me to some more deeper doc. about it? During googling I've discovered that since GHC 6.6, par, forkIO, and forkOS should make the stuff run in parallel if I have more than one CPU core. Is that right? I think not, because on my machine only par makes the things run in parallel and only during the computation (GC runs in a single thread). If it should work, how can I verify that my installation is correct? If it should not work, will it be working someday? Thanks for your patience, responses, and tips Dusan

Simon will probably chime in on it as well, but his paper on the subject is the best there is: http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz If you have questions about the paper, I'd be happy to help, too. I worked through it myself fairly recently. -- Jeff On Tuesday 13 March 2007 12:26, Dusan Kolar wrote:
Hello all,
I'm googling around haskell.org to get some deeper knowledge about Control.Parallel.Strategies than it is presented on http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Parallel -Strategies.html BTW, could someone point me to some more deeper doc. about it?
During googling I've discovered that since GHC 6.6, par, forkIO, and forkOS should make the stuff run in parallel if I have more than one CPU core. Is that right? I think not, because on my machine only par makes the things run in parallel and only during the computation (GC runs in a single thread). If it should work, how can I verify that my installation is correct? If it should not work, will it be working someday?
Thanks for your patience, responses, and tips
Dusan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 13/03/2007, at 17:46, Jefferson Heard wrote:
Simon will probably chime in on it as well, but his paper on the subject is the best there is:
http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz
It does work in GHC 6.6 very nicely. You can try it with the following naive fib function, extracted from the paper mentioned above: \begin{code} import Control.Parallel import System.Environment import Fib main = do (x:_) <- getArgs print$ pfib (read x) pfib 0 = 1 pfib 1 = 1 pfib n = n1 `par` n2 `seq` n1+n2+1 where (n1,n2) = (pfib(n-1), pfib(n-2)) \end{code} pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded pep:~/code/snippets/Parallelism$ time src/Main 33 11405773 real 0m1.444s user 0m1.343s sys 0m0.020s pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2 11405773 real 0m0.764s user 0m1.367s sys 0m0.030s Got a speedup of 100%, and didn't use threads at all. Yay! pepe

Yes, it works for operator /par/. That's what I've reported. But should it work for forkIO and forkOS? Could anybody give more detailed answer than yes, no? :-) (Link to the Web is OK.) BTW, thanks for the link to the paper (moreover, I can see, that googling over haskell.org is not sufficient ;-) ). Regards, Dusan Pepe Iborra wrote:
On 13/03/2007, at 17:46, Jefferson Heard wrote:
Simon will probably chime in on it as well, but his paper on the subject is the best there is:
http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz
It does work in GHC 6.6 very nicely. You can try it with the following naive fib function, extracted from the paper mentioned above:
\begin{code} import Control.Parallel import System.Environment import Fib
main = do (x:_) <- getArgs print$ pfib (read x)
pfib 0 = 1 pfib 1 = 1 pfib n = n1 `par` n2 `seq` n1+n2+1 where (n1,n2) = (pfib(n-1), pfib(n-2)) \end{code}
pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded
pep:~/code/snippets/Parallelism$ time src/Main 33 11405773
real 0m1.444s user 0m1.343s sys 0m0.020s
pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2 11405773
real 0m0.764s user 0m1.367s sys 0m0.030s
Got a speedup of 100%, and didn't use threads at all. Yay!
pepe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Dusan Kolar tel: +420 54 114 1238 UIFS FIT VUT Brno fax: +420 54 114 1270 Bozetechova 2 e-mail: kolar@fit.vutbr.cz Brno 612 66 Czech Republic --

Excuse me, I read too quick. It works for forkIO too, although I'm not sure about forkOS. I don't have a demo around, but you can verify with the concurrency demos in the wiki: http://haskell.org/haskellwiki/Concurrency_demos/Zeta If it doesn't work, perhaps you are in an unsupported platform. Cheers pepe On 13/03/2007, at 18:10, Dusan Kolar wrote:
Yes, it works for operator /par/. That's what I've reported. But should it work for forkIO and forkOS? Could anybody give more detailed answer than yes, no? :-) (Link to the Web is OK.)
BTW, thanks for the link to the paper (moreover, I can see, that googling over haskell.org is not sufficient ;-) ).
Regards,
Dusan
Pepe Iborra wrote:
On 13/03/2007, at 17:46, Jefferson Heard wrote:
Simon will probably chime in on it as well, but his paper on the subject is the best there is:
http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz
It does work in GHC 6.6 very nicely. You can try it with the following naive fib function, extracted from the paper mentioned above:
\begin{code} import Control.Parallel import System.Environment import Fib
main = do (x:_) <- getArgs print$ pfib (read x)
pfib 0 = 1 pfib 1 = 1 pfib n = n1 `par` n2 `seq` n1+n2+1 where (n1,n2) = (pfib(n-1), pfib(n-2)) \end{code}
pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded
pep:~/code/snippets/Parallelism$ time src/Main 33 11405773
real 0m1.444s user 0m1.343s sys 0m0.020s
pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2 11405773
real 0m0.764s user 0m1.367s sys 0m0.030s
Got a speedup of 100%, and didn't use threads at all. Yay!
pepe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
--
Dusan Kolar tel: +420 54 114 1238 UIFS FIT VUT Brno fax: +420 54 114 1270 Bozetechova 2 e-mail: kolar@fit.vutbr.cz Brno 612 66 Czech Republic
--

forkOS should work as well, assuming you have OS threads, like in linux 2.6. You should probably be using the -smp compiler flag and not the -threaded compiler flag, I'm guessing, and make sure that your +RTS arguments indicate that you want to use X total concurrent threads... -- Jeff On Tuesday 13 March 2007 13:10, Dusan Kolar wrote:
Yes, it works for operator /par/. That's what I've reported. But should it work for forkIO and forkOS? Could anybody give more detailed answer than yes, no? :-) (Link to the Web is OK.)
BTW, thanks for the link to the paper (moreover, I can see, that googling over haskell.org is not sufficient ;-) ).
Regards,
Dusan
Pepe Iborra wrote:
On 13/03/2007, at 17:46, Jefferson Heard wrote:
Simon will probably chime in on it as well, but his paper on the subject is the best there is:
http://research.microsoft.com/~simonpj/Papers/strategies.ps.gz
It does work in GHC 6.6 very nicely. You can try it with the following naive fib function, extracted from the paper mentioned above:
\begin{code} import Control.Parallel import System.Environment import Fib
main = do (x:_) <- getArgs print$ pfib (read x)
pfib 0 = 1 pfib 1 = 1 pfib n = n1 `par` n2 `seq` n1+n2+1 where (n1,n2) = (pfib(n-1), pfib(n-2)) \end{code}
pep:~/code/snippets/Parallelism$ ghc --make -O Main -threaded
pep:~/code/snippets/Parallelism$ time src/Main 33 11405773
real 0m1.444s user 0m1.343s sys 0m0.020s
pep:~/code/snippets/Parallelism$ time src/Main 33 +RTS -N2 11405773
real 0m0.764s user 0m1.367s sys 0m0.030s
Got a speedup of 100%, and didn't use threads at all. Yay!
pepe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello Jefferson, Tuesday, March 13, 2007, 9:06:31 PM, you wrote:
forkOS should work as well, assuming you have OS threads, like in linux 2.6. You should probably be using the -smp compiler flag and not the -threaded compiler flag, I'm guessing, and make sure that your +RTS arguments indicate that you want to use X total concurrent threads...
oh... forkOS=forkIO for this case. there is no need to use any compiler flags, because now it is default. you should use +RTS -N2 flag in order to utilize both cores. more info at http://haskell.org/ghc/docs/6.6/html/users_guide/release-6-6.html -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Tue, Mar 13, 2007 at 09:41:47PM +0300, Bulat Ziganshin wrote:
Tuesday, March 13, 2007, 9:06:31 PM, you wrote:
forkOS should work as well, assuming you have OS threads, like in linux 2.6. You should probably be using the -smp compiler flag and not the -threaded compiler flag, I'm guessing, and make sure that your +RTS arguments indicate that you want to use X total concurrent threads...
there is no need to use any compiler flags, because now it is default.
You do need to use -threaded, it's not the default yet. You might be confusing this with ghc itself being built with -threaded by default. Also, there are plans to make -threaded on by default in the future. Thanks Ian

On Mar 13, 2007, at 17:26 , Dusan Kolar wrote:
Hello all,
I'm googling around haskell.org to get some deeper knowledge about Control.Parallel.Strategies than it is presented on http:// www.haskell.org/ghc/docs/latest/html/libraries/base/Control- Parallel-Strategies.html BTW, could someone point me to some more deeper doc. about it?
During googling I've discovered that since GHC 6.6, par, forkIO, and forkOS should make the stuff run in parallel if I have more than one CPU core. Is that right? I think not, because on my machine only par makes the things run in parallel and only during the computation (GC runs in a single thread). If it should work, how can I verify that my installation is correct? If it should not work, will it be working someday?
Thanks for your patience, responses, and tips
Dusan
There's a bit more Haddock for Control.Parallel.Strategies in the current darcs version: http://www.haskell.org/ghc/dist/current/docs/libraries/base/Control- Parallel-Strategies.html /Björn
participants (6)
-
Bjorn Bringert
-
Bulat Ziganshin
-
Dusan Kolar
-
Ian Lynagh
-
Jefferson Heard
-
Pepe Iborra