Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于fnmadd.s指令在溢出边界条件时运算错误 #114

Open
Jishuaishuai123 opened this issue Dec 8, 2022 · 3 comments
Open

关于fnmadd.s指令在溢出边界条件时运算错误 #114

Jishuaishuai123 opened this issue Dec 8, 2022 · 3 comments
Assignees

Comments

@Jishuaishuai123
Copy link

Jishuaishuai123 commented Dec 8, 2022

1.rs1rs2两者结果的解码正好为上溢出时,fnmadd.s的运算结果为rs3的值,正确结果应为0xff800000;
2.rs1
rs2两者结果为上溢出(不包括临界条件),则计算正确;
通过计算:
Fs10_4f057641(rs1):0 100 1111 0000 0101 0111 0110 0100 0001
数符:0
阶:阶码:10011110 阶码的值: 158-127=31 移码:阶码表示=真值+阶码常数
尾数部分:1.0000000000000000 0000000000000000 000000000000 00000000

ft0_0x70000000(rs2):
0 11100000 000 0000 0000 0000 0000 0000
数符:0
阶:阶码:11100000 阶码的值:224-127=97
尾数部分:1.00000 0000000000000000000000000 000000000000000000 0000

Fs5_0xff057641(rs3):
1 111 1111 0 000 0101 0111 0110 0100 0001
数符:1
阶:阶码:111 1111 0 阶码的值:254-127=127
尾数部分:1.00000 0000000000000000000000000 000000000000000000 0000

Fs10*ft0=0x7f800000(0 111 1111 1000 0000 0000 0000 0000 0000)
①0异或0=0,所以符号位等于0
②阶码相加
31+97=128 向上溢出:单精度浮点数阶码值范围为-126~127,128+127=255(边界条件)
③尾数:溢出尾数为0

-(Fs10*ft0)+fs5=-0x7f800000(上溢出)+0xff057641=0xff800000 NEMU结果为0xff057641

@xiaofeibao-xjtu
Copy link

这两种情况正确结果都应该是负无穷0xff800000,NEMU的判断可能有问题

@Jishuaishuai123
Copy link
Author

这两种情况正确结果都应该是负无穷0xff800000,NEMU的判断可能有问题

Hi 您好:我刚下载了2022.12.22版本,尝试运行了一下,这个问题还是存在的

@xiaofeibao-xjtu
Copy link

fnmadd.s计算-(rs1rs2)-rs3
现在我们把rs2符号反向,rs3符号反向,变成(rs1
(-rs2))+(-rs3)
构造新的fma操作数a=rs1,b=-rs2,c=-rs3,计算(ab)+c
a:0x4f057641
b:0xf0000000
c:0x7f057641
a
b是不会舍入的,是否溢出要看(ab)+c整体的值
以下编码不考虑溢出:
(a
b)=0xff857641,c=0x7f057641,(ab)是负数比负无穷还小,但是c是正数,
并且-2c=2(-c)=20xff057641=0xff857641=(a
b),
所以(ab)+c=-c=0xff057641,
结果是精确的,和舍入模式也无关。
原先我回复溢出是我理解错了fnmadd.s,以为计算的-(rs1
rs2)+rs3。

目前结论NEMU计算结果是正确的,也单独对南湖fudian里面的FCMA硬件模块进行了测试,结果和NEMU一致。问题还待进一步复现确定。。。

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

No branches or pull requests

3 participants