You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wrong answers with 0.3.7 on POWER8 and POWER9 #2233
Not sure if you guys were already aware of this, but I wanted to pass this one along, just in case.
I was trying out the OpenBLAS 0.3.7 release on our POWER8 ("garrison") and POWER9 ("newell") OpenPOWER systems here this week. I used GCC 9.2.0, although I have also observed similar behavior with GCC 8.3.0, which leads me to believe that this issue is not related to a particular release of GCC.
The library compiles fine, but several tests are failing on both platforms with accuracy errors:
CGEMV PASSED THE TESTS OF ERROR-EXITS
******* FATAL ERROR - COMPUTED RESULT IS LESS THAN HALF ACCURATE *******
EXPECTED RESULT COMPUTED RESULT
1 ( -0.102385 , 0.226428 ) ( 0.00000 , 0.00000 )
2 ( 0.108077 , 0.805703E-01) ( -0.102385 , 0.226428 )
3 ( 0.992165E-02, -0.840403E-01) ( 0.108077 , 0.805703E-01)
4 ( 0.192725 , 0.176668 ) ( 0.992165E-02, -0.840403E-01)
******* CGEMV FAILED ON CALL NUMBER:
512: CGEMV ('N', 4, 2,( 1.0, 0.0), A, 5, X,-1,( 0.0, 0.0), Y, 1) .
I see similar issues with CGBMV, CHEMV, CHPMV, CTRMV, CTPMV, CTRSV, CTPSV, CGERC, CGERU, CHER, CHPR, CHER2, and CHPR2.
The cblas_cgemv test also fails:
******* FATAL ERROR - COMPUTED RESULT IS LESS THAN HALF ACCURATE *******
EXPECTED RESULT COMPUTED RESULT
1 ( -0.342872 , 0.714919E-02) ( -0.342872 , 0.714919E-02)
2 ( 0.233743 , -0.822020E-01) ( 0.233743 , -0.822020E-01)
3 ( 0.376182E-01, 0.161061 ) ( 0.376182E-01, 0.161061 )
4 ( 0.144652 , 0.137748 ) ( 0.00000 , 0.00000 )
******* cblas_cgemv FAILED ON CALL NUMBER:
440: cblas_cgemv ( CblasNoTrans, 4, 2,( 1.0, 0.0), A,
5, X, 1,( 0.0, 0.0), Y, 1) .
******* cblas_cgemv FAILED ON CALL NUMBER:
4: cblas_cgemv ( CblasNoTrans, 2, 1,( 0.0, 0.0), A,
3, X, 1,( 0.0, 0.0), Y, 1) .
******* FATAL ERROR - TESTS ABANDONED *******
I built this using the following command:
make CC=gcc FC=gfortran USE_OPENMP=1 NUM_THREADS=512 DYNAMIC_ARCH=1 all
I also tried this with USE_OPENMP=0, but still got the same failures.
Environment details:
CPU: POWER8, POWER9
OS: RHEL 7.5
Compiler: GCC 9.2.0, GCC 8.3.0 (both built internally from sources)
This would appear to point to a problem in #1994 - in that case the errors should go away when you switch back kernel/power/KERNEL.POWER8 (and KERNEL.POWER9) to define CGEMVNKERNEL=../arm/zgemv_n.c and CGEMVTKERNEL=../arm/zgemv_t.c instead of the new, local cgemv_n.c/cgemv_t.c
Actually I would hope that these errors will be gone as well, once you do a full recompile. The "banded matrix" etc. variants should all use essentially the same "general" CGEMV microkernel
You're right. Not sure what happened before, but I just cleaned everything and then commented out those two lines in for CGEMVNKERNEL and CGEMVTKERNEL in KERNEL.POWER8- essentially reverting to them how they were before - and everything passes now after I rebuilt.
Our Ci test is passing (e.g. https://travis-ci.org/xianyi/OpenBLAS/jobs/573911250), but it is using an older (5.2) release of gcc. In the past, misbehaviour with gcc 8 was usually a sign of mistakes in our inline assembly, brought to light by more aggressive register reuse. However the new cgemv files do not even use inline assembly directly. @quickwritereader ?
Interesting. I figured I should try a newer GCC for POWER9 support. GCC 5.x doesn't seem to support the -mcpu=power9 argument, at least when I tried it here.
I tried GCC 6.5.0 here instead, which does appear to support -mcpu=power9. Indeed, I did not get the test failures this time. So I would concur with your assessment that newer GCC versions must be doing something involving register selection that is messing with the inline assembly in these routines.
It's not an issue for us to use GCC 6.5.0 to build OpenBLAS here, for the time being. Thanks.
I have now requested&obtained an account on the unicamp.br minicloud - initial POWER8 compile tests there show that building with gcc/gfortran 7.3.1 works flawlessly, but a 8.2.1 build shows failures in a lot of the single-precision complex tests. (CGEMV, CGBMV, CHBMV, CHPMV, CTRMV, CTPMV, CTRSV and CTPSV are flagged as "less than half accurate", often with the deviating values in the 1e10 range . Others like CGERC and CGERU get "parameter 8 was changed incorrectly". Stack corruption ?)
Yes, failed codes by op are written with vector C (So, there are not any inline assembly codes ). So it can be reviewed easily. Sometimes, it is hard to spot your own problems.
Most if not all of the "LESS THAN HALF ACCURATE" errors from the lapack test appear to be related to the new CAXPY. Trying to narrow it down further... my tests are run on openSUSE/ppc64le on POWER8 hardware as provided by unicamp. I have not yet tried to build my own gcc9 there
@martin-frbg if it is possible could you re-check caxpy using BLAS_TESTER ,too
frankly, I don't know what can go wrong. if errors persist I will try to compile those version of gcc to test at the week-end
./xcl1blastst -N 1 1331 1
As individual tests for some of these functions still work, I suspect we are seeing some unexpected side effect of (using) the codes from altivec.h. Not sure why this happens only with the newer gcc,
would it perhaps enforce a requirement for the -maltivec option (which does not appear to be set in Makefile.power) ? (The xcl1blastst passes with both old and new versions of the caxpy kernel)
well, I think that gcc somehow messing ABI while translating if it gets parameters changed error. Such problems arise when writing assembly code by hand and when you improperly use registers.
Same values (with gcc, and all changes reverted except the undefining of the dgemv_t 4x8_ASM):
******* FATAL ERROR - COMPUTED RESULT IS LESS THAN HALF ACCURATE *******
EXPECTED RESULT COMPUTED RESULT
1 ( -0.342872 , 0.714919E-02) ( 0.233743 , -0.822020E-01)
2 ( 0.233743 , -0.822020E-01) ( 0.376182E-01, 0.161061 )
3 ( 0.376182E-01, 0.161061 ) ( 0.144652 , 0.137748 )
4 ( 0.144652 , 0.137748 ) ( 0.00000 , 0.00000 )
******* cblas_cgemv FAILED ON CALL NUMBER:
440: cblas_cgemv ( CblasNoTrans, 4, 2,( 1.0, 0.0), A,
5, X, 1,( 0.0, 0.0), Y, 1) .
******* cblas_cgemv FAILED ON CALL NUMBER:
4: cblas_cgemv ( CblasNoTrans, 2, 1,( 0.0, 0.0), A,
3, X, 1,( 0.0, 0.0), Y, 1) .
Took me a moment to realize what you meant by "shifted", made me wonder if you could do bit shifts on the internal representation of floats in your head...
Edit: with the other errors it is less "obvious" - mostly individual numbers in the middle of a column
that are wrong, or only the last line wrong (CHER,CHPR). Trying #pragma GCC optimize "O0" in cgemv_n.c and cgemv_t.c next...
Adding #pragma GCC optimize "O0" to cgemv_n.c, cgemv_t.c, caxpy.c and cdot.c appears to be a (temporary) solution, at least as far as the built-in tests go. (No idea what that means - though the common factor of these four files is that they use vector intrinsics. Perhaps it is possible to make unsafe assumptions about register (re)usage there as well, with the potential to hit seemingly unrelated functions that use the same registers later ?)
Possible solution. static const char __attribute__((aligned(16))) swap_mask_arr[]={,,}
with pure assembly I would use constant loading, anyway
Alignment did not work. I will recheck ,later.
gcc-8 doing good work getting rid of unnecessary xxswapd but using lvx (MEM & 0xFFFFFF...F0) instructor for loads mostly. but gcc-7 is using lxv (x as the second letter) most times avoiding lvx (v in the middle)
I see.
On power8 and power9 unaligned load store vsx pairs preferred. But they went on with old instructions.
On power9 there are even new load store pairs with immediate offset support but big endian.
It's hard to track pairs and endianess. if you mixes pairs you can end swapped answers.
So should we provide some hint or fix?
I think it is possible to check address and compute missed result for blas1 .
And the same could be applied to cgemv.
Other option is to switch to inline assembly for loads.
Ironically I wrote vector code to make porting easier.
gcc-8 ,incorrectly, using aligned
memory vector codes over 0x....8
address that 8byte aligned.
Not sure I follow you, but wouldn't any "check address and compute missed result" be more expensive than disabling over-enthusiastic optimization ? (As I understand it, there is no simple way in C to require a specific alignment like the .align or .p2align does in assembly)
yes I still have to add align options to internal buffers and swap_mask as default always choose data type size. It still can fail tests as passed cgemv matrix pointer by user is default aligned.
Possible solution. static const char __attribute__((aligned(16))) swap_mask_arr[]={,,} with pure assembly I would use constant loading, anyway
Alignment did not work. I will recheck ,later.
Activity
martin-frbg commentedon Aug 21, 2019
This would appear to point to a problem in #1994 - in that case the errors should go away when you switch back kernel/power/KERNEL.POWER8 (and KERNEL.POWER9) to define
CGEMVNKERNEL=../arm/zgemv_n.candCGEMVTKERNEL=../arm/zgemv_t.cinstead of the new, local cgemv_n.c/cgemv_t.ccparrott73 commentedon Aug 21, 2019
Thanks, Martin. I tried reverting the kernels for CGEMV as you suggested, and indeed, the tests now pass:
I presume I would need to do a similar reversion for CGBMV and the other failures?
Thanks so much.
+chris
martin-frbg commentedon Aug 21, 2019
Actually I would hope that these errors will be gone as well, once you do a full recompile. The "banded matrix" etc. variants should all use essentially the same "general" CGEMV microkernel
cparrott73 commentedon Aug 21, 2019
You're right. Not sure what happened before, but I just cleaned everything and then commented out those two lines in for CGEMVNKERNEL and CGEMVTKERNEL in KERNEL.POWER8- essentially reverting to them how they were before - and everything passes now after I rebuilt.
cparrott73 commentedon Aug 21, 2019
Correction - I did end up having to revert several other files, too. Here are the lines I ended up commenting out in KERNEL.POWER8:
Uncommenting any one of these seems to be sufficient to cause test failures.
martin-frbg commentedon Aug 22, 2019
Our Ci test is passing (e.g. https://travis-ci.org/xianyi/OpenBLAS/jobs/573911250), but it is using an older (5.2) release of gcc. In the past, misbehaviour with gcc 8 was usually a sign of mistakes in our inline assembly, brought to light by more aggressive register reuse. However the new cgemv files do not even use inline assembly directly. @quickwritereader ?
cparrott73 commentedon Aug 22, 2019
Interesting. I figured I should try a newer GCC for POWER9 support. GCC 5.x doesn't seem to support the -mcpu=power9 argument, at least when I tried it here.
I tried GCC 6.5.0 here instead, which does appear to support -mcpu=power9. Indeed, I did not get the test failures this time. So I would concur with your assessment that newer GCC versions must be doing something involving register selection that is messing with the inline assembly in these routines.
It's not an issue for us to use GCC 6.5.0 to build OpenBLAS here, for the time being. Thanks.
martin-frbg commentedon Aug 26, 2019
I have now requested&obtained an account on the unicamp.br minicloud - initial POWER8 compile tests there show that building with gcc/gfortran 7.3.1 works flawlessly, but a 8.2.1 build shows failures in a lot of the single-precision complex tests. (CGEMV, CGBMV, CHBMV, CHPMV, CTRMV, CTPMV, CTRSV and CTPSV are flagged as "less than half accurate", often with the deviating values in the 1e10 range . Others like CGERC and CGERU get "parameter 8 was changed incorrectly". Stack corruption ?)
quickwritereader commentedon Aug 26, 2019
I just saw. could you elaborate on what I should check
quickwritereader commentedon Aug 26, 2019
Passed for me using these:
Operating System: CentOS Linux 7 (AltArch):
gcc (GCC) 8.3.1 20190304 (Advance-Toolchain-at12.0) [revision 269374]
Copyright (C) 2018 Free Software Foundation, Inc.
Operating System: Ubuntu 18.04
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc. E.
quickwritereader commentedon Aug 26, 2019
Yes, failed codes by op are written with vector C (So, there are not any inline assembly codes ). So it can be reviewed easily. Sometimes, it is hard to spot your own problems.
martin-frbg commentedon Aug 26, 2019
Most if not all of the "LESS THAN HALF ACCURATE" errors from the lapack test appear to be related to the new CAXPY. Trying to narrow it down further... my tests are run on openSUSE/ppc64le on POWER8 hardware as provided by unicamp. I have not yet tried to build my own gcc9 there
quickwritereader commentedon Aug 26, 2019
@martin-frbg if it is possible could you re-check caxpy using BLAS_TESTER ,too
frankly, I don't know what can go wrong. if errors persist I will try to compile those version of gcc to test at the week-end
./xcl1blastst -N 1 1331 1
martin-frbg commentedon Aug 26, 2019
As individual tests for some of these functions still work, I suspect we are seeing some unexpected side effect of (using) the codes from altivec.h. Not sure why this happens only with the newer gcc,
would it perhaps enforce a requirement for the -maltivec option (which does not appear to be set in Makefile.power) ? (The xcl1blastst passes with both old and new versions of the caxpy kernel)
quickwritereader commentedon Aug 26, 2019
well, I think that gcc somehow messing ABI while translating if it gets parameters changed error. Such problems arise when writing assembly code by hand and when you improperly use registers.
27 remaining items
quickwritereader commentedon Aug 29, 2019
I remembered that I saw such behaviour once. Probably, lost that after toolchain changes
martin-frbg commentedon Aug 29, 2019
Same values (with gcc, and all changes reverted except the undefining of the dgemv_t 4x8_ASM):
Took me a moment to realize what you meant by "shifted", made me wonder if you could do bit shifts on the internal representation of floats in your head...
Edit: with the other errors it is less "obvious" - mostly individual numbers in the middle of a column
that are wrong, or only the last line wrong (CHER,CHPR). Trying
#pragma GCC optimize "O0"in cgemv_n.c and cgemv_t.c next...martin-frbg commentedon Aug 29, 2019
Adding
#pragma GCC optimize "O0"to cgemv_n.c, cgemv_t.c, caxpy.c and cdot.c appears to be a (temporary) solution, at least as far as the built-in tests go. (No idea what that means - though the common factor of these four files is that they use vector intrinsics. Perhaps it is possible to make unsafe assumptions about register (re)usage there as well, with the potential to hit seemingly unrelated functions that use the same registers later ?)quickwritereader commentedon Aug 29, 2019
for now I am suspicious of swap_mask . I wrote simple code and it did not load fully
quickwritereader commentedon Aug 29, 2019
Possible solution.
static const char __attribute__((aligned(16))) swap_mask_arr[]={,,}with pure assembly I would use constant loading, anyway
Alignment did not work. I will recheck ,later.
quickwritereader commentedon Aug 29, 2019
Ok. So far I cant understand why it chooses load 16byte-aligned lvx over (afaik 4byte or unaligned) lxv
Here is assemblies
gcc-8
gcc-7
quickwritereader commentedon Aug 29, 2019
gcc-8 doing good work getting rid of unnecessary xxswapd but using lvx (MEM & 0xFFFFFF...F0) instructor for loads mostly. but gcc-7 is using lxv (x as the second letter) most times avoiding lvx (v in the middle)
Here is a simple command to check assemblies
martin-frbg commentedon Aug 29, 2019
The change in gcc behaviour could be related to this patch https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg182366.html
quickwritereader commentedon Aug 29, 2019
I see.
On power8 and power9 unaligned load store vsx pairs preferred. But they went on with old instructions.
On power9 there are even new load store pairs with immediate offset support but big endian.
It's hard to track pairs and endianess. if you mixes pairs you can end swapped answers.
So should we provide some hint or fix?
I think it is possible to check address and compute missed result for blas1 .
And the same could be applied to cgemv.
Other option is to switch to inline assembly for loads.
Ironically I wrote vector code to make porting easier.
martin-frbg commentedon Aug 29, 2019
Not sure I follow you, but wouldn't any "check address and compute missed result" be more expensive than disabling over-enthusiastic optimization ? (As I understand it, there is no simple way in C to require a specific alignment like the .align or .p2align does in assembly)
quickwritereader commentedon Aug 29, 2019
yes I still have to add align options to internal buffers and swap_mask as default always choose data type size. It still can fail tests as passed cgemv matrix pointer by user is default aligned.
quickwritereader commentedon Aug 30, 2019
cgemv_n cgemv_t caxpy and cdot were re-written explicitly with vec_vsx_ld so that GCC used new load/store instructions.
martin-frbg commentedon Aug 30, 2019
Fixed by quickwritereader's PR #2243