Personal tools

ThreadScope Tour/Run

From HaskellWiki

< ThreadScope Tour(Difference between revisions)
Jump to: navigation, search
(pandoc paste)
 
m (Objective)
Line 3: Line 3:
 
Run ThreadScope on a sample program and get a trace.
 
Run ThreadScope on a sample program and get a trace.
   
[[Image:ThreadScope-hellofib.png|frame|none|alt=ThreadScope hellofib]]
+
[[Image:ThreadScope-hellofib.png|600px|ThreadScope hellofib]]
   
 
== Steps ==
 
== Steps ==

Revision as of 15:55, 7 December 2011

1 Objective

Run ThreadScope on a sample program and get a trace.

ThreadScope hellofib

2 Steps

  1. Copy the following parallel code to hellofib.hs

     import Control.Parallel.Strategies
     import System.Environment
    
     fib 0 = 1
     fib 1 = 1
     fib n = runEval $ do
       x <- rpar (fib (n-1))
       y <- rseq (fib (n-2))
       return (x + y + 1)
    
     main = do
       args <- getArgs
       n <- case args of
             []    -> return 20 
             [x]   -> return (read x)
             _     -> fail ("Usage: hellofib [n]")
       print (fib n)
  2. Build hellofib.hs

     ghc -O2 -rtsopts -eventlog -threaded hellofib
  3. Run hellofib

     ./hellofib +RTS -N2
  4. View its trace

    threadscope hellofib.eventlog # on Windows, hellofib.exe.eventlog

Follow the installation instructions on the ThreadScope homepage