You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "tqchen (via GitHub)" <gi...@apache.org> on 2023/03/07 14:21:05 UTC

[GitHub] [tvm] tqchen opened a new pull request, #14224: [TIR] Enhance loop unroll with unroll local access.

tqchen opened a new pull request, #14224:
URL: https://github.com/apache/tvm/pull/14224

   This PR enhances the unroller with an unroll local access option. This option will detect loop variables that access local memories and unroll them independent of other options.
   
   A test case is added. This option is by default turned off and can be useful in certain cases to improve unroller as these local memory access have to be unrolled at some time pt to be lifted as registers.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tqchen commented on a diff in pull request #14224: [TIR] Enhance loop unroll with unroll local access

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on code in PR #14224:
URL: https://github.com/apache/tvm/pull/14224#discussion_r1128107313


##########
src/tir/transforms/unroll_loop.cc:
##########
@@ -137,14 +165,36 @@ class LoopUnroller : public StmtExprMutator {
     LOG(FATAL) << "Unexpected use of deprecated StoreNode.  Please use BufferStoreNode instead.";
   }
 
+  PrimExpr VisitExpr_(const BufferLoadNode* op) final {
+    if (unroll_local_access_) {
+      auto storage_scope = runtime::StorageScope::Create(GetPtrStorageScope(op->buffer->data));
+      if (storage_scope.rank == runtime::StorageRank::kLocal) {
+        VarLocalAccessMarker marker(&var_touched_local_);
+        for (PrimExpr e : op->indices) {
+          marker(e);
+        }
+      }
+    }
+    return GetRef<PrimExpr>(op);
+  }
+
   Stmt VisitStmt_(const BufferStoreNode* op) final {
     ++step_count_;
-    return StmtExprMutator::VisitStmt_(op);
+    if (unroll_local_access_) {
+      auto storage_scope = runtime::StorageScope::Create(GetPtrStorageScope(op->buffer->data));
+      if (storage_scope.rank == runtime::StorageRank::kLocal) {
+        VarLocalAccessMarker marker(&var_touched_local_);
+        for (PrimExpr e : op->indices) {
+          marker(e);
+        }
+      }
+    }
+    return StmtMutator::VisitStmt_(op);
   }
 
   Stmt VisitStmt_(const EvaluateNode* op) final {
     ++step_count_;
-    return StmtExprMutator::VisitStmt_(op);
+    return StmtMutator::VisitStmt_(op);

Review Comment:
   good catch updated



##########
src/tir/transforms/unroll_loop.cc:
##########
@@ -137,14 +165,36 @@ class LoopUnroller : public StmtExprMutator {
     LOG(FATAL) << "Unexpected use of deprecated StoreNode.  Please use BufferStoreNode instead.";
   }
 
+  PrimExpr VisitExpr_(const BufferLoadNode* op) final {
+    if (unroll_local_access_) {
+      auto storage_scope = runtime::StorageScope::Create(GetPtrStorageScope(op->buffer->data));
+      if (storage_scope.rank == runtime::StorageRank::kLocal) {

Review Comment:
   added



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] tvm-bot commented on pull request #14224: [TIR] Enhance loop unroll with unroll local access.

Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #14224:
URL: https://github.com/apache/tvm/pull/14224#issuecomment-1458258888

   <!---bot-comment-->
   
   Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
   
   <!--bot-comment-ccs-start-->
    * cc @Hzfengsy, @junrushao, @quic-sanirudh, @shingjan <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
   
   <sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] yzh119 commented on a diff in pull request #14224: [TIR] Enhance loop unroll with unroll local access

Posted by "yzh119 (via GitHub)" <gi...@apache.org>.
yzh119 commented on code in PR #14224:
URL: https://github.com/apache/tvm/pull/14224#discussion_r1127986799


##########
src/tir/transforms/unroll_loop.cc:
##########
@@ -137,14 +165,36 @@ class LoopUnroller : public StmtExprMutator {
     LOG(FATAL) << "Unexpected use of deprecated StoreNode.  Please use BufferStoreNode instead.";
   }
 
+  PrimExpr VisitExpr_(const BufferLoadNode* op) final {
+    if (unroll_local_access_) {
+      auto storage_scope = runtime::StorageScope::Create(GetPtrStorageScope(op->buffer->data));
+      if (storage_scope.rank == runtime::StorageRank::kLocal) {
+        VarLocalAccessMarker marker(&var_touched_local_);
+        for (PrimExpr e : op->indices) {
+          marker(e);
+        }
+      }
+    }
+    return GetRef<PrimExpr>(op);
+  }
+
   Stmt VisitStmt_(const BufferStoreNode* op) final {
     ++step_count_;
-    return StmtExprMutator::VisitStmt_(op);
+    if (unroll_local_access_) {
+      auto storage_scope = runtime::StorageScope::Create(GetPtrStorageScope(op->buffer->data));
+      if (storage_scope.rank == runtime::StorageRank::kLocal) {
+        VarLocalAccessMarker marker(&var_touched_local_);
+        for (PrimExpr e : op->indices) {
+          marker(e);
+        }
+      }
+    }
+    return StmtMutator::VisitStmt_(op);
   }
 
   Stmt VisitStmt_(const EvaluateNode* op) final {
     ++step_count_;
-    return StmtExprMutator::VisitStmt_(op);
+    return StmtMutator::VisitStmt_(op);

Review Comment:
   Why changed to `StmtMutator`?



##########
src/tir/transforms/unroll_loop.cc:
##########
@@ -137,14 +165,36 @@ class LoopUnroller : public StmtExprMutator {
     LOG(FATAL) << "Unexpected use of deprecated StoreNode.  Please use BufferStoreNode instead.";
   }
 
+  PrimExpr VisitExpr_(const BufferLoadNode* op) final {
+    if (unroll_local_access_) {
+      auto storage_scope = runtime::StorageScope::Create(GetPtrStorageScope(op->buffer->data));
+      if (storage_scope.rank == runtime::StorageRank::kLocal) {

Review Comment:
   Should we also consider warp-level memory (identical to local for CUDA).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] junrushao merged pull request #14224: [TIR] Enhance loop unroll with unroll local access

Posted by "junrushao (via GitHub)" <gi...@apache.org>.
junrushao merged PR #14224:
URL: https://github.com/apache/tvm/pull/14224


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org