Class: SGC::Cuda::CudaEvent
- Inherits:
-
Object
- Object
- SGC::Cuda::CudaEvent
- Defined in:
- lib/cuda/runtime/event.rb
Class Method Summary collapse
-
.create(*flags) ⇒ CudaEvent
Create and return an event with flags.
-
.elapsed_time(event_start, event_end) ⇒ Numeric
Compute the elapsed time (ms) from event_start to event_end.
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroy this event.
-
#query ⇒ Boolean
Return true if this event has been recorded.
-
#record(stream = 0) ⇒ CudaEvent
Record this event asynchronously on stream.
-
#synchronize ⇒ CudaEvent
Block the calling CPU thread until this event has been recorded.
Class Method Details
.create ⇒ CudaEvent .create(flags) ⇒ CudaEvent
Create and return an event with flags.
38 39 40 41 42 43 44 45 |
# File 'lib/cuda/runtime/event.rb', line 38 def self.create(*flags) flags.empty? == false or flags = :DEFAULT p = FFI::MemoryPointer.new(:CudaEvent) f = CudaEventFlags.value(flags) status = API::cudaEventCreateWithFlags(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 to event_end.
95 96 97 98 99 |
# File 'lib/cuda/runtime/event.rb', line 95 def self.elapsed_time(event_start, event_end) t = FFI::MemoryPointer.new(:float) API::cudaEventElapsedTime(t, event_start.to_api, event_end.to_api) t.read_float end |
Instance Method Details
#destroy ⇒ Object
Destroy this event.
49 50 51 52 53 54 |
# File 'lib/cuda/runtime/event.rb', line 49 def destroy status = API::cudaEventDestroy(self.to_api) Pvt::handle_error(status, "Failed to destroy event.") API::write_cudaevent(@pevent, 0) nil end |
#query ⇒ Boolean
Return true if this event has been recorded. Otherwise, return false.
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cuda/runtime/event.rb', line 58 def query status = API::cudaEventQuery(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 CudaStandardError, "Error handling fails to catch this error." end |