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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With