diff options
Diffstat (limited to 'tensorflow/core/common_runtime/gpu/gpu_event_mgr_test.cc')
-rw-r--r-- | tensorflow/core/common_runtime/gpu/gpu_event_mgr_test.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tensorflow/core/common_runtime/gpu/gpu_event_mgr_test.cc b/tensorflow/core/common_runtime/gpu/gpu_event_mgr_test.cc index c5ff6c97a1..d2adf699f5 100644 --- a/tensorflow/core/common_runtime/gpu/gpu_event_mgr_test.cc +++ b/tensorflow/core/common_runtime/gpu/gpu_event_mgr_test.cc @@ -19,6 +19,7 @@ limitations under the License. #include <atomic> #include "tensorflow/core/common_runtime/gpu/gpu_init.h" +#include "tensorflow/core/lib/core/notification.h" #include "tensorflow/core/platform/stream_executor.h" #include "tensorflow/core/platform/test.h" #include "tensorflow/core/protobuf/config.pb.h" @@ -243,6 +244,28 @@ TEST(EventMgr, NonEmptyShutdown) { } } +// Tests that WarnIfInCallback() triggers correctly. +TEST(EventMgr, WarnIfInCallback) { + auto stream_exec = GPUMachineManager()->ExecutorForDevice(0).ValueOrDie(); + EventMgr em(stream_exec, GPUOptions()); + TEST_EventMgrHelper th(&em); + std::unique_ptr<se::Stream> stream(new se::Stream(stream_exec)); + CHECK(stream); + stream->Init(); + bool hit = false; + gpu_event_mgr::WarnIfInCallback([&hit] { hit = true; }); + EXPECT_FALSE(hit); + Notification note; + em.ThenExecute(stream.get(), [&hit, ¬e]() { + gpu_event_mgr::WarnIfInCallback([&hit, ¬e] { + hit = true; + note.Notify(); + }); + }); + note.WaitForNotification(); + EXPECT_TRUE(hit); +} + } // namespace } // namespace tensorflow |