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

Test cctest/test-assembler-riscv64 failed 11 case on Qemu #30

Closed
luyahan opened this issue Jul 18, 2020 · 7 comments
Closed

Test cctest/test-assembler-riscv64 failed 11 case on Qemu #30

luyahan opened this issue Jul 18, 2020 · 7 comments
Assignees
Labels
bug Something isn't working cross-compiled Issues specific to building or running cross-compiled v8

Comments

@luyahan
Copy link
Collaborator

luyahan commented Jul 18, 2020

Failed case:

cctest/test-assembler-riscv64/RISCV_UTEST_fmadd_s
cctest/test-assembler-riscv64/RISCV_UTEST_fmadd_d
cctest/test-assembler-riscv64/RISCV_UTEST_fnmadd_s
cctest/test-assembler-riscv64/RISCV_UTEST_fnmadd_d
cctest/test-assembler-riscv64/RISCV_UTEST_swlwu

My test log
https://gist.github.com/luyahan/cfa5050b0d8e36d95872b0401725e14d

@luyahan luyahan changed the title Test cctest failed 11 case on Qemu Test cctest/test-assembler-riscv64 failed 11 case on Qemu Jul 18, 2020
@penguinwu penguinwu added bug Something isn't working cross-compiled Issues specific to building or running cross-compiled v8 labels Jul 18, 2020
@luyahan
Copy link
Collaborator Author

luyahan commented Jul 19, 2020

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

@lazyparser
Copy link
Collaborator

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.

@luyahan
Copy link
Collaborator Author

luyahan commented Jul 19, 2020

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

@luyahan
Copy link
Collaborator Author

luyahan commented Jul 19, 2020

#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;
}

@luyahan
Copy link
Collaborator Author

luyahan commented Jul 20, 2020

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

@amyzxf
Copy link

amyzxf commented Jul 20, 2020

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?

@luyahan
Copy link
Collaborator Author

luyahan commented Aug 4, 2020

This issue had be fixed by #38 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cross-compiled Issues specific to building or running cross-compiled v8
Projects
None yet
Development

No branches or pull requests

4 participants