Skip to content

Fix some build warnings due to signature inconsistencies#409

Closed
h-vetinari wants to merge 2 commits into
Reference-LAPACK:masterfrom
h-vetinari:master
Closed

Fix some build warnings due to signature inconsistencies#409
h-vetinari wants to merge 2 commits into
Reference-LAPACK:masterfrom
h-vetinari:master

Conversation

@h-vetinari

@h-vetinari h-vetinari commented Apr 27, 2020

Copy link
Copy Markdown
Contributor

The following problems were encountered by working on conda-forge/lapack-feedstock#32, trying to package lapack 3.9.0 for conda-forge. I had some missing symbols when I tried initially, and after some investigation, found that the solution lay in #367. After some more problems (mainly build errors on windows), I found I had effectively recreated e0bddb2.

In the process of fixing the build errors (mainly windows) and warnings, I also came up with the two following commits. Things do compile without them, but AFAIS they are needless inconsistencies, and can easily be resolved.

The second commit is somewhat bigger, where @isuruf pointed out to me in that the lapack.h header was defining several of the deprecated functions being reintroduced by #367 to be defined as LAPACKE functions. Some discussion on the original PR made it clear that I don't understand the codebase well, but I'm still baffled how that completely divergent function signature in the header is being swallowed by the compiler, which apparently cannot locate the function.

I haven't investigated if the resulting functions are tested (being deprecated, it seems like a possibility that they're not). In any case, through trial and error (and getting some context from the surrounding declarations in the header), I came up with the second commit. With this, we were able to eliminate the build warnings (and pass the test suite), but I'm happy to accept if what I came up with is wrong.

Some more details in the commit messages.

Build warnings without first commit:

Details
[ 75%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_cgesvdq.c.o
[...]/LAPACKE/src/lapacke_cgesvdq.c: In function 'LAPACKE_cgesvdq':
[...]/LAPACKE/src/lapacke_cgesvdq.c:69:34: warning: passing argument 21 of 'LAPACKE_cgesvdq_work' from incompatible pointer type [-Wincompatible-pointer-types]
                                  &rwork_query, lrwork );
                                  ^
In file included from [...]/LAPACKE/include/lapacke_utils.h:37:0,
                 from [...]/LAPACKE/src/lapacke_cgesvdq.c:34:
[...]/LAPACKE/include/lapacke.h:5769:12: note: expected 'float *' but argument is of type 'double *'
 lapack_int LAPACKE_cgesvdq_work( int matrix_layout, char joba, char jobp,
            ^~~~~~~~~~~~~~~~~~~~
[...]/LAPACKE/src/lapacke_cgesvdq.c:95:64: warning: passing argument 21 of 'LAPACKE_cgesvdq_work' from incompatible pointer type [-Wincompatible-pointer-types]
                                  iwork, liwork, cwork, lcwork, rwork, lrwork );
                                                                ^~~~~
In file included from [...]/LAPACKE/include/lapacke_utils.h:37:0,
                 from [...]/LAPACKE/src/lapacke_cgesvdq.c:34:
