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

Function BM_Parallel

tensorflow/core/lib/core/threadpool_test.cc:234–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232BENCHMARK(BM_Sequential);
233
234static void BM_Parallel(int iters) {
235 ThreadPool pool(Env::Default(), "test", kNumThreads);
236 // Decrement count concurrently until 0.
237 std::atomic_int_fast32_t count(iters);
238 mutex done_lock;
239 bool done_flag = false;
240 for (int i = 0; i < iters; ++i) {
241 pool.Schedule([&count, &done_lock, &done_flag]() {
242 if (count.fetch_sub(1) == 1) {
243 mutex_lock l(done_lock);
244 done_flag = true;
245 }
246 });
247 }
248 mutex_lock l(done_lock);
249 done_lock.Await(Condition(&done_flag));
250}
251BENCHMARK(BM_Parallel);
252
253static void BM_ParallelFor(int iters, int total, int cost_per_unit) {

Callers

nothing calls this directly

Calls 4

DefaultFunction · 0.85
ConditionClass · 0.85
ScheduleMethod · 0.45
AwaitMethod · 0.45

Tested by

no test coverage detected