diff --git a/src/core/impl/comp_node/cpu/comp_node.cpp b/src/core/impl/comp_node/cpu/comp_node.cpp index fe2ff456a71a4907a25cc96a265664a1edfc4122..682b51d7f00c26a635a4dcdd6926546e2cb0f0b1 100644 --- a/src/core/impl/comp_node/cpu/comp_node.cpp +++ b/src/core/impl/comp_node/cpu/comp_node.cpp @@ -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 m_worker_queue; Locator m_locator, m_locator_logical; std::unique_ptr 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 { diff --git a/src/core/test/graph/multi_thread.cpp b/src/core/test/graph/multi_thread.cpp index 0d951ac8c522e13349b5cde3c0d2cae3cd965390..1b9af8b0aed1dfa4a3a9e0f7b2b1cfdc97a7e6d7 100644 --- a/src/core/test/graph/multi_thread.cpp +++ b/src/core/test/graph/multi_thread.cpp @@ -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}}}