Distributed Benchmark

This example runs a MATLAB® benchmark that has been modified for Parallel Computing Toolbox™. We execute the benchmark on our workers to determine the relative speeds of the machines on our distributed computing network. Fluctuations of 5 or 10 percent in the measured times of repeated runs on a single machine are not uncommon.

This benchmark is intended to compare the performance of one particular version of MATLAB on different machines. It does not offer direct comparisons between different versions of MATLAB. The tasks and problem sizes change from version to version.

Because this example uses callbacks, we also verify that we have an MJS cluster object to use, rather than one of the other cluster types.

[difficulty, myCluster, numTasks] = pctdemo_helper_getDefaults();
if ~isequal(myCluster.Type, 'MJS')
error('pctexample:benchdist:NotMJS', ...
['This example uses callbacks, which are only available with '...'an MJS cluster.']);
end
fprintf(['This example will submit a job with %d task(s) '...'to the cluster.\n'], numTasks);

This example will submit a job with 4 task(s) to the cluster.

We will repeat the benchmark count times, and run a total of numTasks benchmarks on the network. Because we cannot control which workers execute the tasks, some of them may be benchmarked more than once. Also, note that the example difficulty level has no effect on the computations we perform in this example. You can view the code for pctdemo_setup_bench for full details.

[fig, count] = pctdemo_setup_bench(difficulty);

Create and Submit the Job

We create one job that consists of numTasks tasks. Each task consists of executing pctdemo_task_bench(count) and calling pctdemo_taskfin_bench when it has completed. The task finished callback collects the task results and stores them. It also updates the plot with all the results obtained so far. You can view the code for pctdemo_task_bench and pctdemo_taskfin_bench for the details.

Retrieve the Results

As the tasks finish, the task finished callback function collects the task results and updates the output figure. Therefore, we do not need to perform any plotting here, and we simply verify that we obtained all the results we were expecting. fetchOutputs will throw an error if the tasks did not complete successfully, in which case we need to delete the job before throwing the error.

try
[~] = fetchOutputs(job);
catch err
delete(job);
rethrow(err);
end

We have now finished all the verifications, so we can delete the job.

delete(job);

Was this topic helpful?

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.

Select Your Country

Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .