Debugging and Profiling Parallel Programs

Roman E. Maeder

Wolfram Research

Parallel Computing Toolkit

Support for parallel programming is implemented entirely within Mathematica

The master kernel interacts with the programmer (through the frontend) and with the slave kernels

All communication between master kernel and slave kernels goes through MathLink

Support for transporting code from the master kernel to the slave kernels

Launching Kernels

{$MachineName,$Version,$ParentLink}

Get["Parallel`Debug`"]

Needs["Parallel`"]

$AvailableMachines = Table["localhost",{4}]

Launching Kernels (2)

LaunchSlaves[]

LinkObject[$Slaves[[1]]]

Kernel Attributes

Local properties:

TableForm[
Through[{Identity,ProcessorID,ProcessorName,ProcessorSpeed,LinkObject}[#]]&/@$Slaves,
TableHeadings->{None,{"slave","id", "name","speed","link"}}]

Remote properties:

TableForm[RemoteEvaluate[{$ProcessorID,$MachineName,$SystemID,$Version,TimeUsed[], MaxMemoryUsed[],$CommandLine}],TableHeadings->{None,{"ID","host", "OS","Mathematica Version", "CPU Time","Memory", "CommandLine"}},TableDepth->2]

Code Distribution

f[n_]:=PrimeQ[2^n-1]

ExportEnvironment[f]

RemoteEvaluate[Information[f],$Slaves[[1]]]

ParallelTable[f[i],{i,100,115}]

PCT's own debugging

Observing certain aspects of remote kernel communication:

OptionValues[Trace]

PCT's own debugging: Tracing Example

SetOptions[$DebugObject,Trace->SendReceive]

ParallelTable[f[i],{i,100, 115}]

SetOptions[$DebugObject,Trace->{}];

Support for Interfacing with Wolfram Workbench

The Workbench needs to establish a connection to each launched slave kernel

It also needs to hook into ExportEnvironment to support breakpoints and profiling in the remote kernels

PCT V2 .1 (prerelease) discovers when it is loaded under the workbench, automatically loads debugging code and provides for hooks that the workbench then uses.

A Workbench Debugging Example

An example from the PCT documentation: finding irreducible polynomials.