Skip to content

Commit

Permalink
Simplify, simdify, and speed up BitArray broadcasts with partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Oct 15, 2019
1 parent 9f24a06 commit 9e10015
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -919,20 +919,19 @@ end
length(dest) < 256 && return invoke(copyto!, Tuple{AbstractArray, Broadcasted{Nothing}}, dest, bc)
tmp = Vector{Bool}(undef, bitcache_size)
destc = dest.chunks
ind = cind = 1
cind = 1
bc′ = preprocess(dest, bc)
@simd for I in eachindex(bc′)
@inbounds tmp[ind] = bc′[I]
ind += 1
if ind > bitcache_size
dumpbitcache(destc, cind, tmp)
cind += bitcache_chunks
ind = 1
for P in Iterators.partition(eachindex(bc′), bitcache_size)
ind = 1
@simd for I in P
@inbounds tmp[ind] = bc′[I]
ind += 1
end
@simd for i in ind:bitcache_size
@inbounds tmp[i] = false
end
end
if ind > 1
@inbounds tmp[ind:bitcache_size] .= false
dumpbitcache(destc, cind, tmp)
cind += bitcache_chunks
end
return dest
end
Expand Down

0 comments on commit 9e10015

Please sign in to comment.