Fence#

Fully qualified name: cupva::Fence

Defined in src/host/cpp_api/include/cupva_host.hpp

class Fence : public cupva::StaticStorage<impl::Fence, priv::CUPVA_FENCE_SIZE, priv::CUPVA_FENCE_ALIGN>#

Fence is used to synchronize between PVA programs.

Fences are used to synchronize between CUPVA Streams and with other engines. Fences may optionally include timestamps. It is recommended that Fences and timestamps are used to ensure that any assumptions made about scheduling on available PVA resources are correct. In some cases scheduling may be outside of the user’s control, for example if multiple applications are submitting work. Timestamps allow verification that scheduling order is as expected.

Public Functions

Fence() noexcept#

Construct a new uninitialized object.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: No

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

explicit Fence(SyncObj &syncObj) noexcept#

Construct a new Fence object.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: No

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

Parameters:

syncObj – The SyncObj the fence is using.

~Fence() noexcept#

Destroy the Fence object.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: No

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

Fence(Fence &&obj) noexcept = default#

Move constructor.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: No

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

Fence &operator=(Fence &&obj) & noexcept = default#

Move assignment operator.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: No

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

Fence(const Fence &obj) noexcept = default#

Copy constructor.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: No

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

Fence &operator=(const Fence &obj) & noexcept = default#

Copy assignment operator.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: No

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

bool wait(int64_t const timeout = -1) const#

Block the calling thread until the fence is triggered or time out.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: Yes

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

Parameters:

timeout – The maximum time to wait in micro seconds. -1 will wait forever.

Throws:

cupva::Exception(DriverAPIError) – The PVA driver returned an unexpected error.

Returns:

true if wait was successful; false if timeout occurred before the fence was triggered

uint64_t timestamp() const#

Gets the time at which current fence expired (in nanoseconds).

Epoch is implementation defined.

cupva::Fence::wait() must return with success prior to calling this API or the timestamp value cannot be considered valid.

Usage considerations

  • Allowed context for the API call

    • Thread-safe: Yes

  • API group

    • Init: No

    • Runtime: Yes

    • De-Init: No

Throws:

cupva::Exception(DriverAPIError) – The PVA driver returned an unexpected error.

Returns:

the time at which current fence expired (in nanoseconds).