...
...
parfeval
parafeval parfeval is useful for when you want to run a loop that you can stop early. For example, if you are analyzing a very large data set, you may want to stop when the results are 'good enough' instead of waiting for the entire set to be completed. parafeval parfeval is also useful for running functions in the background because it doesn't block MATLAB from continuing to work. parafeval parfeval will split up the workers in the pool itself.
...
If you want to break out of a loop using parafeval parfeval use cancel(f) to stop the evaluation of the future object.
...
This example shows how you can use parafeval parfeval to evaluate a function an get the results as they are available.
...
The bash script for this example is identical to the script for previous spmd example. The output file has MATLAB's version information, followed by the cluster and pool properties. The actual results of the MATALAB should be 'Got result with index: 1', then 2, then 3, ... etc., up to 10. If this was a much larger job, then the indexes, may not be in order; it would all depend on which future object was ready for fetchNext(f) first.
Quick Guide
Brief explanation of terms to know when using MATLAB's Parallel Computing Toolbox.
| worker | The MATLAB computational engine that processes the code. Can also be called a lab. Each worker is assigned a number called its rank. |
numlabs | Returns the total number of workers available. |
| labindex | Returns the rank of the worker. |
| parpool | The parallel pool of workers. It is created in the MATLAB program with parpool('local', #ofWorkers). The number of workers is the number of cpus requested on the node - 1. |
| gcp | MATLAB function that will get the current pool. At the end of the parallel code using delete(gcp) will neatly shutdown all the workers. |
| parfor | The parallel for loop. Splits the iterations of the for loop among the workers to be done in parallel. The step of the iteration must be +1, the iterations cannot rely on one another, parfor loops cannot be nested, and you cannot break out of the loop early. |
| spmd | Single Program Multiple Data. Allows for control over each worker. Use the worker's rank to assign jobs. Useful for when you want to do the same thing to different data sets. Like parfor: cannot nest spmd blocks in each other and cannot break out of them. |
parafevalparfeval | Parallel Function Evaluation (not official, just assuming that what it stands for) will allow you to run functions in parallel without having MATLAB be blocked from running other things. Call parafeval parfeval as many times as you want the function to run in a loop and call fetchNext to get the results. |
...