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

Method ParallelForImpl

oneflow/core/thread/thread_runtime.h:99–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97class TbbRuntime final : public RuntimeBase {
98 private:
99 void ParallelForImpl(int64_t begin, int64_t end, const CallableT& func, size_t num_threads,
100 size_t grain_size) override {
101 tbb::global_control global_thread_limit(tbb::global_control::max_allowed_parallelism,
102 num_threads);
103 const size_t chunk_size = std::max(DivUp((end - begin), num_threads), grain_size);
104
105 tbb::parallel_for(
106 tbb::blocked_range<int64_t>(begin, end, chunk_size),
107 [&func](const tbb::blocked_range<int64_t>& r) { SeqFor(r.begin(), r.end(), func); },
108 tbb::static_partitioner{});
109 }
110};
111#endif
112

Callers

nothing calls this directly

Calls 4

DivUpFunction · 0.85
SeqForFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected