8000 BUG: Xerbla doesn't get linked in 1.10-devel. by charris · Pull Request #5383 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
Dec 24, 2014
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
4 changes: 3 additions & 1 deletion numpy/core/bscript
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ def pre_build(context):
]

if bld.env.HAS_CBLAS:
sources.append(pjoin('src', 'multiarray', 'cblasfuncs.c'))
sources.extend([pjoin('src', 'multiarray', 'cblasfuncs.c'),
pjoin('src', 'multiarray', 'python_xerbla.c'),
])
else:
sources = extension.sources

Expand Down
4 changes: 3 additions & 1 deletion numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,9 @@ def generate_multiarray_templated_sources(ext, build_dir):
blas_info = get_info('blas_opt', 0)
if blas_info and ('HAVE_CBLAS', None) in blas_info.get('define_macros', []):
extra_info = blas_info
multiarray_src.append(join('src', 'multiarray', 'cblasfuncs.c'))
multiarray_src.extend([join('src', 'multiarray', 'cblasfuncs.c'),
join('src', 'multiarray', 'python_xerbla.c'),
])
else:
extra_info = {}

Expand Down
1 change: 1 addition & 0 deletions numpy/core/src/multiarray/multiarraymodule_onefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
#include "multiarraymodule.c"

#if defined(HAVE_CBLAS)
#include "python_xerbla.c"
#include "cblasfuncs.c"
#endif
51 changes: 51 additions & 0 deletions numpy/core/src/multiarray/python_xerbla.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "Python.h"
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Contributor

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

Copy link
Member Author

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`.

Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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


/*
* 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;
}
9 changes: 6 additions & 3 deletions numpy/linalg/tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a valid return code?
aren't those limited to 127 on some systems?

Copy link
Member Author

Choose a reason for hiding this comment

The 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):
Expand Down Expand Up @@ -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.')


Expand Down
0