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

Function ParallelFor

tensorflow/core/util/example_proto_fast_parsing.cc:443–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441using Config = FastParseExampleConfig;
442
443void ParallelFor(const std::function<void(size_t)>& f, size_t n,
444 thread::ThreadPool* thread_pool) {
445 if (n == 0) return;
446 if (thread_pool == nullptr) {
447 for (size_t i = 0; i < n; ++i) {
448 f(i);
449 }
450 } else {
451 BlockingCounter counter(n - 1);
452 for (size_t i = 1; i < n; ++i) {
453 thread_pool->Schedule([i, &f, &counter] {
454 f(i);
455 counter.DecrementCount();
456 });
457 }
458 f(0);
459 counter.Wait();
460 }
461}
462
463enum class Type { Sparse, Dense };
464

Callers 1

FastParseExampleFunction · 0.70

Calls 4

fFunction · 0.50
ScheduleMethod · 0.45
DecrementCountMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected