Class DriverAPINativeMethods.Events
Groups all event API calls
Inheritance
Inherited Members
Namespace: ManagedCuda
Assembly: ManagedCuda.dll
Syntax
public static class Events
Methods
cuEventCreate(ref CUevent, CUEventFlags)
Creates an event phEvent
with the flags specified via Flags
. See CUEventFlags
Declaration
public static CUResult cuEventCreate(ref CUevent phEvent, CUEventFlags Flags)
Parameters
Type | Name | Description |
---|---|---|
CUevent | phEvent | Returns newly created event |
CUEventFlags | Flags | Event creation flags |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidValue, ErrorOutOfMemory.
|
cuEventDestroy(CUevent)
Destroys the event specified by event
.
Declaration
[Obsolete("Don't use this CUDA API call with CUDA version >= 4.0.")]
public static CUResult cuEventDestroy(CUevent hEvent)
Parameters
Type | Name | Description |
---|---|---|
CUevent | hEvent | Event to destroy |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidHandle.
|
cuEventDestroy_v2(CUevent)
Destroys the event specified by event
.
In the case that hEvent
has been recorded but has not yet been completed
when cuEventDestroy(CUevent) is called, the function will return immediately and
the resources associated with hEvent
will be released automatically once
the device has completed hEvent
.
Declaration
public static CUResult cuEventDestroy_v2(CUevent hEvent)
Parameters
Type | Name | Description |
---|---|---|
CUevent | hEvent | Event to destroy |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidHandle.
|
cuEventElapsedTime(ref Single, CUevent, CUevent)
Computes the elapsed time between two events (in milliseconds with a resolution of around 0.5 microseconds). If either event has not been recorded yet, this function returns ErrorNotReady. If either event has been recorded with a non-zero stream, the result is undefined.
Declaration
public static CUResult cuEventElapsedTime(ref float pMilliseconds, CUevent hStart, CUevent hEnd)
Parameters
Type | Name | Description |
---|---|---|
System.Single | pMilliseconds | Returned elapsed time in milliseconds |
CUevent | hStart | Starting event |
CUevent | hEnd | Ending event |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidHandle, ErrorNotReady.
|
cuEventQuery(CUevent)
Returns Success if the event has actually been recorded, or ErrorNotReady if not. If cuEventRecord(CUevent, CUstream) has not been called on this event, the function returns ErrorInvalidValue.
Declaration
public static CUResult cuEventQuery(CUevent hEvent)
Parameters
Type | Name | Description |
---|---|---|
CUevent | hEvent | Event to query |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidHandle, ErrorInvalidValue, ErrorNotReady.
|
cuEventRecord(CUevent, CUstream)
Records an event. If stream
is non-zero, the event is recorded after all preceding operations in the stream have been
completed; otherwise, it is recorded after all preceding operations in the CUDA context have been completed. Since
operation is asynchronous, cuEventQuery(CUevent) and/or cuEventSynchronize(CUevent) must be used to determine when the event
has actually been recorded.
If cuEventRecord(CUevent, CUstream) has previously been called and the event has not been recorded yet, this function returns ErrorInvalidValue.
Declaration
public static CUResult cuEventRecord(CUevent hEvent, CUstream hStream)
Parameters
Type | Name | Description |
---|---|---|
CUevent | hEvent | Event to record |
CUstream | hStream | Stream to record event for |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidHandle, ErrorInvalidValue.
|
cuEventSynchronize(CUevent)
Waits until the event has actually been recorded. If cuEventRecord(CUevent, CUstream) has been called on this event, the function returns ErrorInvalidValue. Waiting for an event that was created with the BlockingSync flag will cause the calling CPU thread to block until the event has actually been recorded.
If cuEventRecord(CUevent, CUstream) has previously been called and the event has not been recorded yet, this function returns ErrorInvalidValue.
Declaration
public static CUResult cuEventSynchronize(CUevent hEvent)
Parameters
Type | Name | Description |
---|---|---|
CUevent | hEvent | Event to wait for |
Returns
Type | Description |
---|---|
CUResult | CUDA Error Codes: Success, ErrorDeinitialized, ErrorNotInitialized,
ErrorInvalidContext, ErrorInvalidHandle, ErrorInvalidValue.
|
cuStreamBatchMemOp(CUstream, UInt32, CUstreamBatchMemOpParams[], UInt32)
Batch operations to synchronize the stream via memory operations
This is a batch version of ::cuStreamWaitValue32() and::cuStreamWriteValue32().
Batching operations may avoid some performance overhead in both the API call and the device execution versus adding them to the stream in separate API calls.The operations are enqueued in the order they appear in the array.
See::CUstreamBatchMemOpType for the full set of supported operations, and ::cuStreamWaitValue32() and::cuStreamWriteValue32() for details of specific operations.
On Windows, the device must be using TCC, or this call is not supported. See ::cuDeviceGetAttribute().
Declaration
public static CUResult cuStreamBatchMemOp(CUstream stream, uint count, CUstreamBatchMemOpParams[] paramArray, uint flags)
Parameters
Type | Name | Description |
---|---|---|
CUstream | stream | The stream to enqueue the operations in. |
System.UInt32 | count | The number of operations in the array. Must be less than 256. |
CUstreamBatchMemOpParams[] | paramArray | The types and parameters of the individual operations. |
System.UInt32 | flags | Reserved for future expansion; must be 0. |
Returns
Type | Description |
---|---|
CUResult |
cuStreamWaitValue32(CUstream, CUdeviceptr, UInt32, CUstreamWaitValue_flags)
Wait on a memory location
Enqueues a synchronization of the stream on the given memory location. Work ordered after the operation will block until the given condition on the memory is satisfied. By default, the condition is to wait for (int32_t)(*addr - value) >= 0, a cyclic greater-or-equal.
Other condition types can be specified via \p flags.
If the memory was registered via ::cuMemHostRegister(), the device pointer should be obtained with::cuMemHostGetDevicePointer(). This function cannot be used with managed memory(::cuMemAllocManaged).
Support for this can be queried with ::cuDeviceGetAttribute() and ::CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_MEM_OPS. The only requirement for basic support is that on Windows, a device must be in TCC mode.
Declaration
public static CUResult cuStreamWaitValue32(CUstream stream, CUdeviceptr addr, uint value, CUstreamWaitValue_flags flags)
Parameters
Type | Name | Description |
---|---|---|
CUstream | stream | The stream to synchronize on the memory location. |
CUdeviceptr | addr | The memory location to wait on. |
System.UInt32 | value | The value to compare with the memory location. |
CUstreamWaitValue_flags | flags | See::CUstreamWaitValue_flags. |
Returns
Type | Description |
---|---|
CUResult |
cuStreamWaitValue64(CUstream, CUdeviceptr, UInt64, CUstreamWaitValue_flags)
Wait on a memory location
Enqueues a synchronization of the stream on the given memory location.Work ordered after the operation will block until the given condition on the memory is satisfied.By default, the condition is to wait for (int64_t)(*addr - value) >= 0, a cyclic greater-or-equal.
Other condition types can be specified via \p flags.
If the memory was registered via ::cuMemHostRegister(), the device pointer should be obtained with::cuMemHostGetDevicePointer().
Support for this can be queried with ::cuDeviceGetAttribute() and ::CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS.The requirements are compute capability 7.0 or greater, and on Windows, that the device be in TCC mode.
Declaration
public static CUResult cuStreamWaitValue64(CUstream stream, CUdeviceptr addr, ulong value, CUstreamWaitValue_flags flags)
Parameters
Type | Name | Description |
---|---|---|
CUstream | stream | The stream to synchronize on the memory location. |
CUdeviceptr | addr | The memory location to wait on. |
System.UInt64 | value | The value to compare with the memory location. |
CUstreamWaitValue_flags | flags | See::CUstreamWaitValue_flags. |
Returns
Type | Description |
---|---|
CUResult |
cuStreamWriteValue32(CUstream, CUdeviceptr, UInt32, CUstreamWriteValue_flags)
Write a value to memory
Write a value to memory.Unless the ::CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER flag is passed, the write is preceded by a system-wide memory fence, equivalent to a __threadfence_system() but scoped to the stream rather than a CUDA thread.
If the memory was registered via ::cuMemHostRegister(), the device pointer should be obtained with::cuMemHostGetDevicePointer(). This function cannot be used with managed memory(::cuMemAllocManaged).
Support for this can be queried with ::cuDeviceGetAttribute() and ::CU_DEVICE_ATTRIBUTE_CAN_USE_STREAM_MEM_OPS. The only requirement for basic support is that on Windows, a device must be in TCC mode.
Declaration
public static CUResult cuStreamWriteValue32(CUstream stream, CUdeviceptr addr, uint value, CUstreamWriteValue_flags flags)
Parameters
Type | Name | Description |
---|---|---|
CUstream | stream | The stream to do the write in. |
CUdeviceptr | addr | The device address to write to. |
System.UInt32 | value | The value to write. |
CUstreamWriteValue_flags | flags | See::CUstreamWriteValue_flags. |
Returns
Type | Description |
---|---|
CUResult |
cuStreamWriteValue64(CUstream, CUdeviceptr, UInt64, CUstreamWriteValue_flags)
Write a value to memory
Write a value to memory.Unless the ::CU_STREAM_WRITE_VALUE_NO_MEMORY_BARRIER flag is passed, the write is preceded by a system-wide memory fence, equivalent to a __threadfence_system() but scoped to the stream rather than a CUDA thread.
If the memory was registered via ::cuMemHostRegister(), the device pointer should be obtained with::cuMemHostGetDevicePointer(). This function cannot be used with managed memory(::cuMemAllocManaged).
Support for this can be queried with ::cuDeviceGetAttribute() and ::CU_DEVICE_ATTRIBUTE_CAN_USE_64_BIT_STREAM_MEM_OPS.The requirements are compute capability 7.0 or greater, and on Windows, that the device be in TCC mode.
Declaration
public static CUResult cuStreamWriteValue64(CUstream stream, CUdeviceptr addr, ulong value, CUstreamWriteValue_flags flags)
Parameters
Type | Name | Description |
---|---|---|
CUstream | stream | The stream to do the write in. |
CUdeviceptr | addr | The device address to write to. |
System.UInt64 | value | The value to write. |
CUstreamWriteValue_flags | flags | See::CUstreamWriteValue_flags. |
Returns
Type | Description |
---|---|
CUResult |