8000 BUG: Xerbla doesn't get linked in 1.9 on Fedora 21. by charris · Pull Request #5392 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Xerbla doesn't get linked in 1.9 on Fedora 21. #5392

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

Merged
merged 1 commit into from
Jan 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG: Xerbla doesn't get linked in 1.9 on Fedora 21.
Add our python_xerbla to the blasdot sources. That function is
needed for all modules that link to the ATLAS 3.10 libraries, which
in Fedora 21 are located in just two files: libsatlas and libtatlas.

Also make the test for xerbla linkage work better. If xerbla is not
linked the test will be skipped with a message.
  • Loading branch information
charris committed Dec 24, 2014
commit f0b2dd7d5151878f2b4b3ea20ff551b27243f27d
51 changes: 51 additions & 0 deletions numpy/core/blasdot/python_xerbla.c
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;
}
3 changes: 2 additions & 1 deletion numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,12 +954,13 @@ def get_dotblas_sources(ext, build_dir):
if blas_info:
if ('NO_ATLAS_INFO', 1) in blas_info.get('define_macros', []):
return None # dotblas needs ATLAS, Fortran compiled blas will not be sufficient.
return ext.depends[:2]
return ext.depends[:3]
return None # no extension module will be built

config.add_extension('_dotblas',
sources = [get_dotblas_sources],
depends = [join('blasdot', '_dotblas.c'),
join('blasdot', 'python_xerbla.c'),
join('blasdot', 'apple_sgemv_patch.c'),
join('blasdot', 'cblas.h'),
],
Expand Down
9 changes: 6 additions & 3 deletions numpy/linalg/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,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

try:
pid = os.fork()
except (OSError, AttributeError):
Expand Down Expand Up @@ -1137,15 +1139,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.')


Expand Down
0