- java.lang.Object
-
- com.ibm.cuda.CudaEvent
-
- All Implemented Interfaces:
AutoCloseable
public final class CudaEvent extends Object implements AutoCloseable
TheCudaEvent
class represents an event that can be queued in a stream on a CUDA-capable device.When no longer required, an event must be
close
d.
-
-
Field Summary
Fields Modifier and Type Field Description static int
FLAG_BLOCKING_SYNC
Use blocking synchronization.static int
FLAG_DEFAULT
Default event creation flag.static int
FLAG_DISABLE_TIMING
Do not record timing data.static int
FLAG_INTERPROCESS
Event is suitable for interprocess use.
-
Constructor Summary
Constructors Constructor Description CudaEvent(CudaDevice device)
Creates a new event on the specified device with default flags.CudaEvent(CudaDevice device, int flags)
Creates a new event on the specified device with the specifiedflags
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases resources associated with this event.float
elapsedTimeSince(CudaEvent priorEvent)
Returns the elapsed time (in milliseconds) relative to the specifiedpriorEvent
.int
query()
Queries the state of this event.void
record(CudaDevice device)
Records this event on the default stream of the specified device.void
record(CudaStream stream)
Records this event on the specified stream.void
synchronize()
Synchronizes on this event.
-
-
-
Field Detail
-
FLAG_DEFAULT
public static final int FLAG_DEFAULT
Default event creation flag.- See Also:
- Constant Field Values
-
FLAG_BLOCKING_SYNC
public static final int FLAG_BLOCKING_SYNC
Use blocking synchronization.- See Also:
- Constant Field Values
-
FLAG_DISABLE_TIMING
public static final int FLAG_DISABLE_TIMING
Do not record timing data.- See Also:
- Constant Field Values
-
FLAG_INTERPROCESS
public static final int FLAG_INTERPROCESS
Event is suitable for interprocess use. FLAG_DISABLE_TIMING must be set.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CudaEvent
public CudaEvent(CudaDevice device) throws CudaException
Creates a new event on the specified device with default flags.- Parameters:
device
- the specified device- Throws:
CudaException
- if a CUDA exception occurs
-
CudaEvent
public CudaEvent(CudaDevice device, int flags) throws CudaException
Creates a new event on the specified device with the specifiedflags
.- Parameters:
device
- the specified deviceflags
- the desired flags- Throws:
CudaException
- if a CUDA exception occurs
-
-
Method Detail
-
close
public void close() throws CudaException
Releases resources associated with this event.- Specified by:
close
in interfaceAutoCloseable
- Throws:
CudaException
- if a CUDA exception occurs
-
elapsedTimeSince
public float elapsedTimeSince(CudaEvent priorEvent) throws CudaException
Returns the elapsed time (in milliseconds) relative to the specifiedpriorEvent
.- Parameters:
priorEvent
- the prior event- Returns:
- the elapsed time (in milliseconds) between the occurrence of the prior event and this event
- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this event or the prior event has been closed (seeclose()
)
-
query
public int query()
Queries the state of this event. The common normally occurring states are:- CudaError.Success - event has occurred
- CudaError.NotReady - event has not occurred
- Returns:
- the state of this event
- Throws:
IllegalStateException
- if this event has been closed (seeclose()
)- See Also:
CudaError
-
record
public void record(CudaDevice device) throws CudaException
Records this event on the default stream of the specified device.- Parameters:
device
- the specified device- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this event has been closed (seeclose()
)
-
record
public void record(CudaStream stream) throws CudaException
Records this event on the specified stream.- Parameters:
stream
- the specified stream- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this event has been closed (seeclose()
), or the stream has been closed (seeCudaStream.close()
)
-
synchronize
public void synchronize() throws CudaException
Synchronizes on this event. This method blocks until the associated event has occurred.- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this event has been closed (seeclose()
)
-
-