This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Get current parallel pool


p = gcp
p = gcp('nocreate')



p = gcp returns a parallel.Pool object representing the current parallel pool. The current pool is where parallel language features execute, such as parfor, spmd, distributed, Composite, parfeval and parfevalOnAll.

If no parallel pool exists, gcp starts a new parallel pool and returns a pool object for that, unless automatic pool starts are disabled in your parallel preferences. If no parallel pool exists and automatic pool starts are disabled, gcp returns an empty pool object.


p = gcp('nocreate') returns the current pool if one exists. If no pool exists, the 'nocreate' option causes gcp not to create a pool, regardless of your parallel preferences settings.


collapse all

Find the number of workers in the current parallel pool.

p = gcp('nocreate'); % If no pool, do not create new one.
if isempty(p)
    poolsize = 0;
    poolsize = p.NumWorkers

Use the parallel pool object to delete the current pool.


Introduced in R2013b