Table of Contents

Class CudaEvent

Namespace
JYPPX.CudaSharp
Assembly
JYPPX.CudaSharp.dll

Managed wrapper around a CUDA event handle. CUDA event 句柄的托管封装。

public sealed class CudaEvent : IDisposable
Inheritance
CudaEvent
Implements
Inherited Members

Constructors

CudaEvent()

Creates a CUDA event with default flags. 使用默认标志创建 CUDA event。

public CudaEvent()

CudaEvent(CudaEventCreationFlags)

Creates a CUDA event with explicit creation flags. 使用显式创建标志创建 CUDA event。

public CudaEvent(CudaEventCreationFlags flags)

Parameters

flags CudaEventCreationFlags

The CUDA event creation flags. CUDA event 创建标志。

Properties

Flags

Gets the effective CUDA event flags. 获取实际生效的 CUDA event 标志。

public CudaEventCreationFlags Flags { get; }

Property Value

CudaEventCreationFlags

IsIpcImported

Gets whether this wrapper owns an imported process-local CUDA event. 获取此 wrapper 是否拥有导入的进程内 CUDA event。

public bool IsIpcImported { get; }

Property Value

bool

Methods

Dispose()

Releases the native CUDA event handle. 释放原生 CUDA event 句柄。

public void Dispose()

ElapsedTimeSince(CudaEvent)

Measures elapsed time since a start event. 计算从起始 event 到当前 event 的耗时。

public float ElapsedTimeSince(CudaEvent startEvent)

Parameters

startEvent CudaEvent

The starting CUDA event. 起始 CUDA event。

Returns

float

The elapsed time in milliseconds. 耗时(毫秒)。

ExportIpcToken()

Copies an opaque CUDA IPC export token for this event. 复制当前 event 的 opaque CUDA IPC 导出 token。

public CudaIpcExportToken ExportIpcToken()

Returns

CudaIpcExportToken

Remarks

The event must be created with Interprocess and DisableTiming. Keep this event alive while another process uses the token. event 必须使用 Interprocess 与 DisableTiming 标志创建;其他进程使用 token 期间必须保持当前 event 存活。

ImportIpcToken(CudaIpcExportToken)

Opens a process-local CUDA event from an export token. 从 export token 打开进程内 CUDA event。

public static CudaEvent ImportIpcToken(CudaIpcExportToken token)

Parameters

token CudaIpcExportToken

The event token transported from another process. 从其他进程传输的 event token。

Returns

CudaEvent

An owner wrapper released with cudaEventDestroy. 使用 cudaEventDestroy 释放的 owner wrapper。

IsReady()

Gets whether the CUDA event has already completed. 获取该 CUDA event 是否已经完成。

public bool IsReady()

Returns

bool

true when the event is ready. event 已就绪时返回 true。

Record(CudaStream)

Records this event on a CUDA stream. 在 CUDA stream 上记录当前 event。

public void Record(CudaStream stream)

Parameters

stream CudaStream

The stream that receives the record operation. 接收 record 操作的 stream。

Record(CudaStream, CudaEventRecordFlags)

Records this CUDA event into a stream with explicit event-record flags. 使用显式 event-record flags 将当前 CUDA event 记录到 stream。

public void Record(CudaStream stream, CudaEventRecordFlags flags)

Parameters

stream CudaStream

The stream that receives the event record operation. 接收 event record 操作的 stream。

flags CudaEventRecordFlags

CUDA event-record flags. CUDA event record 标志。

Synchronize()

Blocks until the CUDA event is completed. 阻塞直到 CUDA event 完成。

public void Synchronize()

TryExportIpcToken(out CudaIpcExportToken?, out string)

Tries to copy an IPC export token and returns a diagnostic on failure. 尝试复制 IPC 导出 token,失败时返回诊断。

public bool TryExportIpcToken(out CudaIpcExportToken? token, out string diagnostic)

Parameters

token CudaIpcExportToken
diagnostic string

Returns

bool

TryImportIpcToken(CudaIpcExportToken, out CudaEvent?, out string)

Tries to import a CUDA IPC event token and returns a diagnostic on CUDA failure. 尝试导入 CUDA IPC event token,并在 CUDA 失败时返回诊断。

public static bool TryImportIpcToken(CudaIpcExportToken token, out CudaEvent? cudaEvent, out string diagnostic)

Parameters

token CudaIpcExportToken
cudaEvent CudaEvent
diagnostic string

Returns

bool