Skip to content

Commit

Permalink
Merge pull request #7061 from JuliaLang/dh/reduce3
Browse files Browse the repository at this point in the history
Further refactoring of reduce/mapreduce functions
  • Loading branch information
lindahua committed Jun 2, 2014
2 parents 17b6262 + e8c3a8a commit 4930f60
Show file tree
Hide file tree
Showing 3 changed files with 342 additions and 517 deletions.
9 changes: 4 additions & 5 deletions base/linalg/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ isposdef(x::Number) = imag(x)==0 && real(x) > 0
stride1(x::Array) = 1
stride1(x::StridedVector) = stride(x, 1)::Int

Base.sum_seq{T<:BlasFloat}(::Base.AbsFun, a::Union(Array{T},StridedVector{T}), ifirst::Int, ilast::Int) =
BLAS.asum(ilast-ifirst+1, pointer(a, ifirst), stride1(a))
import Base: mapreduce_seq_impl, AbsFun, Abs2Fun, AddFun

# This appears to show a benefit from a larger block size
Base.sum_pairwise_blocksize(::Base.Abs2Fun) = 4096
mapreduce_seq_impl{T<:BlasFloat}(::AbsFun, ::AddFun, a::Union(Array{T},StridedVector{T}), ifirst::Int, ilast::Int) =
BLAS.asum(ilast-ifirst+1, pointer(a, ifirst), stride1(a))

function Base.sum_seq{T<:BlasFloat}(::Base.Abs2Fun, a::Union(Array{T},StridedVector{T}), ifirst::Int, ilast::Int)
function mapreduce_seq_impl{T<:BlasFloat}(::Abs2Fun, ::AddFun, a::Union(Array{T},StridedVector{T}), ifirst::Int, ilast::Int)
n = ilast-ifirst+1
px = pointer(a, ifirst)
incx = stride1(a)
Expand Down
Loading

0 comments on commit 4930f60

Please sign in to comment.