Class: SGC::CU::CUEvent
- Inherits:
-
Object
- Object
- SGC::CU::CUEvent
- Defined in:
- lib/cuda/driver/event.rb
Class Method Summary collapse
-
.create(*flags) ⇒ CUEvent
Create and return an event with flags (CUEventFlags).
-
.elapsed_time(event_start, event_end) ⇒ Numeric
Compute the elapsed time (ms) from event_start (CUEvent) to event_end (CUEvent).
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroy this event.
-
#query ⇒ Boolean
Return true if this event has been recorded.
-
#record(stream = 0) ⇒ CUEvent
Record this event asynchronously on stream.
-
#synchronize ⇒ CUEvent
Block the calling CPU thread until this event has been recorded.
Class Method Details
.create ⇒ CUEvent .create(flags) ⇒ CUEvent
Create and return an event with flags (CUEventFlags).
46 47 48 49 50 51 52 53 |
# File 'lib/cuda/driver/event.rb', line 46 def self.create(*flags) flags.empty? == false or flags = :DEFAULT p = FFI::MemoryPointer.new(:CUEvent) f = CUEventFlags.value(flags) status = API::cuEventCreate(p, f) Pvt::handle_error(status, "Failed to create event: flags = #{flags}.") new(p) end |
.elapsed_time(event_start, event_end) ⇒ Numeric
Compute the elapsed time (ms) from event_start (CUEvent) to event_end (CUEvent).
102 103 104 105 106 |
# File 'lib/cuda/driver/event.rb', line 102 def self.elapsed_time(event_start, event_end) t = FFI::MemoryPointer.new(:float) API::cuEventElapsedTime(t, event_start.to_api, event_end.to_api) t.read_float end |
Instance Method Details
#destroy ⇒ Object
Destroy this event.
57 58 59 60 61 |
# File 'lib/cuda/driver/event.rb', line 57 def destroy status = API::cuEventDestroy(self.to_api) Pvt::handle_error(status, "Failed to destroy event.") nil end |
#query ⇒ Boolean
Return true if this event has been recorded. Otherwise, return false.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cuda/driver/event.rb', line 65 def query status = API::cuEventQuery(self.to_api) if status == Pvt::CUDA_SUCCESS return true elsif status == Pvt::CUDA_ERROR_NOT_READY return false end Pvt::handle_error(status, "Failed to query event.") raise CUStandardError, "Error handling fails to catch this error." end |