gemini-code-assist[bot] commented on code in PR #19741:
URL: https://github.com/apache/tvm/pull/19741#discussion_r3399949133
##########
python/tvm/tirx/operator/intrinsics/cuda/cp_async.py:
##########
@@ -273,6 +273,12 @@ def _scale(n):
f" uint8_t* dst_p = (uint8_t*)dst + dst_off{dst_scale};\n"
f" uint8_t* src_p = (uint8_t*)src + src_off{src_scale};\n"
" unsigned int dst_addr = __cvta_generic_to_shared(dst_p);\n"
+ " if (!predicate) {\n"
+ f" for (int i = 0; i < {cp_size_v}; ++i) {{\n"
+ " dst_p[i] = 0;\n"
+ " }\n"
+ " return;\n"
+ " }\n"
Review Comment:

We can defer the computation of `dst_addr` (which performs generic-to-shared
address translation) until after the `if (!predicate)` check. This avoids
unnecessary address translation overhead when the predicate is false and the
function returns early.
```suggestion
" if (!predicate) {\n"
f" for (int i = 0; i < {cp_size_v}; ++i) {{\n"
" dst_p[i] = 0;\n"
" }\n"
" return;\n"
" }\n"
" unsigned int dst_addr =
__cvta_generic_to_shared(dst_p);\n"
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]