-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
MAINT: remove unused functions, rearrange headers (from CC=clang) #14534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
|
||
#if !defined(NPY_PY3K) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This splits the @name@_@which@ templates into two parts: one for python2 using long
(below) and one for both 2 and 3 using float
(above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to backport this, or shouldn't we just ignore python 2 for such a specific, rarely touched, code chunk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to backport. NEP 14 is not clear on this, but I think we have not been actively removing python2 code from the master branch yet.
numpy/linalg/umath_linalg.c.src
Outdated
#typ = DOUBLECOMPLEX_t# | ||
#ftyp = fortran_doublecomplex# | ||
#realtyp = double# | ||
#lapack_func = zgeev# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out the cfloat
loops were not used. The python function upcasts to cdouble
. I am not sure why they were added in on commit in gh-3220, but then neutralized in another.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting. Looking yet another time, the python code specifically uses double precision always, but then casts back to single precision. Is there something specific about eig that makes single precision numerically bad? Otherwise it seems like maybe we should register all loops and remove forcing the signature to double.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've seen, the other gufuncs register all the loops. and the deliberately avoid using them in python. Can we do the same thing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this from the PR, will reintroduce a cleaner solution in a future one
@@ -1,13 +1,12 @@ | |||
#ifndef _RANDOMDGEN__DISTRIBUTIONS_H_ | |||
#define _RANDOMDGEN__DISTRIBUTIONS_H_ | |||
|
|||
#pragma once | |||
#include "Python.h" | |||
#include "numpy/npy_common.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change and the others in the random/src files were needed to get rid of a warning. Googling it seems to suggest there is a circular include graph. This reordering solved it and seems harmless.
In file included from /usr/include/python3.6m/Python.h:77:
/usr/include/python3.6m/pytime.h:146:56: error: declaration of 'struct timespec' will not be visible outside of this function [-Werror,-Wvisibility]
PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep getting this warning anytime I compile C code that includes <numpy/random/*.h> with -std=c99
. It is annoying and hides actual informative warnings. It will fill up the screen if included in multiple modules. Any ideas how I can get rid of these without disabling the visibility warning? @mattip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please open a new issue and provide information so we can reproduce: what compiler and platform are you using? What version of NumPy? Some sample code and the actual warning you get would also help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will try and see if I can reproduce with an example. The warning is exactly the same as the one you mentioned above:
In file included from /usr/include/python3.6m/Python.h:77:
/usr/include/python3.6m/pytime.h:146:56: error: declaration of 'struct timespec' will not be visible outside of this function [-Werror,-Wvisibility]
PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
It pops up anytime I compiled C code with numpy/npy_common.h
and numpy/random/distributions.h
. It is caused by the Python.h header included in those files. I can't silence it. Im on Manjaro linux 64bit, python 3.8/3.9.
LGTM. Still seeing some warnings but definitely cleaner. Leaving out the ones from
That's with
|
I am not seeing them on clang 8, and it doesn't seem like I can easily get clang 10 on ubuntu. |
We may need to discuss some of the additional warnings further. For instance, the first one marks the check that
which is exported as a C function from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only real comment is that it would be nice to know whether simply enabling the single precision loops is not the better solution. I understand that that is not an easy thing to say unless you happen to know. @pv if you have a minute. Do you know whether np.linalg.eig
has a good reason to force calculation in double precision?
|
||
|
||
#if !defined(NPY_PY3K) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to backport this, or shouldn't we just ignore python 2 for such a specific, rarely touched, code chunk?
numpy/linalg/umath_linalg.c.src
Outdated
@@ -1858,6 +1864,7 @@ typedef struct geev_params_struct { | |||
char JOBVR; | |||
} GEEV_PARAMS_t; | |||
|
|||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these are obviously just there to help debugging. Maybe create a local #define
, to make it a bit more obvious (and easier to toggle both)?
numpy/linalg/umath_linalg.c.src
Outdated
#typ = DOUBLECOMPLEX_t# | ||
#ftyp = fortran_doublecomplex# | ||
#realtyp = double# | ||
#lapack_func = zgeev# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting. Looking yet another time, the python code specifically uses double precision always, but then casts back to single precision. Is there something specific about eig that makes single precision numerically bad? Otherwise it seems like maybe we should register all loops and remove forcing the signature to double.
numpy/linalg/umath_linalg.c.src
Outdated
#typ = DOUBLECOMPLEX_t# | ||
#ftyp = fortran_doublecomplex# | ||
#realtyp = double# | ||
#lapack_func = zgeev# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of not generating this code at all, can we generate it inside #if 0
? Writing these templates can be hard to get write, so it seems a shame to back out the partial work done for floats.
numpy/linalg/umath_linalg.c.src
Outdated
@@ -861,6 +865,7 @@ nan_@TYPE@_matrix(void *dst_in, const LINEARIZE_DATA_t* data) | |||
} | |||
} | |||
|
|||
#if 0 | |||
static NPY_INLINE void | |||
zero_@TYPE@_matrix(void *dst_in, const LINEARIZE_DATA_t* data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we put __attribute__((unused))
on these instead? #if 0
code is in danger of compilation bitrot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does msvc have an attribute((unused)) equivalent?
b5dac79
to
26079cf
Compare
I removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think on my first read I missed that this was about nb_slots and the long one does not exist on Py3. Two tiny requests...
Co-Authored-By: Sebastian Berg <sebastian@sipsolutions.net>
Cleanup unused function and tweak order of header include to get a clean build on clang (at least on my machine). I built this on top of #14527 to turn all warnings into errors after the
build_src
configuration step.