mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:05:54 +01:00
[PR #247] rdna2spirv: support directed MODE.FP_ROUND[3:2] (+inf/-inf) and dynamic s_setreg_b32 #299
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#299
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/247
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/9982📝 Commits (1)
5f3dea6rdna2spirv: support directed MODE.FP_ROUND[3:2] (+inf/-inf) and dynamic s_setreg_b32📊 Changes
3 files changed (+521 additions, -49 deletions)
View changed files
➕
tests/semantic/test_mode_fp_round_directed.py(+386 -0)📝
tests/semantic/test_scalar_noop_waitcnt.py(+4 -5)📝
tools/rdna2spirv.py(+131 -44)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Adds full IEEE-754 directed rounding support (
RTP/+inf= mode 1 andRTN/-inf= mode 2) and dynamic SGPRs_setreg_b32writes forMODE.FP_ROUND[3:2](f16 and f64 rounding) intools/rdna2spirv.py.What changed
Gen._round_mode_flags(is_neg, mode_val)to map all fourMODE.FP_ROUND[3:2]encodings (0=RNE,1=RTP,2=RTN,3=RTZ) into sign-awareis_trunc(toward zero) andis_away(away from zero) predicates.Gen.f16_bits/Gen.f16_res: extended integer-only f32-to-f16 narrowing to handle all four rounding modes across normals (bias0x1FFFwhenis_away), subnormals & tiny non-zero underflow (all_onesguarded one != 0so±0.0stays±0.0while2^-126 <= |x| < 2^-24rounds away to±0x0001), and overflow boundaries (> 65504.0overflows to±infinis_away, clamps to±65504inis_trunc).Gen.f16_omod: finitemul:2/mul:4overflow now uses sign-awareis_trunc(±65504vs±inf).Gen.sum_toward_zero&Gen.f64_add_mode: extended TwoSum / FastTwoSum error adjustment to step 1 ulp away from zero whenis_away(includingDBL_MAX + 1.0 -> +infunderRTP) and produce-0.0on opposite-sign exact cancellation underRTN(mode == 2), per IEEE-754.Gen.mode_write&Gen.write_half_round_mode: accepted modes1and2ins_round_modeands_setreg_imm32_b32, and lowered dynamic SGPRs_setreg_b32 hwreg(HW_REG_MODE, 2, 2), sX(sX & 3 -> %mode_r16). Writes targeting otherHW_REG_MODEbit ranges remainUnsupported.fractions.FractionIEEE-754 oracle +spirv_asm.assemble()) intests/semantic/test_mode_fp_round_directed.pyand updatedtests/semantic/test_scalar_noop_waitcnt.pyto move modes1/2ands_round_mode 4/8into the modelled set.Verification
python -I -m unittest discover -s tests/semantic -p "test_mode_fp_round_directed.py" -v(PASS)python -I -m unittest discover -s tests/semantic -p "test_scalar_noop_waitcnt.py" -v(PASS)python -I -m unittest discover -s tests/semantic -p "test_valu_add_f64.py" -v(PASS)python -I -m unittest discover -s tests/semantic -p "test_f16_omod_rdna2.py" -v(PASS)python -I -m unittest discover -s tests/semantic -p "test_f16_sum_narrowing.py" -v(PASS)python -I -m unittest discover -s tests/semantic -p "test_valu_mul_f16_mode_round.py" -v(PASS)python -m compileall -q tools/rdna2spirv.py tests/semantic/test_mode_fp_round_directed.py tests/semantic/test_scalar_noop_waitcnt.py(PASS)python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_mode_fp_round_directed.py tests/semantic/test_scalar_noop_waitcnt.py(PASS)Note: AI-assisted implementation, verified locally against the semantic/assembler test suites above (no game data used).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.