MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/framework/run_handler_test.cc:36–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34namespace {
35
36TEST(RunHandlerUtilTest, TestBasicScheduling) {
37 int num_threads = 2;
38 int num_handlers = 10;
39
40 std::unique_ptr<RunHandlerPool> pool(
41 new RunHandlerPool(num_threads, num_threads));
42
43 // RunHandler should always be able to run num_threads inter closures
44 absl::Barrier barrier(num_threads);
45
46 BlockingCounter counter(2 * num_handlers * num_threads);
47
48 thread::ThreadPool test_pool(Env::Default(), "test", num_handlers);
49 for (int i = 0; i < num_handlers; ++i) {
50 test_pool.Schedule([&counter, &barrier, &pool, i, num_threads]() {
51 auto handler = pool->Get(i);
52 BlockingCounter local_counter(2 * num_threads);
53 auto intra_thread_pool = handler->AsIntraThreadPoolInterface();
54
55 for (int j = 0; j < num_threads; ++j) {
56 handler->ScheduleInterOpClosure(
57 [&local_counter, &counter, &barrier, i]() {
58 if (i == 2) {
59 barrier.Block();
60 }
61 counter.DecrementCount();
62 local_counter.DecrementCount();
63 });
64 intra_thread_pool->Schedule([&local_counter, &counter]() {
65 counter.DecrementCount();
66 local_counter.DecrementCount();
67 });
68 }
69 local_counter.Wait();
70 });
71 }
72 counter.Wait();
73}
74
75} // namespace
76} // namespace tensorflow

Callers

nothing calls this directly

Calls 8

DefaultFunction · 0.85
BlockMethod · 0.80
ScheduleMethod · 0.45
GetMethod · 0.45
DecrementCountMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected