From e8e84fa02dad44322ce84e9bfd37cbc3805af970 Mon Sep 17 00:00:00 2001 From: Yida Wang <yidawa@gmail.com> Date: Fri, 11 May 2018 15:38:54 -0700 Subject: [PATCH] make ThreadPool thread local (#1152) * make ThreadPool thread local * add return --- src/runtime/thread_pool.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/runtime/thread_pool.cc b/src/runtime/thread_pool.cc index 71052626a..b7ea6f5b8 100644 --- a/src/runtime/thread_pool.cc +++ b/src/runtime/thread_pool.cc @@ -291,9 +291,8 @@ class ThreadPool { return res; } - static ThreadPool* Global() { - static ThreadPool inst; - return &inst; + static ThreadPool* ThreadLocal() { + return dmlc::ThreadLocalStore<ThreadPool>::Get(); } private: @@ -331,7 +330,7 @@ int TVMBackendParallelLaunch( FTVMParallelLambda flambda, void* cdata, int num_task) { - int res = tvm::runtime::ThreadPool::Global()->Launch( + int res = tvm::runtime::ThreadPool::ThreadLocal()->Launch( flambda, cdata, num_task, 1); return res; } -- GitLab