Skip to content

Commit

Permalink
At build time, check for correct size of BlasInt.
Browse files Browse the repository at this point in the history
Returns helpful error message as discussed in #5050, #4744
  • Loading branch information
jiahao committed Dec 9, 2013
1 parent 043cdfd commit c26206a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3303,4 +3303,18 @@ for (fn, elty) in ((:dtrttf_, :Float64),
end
end
end

#
# Build-time check if BlasInt is of the correct expected bitsize
#
_, _info = potrf!('U', [[1.0, 0.0] [0.0, -1.0]])
if _info!=2 #mangled info code
if _info == 2^33
error("""Wrong size of BlasInt for LAPACK: LAPACK was compiled with 32-bit integer support but Julia expects 64-bit integers. Please check the BLAS and LAPACK libraries your system is using or recompile OpenBLAS with the correct USE_BLAS64 settings.""")
elseif _info == 0
error("""Wrong size of BlasInt for LAPACK: LAPACK was compiled with 64-bit integer support but Julia expects 32-bit integers. Please check the BLAS and LAPACK libraries your system is using or recompile OpenBLAS with the correct USE_BLAS64 settings.""")
else
error("""Unparseable LAPACK info code: Julia did not understand the error codes used by your LAPACK library. Please check the BLAS and LAPACK libraries your system is using or recompile OpenBLAS.""")
end
end
end # module

4 comments on commit c26206a

@ViralBShah
Copy link
Member

Choose a reason for hiding this comment

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

How about making this a runtime check by incorporating it into check_blas in util.jl? People often change LD_LIBRARY_PATH and such, or change the system BLAS, and it's worthwhile to catch this when starting julia.

@jiahao
Copy link
Member Author

@jiahao jiahao commented on c26206a Dec 9, 2013

Choose a reason for hiding this comment

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

Oh ok. I wasn't actually sure where this should go. Go ahead and move it if you like.

@ViralBShah
Copy link
Member

Choose a reason for hiding this comment

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

Ok. Will do.

@staticfloat
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for this, @jiahao. These are problems that we run into all the time, and it will be really great to have more informative error messages!

Please sign in to comment.