OpenMathLib / OpenBLAS

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
http://www.openblas.net
BSD 3-Clause "New" or "Revised" License
6.18k stars 1.47k forks source link

cmake issue on Loongarch64 when INTERFACE64=1 is set #4703

Closed azuresky01 closed 2 months ago

azuresky01 commented 2 months ago

Hello,

I tested cmake compilation on Loongarch64 with the setting INTERFACE64=1. In both loongnix and AOSC operating system most tests in ctest failed. See below.

cmake compilation on current development version of OpenBLAS:

CC=gcc FC=gfortran cmake -B build64 -DBUILD_TESTING=OFF -DINTERFACE64=1
cmake --build build64
cd build64
ctest

Loongnix system details:

OS: Loongnix GNU/Linux 20 (DaoXiangHu) loongarch64                        
Host: Loongson-3A6000-HV-7A2000-1w-V0.1-EVB                               
Kernel: 4.19.0-19-loongson-3                                              
gcc version 8.3.0 (Loongnix 8.3.0-6.lnd.vec.37) 
cmake version 3.29.3 compiled from the source 

ctest results:

      Start  1: openblas_utest
 1/26 Test  #1: openblas_utest ...................***Exception: SegFault  0.01 sec
      Start  2: openblas_utest_ext
 2/26 Test  #2: openblas_utest_ext ...............***Exception: SegFault  0.00 sec
      Start  3: sblas1
 3/26 Test  #3: sblas1 ...........................***Exception: SegFault  0.00 sec
      Start  4: sblas2
 4/26 Test  #4: sblas2 ...........................   Passed    0.00 sec
      Start  5: sblas3
 5/26 Test  #5: sblas3 ...........................   Passed    0.01 sec
      Start  6: dblas1
 6/26 Test  #6: dblas1 ...........................***Exception: SegFault  0.00 sec
      Start  7: dblas2
 7/26 Test  #7: dblas2 ...........................   Passed    0.00 sec
      Start  8: dblas3
 8/26 Test  #8: dblas3 ...........................   Passed    0.01 sec
      Start  9: cblas1
 9/26 Test  #9: cblas1 ...........................***Exception: SegFault  0.00 sec
      Start 10: cblas2
10/26 Test #10: cblas2 ...........................   Passed    0.00 sec
      Start 11: cblas3
11/26 Test #11: cblas3 ...........................   Passed    0.01 sec
      Start 12: zblas1
12/26 Test #12: zblas1 ...........................***Exception: SegFault  0.00 sec
      Start 13: zblas2
13/26 Test #13: zblas2 ...........................   Passed    0.00 sec
      Start 14: zblas3
14/26 Test #14: zblas3 ...........................   Passed    0.00 sec
      Start 15: xscblat1
15/26 Test #15: xscblat1 .........................***Exception: SegFault  0.00 sec
      Start 16: xscblat2
16/26 Test #16: xscblat2 .........................***Failed    0.00 sec
      Start 17: xscblat3
17/26 Test #17: xscblat3 .........................***Failed    0.01 sec
      Start 18: xdcblat1
18/26 Test #18: xdcblat1 .........................***Exception: SegFault  0.00 sec
      Start 19: xdcblat2
19/26 Test #19: xdcblat2 .........................***Failed    0.01 sec
      Start 20: xdcblat3
20/26 Test #20: xdcblat3 .........................***Failed    0.01 sec
      Start 21: xccblat1
21/26 Test #21: xccblat1 .........................***Exception: SegFault  0.00 sec
      Start 22: xccblat2
22/26 Test #22: xccblat2 .........................***Failed    0.00 sec
      Start 23: xccblat3
23/26 Test #23: xccblat3 .........................***Failed    0.01 sec
      Start 24: xzcblat1
24/26 Test #24: xzcblat1 .........................***Exception: SegFault  0.00 sec
      Start 25: xzcblat2
25/26 Test #25: xzcblat2 .........................***Failed    0.00 sec
      Start 26: xzcblat3
26/26 Test #26: xzcblat3 .........................***Failed    0.01 sec

31% tests passed, 18 tests failed out of 26

AOSC system details:

AOSC OS (loongarch64)                                                     
Host: Loongson-3A6000-HV-7A2000-1w-V0.1-EVB                               
Kernel: 6.9.0-aosc-main                                                   
gcc 版本 13.2.0 20230727 (AOSC OS, Core) (GCC) 
cmake version 3.29.2

ctest results:

      Start  1: openblas_utest
 1/26 Test  #1: openblas_utest ...................***Exception: Numerical  0.21 sec
      Start  2: openblas_utest_ext
 2/26 Test  #2: openblas_utest_ext ...............***Exception: SegFault  0.20 sec
      Start  3: sblas1
 3/26 Test  #3: sblas1 ...........................Bus error***Exception:   0.35 sec
      Start  4: sblas2
 4/26 Test  #4: sblas2 ...........................   Passed    0.30 sec
      Start  5: sblas3
 5/26 Test  #5: sblas3 ...........................***Failed    0.26 sec
      Start  6: dblas1
 6/26 Test  #6: dblas1 ...........................Bus error***Exception:   0.30 sec
      Start  7: dblas2
 7/26 Test  #7: dblas2 ...........................   Passed    0.29 sec
      Start  8: dblas3
 8/26 Test  #8: dblas3 ...........................***Failed    0.26 sec
      Start  9: cblas1
 9/26 Test  #9: cblas1 ...........................Bus error***Exception:   0.29 sec
      Start 10: cblas2
