Skip to content

[Bug] global_thread_idx() or-precedence bug makes SPIR-V branch unreachable #644

@alanray-tech

Description

@alanray-tech

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.*).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions