Class: SGC::CU::CUStream
- Inherits:
-
Object
- Object
- SGC::CU::CUStream
- Defined in:
- lib/cuda/driver/stream.rb
Class Method Summary collapse
-
.create(flags = 0) ⇒ CUStream
Create and return a stream with flags.
-
.wait_event(event, flags = 0) ⇒ Object
Let all future operations submitted to any stream in this context wait until event (CUEvent) complete before beginning execution.
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroy this CUDA stream.
-
#query ⇒ Boolean
Return true if all operations in this CUDA stream have completed.
-
#synchronize ⇒ CUStream
Block the calling CPU thread until all operations in this CUDA stream complete.
-
#wait_event(event, flags = 0) ⇒ CUStream
Let all future operations submitted to this CUDA stream wait until event (CUEvent) complete before beginning execution.
Class Method Details
.create ⇒ CUStream .create(flags) ⇒ CUStream
Create and return a stream with flags.
39 40 41 42 43 44 |
# File 'lib/cuda/driver/stream.rb', line 39 def self.create(flags = 0) p = FFI::MemoryPointer.new(:CUStream) status = API::cuStreamCreate(p, flags) Pvt::handle_error(status, "Failed to create stream: flags = #{flags}.") new(p) end |
.wait_event(event) ⇒ Object .wait_event(event, flags) ⇒ Object
Let all future operations submitted to any stream in this context wait until event (CUEvent) complete before beginning execution.
94 95 96 97 98 |
# File 'lib/cuda/driver/stream.rb', line 94 def self.wait_event(event, flags = 0) status = API::cuStreamWaitEvent(nil, event.to_api, flags) Pvt::handle_error(status, "Failed to make any stream's future operations to wait event: flags = #{flags}.") nil end |
Instance Method Details
#destroy ⇒ Object
Destroy this CUDA stream.
48 49 50 51 52 |
# File 'lib/cuda/driver/stream.rb', line 48 def destroy status = API::cuStreamDestroy(self.to_api) Pvt::handle_error(status, "Failed to destroy stream.") nil end |
#query ⇒ Boolean
Return true if all operations in this CUDA stream have completed. Otherwise, return false.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cuda/driver/stream.rb', line 56 def query status = API::cuStreamQuery(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 stream.") raise CUStandardError, "Error handling fails to catch this error." end |
#synchronize ⇒ CUStream
Block the calling CPU thread until all operations in this CUDA stream complete.
70 71 72 73 74 |
# File 'lib/cuda/driver/stream.rb', line 70 def synchronize status = API::cuStreamSynchronize(self.to_api) Pvt::handle_error(status, "Failed to synchronize stream.") self end |
#wait_event(event) ⇒ CUStream #wait_event(event, flags) ⇒ CUStream
Let all future operations submitted to this CUDA stream wait until event (CUEvent) complete before beginning execution.
83 84 85 86 87 |
# File 'lib/cuda/driver/stream.rb', line 83 def wait_event(event, flags = 0) status = API::cuStreamWaitEvent(self.to_api, event.to_api, flags) Pvt::handle_error(status, "Failed to make stream's future operations to wait event: flags = #{flags}.") self end |