Class: SGC::Cuda::CudaStream
- Inherits:
-
Object
- Object
- SGC::Cuda::CudaStream
- Defined in:
- lib/cuda/runtime/stream.rb
Class Method Summary collapse
-
.create ⇒ CudaStream
Create and return a CUDA stream.
-
.wait_event(event, flags = 0) ⇒ Object
Let all future operations submitted to any CUDA stream wait until event 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 ⇒ CudaStream
Block the calling CPU thread until all operations in this CUDA stream complete.
-
#wait_event(event, flags = 0) ⇒ CudaStream
Let all future operations submitted to this CUDA stream wait until event complete before beginning execution.
Class Method Details
.create ⇒ CudaStream
Create and return a CUDA stream.
36 37 38 39 40 41 |
# File 'lib/cuda/runtime/stream.rb', line 36 def self.create p = FFI::MemoryPointer.new(:CudaStream) status = API::cudaStreamCreate(p) Pvt::handle_error(status, "Failed to create CUDA stream.") new(p) end |
.wait_event(event) ⇒ Object .wait_event(event, flags) ⇒ Object
Let all future operations submitted to any CUDA stream wait until event complete before beginning execution.
92 93 94 95 96 |
# File 'lib/cuda/runtime/stream.rb', line 92 def self.wait_event(event, flags = 0) status = API::cudaStreamWaitEvent(nil, event.to_api, flags) Pvt::handle_error(status, "Failed to make any CUDA stream's future operations to wait event: flags = #{flags}.") nil end |
Instance Method Details
#destroy ⇒ Object
Destroy this CUDA stream.
45 46 47 48 49 50 |
# File 'lib/cuda/runtime/stream.rb', line 45 def destroy status = API::cudaStreamDestroy(self.to_api) Pvt::handle_error(status, "Failed to destroy this CUDA stream.") API::write_cudastream(@pstream, 0) nil end |
#query ⇒ Boolean
Return true if all operations in this CUDA stream have completed. Otherwise, return false.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cuda/runtime/stream.rb', line 54 def query status = API::cudaStreamQuery(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 CudaStandardError, "Error handling fails to catch this error." end |
#synchronize ⇒ CudaStream
Block the calling CPU thread until all operations in this CUDA stream complete.
68 69 70 71 72 |
# File 'lib/cuda/runtime/stream.rb', line 68 def synchronize status = API::cudaStreamSynchronize(self.to_api) Pvt::handle_error(status) self end |
#wait_event(event) ⇒ CudaStream #wait_event(event, flags) ⇒ CudaStream
Let all future operations submitted to this CUDA stream wait until event complete before beginning execution.
81 82 83 84 85 |
# File 'lib/cuda/runtime/stream.rb', line 81 def wait_event(event, flags = 0) status = API::cudaStreamWaitEvent(self.to_api, event.to_api, flags) Pvt::handle_error(status, "Failed to make this CUDA stream's future operations to wait event: flags = #{flags}.") self end |