Parallel R packages such as Rmpi
, snow
, foreach
, and so on do not set up a terminal window for each process, thus making it impossible to use R’s debugger on the workers. (My Rdsm
package, which adds a threads capability to R, is an exception to this.)
What then can you do to debug apps for those packages? Let’s consider snow
for a concrete example.
First, you should debug the underlying single-worker function, such as mtl()
in Section 16.2. Here, we would set up some artificial values of the arguments and then use R’s ordinary debugging facilities.
Debugging the underlying function may be sufficient. However, the bug may be in the arguments themselves or in the way we set them up. Then things get more difficult.
It’s even hard to print out trace information, such as values of variables, since print()
won’t work in the worker processes. The message()
function may work for some of these packages; if not, you may need to resort to using cat()
to write to a file.