| 24 | namespace se = stream_executor; |
| 25 | |
| 26 | TEST(HostStream, EnforcesFIFOOrder) { |
| 27 | se::Platform* platform = |
| 28 | se::MultiPlatformManager::PlatformWithName("Host").ValueOrDie(); |
| 29 | se::StreamExecutor* executor = platform->ExecutorForDevice(0).ValueOrDie(); |
| 30 | se::Stream stream(executor); |
| 31 | stream.Init(); |
| 32 | |
| 33 | absl::Mutex mu; |
| 34 | int expected = 0; |
| 35 | bool ok = true; |
| 36 | for (int i = 0; i < 2000; ++i) { |
| 37 | stream.ThenDoHostCallback([i, &mu, &expected, &ok]() { |
| 38 | absl::MutexLock lock(&mu); |
| 39 | if (expected != i) { |
| 40 | ok = false; |
| 41 | } |
| 42 | ++expected; |
| 43 | }); |
| 44 | } |
| 45 | TF_ASSERT_OK(stream.BlockHostUntilDone()); |
| 46 | absl::MutexLock lock(&mu); |
| 47 | EXPECT_TRUE(ok); |
| 48 | } |
nothing calls this directly
no test coverage detected