Waits for completion of the last kernel in the offload queue. This topic only applies to Intel® 64 and IA-32 architectures targeting Intel® Graphics Technology.


int _GFX_wait(GfxTaskId task_id = 0, int wait_time_ms = -1);



The id of the task to wait for, returned previously by _GFX_enqueue. If the task id is 0, _GFX_wait waits for the most recent task in the queue at the moment of calling the function.


The time in milliseconds to wait in _GFX_wait. Setting this parameter to -1 causes the function to wait for the default timeout value. The default timeout value depends on your implementation and other environment settings, or it may be infinite.


Use this function to wait for completion of the last kernel in the queue. The Intel® Graphics Technology runtime maintains only one default queue, for simplicity.

This function also serves as a resource cleanup point, including checking for internal object usage, and, possibly, performing the cleanup operations.

Upon successful completion of the function, the task id provided to the function becomes invalid and the corresponding task object no longer exists. If the function succeeds for a particular task id, indicating successful completion of the task, then all tasks enqueued earlier have completed, and the task ids for all earlier submitted tasks also become invalid.

If the task id passed to the function is not valid, meaning, for example that the corresponding task already finished and the task object is already destroyed, the function returns the error GFX_TASKID_NOT_FOUND.

This function is thread safe; it can be accessed from different host threads without extra synchronization effort on your part.


If multiple threads add offload tasks using _GFX_enqueue , _GFX_wait waits for completion of all the tasks globally added before it is called, including tasks added by other threads.

Return Values


The function succeeded.

A non-zero error code

An error has occurred. Use the function _GFX_get_last_error() to get the specific error code. Additonally, gfx_rt.h defines various error status values.

For more complete information about compiler optimizations, see our Optimization Notice.