Skip to content

Raising: fold null-guarded pointer selects - #2992

Open
wsmoses wants to merge 1 commit into
mainfrom
pb/null-select-fold
Open

Raising: fold null-guarded pointer selects#2992
wsmoses wants to merge 1 commit into
mainfrom
pb/null-select-fold

Conversation

@wsmoses

@wsmoses wsmoses commented Aug 27, 2026

Copy link
Copy Markdown
Member

mfem's staging helpers (Read()/Write() in device.hpp) return null for empty buffers, so a captured device pointer reaches the kernel as select(size > 0, ptr, null), and raising fails on the select (hit by EABilinearFormExtension::GetElementMatrices and other assembly paths in the MFEM CUDA campaign, #2968).

When the pointer's value is only ever consumed as the address of a memory access (through geps, casts, further selects, or pointer2memref views feeding loads/stores/atomics), the null arm can only fault, so the select collapses to the real pointer. Pointers whose value is observed directly — compared, cast to int, stored as data, passed to a call — are left alone.

Includes a lit test where the folded kernel then raises end-to-end.

🤖 Generated with Claude Code

https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD

Staging helpers (mfem's Read/Write) return null for empty buffers, so a
captured device pointer reaches the kernel as select(size > 0, ptr, null)
and the raising fails on the select. When the pointer's value is only
ever consumed as the address of a memory access, the null arm can only
fault, so the select collapses to the real pointer. Pointers whose value
is observed directly (compared, cast to int, stored as data, passed to a
call) are left alone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
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