Skip to content

[Bug] grid.memfence() missing Python-level arch guard #645

@alanray-tech

Description

@alanray-tech

Summary

grid.memfence() in python/quadrants/lang/simt/grid.py lacks a Python-level arch check, unlike every other SIMT primitive in block.py.

Details

The current implementation:

def memfence():
    return impl.call_internal("grid_memfence", with_runtime_context=False)

Every other op in block.py checks impl.get_runtime().prog.config().arch and raises a clear ValueError when the op is not supported on the current backend. grid.memfence() skips this check entirely.

According to the documentation in #638, grid.memfence() is CUDA-only. A user calling it on AMDGPU or SPIR-V will get a confusing error from the C++ runtime rather than a clean Python-level ValueError with a helpful message.

Suggested fix

Add an arch guard consistent with the pattern used in block.py:

def memfence():
    arch = impl.get_runtime().prog.config().arch
    if arch == _qd_core.cuda:
        return impl.call_internal("grid_memfence", with_runtime_context=False)
    raise ValueError(f"qd.simt.grid.memfence is not supported for arch {arch}")

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