MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / ParallelFor

Method ParallelFor

oneflow/core/embedding/persistent_table.cpp:711–729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

709
710template<typename Key, typename Engine>
711void PersistentTableImpl<Key, Engine>::ParallelFor(size_t total,
712 const ForRange<Engine>& for_range) {
713 BlockingCounter bc(workers_.size());
714 std::atomic<size_t> counter(0);
715 for (size_t i = 0; i < workers_.size(); ++i) {
716 workers_.at(i)->Schedule([&](Engine* engine) {
717 while (true) {
718 const size_t start = counter.fetch_add(kParallelForStride, std::memory_order_relaxed);
719 if (start >= total) { break; }
720 const size_t next_start = start + kParallelForStride;
721 const size_t end = std::min(next_start, total);
722 for_range(engine, start, end);
723 }
724 engine->WaitUntilDone();
725 bc.Decrease();
726 });
727 }
728 bc.WaitForeverUntilCntEqualZero();
729}
730
731template<typename Key, typename Engine>
732class SnapshotIteratorImpl : public PersistentTable::Iterator {

Callers

nothing calls this directly

Calls 6

sizeMethod · 0.45
ScheduleMethod · 0.45
atMethod · 0.45
WaitUntilDoneMethod · 0.45
DecreaseMethod · 0.45

Tested by

no test coverage detected