Table of Contents

Class OpenCLEventManager

Namespace
DotCompute.Backends.OpenCL.Execution
Assembly
DotCompute.Backends.OpenCL.dll

Manages OpenCL events with pooling and recycling for optimal performance. Provides profiling support, event chaining, and wait list management. Follows proven patterns from CUDA's event management for production-grade synchronization.

public sealed class OpenCLEventManager : IAsyncDisposable
Inheritance
OpenCLEventManager
Implements
Inherited Members

Methods

AcquireEventAsync(EventProperties, CancellationToken)

Acquires an event from the pool or creates a new one. This is the primary method for obtaining events with pooling optimization.

public ValueTask<EventHandle> AcquireEventAsync(EventProperties properties, CancellationToken cancellationToken = default)

Parameters

properties EventProperties

Event properties specifying profiling and user event modes.

cancellationToken CancellationToken

Cancellation token for async operations.

Returns

ValueTask<EventHandle>

A handle to the acquired event with RAII cleanup semantics.

CreateUserEventAsync(CancellationToken)

Creates a user event for host-side synchronization. User events allow the host to signal completion of operations.

public ValueTask<EventHandle> CreateUserEventAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<EventHandle>

A handle to the created user event.

DisposeAsync()

Asynchronously disposes the event manager and all managed events.

public ValueTask DisposeAsync()

Returns

ValueTask

GetProfilingInfoAsync(OpenCLEventHandle)

Gets profiling information for an event (if profiling was enabled). Returns null if profiling is not available or event has not completed.

public ValueTask<EventProfilingInfo?> GetProfilingInfoAsync(OpenCLEventHandle evt)

Parameters

evt OpenCLEventHandle

The event to query profiling information for.

Returns

ValueTask<EventProfilingInfo>

Profiling information or null if not available.

GetStatistics()

Gets comprehensive statistics about event usage and pool performance.

public EventStatistics GetStatistics()

Returns

EventStatistics

Statistics snapshot for monitoring and optimization.

SetUserEventStatus(OpenCLEventHandle, int)

Sets the execution status of a user event. Use this to signal completion or failure of host-side operations.

public void SetUserEventStatus(OpenCLEventHandle evt, int status)

Parameters

evt OpenCLEventHandle

The user event to update.

status int

Execution status (0 for complete, negative for error).

WaitForEventAsync(OpenCLEventHandle, CancellationToken)

Waits for a single event to complete.

public ValueTask WaitForEventAsync(OpenCLEventHandle evt, CancellationToken cancellationToken = default)

Parameters

evt OpenCLEventHandle

The event to wait for.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask

WaitForEventsAsync(IEnumerable<OpenCLEventHandle>, CancellationToken)

Waits for multiple events to complete. Efficiently batches waiting using clWaitForEvents for optimal performance.

public ValueTask WaitForEventsAsync(IEnumerable<OpenCLEventHandle> events, CancellationToken cancellationToken = default)

Parameters

events IEnumerable<OpenCLEventHandle>

Collection of events to wait for.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask