1 | #include <c10/core/Stream.h> |
---|---|
2 | #include <c10/core/impl/VirtualGuardImpl.h> |
3 | |
4 | namespace c10 { |
5 | |
6 | // Return whether all asynchronous work previously enqueued on this stream |
7 | // has completed running on the device. |
8 | bool Stream::query() const { |
9 | impl::VirtualGuardImpl impl{device_.type()}; |
10 | return impl.queryStream(*this); |
11 | } |
12 | |
13 | // Wait (by blocking the calling thread) until all asynchronous work enqueued |
14 | // on this stream has completed running on the device. |
15 | void Stream::synchronize() const { |
16 | impl::VirtualGuardImpl impl{device_.type()}; |
17 | impl.synchronizeStream(*this); |
18 | } |
19 | |
20 | // Not very parsable, but I don't know a good compact syntax for streams. |
21 | // Feel free to change this into something more compact if needed. |
22 | std::ostream& operator<<(std::ostream& stream, const Stream& s) { |
23 | stream << "stream "<< s.id() << " on device "<< s.device(); |
24 | return stream; |
25 | } |
26 | |
27 | } // namespace c10 |
28 |