Repository navigation
Closed
Description
(This supersedes #379.)
I'm using
$ ./configure -d CC=gcc auto
configure: detected Linux kernel version 5.5.8-200.fc31.x86_64.
configure: python interpeter search list is: python python3 python2.
configure: using 'python' python interpreter.
configure: found python version 3.7.6 (maj: 3, min: 7, rev: 6).
configure: python 3.7.6 appears to be supported.
configure: C compiler search list is: gcc clang cc.
configure: using 'gcc' C compiler.
configure: C++ compiler search list is: g++ clang++ c++.
configure: using 'g++' C++ compiler (for sandbox only).
configure: found gcc version 9.2.1 (maj: 9, min: 2, rev: 1).
configure: checking for blacklisted configurations due to gcc 9.2.1.
configure: checking gcc 9.2.1 against known consequential version ranges.
configure: found assembler ('as') version 2.32 (maj: 2, min: 32, rev: ).
configure: checking for blacklisted configurations due to as 2.32.
configure: reading configuration registry...done.
configure: determining default version string.
configure: found '.git' directory; assuming git clone.
configure: executing: git describe --tags.
configure: got back 0.6.1-5-gc01d249d.
configure: truncating to 0.6.1-5.
configure: starting configuration of BLIS 0.6.1-5.
configure: configuring with official version string.
configure: found shared library .so version '3.0.0'.
configure: .so major version: 3
configure: .so minor.build version: 0.0
configure: automatic configuration requested.
configure: hardware detection driver returned 'haswell'.
configure: checking configuration against contents of 'config_registry'.
configure: configuration 'haswell' is registered.
configure: 'haswell' is defined as having the following sub-configurations:
configure: haswell
configure: which collectively require the following kernels:
configure: haswell zen
configure: checking sub-configurations:
configure: 'haswell' is registered...and exists.
configure: checking sub-configurations' requisite kernels:
configure: 'haswell' kernels...exist.
configure: 'zen' kernels...exist.
configure: no install prefix option given; defaulting to '/usr/local'.
configure: no install exec_prefix option given; defaulting to PREFIX.
configure: no install libdir option given; defaulting to EXECPREFIX/lib.
configure: no install includedir option given; defaulting to PREFIX/include.
configure: no install sharedir option given; defaulting to PREFIX/share.
configure: final installation directories:
configure: prefix: /usr/local
configure: exec_prefix: ${prefix}
configure: libdir: ${exec_prefix}/lib
configure: includedir: ${prefix}/include
configure: sharedir: ${prefix}/share
configure: NOTE: the variables above can be overridden when running make.
configure: no preset CFLAGS detected.
configure: no preset LDFLAGS detected.
configure: enabling debug symbols; optimizations disabled.
configure: disabling verbose make output. (enable with 'make V=1'.)
configure: disabling ARG_MAX hack.
configure: building BLIS as both static and shared libraries.
configure: exporting only public symbols within shared library.
configure: threading is disabled.
configure: requesting slab threading in jr and ir loops.
configure: internal memory pools for packing blocks are enabled.
configure: internal memory pools for small blocks are enabled.
configure: memory tracing output is disabled.
configure: libmemkind not found; disabling.
configure: compiler appears to support #pragma omp simd.
configure: the BLAS compatibility layer is enabled.
configure: the CBLAS compatibility layer is disabled.
configure: mixed datatype support is enabled.
configure: mixed datatype optimizations requiring extra memory are enabled.
configure: small matrix handling is enabled.
configure: the BLIS API integer size is automatically determined.
configure: the BLAS/CBLAS API integer size is 32-bit.
configure: configuring for conventional gemm implementation.
configure: creating ./config.mk from ./build/config.mk.in
configure: creating ./bli_config.h from ./build/bli_config.h.in
configure: creating ./obj/haswell
configure: creating ./obj/haswell/config/haswell
configure: creating ./obj/haswell/kernels/haswell
configure: creating ./obj/haswell/kernels/zen
configure: creating ./obj/haswell/ref_kernels/haswell
configure: creating ./obj/haswell/frame
configure: creating ./obj/haswell/blastest
configure: creating ./obj/haswell/testsuite
configure: creating ./lib/haswell
configure: creating ./include/haswell
configure: mirroring ./config/haswell to ./obj/haswell/config/haswell
configure: mirroring ./kernels/haswell to ./obj/haswell/kernels/haswell
configure: mirroring ./kernels/zen to ./obj/haswell/kernels/zen
configure: mirroring ./ref_kernels to ./obj/haswell/ref_kernels
configure: mirroring ./ref_kernels to ./obj/haswell/ref_kernels/haswell
configure: mirroring ./frame to ./obj/haswell/frame
configure: creating makefile fragments in ./obj/haswell/config/haswell
configure: creating makefile fragments in ./obj/haswell/kernels/haswell
configure: creating makefile fragments in ./obj/haswell/kernels/zen
configure: creating makefile fragments in ./obj/haswell/ref_kernels
configure: creating makefile fragments in ./obj/haswell/frame
configure: configured to build within top-level directory of source distribution.
on Core i9.
The following Fortran program shows incorrect results for i*amax:
Program p
Real, Allocatable :: f(:)
Double Precision, Allocatable :: x(:)
Character (:), Allocatable :: c
x = [ (42.D0,i=1,4) ]
c = ' double, constant'
Print *, merge('PASS', 'FAIL', idamax(size(x),x,1)==1)//c
f = [ (42.E0,i=1,4) ]
c = ' float, constant'
Print *, merge('PASS', 'FAIL', isamax(size(f),f,1)==1)//c
x = [ Double Precision :: 8, -7, 9, 5, 9, 8, 7, 7 ]
c = ' double'
Print *, merge('PASS', 'FAIL', idamax(size(x),x,1)==3)//c
f = [ Real :: 8, -7, 9, 5, 9, 8, 7, 7 ]
c = ' float'
Print *, merge('PASS', 'FAIL', isamax(size(f),f,1)==3)//c
End Program
in which the smallest of the max indices are not being returned:
FAIL double, constant
PASS float, constant
FAIL double
FAIL float
Metadata
Metadata
Assignees
Labels
No labels
Activity
fgvanzee commentedon Mar 20, 2020
@matcross Thanks for this bug report. I'm going to try to reproduce this. In the meantime, could you modify and rerun your test driver to instead output the return value of
i?amax()?matcross commentedon Mar 20, 2020
Sure, here's
with output (gfortran -g)
fgvanzee commentedon Mar 20, 2020
@matcross Thanks for those additional printouts. They were quite helpful.
All three failures appear to be a result of how the
amaxvkernel is implemented (via vector instructions), and fixing them will take a bit of time since I did not write those kernels (they were contributed by AMD).Furthermore, I suspect if you made your
Real(float) vector length 8 instead of 4, you would also observe a failure for that case.As for the failure itself... I am not a heavy user of
amaxv/i?amax(), so please forgive the question, but can you explain to me why the above printouts are "wrong"? In all cases, the index leads to a value whose absolute value is the maximum across all elements, but it seems to be that you have a preference for which of the eligible values is returned (or that there is some convention whereby it must be the first value). Can you elaborate on this?matcross commentedon Mar 21, 2020
Thanks for the comments. Good point about the constant float case, you are right that using 8 elements does also wrongly return 2.
The spec of i*amax is that it returns the smallest integer for which the corresponding array element is of max abs value.
Our testing at NAG shows that a number of LAPACK failures occur if this is not observed.
fgvanzee commentedon Mar 21, 2020
@matcross Thanks for pointing this out. I actually pulled up
idamax.fyesterday and looked at the subroutine definition and still somehow missed this detail. I will use the old "distracted by a global pandemic" excuse. :)My PI has pointed out to me that this operation should probably not be vectorized in the first place since it is never amounts to any significant portion of computation, and therefore it is hard to imagine it ever being a bottleneck. I will disable the vectorized code in the
haswellandzensubconfigurations so that this is no longer an issue for you (and others).Disabled optimized amaxv kernels.
devinamatthews commentedon Mar 21, 2020
FYI I just peeked at the code and it wouldn't be too hard to fix it to return the expected result. In fact, I think the whole problem is here and here.
fgvanzee commentedon Mar 21, 2020
@devinamatthews Thanks for pointing this out. If you (or someone else) wants to develop a quick patch and confirm it works, I'll merge it.
devinamatthews commentedon Mar 22, 2020
There's another wrinkle: if the vector contains NaNs then i?amax is supposed to return the index of the first NaN. I think I can handle this too but it will certainly need some testing.
devinamatthews commentedon Mar 22, 2020
@matcross I made a PR (#382) with a possible fix. This should also fix issues with NaNs. I recommend testing on arrays of size 23 with value like you have now, and also on arrays of the form (0 [repeats n times], NaN [repeats 23-n times]).
devinamatthews commentedon Mar 22, 2020
OK, I wrote a new test program to test a couple extra facets of the code:
#382 works for the
constlandconstrtests but NaN is still a problem. Will fix.devinamatthews commentedon Mar 22, 2020
@matcross, I finally managed to test #382 completely and it works as expected now. Can you comment on why the LAPACK test suite fails for the previous behavior? Perhaps it is explicitly checking this behavior and otherwise it would be fine?
matcross commentedon Mar 22, 2020
Thanks a lot guys (particularly @devinamatthews )
I'll start a test run with our library tomorrow when I'm back in the 'office' and feed back here.
We were seeing incorrect pivots ipiv returned by dgetrf for singular input A, a number of failures in the example programs that we distribute for LAPACK eigensolvers, and another in our example program for a Jacobi solver of sparse linear systems.
devinamatthews commentedon Mar 22, 2020
Hmm, so I guess the result with the "wrong" pivots would be numerically equivalent but not the particular solution expected. Well, that's the interface so we'll live with it.
devinamatthews commentedon Mar 22, 2020
@fgvanzee I should note that there is another lurking problem: the indices are stored as floats, so they could overflow/lose precision for very large arrays. Technically we should use proper integer vectors; I suppose we could use uint32_t's and split very large arrays into chunks?
matcross commentedon Mar 22, 2020
In this particular instance we were seeing that the dgetrf output didn't remotely satisfy A = PLU.
devinamatthews commentedon Mar 22, 2020
Weird. But I am not a numerical analysis person so I couldn't say why that is.
matcross commentedon Mar 23, 2020
Yes, this is looking good. Thanks again.
fgvanzee commentedon Mar 23, 2020
Could you clarify what code you're talking about? The reference kernels store the index as integers. Are you referring to the vector intrinsic code in
kernels/zen/1/bli_amaxv_zen_int.c?fgvanzee commentedon Mar 23, 2020
Nevermind, I just saw #386.
Re-enabled optimized amaxv kernels.
Fix vectorized version of bli_amaxv (#382)
fgvanzee commentedon Mar 24, 2020
I just merged #382, so this should be fixed now.
Fix heap corruption in mixed-domain/precision GEMM (flame#380)