-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: Xerbla doesn't get linked in 1.10-devel. #5383
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,5 +56,6 @@ | |
#include "multiarraymodule.c" | ||
|
||
#if defined(HAVE_CBLAS) | ||
#include "python_xerbla.c" | ||
#include "cblasfuncs.c" | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "Python.h" | ||
|
||
/* | ||
* From f2c.h, this should be safe unless fortran is set to use 64 | ||
* bit integers. We don't seem to have any good way to detect that. | ||
*/ | ||
typedef int integer; | ||
|
||
/* | ||
From the original manpage: | ||
-------------------------- | ||
XERBLA is an error handler for the LAPACK routines. | ||
It is called by an LAPACK routine if an input parameter has an invalid value. | ||
A message is printed and execution stops. | ||
|
||
Instead of printing a message and stopping the execution, a | ||
ValueError is raised with the message. | ||
|
||
Parameters: | ||
----------- | ||
srname: Subroutine name to use in error message, maximum six characters. | ||
Spaces at the end are skipped. | ||
info: Number of the invalid parameter. | ||
*/ | ||
|
||
int xerbla_(char *srname, integer *info) | ||
{ | ||
static const char format[] = "On entry to %.*s" \ | ||
" parameter number %d had an illegal value"; | ||
char buf[sizeof(format) + 6 + 4]; /* 6 for name, 4 for param. num. */ | ||
|
||
int len = 0; /* length of subroutine name*/ | ||
#ifdef WITH_THREAD | ||
PyGILState_STATE save; | ||
#endif | ||
|
||
while( len<6 && srname[len]!='\0' ) | ||
len++; | ||
while( len && srname[len-1]==' ' ) | ||
len--; | ||
#ifdef WITH_THREAD | ||
save = PyGILState_Ensure(); | ||
#endif | ||
PyOS_snprintf(buf, sizeof(buf), format, len, srname, *info); | ||
PyErr_SetString(PyExc_ValueError, buf); | ||
#ifdef WITH_THREAD | ||
PyGILState_Release(save); | ||
#endif | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1152,6 +1152,8 @@ def test_xerbla_override(): | |
# and may, or may not, abort the process depending on the LAPACK package. | ||
from nose import SkipTest | ||
|
||
XERBLA_OK = 255 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a valid return code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know, it's valid on Linux, and windows returns 16 bit values. It can be anything that is not common. |
||
|
||
try: | ||
pid = os.fork() | ||
except (OSError, AttributeError): | ||
|
@@ -1181,15 +1183,16 @@ def test_xerbla_override(): | |
a, a, 0, 0) | ||
except ValueError as e: | ||
if "DORGQR parameter number 5" in str(e): | ||
# success | ||
os._exit(os.EX_OK) | ||
# success, reuse error code to mark success as | ||
# FORTRAN STOP returns as success. | ||
os._exit(XERBLA_OK) | ||
|
||
# Did not abort, but our xerbla was not linked in. | ||
os._exit(os.EX_CONFIG) | ||
else: | ||
# parent | ||
pid, status = os.wait() | ||
if os.WEXITSTATUS(status) != os.EX_OK or os.WIFSIGNALED(status): | ||
if os.WEXITSTATUS(status) != XERBLA_OK: | ||
raise SkipTest('Numpy xerbla not linked in.') | ||
|
||
|
||
|
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.
can't you use the same file as from lapack?
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.
What do you mean?
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 meant linalg, this file is now twice in numpy, once in multiarray and once in numpy/linalg
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.
If you mean the same
python_xerbla
source, it is inconveniently located in numpy/linalg/lapack_lite/python_xerbla.c`.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.
is that a problem for reusing it?
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 doesn't use f2c.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.
That's because I removed the include for this version.
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.
weird I guess numpy.distutils automatically adds the include path then
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.
Your version is cleaner, so if it works it is preferable. We can give it a try and see if there are any problems.
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 think onefile compilation will not work