Avoid warning about unused variables#1125
Conversation
Commonly the NVTX annotations do not get a variable assigned
Greptile OverviewGreptile SummaryAdded Key Changes
Previous Review Thread ClarificationThe previous comments claiming variables are "now undefined" are incorrect. The variables remain properly defined and assigned. The Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Code as kernel_fusion.cu
participant NVTX as NVTX Macros
participant Compiler as C++ Compiler
Note over Code,Compiler: When NVTX is enabled
Code->>NVTX: MATX_NVTX_START_RANGE("Unfused Kernels")
NVTX->>NVTX: autoCreateNvtxEvent() returns int ID
NVTX-->>Code: Returns range ID
Code->>Code: Store in [[maybe_unused]] int unfused_range
Code->>Code: Execute operations
Code->>NVTX: MATX_NVTX_END_RANGE(unfused_range)
NVTX->>NVTX: endEvent(id) uses the variable
Note over Code,Compiler: When NVTX is disabled
Code->>NVTX: MATX_NVTX_START_RANGE("Unfused Kernels")
NVTX-->>Code: Macro expands to 0
Code->>Code: Store in [[maybe_unused]] int unfused_range = 0
Code->>Code: Execute operations
Code->>NVTX: MATX_NVTX_END_RANGE(unfused_range)
NVTX-->>Code: Macro expands to no-op
Note over Code,Compiler: [[maybe_unused]] prevents warning
|
| MATX_NVTX_START_RANGE("Unfused Kernels"); | ||
| (result = cos(C)).run(exec); | ||
| (result = result / D).run(exec); | ||
| (result = result * B).run(exec); | ||
| MATX_NVTX_END_RANGE(unfused_range); |
There was a problem hiding this comment.
unfused_range is now undefined. MATX_NVTX_START_RANGE was changed to not assign to a variable, but line 36 still references unfused_range in MATX_NVTX_END_RANGE(unfused_range).
| MATX_NVTX_START_RANGE("Unfused Kernels"); | |
| (result = cos(C)).run(exec); | |
| (result = result / D).run(exec); | |
| (result = result * B).run(exec); | |
| MATX_NVTX_END_RANGE(unfused_range); | |
| [[maybe_unused]] int unfused_range = MATX_NVTX_START_RANGE("Unfused Kernels"); | |
| (result = cos(C)).run(exec); | |
| (result = result / D).run(exec); | |
| (result = result * B).run(exec); | |
| MATX_NVTX_END_RANGE(unfused_range); |
| MATX_NVTX_START_RANGE("Fused Operation"); | ||
| (A = B * cos(C)/D).run(exec); | ||
| MATX_NVTX_END_RANGE(fused_range); |
There was a problem hiding this comment.
fused_range is now undefined. MATX_NVTX_START_RANGE was changed to not assign to a variable, but line 41 still references fused_range in MATX_NVTX_END_RANGE(fused_range).
| MATX_NVTX_START_RANGE("Fused Operation"); | |
| (A = B * cos(C)/D).run(exec); | |
| MATX_NVTX_END_RANGE(fused_range); | |
| [[maybe_unused]] int fused_range = MATX_NVTX_START_RANGE("Fused Operation"); | |
| (A = B * cos(C)/D).run(exec); | |
| MATX_NVTX_END_RANGE(fused_range); |
Additional Comments (1)
|
|
/build |
Commonly the NVTX annotations do not get a variable assigned
Picked up in CCCL CI