Skip to content

[Comgr][hotswap] Add the per-kernel raise context - #3720

Open
ftynse wants to merge 19 commits into
users/mluecke/comgr-static-closure-2927from
users/ftynse/hotswap-m0-08-raise-context
Open

[Comgr][hotswap] Add the per-kernel raise context#3720
ftynse wants to merge 19 commits into
users/mluecke/comgr-static-closure-2927from
users/ftynse/hotswap-m0-08-raise-context

Conversation

@ftynse

@ftynse ftynse commented Jul 30, 2026

Copy link
Copy Markdown

Add the per-kernel RaiseContext used by upcoming instruction handlers for operand resolution, register access, wave projection, and kernel layout state.
Register writes now keep EXEC caching, SGPR tracking, pointer provenance, and M0 tracking consistent. The change also handles the high and low halves of VCC and FLAT_SCR correctly and reports unsupported register operands.
Focused tests cover register mapping and state updates.
This PR is stacked on #3869. The following handler PR in this stack adds the production callers.

@ftynse
ftynse requested review from harsh-amd and xintin July 30, 2026 21:11
@github-actions github-actions Bot added comgr Related to Code Object Manager hotswap Related to the Comgr Hotswap feature labels Jul 30, 2026
Comment thread amd/comgr/src/hotswap/raiser/raise-context.cpp Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.cpp Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.cpp Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.cpp Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.h Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.h Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.h Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.h Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.h
Comment thread amd/comgr/src/hotswap/raiser/raise-context.h Outdated
Comment thread amd/comgr/src/hotswap/raiser/raise-context.h Outdated
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-07-layouts branch from 6816886 to 6ce2386 Compare August 5, 2026 11:38
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from a785ba6 to 0fa8ddd Compare August 5, 2026 11:38
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-07-layouts branch from 6ce2386 to c42e041 Compare August 5, 2026 11:50
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from 0fa8ddd to 3217ab9 Compare August 5, 2026 11:50
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-07-layouts branch from c42e041 to b21056a Compare August 5, 2026 11:59
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from 3217ab9 to 676c32c Compare August 5, 2026 11:59
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-07-layouts branch from b21056a to 90971ab Compare August 7, 2026 10:48
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from 676c32c to a993586 Compare August 7, 2026 10:48
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-07-layouts branch 2 times, most recently from c8352b4 to c6116b3 Compare August 7, 2026 12:25
@ftynse
ftynse force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from a993586 to fbe45f3 Compare August 7, 2026 12:57
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-07-layouts branch 4 times, most recently from 2e60b1a to 4c78c4f Compare August 11, 2026 12:38
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from fbe45f3 to 1bd626d Compare August 11, 2026 13:53
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-07-layouts branch from 4c78c4f to 6497687 Compare August 11, 2026 18:08
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from 037b1a8 to fa275f9 Compare August 11, 2026 18:09
Base automatically changed from users/ftynse/hotswap-m0-07-layouts to amd-staging August 11, 2026 23:22
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from fa275f9 to fde1246 Compare August 12, 2026 06:34
@martin-luecke
martin-luecke changed the base branch from amd-staging to users/ftynse/hotswap-m0-05-dylib-amdgpu-utils August 12, 2026 06:34
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from fde1246 to bda8042 Compare August 12, 2026 09:12
@martin-luecke
martin-luecke changed the base branch from users/ftynse/hotswap-m0-05-dylib-amdgpu-utils to users/mluecke/hotswap-reject-dylib-linkage August 12, 2026 09:14
@martin-luecke
martin-luecke requested a review from tgymnich August 12, 2026 12:26
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from d789b8b to 5e116f5 Compare August 13, 2026 12:25
An error occurred while trying to automatically change base from users/mluecke/hotswap-reject-dylib-linkage to amd-staging August 13, 2026 12:55
@martin-luecke
martin-luecke changed the base branch from users/mluecke/hotswap-reject-dylib-linkage to amd-staging August 13, 2026 13:52
@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-08-raise-context branch 2 times, most recently from 3cbaedf to a081014 Compare August 13, 2026 14:12
@martin-luecke
martin-luecke enabled auto-merge (squash) August 13, 2026 14:41
Teach llvm_add_library to preserve both the monolithic LLVM and component-library interfaces when LLVM is configured to link the dylib. A final consumer target property can select the component interface without changing the producer-wide default.

