Summary
block.global_thread_idx() in python/quadrants/lang/simt/block.py has a Python operator-precedence bug that makes the SPIR-V codepath unreachable.
Details
Line 61:
if arch == _qd_core.cuda or _qd_core.amdgpu:
Due to Python's operator precedence, this parses as (arch == _qd_core.cuda) or (_qd_core.amdgpu). Since _qd_core.amdgpu is a truthy enum value, the condition is always true regardless of arch. This means:
- The SPIR-V branch on lines 63-64 (
globalInvocationId) is dead code and can never execute.
- Calling
global_thread_idx() on a Vulkan/Metal backend will attempt to call insert_thread_idx_expr() instead of globalInvocationId, which is incorrect.
Fix
if arch == _qd_core.cuda or arch == _qd_core.amdgpu:
Found during
Review of #638 (docs for qd.simt.block.*).
Summary
block.global_thread_idx()inpython/quadrants/lang/simt/block.pyhas a Python operator-precedence bug that makes the SPIR-V codepath unreachable.Details
Line 61:
Due to Python's operator precedence, this parses as
(arch == _qd_core.cuda) or (_qd_core.amdgpu). Since_qd_core.amdgpuis a truthy enum value, the condition is always true regardless ofarch. This means:globalInvocationId) is dead code and can never execute.global_thread_idx()on a Vulkan/Metal backend will attempt to callinsert_thread_idx_expr()instead ofglobalInvocationId, which is incorrect.Fix
Found during
Review of #638 (docs for
qd.simt.block.*).