Skip to Main Content Skip to Search
Product Documentation

wait - Wait for job to change state or for GPU calculation to complete

Syntax

wait(j)
wait(j,'state')
wait(j,'state',timeout)
wait(gpudev)

Arguments

job

Job object whose change in state to wait for.

'state'

Value of the job object's State property to wait for.

timeout

Maximum time to wait, in seconds.

gpudev

GPU device object whose calculations to wait for.

Description

wait(j) blocks execution in the client session until the job identified by the object j reaches the 'finished' state or fails. This occurs when all the job's tasks are finished processing on the workers.

wait(j,'state') blocks execution in the client session until the specified job object changes state to the value of 'state'. The valid states to wait for are 'queued', 'running', and 'finished'.

If the object is currently or has already been in the specified state, a wait is not performed and execution returns immediately. For example, if you execute wait(j,'queued') for a job already in the 'finished' state, the call returns immediately.

wait(j,'state',timeout) blocks execution until either the job reaches the specified 'state', or timeout seconds elapse, whichever happens first.

wait(gpudev) blocks execution in MATLAB until the GPU device identified by the object gpudev completes its calculations. When gathering results from a GPU, MATLAB automatically waits until all GPU calculations are complete, so you do not need to explicitly call wait in that situation. wait can be useful when you are timing GPU calculations to profile your code.

Examples

Submit a job to the queue, and wait for it to finish running before retrieving its results.

submit(j);
wait(j,'finished')
results = fetchOutputs(j)

Submit a batch job and wait for it to finish before retrieving its variables.

j = batch('myScript');
wait(j)
load(j)

See Also

pause | resume | waitForState

  


Free Parallel Computing Interactive Kit

See how to solve large problems with minimal effort and reduce simulation time.

Get free kit

Trials Available

Try the latest versions of parallel computing products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS