Git Product home page Git Product logo

Comments (7)

luyahan avatar luyahan commented on August 28, 2024

At present, I suspect that qume's floating-point fmadd are not accurate enough.

from v8.

lazyparser avatar lazyparser commented on August 28, 2024

nice catch.

if it is a QEMU bug, the simulator team in PLCT would fix it.

you can report the issue to
https://github.com/isrc-cas/plct-qemu/issues
and mention Junqiang Wang or Weiwei Li. They would have a look for us.

from v8.

luyahan avatar luyahan commented on August 28, 2024

At present, I suspect that fmadd are not accurate enough.
I run the code on hifive unleashed:

int main() {
  float a = 67.56f, b = -1012.01f, c = 3456.13f;
  float acc = a * b + c;
  float exxpected = 67.56f * (-1012.01f) + 3456.13f;
  std::cout << (exxpected == acc) << " " << exxpected << " " << acc  << std::endl;
  asm(   
      "fmadd.s %0,%1,%2,%3\n"   
      :"=f"(acc)     
      :"f"(a),"f"(b),"f"(c)
      :
  );
  std::cout << (exxpected == acc) << " " << exxpected << " " << acc  << std::endl;
  return 0;
}

output:

1 -64915.3 -64915.3
0 -64915.3 -64915.3

compile command:
riscv64-unknown-linux-gnu-g++ ./test.cpp -o test

from v8.

luyahan avatar luyahan commented on August 28, 2024
#include <limits>
#include<iostream>
#include<string.h>

int main() {
  float a = 67.56f, b = -1012.01f, c = 3456.13f;
  float acc;
  float exxpected = 67.56f * (-1012.01f) + 3456.13f;
  asm(   
      "fmul.s %0,%1,%2\n"
      "fadd.s %0,%0,%3\n"   
      :"=f"(acc)     
      :"f"(a),"f"(b),"f"(c)
      :
  );
  std::cout << (exxpected == acc) << " " << exxpected << " " << acc  << std::endl;
 
  asm(   
      "fmadd.s %0,%1,%2,%3\n"   
      :"=f"(acc)     
      :"f"(a),"f"(b),"f"(c)
      :
  );
  std::cout << (exxpected == acc) << " " << exxpected << " " << acc  << std::endl;

  return 0;
}

from v8.

luyahan avatar luyahan commented on August 28, 2024

I run cctest/test-assembler-riscv64/RISCV_UTEST_swlwu

My code
https://github.com/luyahan/v8/blob/fix-macroassembler-test-macro_float_minmax_f64/test/cctest/test-assembler-riscv64.cc#L146

On qemu

Linux fedora-riscv 5.4.0-0.rc7.git0.1.1.riscv64.fc32.riscv64 #1 SMP Thu Nov 21 16:53:49 UTC 2019 riscv64 riscv64 riscv64 GNU/Linux
=== cctest/test-assembler-riscv64/RISCV_UTEST_swlwu ===
converted_res:int 2238380180 856af894
expected_res:int -2056587116 856af894
0
#
# Fatal error in ../../test/cctest/test-assembler-riscv64.cc, line 149
# Check failed: converted_res == expected_res (2238380180 vs. -2056587116).
#
#
#
#FailureMessage Object: 0x3fffc80ad8
==== C stack trace ===============================

    /root/cctest(v8::base::debug::StackTrace::StackTrace()+0x18) [0x2aba73f6ba]
    /root/cctest(+0x3c2e488) [0x2aba6aa488]
    /root/cctest(V8_Fatal(char const*, int, char const*, ...)+0xe2) [0x2aba4a4456]
    /root/cctest(+0x17b94c8) [0x2ab82354c8]
    /root/cctest(+0x17bfc54) [0x2ab823bc54]
    /root/cctest(CcTest::Run()+0x9e) [0x2ab7b61caa]
    /root/cctest(main+0x36e) [0x2ab7ae99de]
    /lib64/lp64d/libc.so.6(__libc_start_main+0xa0) [0x3fc12362a2]
    /root/cctest(_start+0x2c) [0x2ab7b5f1ec]
Command: cctest test-assembler-riscv64/RISCV_UTEST_swlwu --random-seed=1431394633 --nohard-abort --enable-slow-asserts --verify-heap --testing-d8-test-runner
[00:08|%   0|+   0|-   1]: Done
>>> 6579 base tests produced 1 (0%) non-filtered tests
>>> 1 tests ran

riscv64 toolchain

Using built-in specs.
COLLECT_GCC=riscv64-unknown-linux-gnu-g++
COLLECT_LTO_WRAPPER=/home/user/opt/riscv64/libexec/gcc/riscv64-unknown-linux-gnu/10.1.0/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: /home/user/qemu/plct-toolbox/riscv-gnu-toolchain/riscv-gcc/configure --target=riscv64-unknown-linux-gnu --prefix=/home/user/opt/riscv64 --with-sysroot=/home/user/opt/riscv64/sysroot --with-system-zlib --enable-shared --enable-tls --enable-languages=c,c++,fortran --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libsanitizer --disable-nls --disable-bootstrap --src=.././riscv-gcc --disable-multilib --with-abi=lp64d --with-arch=rv64imafdc --with-tune=rocket 'CFLAGS_FOR_TARGET=-O2   -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-O2   -mcmodel=medlow'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC)

Output on x86 by clang or gcc7.5:

converted_res: -2056587116 856af894
expected_res: -2056587116 856af894
1

from v8.

amyzxf avatar amyzxf commented on August 28, 2024

I run cctest/test-assembler-riscv64/RISCV_UTEST_swlwu
My code
https://github.com/luyahan/v8/blob/fix-macroassembler-test-macro_float_minmax_f64/test/cctest/test-assembler-riscv64.cc#L146
On qemu
Linux fedora-riscv 5.4.0-0.rc7.git0.1.1.riscv64.fc32.riscv64 #1 SMP Thu Nov 21 16:53:49 UTC 2019 riscv64 riscv64 riscv64 GNU/Linux

=== cctest/test-assembler-riscv64/RISCV_UTEST_swlwu ===
converted_res:int 2238380180 856af894
expected_res:int -2056587116 856af894
0

Fatal error in ../../test/cctest/test-assembler-riscv64.cc, line 149

Check failed: converted_res == expected_res (2238380180 vs. -2056587116).

#FailureMessage Object: 0x3fffc80ad8
==== C stack trace ===============================

/root/cctest(v8::base::debug::StackTrace::StackTrace()+0x18) [0x2aba73f6ba]
/root/cctest(+0x3c2e488) [0x2aba6aa488]
/root/cctest(V8_Fatal(char const*, int, char const*, ...)+0xe2) [0x2aba4a4456]
/root/cctest(+0x17b94c8) [0x2ab82354c8]
/root/cctest(+0x17bfc54) [0x2ab823bc54]
/root/cctest(CcTest::Run()+0x9e) [0x2ab7b61caa]
/root/cctest(main+0x36e) [0x2ab7ae99de]
/lib64/lp64d/libc.so.6(__libc_start_main+0xa0) [0x3fc12362a2]
/root/cctest(_start+0x2c) [0x2ab7b5f1ec]

Command: cctest test-assembler-riscv64/RISCV_UTEST_swlwu --random-seed=1431394633 --nohard-abort --enable-slow-asserts --verify-heap --testing-d8-test-runner
[00:08|% 0|+ 0|- 1]: Done

6579 base tests produced 1 (0%) non-filtered tests
1 tests ran

riscv64 toolchain
Using built-in specs.
COLLECT_GCC=riscv64-unknown-linux-gnu-g++
COLLECT_LTO_WRAPPER=/home/user/opt/riscv64/libexec/gcc/riscv64-unknown-linux-gnu/10.1.0/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with: /home/user/qemu/plct-toolbox/riscv-gnu-toolchain/riscv-gcc/configure --target=riscv64-unknown-linux-gnu --prefix=/home/user/opt/riscv64 --with-sysroot=/home/user/opt/riscv64/sysroot --with-system-zlib --enable-shared --enable-tls --enable-languages=c,c++,fortran --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libsanitizer --disable-nls --disable-bootstrap --src=.././riscv-gcc --disable-multilib --with-abi=lp64d --with-arch=rv64imafdc --with-tune=rocket 'CFLAGS_FOR_TARGET=-O2 -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-O2 -mcmodel=medlow'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC)

Output on x86 by clang or gcc7.5:
converted_res: -2056587116 856af894
expected_res: -2056587116 856af894
1

On qemu
./cctest test-assembler-riscv64/RISCV_UTEST_swlwu --random-seed=-842269837 --nohard-abort --enable-slow-asserts --verify-heap --testing-d8-test-runner
report error.

b ValidateResult<int, int> ()
Thread 1 "cctest" hit Breakpoint 4, ValidateResult<int, int> ()
(gdb) info r a0
a0 0x856af894 2238380180
(gdb) info r a1
a1 0xffffffff856af894 -2056587116
(gdb)
may be the value 0x856af894 is zero extend in a0, and sign extend in a1?

from v8.

luyahan avatar luyahan commented on August 28, 2024

This issue had be fixed by #38 .

from v8.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.