Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CODEGEN] Fix code generation bugs for C/CUDA & Improve VerifyGPUCode pass #6041

Merged
merged 3 commits into from
Jul 13, 2020

Conversation

merrymercy
Copy link
Member

@merrymercy merrymercy commented Jul 13, 2020

  • Fix a bug when generating c code fortir.reinterpret
    If we call tir.reinterpret on an rvalue, the existing strategy will generate the wrong code. Because we cannot get the address of an rvalue. To fix this, we need to store the rvalue into a temporary variable and get the address of this temporary variable.
  • Fix a bug when generating unrolled and vectorized c code
    This bug is the same as the bug in [CODEGEN] update codegen for vector operation #711. In the old PR, I only added a new SSA scope for the "else" branch. But in the "then" branch, it has the same problem. So I moved the addition of a new SSA scope to the top-level to cover both "then" and "else" branch.
  • Improve the VeirfyGPUCode pass
    Besides checking the LoadNode, we should also check the StoreNode.

cc @weberlo @tqchen @jcf94

@merrymercy merrymercy force-pushed the pr-fix-cuda-codegen branch 2 times, most recently from 993c6fe to a877f3d Compare July 13, 2020 04:54
@merrymercy merrymercy requested a review from tqchen July 13, 2020 05:00
@merrymercy merrymercy changed the title [CODEGEN] Fix code generation bugs for cuda & Improve VerifyGPUCode pass [CODEGEN] Fix code generation bugs for C/CUDA & Improve VerifyGPUCode pass Jul 13, 2020
@@ -720,14 +720,15 @@ void CodeGenC::VisitStmt_(const StoreNode* op) {
} else {
CHECK(is_one(op->predicate)) << "Predicated store is not supported";
arith::PVar<PrimExpr> base;

// The assignment below introduces side-effect, and the resulting value cannot
// be reused across multiple expression, thus a new scope is needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!
Do we need to add some UTs to cover these cases?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test case added

@tqchen tqchen merged commit 5f4b9a9 into apache:master Jul 13, 2020
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jul 14, 2020
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jul 14, 2020
@merrymercy merrymercy deleted the pr-fix-cuda-codegen branch July 17, 2020 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants