Comments (1)
The RISC-V spec (v2.1, section 7.3) makes a compelling case for not supporting this:
"Except when otherwise stated, if the result of a floating-point operation is NaN, it is the canonical NaN. The canonical NaN has a positive sign and all significand bits clear except the MSB, a.k.a. the quiet bit...We considered propagating NaN payloads, as is recommended by the standard, but this decision would have increased hardware cost. Moreover, since this feature is optional in the standard, it cannot be used in portable code."
I found another more subtle problem that makes NaN propagation less useful (and hard to validate): the Clang compiler treats floating point addition as commutative and will freely reorder operands, which makes the behavior unpredictable. For example, the following code in the emulator:
case OP_ADD_F:
return value_as_int(value_as_float(value1) + value_as_float(value2));
case OP_SUB_F:
return value_as_int(value_as_float(value1) - value_as_float(value2));
Assembles to:
case OP_ADD_F:
100005663: 66 0f 6e c6 movd %esi, %xmm0
100005667: 66 0f 6e ca movd %edx, %xmm1
10000566b: f3 0f 58 c8 addss %xmm0, %xmm1
10000566f: eb 21 jmp 33 <_scalar_arithmetic_op+0x1A2>
case OP_SUB_F:
100005671: 66 0f 6e c6 movd %esi, %xmm0
100005675: 66 0f 6e ca movd %edx, %xmm1
100005679: f3 0f 5c c1 subss %xmm1, %xmm0
In the OP_ADD_F case, %esi is passed as the first parameter of addss, but in the OP_SUB_F case, it is passed as the second. The compiler has reordered the operands for the add case. The addss instruction on x86 uses the first operand as the result in the case where both are NaN, but the behavior of the emulator is to use the second value now because the compiler has rearranged them.
from nyuziprocessor.
Related Issues (20)
- Switch to github actions for CI build.
- Is this project going to support the openCL? HOT 2
- I saw a similar crash in the user_copy_fault test. HOT 2
- I want to use quartus to generate the RTL of GPU HOT 3
- Error building NyuziProcessor (probably NyuziToolchain) HOT 16
- Crash w/ latest version of Verilator
- Is there a problem with these lines of code in cache_lru.sv or is it just that I don't understand the algorithm? HOT 2
- Suggestions HOT 1
- hi how can i get linux driver HOT 3
- May be a icache miss thread still can be scheduled again? HOT 3
- Khronos ML summit HOT 2
- run_fpga command does not work properly for me HOT 6
- 00000000 Did not get ack for load memory, got c8 instead HOT 7
- make error HOT 6
- setup_tools.sh failure HOT 10
- ./scripts/setup_tools.sh error on MAC M1 HOT 2
- Questions related to integration. HOT 1
- TARGET_FILE:llvm-strip : build error HOT 1
- Performance measure using hash program HOT 8
- solution of ASM compiler identification is unknown
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nyuziprocessor.