Unverified Commit ce7b9323 authored by yyttt6's avatar yyttt6 Committed by GitHub
Browse files

[Bugfix]:Fix atomic add auto vectorize memory access out of bound error (#742)

* [Bugfix]:Fix atomic add auto vectorize memory access out of bound error

* Update atomicadd_vectorize.cc

* format
parent fff24aee
...@@ -170,10 +170,10 @@ private: ...@@ -170,10 +170,10 @@ private:
ICHECK(tx_var.defined()) << "Failed to find tx var"; ICHECK(tx_var.defined()) << "Failed to find tx var";
Var outer_var = Var(old_var->name_hint + "_outer"); Var outer_var = Var(old_var->name_hint + "_outer");
Map<Var, PrimExpr> vmap; Map<Var, PrimExpr> vmap;
vmap.Set(tx_var, // Scale thread index (tx) and loop variable by vector_size to map each
truncmod(tx_var, extent / vector_size_) * vector_size_); // new iteration to a vectorized chunk
vmap.Set(fnode->loop_var, outer_var * vector_size_ + vmap.Set(tx_var, tx_var * vector_size_);
truncdiv(tx_var, extent / vector_size_)); vmap.Set(fnode->loop_var, outer_var * vector_size_);
Stmt body = Substitute(fnode->body, vmap); Stmt body = Substitute(fnode->body, vmap);
return For(outer_var, 0, extent / vector_size_, fnode->kind, body, return For(outer_var, 0, extent / vector_size_, fnode->kind, body,
fnode->thread_binding, fnode->annotations, fnode->span); fnode->thread_binding, fnode->annotations, fnode->span);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment