MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / set_affinity

Method set_affinity

src/core/impl/utils/thread_pool.cpp:103–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void ThreadPool::set_affinity(AffinityCallBack affinity_cb) {
104 mgb_assert(affinity_cb, "The affinity callback must not be nullptr");
105 std::lock_guard<std::mutex> lock(m_mutex_task);
106 m_core_binding_function = affinity_cb;
107 for (size_t i = 0; i < m_nr_threads - 1; i++) {
108 m_workers[i]->affinity_flag = true;
109 }
110 m_main_affinity_flag = true;
111}
112
113size_t ThreadPool::nr_threads() const {
114 return m_nr_threads;

Callers 3

TESTFunction · 0.45

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.36