Skip to content

Commit

Permalink
Improve warning
Browse files Browse the repository at this point in the history
  • Loading branch information
asistradition committed Apr 28, 2024
1 parent f935eb7 commit 1065f4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
### Version 0.9.2

* Explicit check for interface env MKL_INTERFACE_LAYER and interface selection in python.
Will raise a RuntimeWarning if ILP64 is requested but the 64-bit interface layer is unavailable.
Note that the MKL_INTERFACE_LAYER env must be set before this package is imported.

### Version 0.9.1

Expand Down
10 changes: 6 additions & 4 deletions sparse_dot_mkl/_mkl_interface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,24 @@ def _empirical_set_dtype():

# Check to make sure that the MKL_Set_Interface_Layer call was correct
# And fail back to 32bit if it wasn't
if MKL.MKL_INT is None and _mkl_interface_env == 'ILP64':
if _mkl_interface_env == 'ILP64':
try:
_validate_dtype()
except (ValueError, RuntimeError):
_warnings.warn(
"MKL_INTERFACE_LAYER=ILP64 failed to set MKL interface; "
"64-bit integer support unavailable"
"64-bit integer support unavailable",
RuntimeWarning
)
MKL._set_int_type(_ctypes.c_int, _np.int32)
_validate_dtype()
elif MKL.MKL_INT is None and _mkl_interface_env == 'LP64':
elif _mkl_interface_env == 'LP64':
_validate_dtype()
elif MKL.MKL_INT is None and _mkl_interface_env is not None:
_warnings.warn(
f"MKL_INTERFACE_LAYER value {_mkl_interface_env} invalid; "
"set 'ILP64' or 'LP64'"
"set 'ILP64' or 'LP64'",
RuntimeWarning
)
_empirical_set_dtype()
elif MKL.MKL_INT is None:
Expand Down

0 comments on commit 1065f4c

Please sign in to comment.