Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identifying the current HEC for a function in Haskell

I'm writing a parallel Haskell program using Strategies. It's not doing what it's supposed to do, and I would like to inspect which Haskell Execution Context (HEC) a function is executed in.

Is there a getHEC call or something similar which I could use in my debug output?

like image 761
Jonatan Avatar asked Oct 09 '22 03:10

Jonatan


1 Answers

You can find out which capability (i.e. CPU core) a Haskell thread is running on by calling threadCapability from Control.Concurrent.

If you're running your program with +RTS -N, there will be one OS-level thread (HEC) spawned per core, so the capability number returned by threadCapability will tell you which OS thread your forkIO green thread is running on. If, however, you are explicitly specifying the number of OS threads with +RTS -Nn, where n is some integer other than the number of cores on your system, this will probably be less useful to you.

You might also find ThreadScope to be useful for debugging and visualizing the execution of parallel programs.

like image 136
bitbucket Avatar answered Oct 18 '22 10:10

bitbucket