- 
                Notifications
    You must be signed in to change notification settings 
- Fork 290
[Bugfix] Correctly construct the argument list for atomic add based on the vector size #1137
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
Conversation
| 👋 Hi! Thank you for contributing to the TileLang project. Please remember to run  We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 | 
| WalkthroughModified the atomic add vectorization rewriter to inline destination and value address arguments within each vector-size branch (4, 2) and use original nodes for the scalar path, eliminating duplicate argument emissions from the previous post-branching generic addition approach. Changes
 Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 
 Possibly related PRs
 Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/transform/atomicadd_vectorize.cc (1)
239-251: Consider reducing code duplication between vector size branches.The vector_size_ == 4 and vector_size_ == 2 branches are nearly identical except for the function name string. You could refactor to reduce duplication:
+ const char* func_name = nullptr; + bool use_addresses = false; + if (vector_size_ == 4) { - new_args.push_back(StringImm("AtomicAddx4")); - new_args.push_back(address_of_dst); - new_args.push_back(address_of_value); + func_name = "AtomicAddx4"; + use_addresses = true; } else if (vector_size_ == 2) { - new_args.push_back(StringImm("AtomicAddx2")); - new_args.push_back(address_of_dst); - new_args.push_back(address_of_value); + func_name = "AtomicAddx2"; + use_addresses = true; } else { - new_args.push_back(StringImm("AtomicAdd")); - new_args.push_back(dst_node); - new_args.push_back(value_node); + func_name = "AtomicAdd"; + use_addresses = false; } + + new_args.push_back(StringImm(func_name)); + if (use_addresses) { + new_args.push_back(address_of_dst); + new_args.push_back(address_of_value); + } else { + new_args.push_back(dst_node); + new_args.push_back(value_node); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
- src/transform/atomicadd_vectorize.cc(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/transform/atomicadd_vectorize.cc (1)
tilelang/language/tir/op.py (1)
address_of(464-480)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test for Python 3.12 with Metal (on macos-latest)
- GitHub Check: Test for Python 3.12 with ROCm-6.3 (on self-hosted-amd)
🔇 Additional comments (1)
src/transform/atomicadd_vectorize.cc (1)
234-253: LGTM! Argument construction now correctly distinguishes vectorized and scalar cases.The fix properly ensures that:
- Vectorized atomic adds (size 4 and 2) receive address pointers via
address_of()- Scalar atomic adds (else branch) receive the BufferLoad nodes directly
- The memory_order argument is appended consistently for all cases
This aligns perfectly with the PR objectives and resolves the argument list mismatch issue.
This pull request updates the argument handling logic in the
AtomicAddVectorizeRewriterclass to correctly construct the argument list for atomic add operations based on the vector size. The main change ensures that the correct arguments are passed for vectorized and non-vectorized atomic add calls.Atomic add argument handling improvements:
new_argsnow pushesaddress_of_dstandaddress_of_valueonly for vector sizes 2 and 4, while for the scalar case, it pushesdst_nodeandvalue_nodedirectly. This ensures that the argument list matches the expected function signature for each case.Summary by CodeRabbit