ActivityMonitor - Parallel pool activity monitor - MATLAB (original) (raw)
Parallel pool activity monitor
Since R2025a
Description
Use ActivityMonitor
to monitor and collect data on worker activity in a parallel pool.
Monitoring data includes:
- The type of parallel construct, such as
parfor
,parfeval
, andspmd
. - The amount of data (in bytes) the client and workers send and receive.
- The time each worker spends processing their portion of the parallel code.
You can retrieve the monitoring results using the results function and view the monitoring data in the Pool Dashboard.
Creation
Syntax
Description
[monitor](#mw%5F541cb048-1544-4527-83b2-673734e969c1) = parallel.pool.ActivityMonitor
creates an ActivityMonitor
object and starts collecting activity monitoring data on the current parallel pool. If no parallel pool exists,parallel.pool.ActivityMonitor
starts a new parallel pool using the default profile, unless you disable automatic pool creation in your parallel settings.
To save monitoring results, use the results function. To stop collecting and save monitoring results, use the stop function.
[monitor](#mw%5F541cb048-1544-4527-83b2-673734e969c1) = parallel.pool.ActivityMonitor([pool](#mw%5Ff9d55cda-effb-43d0-836b-f87a4057cf10))
starts collecting activity monitoring data on the parallel pool specified bypool
.
[monitor](#mw%5F541cb048-1544-4527-83b2-673734e969c1) = parallel.pool.ActivityMonitor(___,`Start=false`)
creates an ActivityMonitor
object but does not start collecting activity monitoring data. To start collecting monitoring data, use the start function.
Input Arguments
Parallel pool, specified as a parallel.Pool.ProcessPool
orparallel.pool.ClusterPool
object.
You can use an interactive or batch parallel pool. ActivityMonitor
is not supported on parallel pools of thread workers.
Example: parpool("Processes");
Example: batch(...,Pool=4);
Output Arguments
Pool activity monitor, returned as an ActivityMonitor
object.
Object Functions
results | Retrieve results from parallel pool activity monitor |
---|---|
stop | Stop monitoring parallel pool activity |
start | Start collecting parallel pool activity monitoring data |
Examples
Create an ActivityMonitor
object to start collecting pool monitoring data. With default settings, parallel.pool.ActivityMonitor
automatically starts an interactive parallel pool using the default profile if one does not exist.
monitor = parallel.pool.ActivityMonitor;
Starting parallel pool (parpool) using the 'Processes' profile ... Connected to parallel pool with 6 workers.
Run a parfor
-loop to generate random numbers and store them in an array.
data = zeros(1,100); parfor idx = 1:100 data(idx) = rand; end
Stop the activity monitor and retrieve the results collected during the parfor
execution.
monitorResults = stop(monitor);
Create a parallel pool using the cluster profile,MyCluster
.
pool = parpool("MyCluster");
Create an ActivityMonitor
object to collect monitoring data for the pool but do not start collecting data immediately.
monitor = parallel.pool.ActivityMonitor(pool,Start=false);
Collect activity monitoring data on a batch pool job using an ActivityMonitor
object.
Write a function that creates an ActivityMonitor
object to collect monitoring data, executes parallel tasks, and collects pool monitoring results.
function monitorResults = myParallelCode
monitor = parallel.pool.ActivityMonitor;
f(1:100) = parallel.FevalFuture; for idx = 1:100 f(idx) = parfeval(@(n) real(eig(randn(n))),1,5e2); end maxFuture = afterEach(f,@max,1); wait(maxFuture);
monitorResults = stop(monitor); end
Run the myParallelCode
function as a batch pool job using the myCluster
profile and wait for the batch job to complete.
j = batch(@myParallelCode,1,Pool=4,Profile="myCluster"); wait(j);
Fetch the monitoring results from the completed batch job.
out = fetchOutputs(j); monitoringResults = out{1};
Limitations
ActivityMonitor
is not supported on parallel pools of thread workers.
Alternative Functionality
Tool
You can use the Pool Dashboard to collect and view pool monitoring data on an interactive parallel pool.
Version History
Introduced in R2025a