Use this interface for COMGR_STATIC_LLVM and capture COMGR's effective LLVM and Clang linkage before repeated package discovery. This lets the shared COMGR library embed its complete LLVM, Clang, and LLD closure while normal consumers continue using the configured dylibs.

This addresses #2927.
ftynse and others added 18 commits August 14, 2026 10:19
RaiseContext is the mutable state threaded through every instruction handler:
the IRBuilder and module, the register file, the wave projection, the MC state,
the decoded block-to-BasicBlock map, and the operand resolver that turns a
decoded operand into an SSA value or a register write. It ties together the
register file, projection, and layouts from the preceding patches into the
single object the handlers operate on.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use optional and unsigned types for register indices, consistently name the MC state, and append SmallVector ranges directly. This removes sentinel values and redundant casts without changing behavior.
The IRBuilder provides the LLVMContext and canonical scalar types, while the per-kernel function identifies its module. Drop the duplicated fields and derive these values at their use sites.
Use an i32 input so the half-write test exercises wave-mask decoding instead of the per-lane i1 shortcut.
Treat XNACK mask operands as unsupported instead of silently mapping them to zero, and make unknown register classification propagate a structured refusal. Null-register writes remain explicit discard operations.

Size VGPR bank adjustments from the decoded instruction and descriptor rather than a fixed operand limit. Assert decoded operand-shape invariants and cover the new refusal and discard paths directly.
Make RaiseContext update its EXEC cache, SGPR shadows and provenance, and M0 constant state as part of each handler-visible register write. Entry initialization can continue using direct AllocaRegFile stores without installing mutable callbacks.

This removes the register-file callback hooks and covers the coupled state changes through the normal RaiseContext write path.
Obtain the source and target ISA from the wave projection, require the descriptor-derived user-SGPR layout by reference, and drop the unused kernel and lane-cache block fields.

Use the provenance map itself to identify precomputed block state, and leave the handler result type for the handler-dispatch patch that first consumes it.
Reject unsupported architectural registers while parsing both source and destination operands, and invalidate every SGPR shadow touched by an EXEC-width write. Trust the AMDGPU operand tables to identify instructions affected by VGPR-MSB state instead of duplicating their classification.
The AMDGPU operand-role table is authoritative for whether an instruction uses S_SET_VGPR_MSB state. Treat malformed table entries as compiler invariants and remove the unused recoverable-error path.
AMDGPU subregister indices include composite ranges and cannot be counted as consecutive dword lanes. Query the active hardware-mode operand register class instead, and refuse decoded registers that the class does not accept.

Add focused coverage for an eight-dword scalar destination, mismatched register classes, and both null-register sink halves.
Preserve kernarg offsets across unrelated loads and keep source-wave shadow validity unchanged for inactive waves. Make RaiseContext own its per-SGPR shadow storage and report AMDGPU encoding formats through structured failures. Add focused coverage for each behavior.
Project VCC, EXEC, and zero-predicate reads to the current source wave when the target mask is wider. Keep SGPR shadow pair width in the alloca-backed state so a high-half write invalidates stale pair masks after a block boundary.

Add focused coverage for distinct widened mask halves and cross-block pair invalidation.
@martin-luecke
martin-luecke changed the base branch from amd-staging to users/mluecke/comgr-static-closure-2927 August 14, 2026 10:25
auto-merge was automatically disabled August 14, 2026 10:25

Invalid email address

@martin-luecke
martin-luecke force-pushed the users/ftynse/hotswap-m0-08-raise-context branch from a081014 to c178c32 Compare August 14, 2026 10:25
@martin-luecke
martin-luecke force-pushed the users/mluecke/comgr-static-closure-2927 branch from 22249e4 to 2499e97 Compare August 14, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comgr Related to Code Object Manager hotswap Related to the Comgr Hotswap feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants