Skip to content

The Grid Size Guard #28

@kellen-sun

Description

@kellen-sun

A Gemini comment??

When you write the UNARY_OP and BINARY_OP macros into your string generator, I highly recommend adding a grid boundary check.

In your C++ execute() loop, threadgroup sizes are often multiples of 32 or 64. If your tensor has 100 elements, you might dispatch 128 threads to the GPU. Those extra 28 threads will execute the kernel, read past the end of your buffer, and crash the GPU driver.

Pass the total_elements (numel) as a scalar, and put this at the very top of your macros:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions