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

Function BM_ParallelFor

tensorflow/core/lib/core/threadpool_test.cc:253–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251BENCHMARK(BM_Parallel);
252
253static void BM_ParallelFor(int iters, int total, int cost_per_unit) {
254 ThreadPool pool(Env::Default(), "test", kNumThreads);
255 // Decrement count concurrently until 0.
256 std::atomic_int_fast32_t count(iters);
257 mutex done_lock;
258 bool done_flag = false;
259 for (int i = 0; i < iters; ++i) {
260 pool.ParallelFor(total, cost_per_unit,
261 [&count, &done_lock, &done_flag](int64 begin, int64 end) {
262 for (int64 i = begin; i < end; ++i) {
263 if (count.fetch_sub(1) == 1) {
264 mutex_lock l(done_lock);
265 done_flag = true;
266 }
267 }
268 });
269 }
270 mutex_lock l(done_lock);
271 done_lock.Await(Condition(&done_flag));
272}
273BENCHMARK(BM_ParallelFor)
274 ->ArgPair(1 << 10, 1)
275 ->ArgPair(1 << 20, 1)

Callers

nothing calls this directly

Calls 4

DefaultFunction · 0.85
ConditionClass · 0.85
ParallelForMethod · 0.80
AwaitMethod · 0.45

Tested by

no test coverage detected