10/26 Test #10: cblas2 ...........................   Passed    0.31 sec
      Start 11: cblas3
11/26 Test #11: cblas3 ...........................   Passed    0.26 sec
      Start 12: zblas1
12/26 Test #12: zblas1 ...........................Bus error***Exception:   0.28 sec
      Start 13: zblas2
13/26 Test #13: zblas2 ...........................   Passed    0.29 sec
      Start 14: zblas3
14/26 Test #14: zblas3 ...........................***Failed    0.01 sec
      Start 15: xscblat1
15/26 Test #15: xscblat1 .........................Bus error***Exception:   0.28 sec
      Start 16: xscblat2
16/26 Test #16: xscblat2 .........................***Failed    0.28 sec
      Start 17: xscblat3
17/26 Test #17: xscblat3 .........................***Failed    0.28 sec
      Start 18: xdcblat1
18/26 Test #18: xdcblat1 .........................Bus error***Exception:   0.33 sec
      Start 19: xdcblat2
19/26 Test #19: xdcblat2 .........................***Failed    0.31 sec
      Start 20: xdcblat3
20/26 Test #20: xdcblat3 .........................***Failed    0.26 sec
      Start 21: xccblat1
21/26 Test #21: xccblat1 .........................Bus error***Exception:   0.29 sec
      Start 22: xccblat2
22/26 Test #22: xccblat2 .........................***Failed    0.28 sec
      Start 23: xccblat3
23/26 Test #23: xccblat3 .........................***Failed    0.26 sec
      Start 24: xzcblat1
24/26 Test #24: xzcblat1 .........................Bus error***Exception:   0.31 sec
      Start 25: xzcblat2
25/26 Test #25: xzcblat2 .........................***Failed    0.28 sec
      Start 26: xzcblat3
26/26 Test #26: xzcblat3 .........................***Failed    0.27 sec

19% tests passed, 21 tests failed out of 26

Solution:

I next tried CC=gcc FC=gfortran INTERFACE64=1 make and I met no failure. So this should be cmake issue. I checked the code in cmake/fc.cmake from line 62-88:

https://github.com/OpenMathLib/OpenBLAS/blob/5015548d18e5f6d9d2185d1a3bd54e7252d3278f/cmake/fc.cmake#L62-L88

There is support to INTERFACE64 on other architectures such as RISCV64 and ARM64, but none on loongarch64. After adding these 3 lines under the line 69 in fc.cmake:

if (INTERFACE64) set(FCOMMON_OPT "${FCOMMON_OPT} -fdefault-integer-8") endif ()

The failure in ctest disappears. The new ctest result from cmake compilation is:

      Start  1: openblas_utest
 1/26 Test  #1: openblas_utest ...................   Passed    0.04 sec
      Start  2: openblas_utest_ext
 2/26 Test  #2: openblas_utest_ext ...............   Passed    0.04 sec
      Start  3: sblas1
 3/26 Test  #3: sblas1 ...........................   Passed    0.00 sec
      Start  4: sblas2
 4/26 Test  #4: sblas2 ...........................   Passed    0.58 sec
      Start  5: sblas3
 5/26 Test  #5: sblas3 ...........................   Passed    0.37 sec
      Start  6: dblas1
 6/26 Test  #6: dblas1 ...........................   Passed    0.00 sec
      Start  7: dblas2
 7/26 Test  #7: dblas2 ...........................   Passed    0.59 sec
      Start  8: dblas3
 8/26 Test  #8: dblas3 ...........................   Passed    0.37 sec
      Start  9: cblas1
 9/26 Test  #9: cblas1 ...........................   Passed    0.00 sec
      Start 10: cblas2
10/26 Test #10: cblas2 ...........................   Passed    0.80 sec
      Start 11: cblas3
11/26 Test #11: cblas3 ...........................   Passed    0.61 sec
      Start 12: zblas1
12/26 Test #12: zblas1 ...........................   Passed    0.00 sec
      Start 13: zblas2
13/26 Test #13: zblas2 ...........................   Passed    0.81 sec
      Start 14: zblas3
14/26 Test #14: zblas3 ...........................   Passed    0.62 sec
      Start 15: xscblat1
15/26 Test #15: xscblat1 .........................   Passed    0.00 sec
      Start 16: xscblat2
16/26 Test #16: xscblat2 .........................   Passed    0.96 sec
      Start 17: xscblat3
17/26 Test #17: xscblat3 .........................   Passed    1.28 sec
      Start 18: xdcblat1
18/26 Test #18: xdcblat1 .........................   Passed    0.00 sec
      Start 19: xdcblat2
19/26 Test #19: xdcblat2 .........................   Passed    0.97 sec
      Start 20: xdcblat3
20/26 Test #20: xdcblat3 .........................   Passed    1.55 sec
      Start 21: xccblat1
21/26 Test #21: xccblat1 .........................   Passed    0.00 sec
      Start 22: xccblat2
22/26 Test #22: xccblat2 .........................   Passed    1.31 sec
      Start 23: xccblat3
23/26 Test #23: xccblat3 .........................   Passed    0.21 sec
      Start 24: xzcblat1
24/26 Test #24: xzcblat1 .........................   Passed    0.00 sec
      Start 25: xzcblat2
25/26 Test #25: xzcblat2 .........................   Passed    1.30 sec
      Start 26: xzcblat3
26/26 Test #26: xzcblat3 .........................   Passed    1.86 sec

100% tests passed, 0 tests failed out of 26
XiWeiGu commented 2 months ago

Thank you very much for your work. I will verify this issue promptly.