Skip to content

Don't flag host stack allocations feeding a GPU kernel as cross-talk - #9450

Open
abadams wants to merge 1 commit into
mainfrom
abadams/fix_compute_root_stack_input_to_gpu_kernel
Open

abadams wants to merge 1 commit into
mainfrom
abadams/fix_compute_root_stack_input_to_gpu_kernel

Conversation

@abadams

@abadams abadams commented Sep 14, 2026

Copy link
Copy Markdown
Member

Problem

A Func scheduled compute_root().store_in(MemoryType::Stack) and read by a GPU kernel was tripping the GPU register/stack cross-talk check added in #9325, e.g.:

Func input;
input(x) = x * 2;
input.compute_root().store_in(MemoryType::Stack);

Func f;
f(x, y) = input(x) + input(x + 1);
f.gpu_tile(x, y, xo, yo, xi, yi, 8, 8);

fails with:

Error: The allocation f0 is scheduled to live in Stack memory, which is private
to a GPU thread ...

But this allocation lives on the CPU stack — a single host copy that every GPU
thread reads, like any other input buffer — not a per-thread private copy, so
there is no cross-talk to check for.

Cause

CheckCrossTalk::visit(Realize*) flagged any Register/Stack allocation
scheduled outside the loops over GPU threads, without checking whether it was
inside a GPU kernel at all. It couldn't distinguish a genuine block-level
per-thread allocation from a host allocation that merely happens to be read by a
kernel.

Fix

Track whether we are inside any GPU loop (is_gpu(op->for_type)) and only run
the check when the allocation is both inside a kernel and outside the thread
loops.

Test

Added a case to test/correctness/gpu_register_at_block_level.cpp covering a
host stack allocation feeding a GPU kernel. Verified the existing
test/error/gpu_register_* negative tests still correctly reject real
cross-talk.

🤖 Generated with Claude Code

The GPU register/stack cross-talk check flagged any Register or Stack
allocation scheduled outside the loops over GPU threads. But a Func
scheduled compute_root().store_in(MemoryType::Stack) and read by a GPU
kernel lives in ordinary host memory: a single copy every thread reads,
not a per-thread private copy, so there is nothing to tell apart.

Only run the check on allocations that are actually inside a GPU kernel
by tracking whether we are within any GPU loop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.06%. Comparing base (e02a03f) to head (5bac27e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9450      +/-   ##
==========================================
+ Coverage   70.03%   70.06%   +0.02%     
==========================================
  Files         261      261              
  Lines       79802    79805       +3     
  Branches    19455    19456       +1     
==========================================
+ Hits        55892    55912      +20     
- Misses      17997    18013      +16     
+ Partials     5913     5880      -33     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant