From 61dcfab7864b7406eb29626e577e29b91c71fa80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9E=A5=EC=A7=80=EC=84=AD/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 30 Aug 2019 17:37:25 +0900 Subject: [PATCH] Revert commits related to mutex in acl_cl::Object (#7062) - Revert "Fix deadlock when access two acl_cl at once (#6500)" - Revert "[neurun] Change acl_cl::Object::access to multithread safe (#5636)" This reverts commit 51671b098692a133d86624afc5455c6e01ef9302 This reverts commit 6097ce0e7d59be4342db40e1bfc104d5ec88c5fa Signed-off-by: jiseob.jang --- .../neurun/backend/acl_cl/kernel/ConcatLayer.cc | 15 ++++----- runtimes/neurun/backend/acl_cl/operand/Object.cc | 37 ++-------------------- runtimes/neurun/backend/acl_cl/operand/Object.h | 5 --- 3 files changed, 9 insertions(+), 48 deletions(-) diff --git a/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc b/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc index db4e04e..bc9a101 100644 --- a/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc +++ b/runtimes/neurun/backend/acl_cl/kernel/ConcatLayer.cc @@ -84,12 +84,12 @@ template bool ConcatLayer::concatenate() { uint32_t axis_offset = 0; - auto fn = [&](::neurun::backend::operand::ITensor &out_tensor, - ::neurun::backend::operand::ITensor &in_tensor) { + auto outout_fn = [&](::neurun::backend::operand::ITensor &out_tensor) { + for (auto input : _input_allocs) { auto &out_cl_tensor = static_cast<::neurun::backend::acl_cl::operand::ICLTensor &>(out_tensor); - { + auto input_fn = [&](::neurun::backend::operand::ITensor &in_tensor) { auto &in_cl_tensor = static_cast<::neurun::backend::acl_cl::operand::ICLTensor &>(in_tensor); for (uint32_t i = 0; i < in_cl_tensor.info()->dimension(0); i++) @@ -120,14 +120,11 @@ template bool ConcatLayer::concatenate() axis_offset += in_cl_tensor.info()->dimension(2); if (_axis == 3) axis_offset += in_cl_tensor.info()->dimension(3); - } + }; + input->access(input_fn); } }; - - for (auto input : _input_allocs) - { - _output_alloc->access(fn, *input); - } + _output_alloc->access(outout_fn); } VERBOSE(Concat_RUN) << "End Concat" << std::endl; diff --git a/runtimes/neurun/backend/acl_cl/operand/Object.cc b/runtimes/neurun/backend/acl_cl/operand/Object.cc index d49cb26..8f9b2a1 100644 --- a/runtimes/neurun/backend/acl_cl/operand/Object.cc +++ b/runtimes/neurun/backend/acl_cl/operand/Object.cc @@ -26,48 +26,17 @@ namespace acl_cl { namespace operand { -std::mutex Object::_mu{}; + void Object::access(const std::function &fn) const { - // This is an optional input - if (_tensor->total_size() == 0) - return; - auto &queue = ::arm_compute::CLScheduler::get().queue(); - // Calling access for more than one tensor causing an error in map(). May be sum of memory - // requests are too large. - // TODO: Need to investigate. Ideally it must have a non-static mutex and - // counter and in case of parallel call of THE SAME OBJECT, - // call the map() for the first one and unmap() for the last one - std::lock_guard lock{_mu}; - _tensor->map(queue); - - fn(*_tensor); - _tensor->unmap(queue); -} - -void Object::access(const std::function &fn, - backend::acl_cl::operand::Object &tensor_other) const -{ // This is an optional input - if (_tensor->total_size() == 0 || tensor_other.ptr()->total_size() == 0) + if (_tensor->total_size() == 0) return; - auto &queue = ::arm_compute::CLScheduler::get().queue(); - // Calling access for more than one tensor causing an error in map(). May be sum of memory - // requests are too large. - // TODO: Need to investigate. Ideally it must have a non-static mutex and - // counter and in case of parallel call of THE SAME OBJECT, - // call the map() for the first one and unmap() for the last one - std::lock_guard lock{_mu}; _tensor->map(queue); - tensor_other.ptr()->map(queue); - - fn(*_tensor, *tensor_other.ptr()); - - tensor_other.ptr()->unmap(queue); + fn(*_tensor); _tensor->unmap(queue); } diff --git a/runtimes/neurun/backend/acl_cl/operand/Object.h b/runtimes/neurun/backend/acl_cl/operand/Object.h index c0789ee..a4308fe 100644 --- a/runtimes/neurun/backend/acl_cl/operand/Object.h +++ b/runtimes/neurun/backend/acl_cl/operand/Object.h @@ -18,7 +18,6 @@ #define __NEURUN_BACKEND_ACL_CL_OPERAND_OBJECT_H__ #include -#include #include #include "operand/ICLTensor.h" @@ -48,13 +47,9 @@ public: private: std::shared_ptr _tensor; - static std::mutex _mu; public: void access(const std::function &fn) const override; - void access(const std::function &fn, - backend::acl_cl::operand::Object &tensor_other) const; }; } // namespace operand -- 2.7.4