Skip to content

Commit 1edfa27

Browse files
authored
Merge branch 'backports-release-1.8' into vc/fp16_bb
2 parents e54b624 + f3bc6bf commit 1edfa27

File tree

23 files changed

+168
-108
lines changed

23 files changed

+168
-108
lines changed

base/abstractarray.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,10 @@ julia> y
10111011
"""
10121012
function copyto!(dest::AbstractArray, src::AbstractArray)
10131013
isempty(src) && return dest
1014+
if dest isa BitArray
1015+
# avoid ambiguities with other copyto!(::AbstractArray, ::SourceArray) methods
1016+
return _copyto_bitarray!(dest, src)
1017+
end
10141018
src′ = unalias(dest, src)
10151019
copyto_unaliased!(IndexStyle(dest), dest, IndexStyle(src′), src′)
10161020
end
@@ -1115,10 +1119,10 @@ function copyto!(B::AbstractVecOrMat{R}, ir_dest::AbstractRange{Int}, jr_dest::A
11151119
return B
11161120
end
11171121

1118-
function copyto_axcheck!(dest, src)
1119-
@noinline checkaxs(axd, axs) = axd == axs || throw(DimensionMismatch("axes must agree, got $axd and $axs"))
1122+
@noinline _checkaxs(axd, axs) = axd == axs || throw(DimensionMismatch("axes must agree, got $axd and $axs"))
11201123

1121-
checkaxs(axes(dest), axes(src))
1124+
function copyto_axcheck!(dest, src)
1125+
_checkaxs(axes(dest), axes(src))
11221126
copyto!(dest, src)
11231127
end
11241128

base/bitarray.jl

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -501,40 +501,42 @@ function Array{T,N}(B::BitArray{N}) where {T,N}
501501
end
502502

503503
BitArray(A::AbstractArray{<:Any,N}) where {N} = BitArray{N}(A)
504+
504505
function BitArray{N}(A::AbstractArray{T,N}) where N where T
505506
B = BitArray(undef, convert(Dims{N}, size(A)::Dims{N}))
506-
Bc = B.chunks
507-
l = length(B)
507+
_checkaxs(axes(B), axes(A))
508+
_copyto_bitarray!(B, A)
509+
return B::BitArray{N}
510+
end
511+
512+
function _copyto_bitarray!(B::BitArray, A::AbstractArray)
513+
l = length(A)
508514
l == 0 && return B
509-
ind = 1
515+
l > length(B) && throw(BoundsError(B, length(B)+1))
516+
Bc = B.chunks
517+
nc = num_bit_chunks(l)
518+
Ai = first(eachindex(A))
510519
@inbounds begin
511-
for i = 1:length(Bc)-1
520+
for i = 1:nc-1
512521
c = UInt64(0)
513522
for j = 0:63
514-
c |= (UInt64(convert(Bool, A[ind])::Bool) << j)
515-
ind += 1
523+
c |= (UInt64(convert(Bool, A[Ai])::Bool) << j)
524+
Ai = nextind(A, Ai)
516525
end
517526
Bc[i] = c
518527
end
519528
c = UInt64(0)
520-
for j = 0:_mod64(l-1)
521-
c |= (UInt64(convert(Bool, A[ind])::Bool) << j)
522-
ind += 1
529+
tail = _mod64(l - 1) + 1
530+
for j = 0:tail-1
531+
c |= (UInt64(convert(Bool, A[Ai])::Bool) << j)
532+
Ai = nextind(A, Ai)
523533
end
524-
Bc[end] = c
534+
msk = _msk_end(tail)
535+
Bc[nc] = (c & msk) | (Bc[nc] & ~msk)
525536
end
526537
return B
527538
end
528539

529-
function BitArray{N}(A::Array{Bool,N}) where N
530-
B = BitArray(undef, size(A))
531-
Bc = B.chunks
532-
l = length(B)
533-
l == 0 && return B
534-
copy_to_bitarray_chunks!(Bc, 1, A, 1, l)
535-
return B::BitArray{N}
536-
end
537-
538540
reinterpret(::Type{Bool}, B::BitArray, dims::NTuple{N,Int}) where {N} = reinterpret(B, dims)
539541
reinterpret(B::BitArray, dims::NTuple{N,Int}) where {N} = reshape(B, dims)
540542

@@ -721,24 +723,25 @@ function _unsafe_setindex!(B::BitArray, X::AbstractArray, I::BitArray)
721723
lx = length(X)
722724
last_chunk_len = _mod64(length(B)-1)+1
723725

724-
c = 1
726+
Xi = first(eachindex(X))
727+
lastXi = last(eachindex(X))
725728
for i = 1:lc
726729
@inbounds Imsk = Ic[i]
727730
@inbounds C = Bc[i]
728731
u = UInt64(1)
729732
for j = 1:(i < lc ? 64 : last_chunk_len)
730733
if Imsk & u != 0
731-
lx < c && throw_setindex_mismatch(X, c)
732-
@inbounds x = convert(Bool, X[c])
734+
Xi > lastXi && throw_setindex_mismatch(X, count(I))
735+
@inbounds x = convert(Bool, X[Xi])
733736
C = ifelse(x, C | u, C & ~u)
734-
c += 1
737+
Xi = nextind(X, Xi)
735738
end
736739
u <<= 1
737740
end
738741
@inbounds Bc[i] = C
739742
end
740-
if length(X) != c-1
741-
throw_setindex_mismatch(X, c-1)
743+
if Xi != nextind(X, lastXi)
744+
throw_setindex_mismatch(X, count(I))
742745
end
743746
return B
744747
end

base/math.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ end
4242

4343
# non-type specific math functions
4444

45-
@inline function two_mul(x::Float64, y::Float64)
45+
@assume_effects :consistent @inline function two_mul(x::Float64, y::Float64)
4646
if Core.Intrinsics.have_fma(Float64)
4747
xy = x*y
4848
return xy, fma(x, y, -xy)
4949
end
5050
return Base.twomul(x,y)
5151
end
5252

53-
@inline function two_mul(x::T, y::T) where T<: Union{Float16, Float32}
53+
@assume_effects :consistent @inline function two_mul(x::T, y::T) where T<: Union{Float16, Float32}
5454
if Core.Intrinsics.have_fma(T)
5555
xy = x*y
5656
return xy, fma(x, y, -xy)

base/reinterpretarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ stride(A::Union{DenseArray,StridedReshapedArray,StridedReinterpretArray}, k::Int
153153
k ndims(A) ? strides(A)[k] : length(A)
154154

155155
function strides(a::ReinterpretArray{T,<:Any,S,<:AbstractArray{S},IsReshaped}) where {T,S,IsReshaped}
156-
_checkcontiguous(Bool, a) && return size_to_strides(1, size(a))
156+
_checkcontiguous(Bool, a) && return size_to_strides(1, size(a)...)
157157
stp = strides(parent(a))
158158
els, elp = sizeof(T), sizeof(S)
159159
els == elp && return stp # 0dim parent is also handled here.

base/tuple.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ function setindex(x::Tuple, v, i::Integer)
5555
_setindex(v, i, x...)
5656
end
5757

58-
function _setindex(v, i::Integer, args...)
58+
function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N}
5959
@inline
60-
return ntuple(j -> ifelse(j == i, v, args[j]), length(args))
60+
return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}())
6161
end
6262

6363

deps/Versions.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ MPFR_VER := 4.1.0
6666
MPFR_JLL_NAME := MPFR
6767

6868
# nghttp2
69-
NGHTTP2_VER := 1.47.0
69+
NGHTTP2_VER := 1.48.0
7070
NGHTTP2_JLL_NAME := nghttp2
7171

7272
# Objconv (we don't ship this, so no need for a fake JLL; therefore we specify the JLL_VER here)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
505a28c1e9246f92d0440b7ed9599e27
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
67d76980cc5430274bc7c1d5c1de4cc163a1583bbd373e074fc15296481e8bc202f7a4b77af6fd32677a974e9ad5d65dcfd72d74bf0ff657d4cee067eba595f0

deps/checksums/Pkg-f0bef8af0ab951d9cf3cceb3c709873737df9471.tar.gz/md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/checksums/Pkg-f0bef8af0ab951d9cf3cceb3c709873737df9471.tar.gz/sha512

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)