Skip to content
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

Unify the method name to get library versions #23323

Merged
merged 4 commits into from
Aug 24, 2017
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
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ Deprecated or removed

* `diagm(A::BitMatrix)` has been deprecated, use `diagm(vec(A))` instead ([#23373]).

* `GMP.gmp_version()`, `GMP.GMP_VERSION`, `GMP.gmp_bits_per_limb()`, and `GMP.GMP_BITS_PER_LIBM`
have been renamed to `GMP.version()`, `GMP.VERSION`, `GMP.bits_per_libm()`, and `GMP.BITS_PER_LIBM`,
respectively. Similarly, `MPFR.get_version()`, has been renamed to `MPFR.version()` ([#23323]). Also,
`LinAlg.LAPACK.laver()` has been renamed to `LinAlg.LAPACK.version()` and now returns a `VersionNumber`.

Command-line option changes
---------------------------

Expand Down
8 changes: 8 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,14 @@ export hex2num
# PR #23373
@deprecate diagm(A::BitMatrix) diagm(vec(A))

# PR 23341
@eval GMP @deprecate gmp_version() version() false
@eval GMP @Base.deprecate_binding GMP_VERSION VERSION false
@eval GMP @deprecate gmp_bits_per_limb() bits_per_limb() false
@eval GMP @Base.deprecate_binding GMP_BITS_PER_LIMB BITS_PER_LIMB false
@eval MPFR @deprecate get_version() version() false
@eval LinAlg.LAPACK @deprecate laver() version() false
Copy link
Contributor

Choose a reason for hiding this comment

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

to give the same behavior as the previous function this deprecation should return a tuple

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true (anyone mind fixing this? I don't have time to do it)

Copy link
Member

Choose a reason for hiding this comment

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

I think the best way to fix this is to leave laver as it was before this change and just add version since, generally, our LAPACK wrappers are pretty thin and don't add much Julia abstraction on top of LAPACK.


# PR #23271
function IOContext(io::IO; kws...)
depwarn("IOContext(io, k=v, ...) is deprecated, use IOContext(io, :k => v, ...) instead.", :IOContext)
Expand Down
22 changes: 11 additions & 11 deletions base/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ else
end
const CdoubleMax = Union{Float16, Float32, Float64}

gmp_version() = VersionNumber(unsafe_string(unsafe_load(cglobal((:__gmp_version, :libgmp), Ptr{Cchar}))))
gmp_bits_per_limb() = Int(unsafe_load(cglobal((:__gmp_bits_per_limb, :libgmp), Cint)))
version() = VersionNumber(unsafe_string(unsafe_load(cglobal((:__gmp_version, :libgmp), Ptr{Cchar}))))
bits_per_limb() = Int(unsafe_load(cglobal((:__gmp_bits_per_limb, :libgmp), Cint)))

const GMP_VERSION = gmp_version()
const GMP_BITS_PER_LIMB = gmp_bits_per_limb()
const VERSION = version()
const BITS_PER_LIMB = bits_per_limb()

# GMP's mp_limb_t is by default a typedef of `unsigned long`, but can also be configured to be either
# `unsigned int` or `unsigned long long int`. The correct unsigned type is here named Limb, and must
# be used whenever mp_limb_t is in the signature of ccall'ed GMP functions.
if GMP_BITS_PER_LIMB == 32
if BITS_PER_LIMB == 32
const Limb = UInt32
const SLimbMax = Union{Int8, Int16, Int32}
const ULimbMax = Union{UInt8, UInt16, UInt32}
elseif GMP_BITS_PER_LIMB == 64
elseif BITS_PER_LIMB == 64
const Limb = UInt64
const SLimbMax = Union{Int8, Int16, Int32, Int64}
const ULimbMax = Union{UInt8, UInt16, UInt32, UInt64}
else
error("GMP: cannot determine the type mp_limb_t (__gmp_bits_per_limb == $GMP_BITS_PER_LIMB)")
error("GMP: cannot determine the type mp_limb_t (__gmp_bits_per_limb == $BITS_PER_LIMB)")
end

"""
Expand Down Expand Up @@ -82,10 +82,10 @@ BigInt(x)

function __init__()
try
if gmp_version().major != GMP_VERSION.major || gmp_bits_per_limb() != GMP_BITS_PER_LIMB
msg = gmp_bits_per_limb() != GMP_BITS_PER_LIMB ? error : warn
msg(string("The dynamically loaded GMP library (version $(gmp_version()) with __gmp_bits_per_limb == $(gmp_bits_per_limb()))\n",
"does not correspond to the compile time version (version $GMP_VERSION with __gmp_bits_per_limb == $GMP_BITS_PER_LIMB).\n",
if version().major != VERSION.major || bits_per_limb() != BITS_PER_LIMB
msg = bits_per_limb() != BITS_PER_LIMB ? error : warn
msg(string("The dynamically loaded GMP library (version $(version()) with __gmp_bits_per_limb == $(bits_per_limb()))\n",
"does not correspond to the compile time version (version $VERSION with __gmp_bits_per_limb == $BITS_PER_LIMB).\n",
"Please rebuild Julia."))
end

Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function version()
minor = Ref{Cint}(0)
patch = Ref{Cint}(0)
ccall((:git_libgit2_version, :libgit2), Void,
(Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), major, minor, patch)
(Ref{Cint}, Ref{Cint}, Ref{Cint}), major, minor, patch)
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated? Perhaps better in a separate pull request as such?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps, but since this is related to version might as well just do it here. THis is in any case a very trivial change.

return VersionNumber(major[], minor[], patch[])
end
const VERSION = version()
Expand Down
8 changes: 4 additions & 4 deletions base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ function chkfinite(A::StridedMatrix)
end

# LAPACK version number
function laver()
function version()
major = Ref{BlasInt}(0)
minor = Ref{BlasInt}(0)
patch = Ref{BlasInt}(0)
ccall((@blasfunc(ilaver_), liblapack), Void,
(Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}),
major, minor, patch)
return major[], minor[], patch[]
(Ptr{BlasInt}, Ptr{BlasInt}, Ptr{BlasInt}),
major, minor, patch)
return VersionNumber(major[], minor[], patch[])
end

# (GB) general banded matrices, LU decomposition and solver
Expand Down
4 changes: 2 additions & 2 deletions base/linalg/svd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ end
"""
function svdfact!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasFloat
# xggsvd3 replaced xggsvd in LAPACK 3.6.0
if LAPACK.laver() < (3, 6, 0)
if LAPACK.version() < v"3.6.0"
U, V, Q, a, b, k, l, R = LAPACK.ggsvd!('U', 'V', 'Q', A, B)
else
U, V, Q, a, b, k, l, R = LAPACK.ggsvd3!('U', 'V', 'Q', A, B)
Expand Down Expand Up @@ -290,7 +290,7 @@ end

function svdvals!(A::StridedMatrix{T}, B::StridedMatrix{T}) where T<:BlasFloat
# xggsvd3 replaced xggsvd in LAPACK 3.6.0
if LAPACK.laver() < (3, 6, 0)
if LAPACK.version() < v"3.6.0"
_, _, _, a, b, k, l, _ = LAPACK.ggsvd!('N', 'N', 'N', A, B)
else
_, _, _, a, b, k, l, _ = LAPACK.ggsvd3!('N', 'N', 'N', A, B)
Expand Down
2 changes: 1 addition & 1 deletion base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Base.Math.lgamma_r

import Base.FastMath.sincos_fast

function get_version()
function version()
version = unsafe_string(ccall((:mpfr_get_version,:libmpfr), Ptr{Cchar}, ()))
build = replace(unsafe_string(ccall((:mpfr_get_patches,:libmpfr), Ptr{Cchar}, ())), ' ', '.')
isempty(build) ? VersionNumber(version) : VersionNumber(version * '+' * build)
Expand Down
2 changes: 1 addition & 1 deletion test/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ end
@test V' ≈ lVt
B = rand(elty,10,10)
# xggsvd3 replaced xggsvd in LAPACK 3.6.0
if LAPACK.laver() < (3, 6, 0)
if LAPACK.version() < v"3.6.0"
@test_throws DimensionMismatch LAPACK.ggsvd!('S','S','S',A,B)
else
@test_throws DimensionMismatch LAPACK.ggsvd3!('S','S','S',A,B)
Expand Down
2 changes: 1 addition & 1 deletion test/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ setprecision(256) do
end

# issue #22758
if MPFR.get_version() > v"3.1.5" || "r11590" in MPFR.get_version().build
if MPFR.version() > v"3.1.5" || "r11590" in MPFR.version().build
setprecision(2_000_000) do
@test abs(sin(big(pi)/6) - 0.5) < ldexp(big(1.0),-1_999_000)
end
Expand Down