Skip to content

Commit

Permalink
[VTA][Runtime] fix hardcode VerifyDep step
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghaohit committed Apr 28, 2020
1 parent 702db6f commit 95c551a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/vta/dev/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
+-----------------------+------------+--------------------------------------------------------+


Expand Down
11 changes: 10 additions & 1 deletion vta/runtime/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ struct DataBuffer {
*/
class UopKernel {
public:
static const size_t kDefaultAccDepDistance = 3U;
/*! \brief Loop information. */
struct LoopEntry {
uint32_t extent;
Expand All @@ -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.
Expand Down Expand Up @@ -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<size_t>(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);
}
Expand All @@ -308,6 +315,8 @@ class UopKernel {
std::vector<LoopEntry> loop_;
// The loop pointer
size_t loop_ptr_{0};
// acc dep distance
size_t acc_dep_distance_{0};
};

/*!
Expand Down

0 comments on commit 95c551a

Please sign in to comment.