[...]/LAPACKE/include/lapacke.h:5769:12: note: expected 'float *' but argument is of type 'double *'
 lapack_int LAPACKE_cgesvdq_work( int matrix_layout, char joba, char jobp,
            ^~~~~~~~~~~~~~~~~~~~
[ 75%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_cgesvdq_work.c.o
[ 89%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_zgesvdx.c.o
[...]/LAPACKE/src/lapacke_zgesvdq_work.c: In function 'LAPACKE_zgesvdq_work':
[...]/LAPACKE/src/lapacke_zgesvdq_work.c:49:49: warning: passing argument 18 of 'zgesvdq_' from incompatible pointer type [-Wincompatible-pointer-types]
                        numrank, iwork, &liwork, cwork, &lcwork, rwork, &lrwork, &info );
                                                 ^~~~~
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_zgesvdq_work.c:34:
[...]/LAPACKE/include/lapack.h:2497:38: note: expected '_Complex float *' but argument is of type '_Complex double *'
 #define LAPACK_zgesvdq LAPACK_GLOBAL(zgesvdq,ZGESVDQ)
                                      ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/include/lapack.h:2498:6: note: in expansion of macro 'LAPACK_zgesvdq'
 void LAPACK_zgesvdq(
      ^~~~~~~~~~~~~~
[...]/LAPACKE/src/lapacke_zgesvdq_work.c:86:30: warning: passing argument 18 of 'zgesvdq_' from incompatible pointer type [-Wincompatible-pointer-types]
                              cwork, &lcwork, rwork, &lrwork, &info );
[...]/LAPACKE/include/lapack.h:2498:6: note: in expansion of macro 'LAPACK_zgesvdq'
 void LAPACK_zgesvdq(
      ^~~~~~~~~~~~~~
[ 89%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_zgesvdx_work.c.o

Build warnings without second patch:

Details
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_dggsvp.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_cggsvp_work.c:34:
[...]/LAPACKE/src/lapacke_cggsvp_work.c: In function 'LAPACKE_cggsvp_work':
[...]/LAPACKE/include/lapack.h:3761:37: warning: implicit declaration of function 'cggsvp_'; did you mean 'cggsvp3_'? [-Wimplicit-function-declaration]
 #define LAPACK_cggsvp LAPACK_GLOBAL(cggsvp,CGGSVP)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_cggsvp_work.c:52:9: note: in expansion of macro 'LAPACK_cggsvp'
         LAPACK_cggsvp( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_dggsvp_work.c.o
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_sggsvp.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_dggsvp_work.c:34:
[...]/LAPACKE/src/lapacke_dggsvp_work.c: In function 'LAPACKE_dggsvp_work':
[...]/LAPACKE/include/lapack.h:3753:37: warning: implicit declaration of function 'dggsvp_'; did you mean 'dggsvp3_'? [-Wimplicit-function-declaration]
 #define LAPACK_dggsvp LAPACK_GLOBAL(dggsvp,DGGSVP)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_dggsvp_work.c:48:9: note: in expansion of macro 'LAPACK_dggsvp'
         LAPACK_dggsvp( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_sggsvp_work.c.o
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_zggsvp.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_sggsvp_work.c:34:
[...]/LAPACKE/src/lapacke_sggsvp_work.c: In function 'LAPACKE_sggsvp_work':
[...]/LAPACKE/include/lapack.h:3745:37: warning: implicit declaration of function 'sggsvp_'; did you mean 'sggsvp3_'? [-Wimplicit-function-declaration]
 #define LAPACK_sggsvp LAPACK_GLOBAL(sggsvp,SGGSVP)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_sggsvp_work.c:48:9: note: in expansion of macro 'LAPACK_sggsvp'
         LAPACK_sggsvp( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_zggsvp_work.c.o
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_cggsvd.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_zggsvp_work.c:34:
[...]/LAPACKE/src/lapacke_zggsvp_work.c: In function 'LAPACKE_zggsvp_work':
[...]/LAPACKE/include/lapack.h:3771:37: warning: implicit declaration of function 'zggsvp_'; did you mean 'zggsvp3_'? [-Wimplicit-function-declaration]
 #define LAPACK_zggsvp LAPACK_GLOBAL(zggsvp,ZGGSVP)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_zggsvp_work.c:52:9: note: in expansion of macro 'LAPACK_zggsvp'
         LAPACK_zggsvp( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_cggsvd_work.c.o
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_dggsvd.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_cggsvd_work.c:34:
[...]/LAPACKE/src/lapacke_cggsvd_work.c: In function 'LAPACKE_cggsvd_work':
[...]/LAPACKE/include/lapack.h:3660:37: warning: implicit declaration of function 'cggsvd_'; did you mean 'cggsvd3_'? [-Wimplicit-function-declaration]
 #define LAPACK_cggsvd LAPACK_GLOBAL(cggsvd,CGGSVD)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_cggsvd_work.c:51:9: note: in expansion of macro 'LAPACK_cggsvd'
         LAPACK_cggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_dggsvd_work.c.o
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_sggsvd.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_dggsvd_work.c:34:
[...]/LAPACKE/src/lapacke_dggsvd_work.c: In function 'LAPACKE_dggsvd_work':
[...]/LAPACKE/include/lapack.h:3651:37: warning: implicit declaration of function 'dggsvd_'; did you mean 'dggsvd3_'? [-Wimplicit-function-declaration]
 #define LAPACK_dggsvd LAPACK_GLOBAL(dggsvd,DGGSVD)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_dggsvd_work.c:48:9: note: in expansion of macro 'LAPACK_dggsvd'
         LAPACK_dggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_sggsvd_work.c.o
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_zggsvd.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_sggsvd_work.c:34:
[...]/LAPACKE/src/lapacke_sggsvd_work.c: In function 'LAPACKE_sggsvd_work':
[...]/LAPACKE/include/lapack.h:3642:37: warning: implicit declaration of function 'sggsvd_'; did you mean 'sggsvd3_'? [-Wimplicit-function-declaration]
 #define LAPACK_sggsvd LAPACK_GLOBAL(sggsvd,SGGSVD)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_sggsvd_work.c:48:9: note: in expansion of macro 'LAPACK_sggsvd'
         LAPACK_sggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_zggsvd_work.c.o
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_cgeqpf.c.o
In file included from [...]/LAPACKE/include/lapack.h:11:0,
                 from [...]/LAPACKE/include/lapacke.h:37,
                 from [...]/LAPACKE/include/lapacke_utils.h:37,
                 from [...]/LAPACKE/src/lapacke_zggsvd_work.c:34:
[...]/LAPACKE/src/lapacke_zggsvd_work.c: In function 'LAPACKE_zggsvd_work':
[...]/LAPACKE/include/lapack.h:3671:37: warning: implicit declaration of function 'zggsvd_'; did you mean 'zggsvd3_'? [-Wimplicit-function-declaration]
 #define LAPACK_zggsvd LAPACK_GLOBAL(zggsvd,ZGGSVD)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_zggsvd_work.c:51:9: note: in expansion of macro 'LAPACK_zggsvd'
         LAPACK_zggsvd( &jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb,
         ^~~~~~~~~~~~~
[ 98%] Building C object LAPACKE/CMakeFiles/lapacke.dir/src/lapacke_cgeqpf_work.c.o

For LAPACKE_cgesvdq, align datatype of `rwork` with lapacke.h and callsite
in LAPACKE_cgesvdq_work; both of the latter use `float* rwork`, so there's
no need to calculate with doubles that only get downcast anyway.

Similarly, make the signature of lapacke_zgesvdq_work consistent across
lapack.h (modified here), the fortran side and lapacke_zgesvdq_work, see:
https://github.com/Reference-LAPACK/lapack/blob/v3.9.0/LAPACKE/src/lapacke_zgesvdq_work.c#L42
https://github.com/Reference-LAPACK/lapack/blob/v3.9.0/SRC/zgesvdq.f#L422
…ons [cdsz]ggsv[dp]

These functions were inadvertently removed before 3.9.0 and readded
by Reference-LAPACK#367. However, some of the LAPACK-functions in lapack.h were
declared as LAPACKE-functions (which also have a different signature
than their LAPACK-counterparts), which leads (at least) to the compiler
emitting a [-Wimplicit-function-declaration] warning and not knowing
which function to choose:

[...]/LAPACKE/src/lapacke_cggsvp_work.c: In function 'LAPACKE_cggsvp_work':
[...]/LAPACKE/include/lapack.h:3761:37: warning: implicit declaration of function 'cggsvp_'; did you mean 'cggsvp3_'? [-Wimplicit-function-declaration]
 #define LAPACK_cggsvp LAPACK_GLOBAL(cggsvp,CGGSVP)
                                     ^
[...]/LAPACKE/include/lapacke_mangling.h:12:39: note: in definition of macro 'LAPACK_GLOBAL'
 #define LAPACK_GLOBAL(lcname,UCNAME)  lcname##_
                                       ^~~~~~
[...]/LAPACKE/src/lapacke_cggsvp_work.c:52:9: note: in expansion of macro 'LAPACK_cggsvp'
         LAPACK_cggsvp( &jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola,
         ^~~~~~~~~~~~~

Here, we align the declarations in lapack.h with their callsites in
the various LAPACKE_[cdsz]ggsv[dp]_work functions again.

For more discussion see
conda-forge/lapack-feedstock#32

Suggested-By: Isuru Fernando <isuruf@gmail.com>
@Reference-LAPACK Reference-LAPACK deleted a comment from codecov Bot Sep 2, 2020
@langou langou closed this in #436 Sep 2, 2020
h-vetinari added a commit to h-vetinari/lapack that referenced this pull request Sep 4, 2020
h-vetinari added a commit to h-vetinari/lapack that referenced this pull request Sep 4, 2020
… 'const' in signatures

Based on how the surrounding functions in lapack.h are handling the
parameters, particularly the ?ggsv?3-variants of the affected functions
langou added a commit that referenced this pull request Sep 4, 2020
christoph-conrads pushed a commit to christoph-conrads/lapack that referenced this pull request May 23, 2021
christoph-conrads pushed a commit to christoph-conrads/lapack that referenced this pull request May 23, 2021
… 'const' in signatures

Based on how the surrounding functions in lapack.h are handling the
parameters, particularly the ?ggsv?3-variants of the affected functions
christoph-conrads pushed a commit to christoph-conrads/lapack that referenced this pull request May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant