diff options
author | Todd Wang <toddw@google.com> | 2018-07-25 23:53:16 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-07-25 23:57:12 -0700 |
commit | 33879661ed221167f3987bcc2fdc5298986d29fb (patch) | |
tree | 5c33753b812221f3685419a1c211b345030cefbb /tensorflow/stream_executor/stream.cc | |
parent | fae3a601193c9a9e565e0a3a2b82e9e849abe49d (diff) |
Ensure failed sub-streams are not re-used.
Streams have a monotonic state machine; if a stream encounters any
error, it will remain in an error state forever. Without this change,
a previously failed sub-stream will be put back on sub_streams_, only
to cause the next usage of the sub-stream to trivially fail.
PiperOrigin-RevId: 206112024
Diffstat (limited to 'tensorflow/stream_executor/stream.cc')
-rw-r--r-- | tensorflow/stream_executor/stream.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tensorflow/stream_executor/stream.cc b/tensorflow/stream_executor/stream.cc index 2c495c99e1..6248aa2d01 100644 --- a/tensorflow/stream_executor/stream.cc +++ b/tensorflow/stream_executor/stream.cc @@ -1941,7 +1941,14 @@ void Stream::ReturnSubStream(Stream *sub_stream) { mutex_lock lock(mu_); for (auto &stream : sub_streams_) { if (stream.first.get() == sub_stream) { - stream.second = true; + // Streams have a monotonic state machine; if a stream + // encounters an error, it will remain in an error state + // forever. Only allow re-use of ok streams. + // + // TODO(toddw): Improve this mechanism, if necessary, to drop + // failed streams completely. + const bool ready_to_reuse = sub_stream->ok(); + stream.second = ready_to_reuse; return; } } |