Class CudaEventManager
- Namespace
- DotCompute.Backends.CUDA.Execution
- Assembly
- DotCompute.Backends.CUDA.dll
Advanced CUDA event manager with timing, profiling, synchronization, and event pooling
public sealed class CudaEventManager : IDisposable
- Inheritance
-
CudaEventManager
- Implements
- Inherited Members
- Extension Methods
Constructors
CudaEventManager(CudaContext, ILogger<CudaEventManager>)
Initializes a new instance of the CudaEventManager class.
public CudaEventManager(CudaContext context, ILogger<CudaEventManager> logger)
Parameters
contextCudaContextThe context.
loggerILogger<CudaEventManager>The logger.
Methods
AddEventCallback(EventId, Func<EventId, Task>)
Adds an asynchronous callback for when an event completes
public void AddEventCallback(EventId eventId, Func<EventId, Task> callback)
Parameters
CreateEvent(CudaEventFlags)
Creates a new CUDA event with specified flags (backward compatibility)
public nint CreateEvent(CudaEventFlags flags = CudaEventFlags.Default)
Parameters
flagsCudaEventFlags
Returns
CreateEventBatchAsync(int, CudaEventType, CancellationToken)
Creates a batch of events for parallel operations
public Task<CudaEventHandle[]> CreateEventBatchAsync(int count, CudaEventType eventType = CudaEventType.Timing, CancellationToken cancellationToken = default)
Parameters
countinteventTypeCudaEventTypecancellationTokenCancellationToken
Returns
CreateSyncEventAsync(CancellationToken)
Creates a synchronization event optimized for stream coordination
public Task<CudaEventHandle> CreateSyncEventAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
CreateTimingEventAsync(CancellationToken)
Creates a high-performance timing event for precise measurements
public Task<CudaEventHandle> CreateTimingEventAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
CreateTimingPairAsync(CancellationToken)
Creates a matched pair of timing events for measuring elapsed time
public Task<(CudaEventHandle start, CudaEventHandle end)> CreateTimingPairAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
DestroyEvent(nint)
Destroys a CUDA event (backward compatibility)
public void DestroyEvent(nint eventHandle)
Parameters
eventHandlenint
Dispose()
Performs dispose.
public void Dispose()
ElapsedTime(nint, nint)
Calculates elapsed time between two events (backward compatibility)
public float ElapsedTime(nint startEvent, nint endEvent)
Parameters
Returns
GetStatistics()
Gets comprehensive event manager statistics
public CudaEventStatistics GetStatistics()
Returns
IsEventComplete(EventId)
Checks if an event has completed
public bool IsEventComplete(EventId eventId)
Parameters
eventIdEventId
Returns
MeasureElapsedTime(EventId, EventId)
Measures elapsed time between two timing events in milliseconds
public float MeasureElapsedTime(EventId startEvent, EventId endEvent)
Parameters
Returns
MeasureOperationAsync(Func<nint, Task>, nint, string?, CancellationToken)
Performs high-precision timing measurement of an operation
public Task<CudaTimingResult> MeasureOperationAsync(Func<nint, Task> operation, nint stream = 0, string? operationName = null, CancellationToken cancellationToken = default)
Parameters
Returns
ProfileOperationAsync(Func<nint, Task>, int, nint, string?, CancellationToken)
Performs comprehensive profiling with statistical analysis
public Task<CudaProfilingResult> ProfileOperationAsync(Func<nint, Task> operation, int iterations = 100, nint stream = 0, string? operationName = null, CancellationToken cancellationToken = default)
Parameters
operationFunc<nint, Task>iterationsintstreamnintoperationNamestringcancellationTokenCancellationToken
Returns
RecordEvent(EventId, nint)
Records an event on the specified stream
public void RecordEvent(EventId eventId, nint stream = 0)
Parameters
RecordEventFast(nint, nint)
Records an event using the handle directly for performance
public void RecordEventFast(nint eventHandle, nint stream = 0)
Parameters
SynchronizeEventAsync(EventId, TimeSpan?, CancellationToken)
Synchronizes with an event asynchronously
public Task SynchronizeEventAsync(EventId eventId, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
eventIdEventIdtimeoutTimeSpan?cancellationTokenCancellationToken