Fence#

oneAPI Level Zero Specification - Version 1.18.31

Fence Functions#

zeFenceCreate#

Added in version 1.0

ZE_APIEXPORT ze_result_t ZE_APICALL zeFenceCreate(ze_command_queue_handle_t hCommandQueue, const ze_fence_desc_t *desc, ze_fence_handle_t *phFence)#

Creates a fence for the command queue.

  • A fence is a heavyweight synchronization primitive used to communicate to the host that command list execution has completed.

  • The application must only use the fence for the command queue which was provided during creation.

  • The application may call this function from simultaneous threads.

  • The implementation of this function must be thread-safe.

Remark

Analogues

  • vkCreateFence

Parameters:
  • hCommandQueue – [in] handle of command queue

  • desc – [in] pointer to fence descriptor

  • phFence – [out] pointer to handle of fence object created

Returns:

zeFenceDestroy#

Added in version 1.0

ZE_APIEXPORT ze_result_t ZE_APICALL zeFenceDestroy(ze_fence_handle_t hFence)#

Deletes a fence object.

  • The application must ensure the device is not currently referencing the fence before it is deleted.

  • The implementation of this function may immediately free all Host and Device allocations associated with this fence.

  • The application must not call this function from simultaneous threads with the same fence handle.

  • The implementation of this function must be thread-safe.

Remark

Analogues

  • vkDestroyFence

Parameters:

hFence – [in][release] handle of fence object to destroy

Returns:

zeFenceHostSynchronize#

Added in version 1.0

ZE_APIEXPORT ze_result_t ZE_APICALL zeFenceHostSynchronize(ze_fence_handle_t hFence, uint64_t timeout)#

The current host thread waits on a fence to be signaled.

  • The application may call this function from simultaneous threads.

  • The implementation of this function should be lock-free.

Remark

Analogues

  • vkWaitForFences

Parameters:
  • hFence – [in] handle of the fence

  • timeout – [in] if non-zero, then indicates the maximum time (in nanoseconds) to yield before returning ZE_RESULT_SUCCESS or ZE_RESULT_NOT_READY; if zero, then operates exactly like zeFenceQueryStatus; if UINT64_MAX, then function will not return until complete or device is lost. Due to external dependencies, timeout may be rounded to the closest value allowed by the accuracy of those dependencies.

Returns:

zeFenceQueryStatus#

Added in version 1.0

ZE_APIEXPORT ze_result_t ZE_APICALL zeFenceQueryStatus(ze_fence_handle_t hFence)#

Queries a fence object’s status.

  • The application may call this function from simultaneous threads.

  • The implementation of this function should be lock-free.

Remark

Analogues

  • vkGetFenceStatus

Parameters:

hFence – [in] handle of the fence

Returns:

zeFenceReset#

Added in version 1.0

ZE_APIEXPORT ze_result_t ZE_APICALL zeFenceReset(ze_fence_handle_t hFence)#

Reset a fence back to the not signaled state.

  • The application may call this function from simultaneous threads.

  • The implementation of this function should be lock-free.

Remark

Analogues

  • vkResetFences

Parameters:

hFence – [in] handle of the fence

Returns:

Fence Enums#

ze_fence_flags_t#

Added in version 1.0

enum ze_fence_flag_t#

Values:

enumerator ZE_FENCE_FLAG_SIGNALED#

fence is created in the signaled state, otherwise not signaled.

enumerator ZE_FENCE_FLAG_FORCE_UINT32#

Value marking end of ZE_FENCE_FLAG_* ENUMs.

Fence Structures#

ze_fence_desc_t#

Added in version 1.0

struct ze_fence_desc_t#

Fence descriptor.

Public Members

ze_structure_type_t stype#

[in] type of this structure

const void *pNext#

[in][optional] must be null or a pointer to an extension-specific structure (i.e. contains stype and pNext).

ze_fence_flags_t flags#

[in] creation flags. must be 0 (default) or a valid combination of ze_fence_flag_t.