Gromacs  2022.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
GpuEventSynchronizer Class Reference

#include <gromacs/gpu_utils/gpueventsynchronizer.h>

Description

A class which allows for CPU thread to mark and wait for certain GPU stream execution point.

The event can be put into the stream with markEvent and then later waited on with waitForEvent or enqueueWaitEvent.

Additionally, this class offers facilities for runtime checking of correctness by counting how many times each marked event is used as a synchronization point.

Default minConsumptionCount=maxConsumptionCount=1 limits mean that each call to markEvent must be followed by exactly one enqueueWaitEvent or enqueueWaitEvent. This is the recommended pattern for most use cases. By providing other constructor arguments, this requirement can be relaxed as needed.

Public Member Functions

 GpuEventSynchronizer (int minConsumptionCount, int maxConsumptionCount)
 A constructor.
 
 ~GpuEventSynchronizer ()=default
 A destructor.
 
GpuEventSynchronizeroperator= (const GpuEventSynchronizer &)=delete
 Remove copy assignment, because we can not copy the underlying event object.
 
 GpuEventSynchronizer (const GpuEventSynchronizer &)=delete
 Remove copy constructor, because we can not copy the underlying event object.
 
GpuEventSynchronizeroperator= (GpuEventSynchronizer &&)=delete
 Remove move assignment, because we don't allow moving the underlying event object.
 
 GpuEventSynchronizer (GpuEventSynchronizer &&)=delete
 Remove move constructor, because we don't allow moving the underlying event object.
 
void markEvent (const DeviceStream &deviceStream)
 Marks the synchronization point in the stream and reset the consumption counter. More...
 
void waitForEvent ()
 Synchronizes the host thread on the marked event. More...
 
bool isReady ()
 Checks the completion of the underlying event and consumes the event if it is ready.
 
bool isMarked () const
 Checks whether the event was marked (and was not reset since then).
 
void consume ()
 Manually consume the event without waiting for it. More...
 
void resetIfFullyConsumed ()
 Helper function to reset the event when it is fully consumed.
 
void enqueueWaitEvent (const DeviceStream &deviceStream)
 Enqueues a wait for the recorded event in stream deviceStream. More...
 
void reset ()
 Resets the event to unmarked state, releasing the underlying event object if needed.
 
void setConsumptionLimits (int minConsumptionCount, int maxConsumptionCount)
 Set the event consumption limits.
 

Member Function Documentation

void GpuEventSynchronizer::consume ( )
inline

Manually consume the event without waiting for it.

If the event is already fully consumed, throws gmx::InternalError.

void GpuEventSynchronizer::enqueueWaitEvent ( const DeviceStream deviceStream)
inline

Enqueues a wait for the recorded event in stream deviceStream.

Consumes the event if able, otherwise throws gmx::InternalError.

void GpuEventSynchronizer::markEvent ( const DeviceStream deviceStream)
inline

Marks the synchronization point in the stream and reset the consumption counter.

Should be called before implicitly consuming actions (waitForEvent() or enqueueWaitEvent()) are executed or explicit consume() calls are made.

If the event has been marked before and not fully consumed, throws gmx::InternalError.

void GpuEventSynchronizer::waitForEvent ( )
inline

Synchronizes the host thread on the marked event.

Consumes the event if able, otherwise throws gmx::InternalError.


The documentation for this class was generated from the following file: