Repository navigation
Closed
Milestone
Description
Some tests fail when compiled with -fcheck=bounds.
The following tests FAILED:
14 - CBLAS-xscblat2 (Failed)
15 - CBLAS-xscblat3 (Failed)
17 - CBLAS-xdcblat2 (Failed)
18 - CBLAS-xdcblat3 (Failed)
20 - CBLAS-xccblat2 (Failed)
21 - CBLAS-xccblat3 (Failed)
23 - CBLAS-xzcblat2 (Failed)
24 - CBLAS-xzcblat3 (Failed)
25 - example1_CBLAS (Failed)
26 - example2_CBLAS (Failed)
120 - example_DGELS_rowmajor (Failed)
121 - example_DGELS_colmajor (Failed)
The errors are:
At line 183 of file /home/travis/build/weslleyspereira/lapack/SRC/dgels.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'trans' (-681041696/1)
At line 188 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/dgemm.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'transb' (0/1)
At line 157 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/sgemv.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'trans' (0/1)
At line 157 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/dgemv.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'trans' (0/1)
At line 188 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/dgemm.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'transb' (0/1)
At line 188 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/sgemm.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'transa' (0/1)
At line 188 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/cgemm.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'transb' (0/1)
At line 183 of file /home/travis/build/weslleyspereira/lapack/SRC/dgels.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'trans' (0/1)
At line 159 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/cgemv.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'trans' (0/1)
At line 188 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/zgemm.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'transb' (-1406718144/1)
At line 159 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/zgemv.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'trans' (-2068420400/1)
At line 157 of file /home/travis/build/weslleyspereira/lapack/BLAS/SRC/dgemv.f
Fortran runtime error: Actual string length is shorter than the declared one for dummy argument 'trans' (0/1)
So far I couldn't find any problems during the debug.
Travis results: https://github.com/weslleyspereira/lapack/runs/2098841918
Branch: https://github.com/weslleyspereira/lapack/tree/try-flag--fcheck=bounds
Metadata
Metadata
Assignees
Labels
No labels
Activity
langou commentedon Mar 13, 2021
Ah, the joy of passing character from C to Fortran.
We start with LAPACKE/example/example_DGELS_colmajor.c
lapack/LAPACKE/example/example_DGELS_colmajor.c
Line 89 in 1827da0
then we use LAPACKE
lapack/LAPACKE/src/lapacke_dgels.c
Line 36 in 1827da0
that calls the
worklayer at linelapack/LAPACKE/src/lapacke_dgels.c
Line 73 in 1827da0
the work layer is here:
lapack/LAPACKE/src/lapacke_dgels_work.c
Line 36 in 1827da0
Finally we call LAPACK at:
lapack/LAPACKE/src/lapacke_dgels_work.c
Line 86 in 1827da0
And here is LAPACK:
lapack/SRC/dgels.f
Line 183 in 1827da0
Seems like the
&transis not doing what we expect it to do.martin-frbg commentedon Mar 13, 2021
probably just #339 (#440) again - the GCC folks "fixed" the behavior of their compiler during code generation to allow"traditional" single-character argument passing again but they did not disarm the warning.
weslleyspereira commentedon Mar 13, 2021
Yes, I agree. I forgot about #440. Maybe we can continue discussing from there.
mgates3 commentedon Mar 15, 2021
Most Fortran compilers (all current ones that I have encountered) add a strlen argument for each character string to the end of the argument list. For instance, in LAPACK++ we have:
The wrapper calls this with a strlen of 1:
This has been fixed in LAPACK++ but not yet in BLAS++.
The better fix would be to write a Fortran routine using the Fortran 2003 bind(C) interface, which handles the C => Fortran string conversion in a Fortran-sanctioned way. E.g., adding an LAPACKE_stptrs_fortran wrapper written in Fortran 2003:
LAPACKE_stptrs => LAPACKE_stptrs_work => LAPACKE_stptrs_fortran => stptrs_
In the past, I think some Fortran compilers stuck the strlen as an argument immediately after the string, e.g.,
Also in the past, there were some Fortran compilers that had a struct, maybe something like:
I can't find references for these last 2 conventions at the moment, and I haven't run into them in practice.
Mark
mgates3 commentedon Mar 15, 2021
One caution: with the added strlen arguments, your Fortran prototypes won't match other folks' strlen arguments (say, in MKL, ESSL). So be careful to not put them in public headers that would get included along with, say, mkl.h.
For instance, in LAPACK++
#include <lapack.hh>
does not include
#include <lapack/fortran.h>
which has to be included explicitly if desired. fortran.h is basically viewed as an internal header.
Mark
mgates3 commentedon Mar 15, 2021
For CBLAS, it seems cblas_f77.h is fine for that purpose — as far as I can see, it isn't included via cblas.h, and is only included in CBLAS/src/*.c
See:
weslleyspereira commentedon Mar 15, 2021
Thanks @mgates3 ! I will try your suggestions in the following commit here.
weslleyspereira commentedon Mar 16, 2021
I am writing #515 to try solving this issue.