|Can't gain any speedup benefits from parallelizing||Kir||1/26/12 4:53 AM|
I've tried first two examples from this tutorial:
But when i launched programs with +RTS -N2 flags i had bigger
execution time rather then without this flag. I've compiled examples
with -O2 flags, but when i compile first example without this flag i
saw some speedup, second example faster in serial mode in this
situation too. What can i did wrong? Is these some limitation on using
optimizations and parallelizing?
Ran on Windows 7 Haskell Platform 2011.4.0.0. Intel core i5.
Compilation command: ghc --make -O2 -rtsopts -threaded test.hs
Run command: test.exe +RTS -N2 -s
|Re: Can't gain any speedup benefits from parallelizing||Mikolaj Konarski||1/26/12 5:37 AM|
There is a step-by-step tutorial about diagnosing
It focuses on ThreadScope and problems in the tested code,
|Re: Can't gain any speedup benefits from parallelizing||Kir||1/26/12 5:44 AM|
Thanks for advise but there is a problem with current version of ThreadScope under windows (i did not try under Linux) - it does not compiled on my system. Compiler say that widgetSetCanFocus is out of scope in Gtk2hs 0.12.2 (I can't install previous version because of missing dependencies). I've installed ThreadScope from sources and remove widgetSetCanFocus call, but now ThreadScope crashes every time i try to open the event log.
|Re: Can't gain any speedup benefits from parallelizing||Mikolaj Konarski||1/26/12 5:57 AM|
Too bad about TS compilation. Still there is one chapter
of the tutorial does does not depend on TS at all.
I wonder how do your numbers compare to those:
> Thanks for advise but there is a problem with current version of ThreadScope
I think we've had no problems under Linux with GHC 7.0.4,
> - it does not compiled on my
That happens when installing Gtk2hs alone, too, doesn't it?
> (I can't install previous version because of missing dependencies).
0.12.1? 0.12.0? Or previous version of TS?
> I've installed ThreadScope from sources and remove widgetSetCanFocus call,
You mean you've removed the line
|Re: Can't gain any speedup benefits from parallelizing||Kir||1/26/12 6:08 AM|
1. Of cause i've checked statistics, and it shows that all sparks were converted to parallel. Here is my output:
MUT time (elapsed) GC time (elapsed)
Task 0 (worker) : 0.00s ( 2.43s) 0.00s ( 0.00s)
Task 1 (worker) : 1.34s ( 2.43s) 0.00s ( 0.00s)
Task 2 (bound) : 2.14s ( 2.43s) 0.03s ( 0.00s)
Task 3 (worker) : 0.00s ( 0.00s) 0.00s ( 0.00s)
SPARKS: 1 (1 converted, 0 pruned)
INIT time 0.00s ( 0.00s elapsed)
MUT time 3.48s ( 2.43s elapsed)
GC time 0.03s ( 0.00s elapsed)
EXIT time 0.00s ( 0.00s elapsed)
Total time 3.51s ( 2.43s elapsed)
2. Gtk2hs was installed without any problems, demos were compiled and launched succesfully
3. Yes I've removed line "widgetSetCanFocus drawArea True" in EventsView.hs
_cairo_win32_scaled_font_ucs4_to_index:GetGlyphIndicesW: Unknown GDI error>threa
dscope: user error (out of memory)
|Re: Can't gain any speedup benefits from parallelizing||Christopher Brown||1/26/12 6:11 AM|
According to that you are getting 1 spark converted. That's not enough to get any parallelism.
It would help if you could show us the exact code for your example. Perhaps you typed something in wrong?
|Re: Can't gain any speedup benefits from parallelizing||Kir||1/26/12 6:15 AM|
I've took example from tutorial:
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
mkList :: Int -> [Int]
mkList n = [1..n-1]
relprime :: Int -> Int -> Bool
relprime x y = gcd x y == 1
euler :: Int -> Int
euler n = length (filter (relprime n) (mkList n))
sumEuler :: Int -> Int
sumEuler = sum . (map euler) . mkList
parSumFibEuler :: Int -> Int -> Int
parSumFibEuler a b = f `par` (e `pseq`(f + e))
where f = fib a
e = sumEuler b
secDiff :: ClockTime -> ClockTime -> Float
secDiff (TOD secs1 psecs1) (TOD secs2 psecs2) = fromInteger (psecs2 - psecs1) / 1e12 + fromInteger (secs2 - secs1)
r1 :: Int
r1 = parSumFibEuler 40 5300
main :: IO ()
main = do
t4 <- getClockTime
pseq r1 (return ())
t5 <- getClockTime
putStrLn ("sum: " ++ show r1)
putStrLn ("time: " ++ show (secDiff t4 t5) ++ " seconds")
Also i measured times for "fib" and "sumEuler" functions separately and on my system each took about one second.
|Re: Can't gain any speedup benefits from parallelizing||Mikolaj Konarski||1/26/12 1:11 PM|
I've run your code and I've got no speedup either.
SPARKS: 1 (0 converted, 0 overflowed, 0 dud, 1 GC'd, 0 fizzled)
which shows there was no real parallelism at all,
It's possible we actually have the same spark profile,
> 2. Gtk2hs was installed without any problems, demos were compiled and
Thank you. I will file two bug reports with this data.
The second looks like an OS-specific gtk2hs crash,
|Re: Can't gain any speedup benefits from parallelizing||Mikolaj Konarski||1/26/12 2:20 PM|
I've experimented a bit with the code and I think there may be
a problem in RTS, but I won't go any further without help
of a more experienced person.
When I exchange what 'f' and 'e' compute as follows
where f = sumEuler b
SPARKS: 1 (1 converted, 0 overflowed, 0 dud, 0 GC'd, 0 fizzled)
So perhaps you've also got one converted spark, after all.
OTOH, when I make both 'f' and 'e' compute the same thing
It seems GHC 7.* RTS does not like to compute such functions
|Re: Can't gain any speedup benefits from parallelizing||Johannes Waldmann||1/27/12 12:38 AM|
I am getting the same behaviour here (x86_64, linux, ghc-7.2.2)
my guess is that this program does not allocation (mkList is fused) (?)
A fun observation is that it you compile with "-O0" (no fusion then?)
|Re: Can't gain any speedup benefits from parallelizing||Simon Marlow||1/27/12 12:59 AM|
GHC will optimise the fib function so that it does no allocation, and
Regarding this tutorial, I strongly recommend using my tutorial instead
|Re: Can't gain any speedup benefits from parallelizing||Kir||1/27/12 1:34 AM|
Yes I've used gtk2hs is 0.12.2 and TS is 0.2.1 and GTK 2.24.8 in installed in Windows 7.
|Re: Can't gain any speedup benefits from parallelizing||Mikolaj Konarski||1/27/12 2:51 AM|
|Re: Can't gain any speedup benefits from parallelizing||Kir||1/27/12 6:21 AM|
Thanks for the answer, yours tutorial really helps me to solve parallelization problems in my program.
|Re: Can't gain any speedup benefits from parallelizing||Mikolaj Konarski||1/27/12 6:33 AM|
On Fri, Jan 27, 2012 at 15:21, Kir <kolodyazh...@gmail.com> wrote:
I'm sure Eric Kow of Well-Typed, the author of the tutorial. will be glad
|Re: Can't gain any speedup benefits from parallelizing||Kir||1/27/12 6:52 AM|