提交 cb8e5363 编写于 作者: M Megvii Engine Team

fix(mgb/core): disable thread_local in ios due to x-code bug

GitOrigin-RevId: 4a7c838810cdaeeb53055a1e551280a7c7b73296
上级 ab698834
......@@ -243,7 +243,16 @@ class CpuCompNode::CompNodeImpl final: public CpuDispatchableBase {
class CompSeqRecEventImpl;
class CpuEventImpl;
//! TODO: because the x-code bug, see
//! https://github.com/tensorflow/tensorflow/issues/18356
//! thread local is no support on IOS,
//! When update x-xode, this code should be deleted
#ifndef IOS
static thread_local SeqRecorderImpl* sm_cur_recorder;
#else
SeqRecorderImpl* sm_cur_recorder = nullptr;
#endif
std::shared_ptr<WorkerQueue> m_worker_queue;
Locator m_locator, m_locator_logical;
std::unique_ptr<ThreadPool> m_thread_pool;
......@@ -444,8 +453,12 @@ class CpuCompNode::CompNodeImpl final: public CpuDispatchableBase {
m_thread_pool.get(), this);
}
//! current sequence recorder
SeqRecorderImpl* cur_recorder() const { return sm_cur_recorder; }
//! current sequence recorder of this thread
#ifndef IOS
static SeqRecorderImpl* cur_recorder() { return sm_cur_recorder; }
#else
SeqRecorderImpl* cur_recorder() { return sm_cur_recorder; }
#endif
void add_callback(Task &&task) override {
if (!check_global_finalized("add_callback()")) {
......@@ -457,8 +470,10 @@ class CpuCompNode::CompNodeImpl final: public CpuDispatchableBase {
};
MGB_DYN_TYPE_OBJ_FINAL_IMPL(CpuCompNodeImpl);
CpuCompNodeImpl* CpuCompNodeImpl::sm_default_cpu_comp_node_ptr;
#ifndef IOS
thread_local CpuCompNode::SeqRecorderImpl* CpuCompNodeImpl::sm_cur_recorder =
nullptr;
#endif
void CpuCompNode::SeqRecorderImpl::check_the_same_comp_node(
const CompNode& comp_node) const {
......
......@@ -196,7 +196,7 @@ TEST(TestGraph, ParallelRun) {
for (auto&& i : workers)
i.join();
}
#ifndef IOS
TEST(TestGraph, MultiThreadRecorder) {
using ConvParam = opr::Convolution::Param;
ConvParam param;
......@@ -227,5 +227,6 @@ TEST(TestGraph, MultiThreadRecorder) {
for (auto&& i : workers)
i.join();
}
#endif
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册