From 3b0d179de41e4212d94c2920c91004709ab78003 Mon Sep 17 00:00:00 2001 From: Zhang Hao Date: Tue, 28 Apr 2020 13:54:52 +0800 Subject: [PATCH] [VTA][Runtime] fix hardcode VerifyDep step --- docs/vta/dev/config.rst | 2 ++ vta/runtime/runtime.cc | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/vta/dev/config.rst b/docs/vta/dev/config.rst index 2f98d777608e..efbaafc7a619 100644 --- a/docs/vta/dev/config.rst +++ b/docs/vta/dev/config.rst @@ -55,6 +55,8 @@ below. | ``LOG_WGT_BUFF_SIZE`` | Int (log2) | Weight on-chip buffer in Bytes. | +-----------------------+------------+--------------------------------------------------------+ | ``LOG_ACC_BUFF_SIZE`` | Int (log2) | Accumulator on-chip buffer in Bytes. | ++-----------------------+------------+--------------------------------------------------------+ +| ``ACC_DEP_DISTANCE`` | Int | Accumulator dependence distance. | +-----------------------+------------+--------------------------------------------------------+ diff --git a/vta/runtime/runtime.cc b/vta/runtime/runtime.cc index 038d5cfa398c..276872526a14 100644 --- a/vta/runtime/runtime.cc +++ b/vta/runtime/runtime.cc @@ -145,6 +145,7 @@ struct DataBuffer { */ class UopKernel { public: + static const size_t kDefaultAccDepDistance = 3U; /*! \brief Loop information. */ struct LoopEntry { uint32_t extent; @@ -159,6 +160,12 @@ class UopKernel { */ UopKernel(const char* signature, int nbytes) : signature_(signature, signature + nbytes) { + const char* d_str = std::getenv("VTA_ACC_DEP_DISTANCE"); + if (d_str) { + acc_dep_distance_ = std::atoi(d_str); + } else { + acc_dep_distance_ = kDefaultAccDepDistance; + } } /*! * \brief Verify if the signature is correct. @@ -288,7 +295,7 @@ class UopKernel { private: // Verify that we don't write to the same acc_mem index two cycles in a row void VerifyDep(uint32_t dst_index) { - size_t step = std::min(static_cast(2U), seq_.size()); + size_t step = std::min(acc_dep_distance_ - 1, seq_.size()); for (size_t i = seq_.size() - step; i < seq_.size(); ++i) { CHECK(seq_[i].dst_idx != dst_index); } @@ -308,6 +315,8 @@ class UopKernel { std::vector loop_; // The loop pointer size_t loop_ptr_{0}; + // acc dep distance + size_t acc_dep_distance_{0}; }; /*!