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

Remove use of views for performance, and use scaling + BLAS call #8

Merged
merged 2 commits into from
Jun 14, 2018
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
37 changes: 21 additions & 16 deletions src/Cholesky/denseBlockAngular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,23 @@ function CpBDBt!(C::StridedMatrix{T}, B::StridedMatrix{T}, d::StridedVector{T})

# compute symmetric rank-k update
# only the upper-triangular part of C is modified
temp = zero(T)
for j=1:m
for l = 1:k
@inbounds temp = d[l] * B[j, l]
if temp == zero(T)
# skip loop if temp is zero
continue
end
for i=1:j
@inbounds C[i, j] = C[i, j] + temp * B[i, l]
end
end
end
# temp = zero(T)
# for j=1:m
# for l = 1:k
# @inbounds temp = d[l] * B[j, l]
# if temp == zero(T)
# # skip loop if temp is zero
# continue
# end
# for i=1:j
# @inbounds C[i, j] = C[i, j] + temp * B[i, l]
# end
# end
# end

# # Linear scaling + BLAS call is more efficient
B_ = B * Diagonal(sqrt.(d))
Base.BLAS.syrk!('U', 'N', 1.0, B_, 1.0, C)

return C
end
Expand All @@ -267,8 +271,9 @@ function cholesky!(
C = zeros(Tv, A.m, A.m)

for r in 1:A.R
# copying ararys uses more memory, but is faster
θ_ = view(θ, A.colptr[r]:(A.colptr[r+1]-1))
A_ = view(A.cols, :, A.colptr[r]:(A.colptr[r+1]-1))
A_ = A.cols[:, A.colptr[r]:(A.colptr[r+1]-1)]
η_ = view(F.η, :, r)

# diagonal elements
Expand Down Expand Up @@ -299,8 +304,8 @@ function cholesky(

for r in 1:A.R
θ_ = view(θ, A.colptr[r]:(A.colptr[r+1]-1))
A_ = view(A.cols, :, A.colptr[r]:(A.colptr[r+1]-1))
η_ = view(η, :, r)
A_ = A.cols[:, A.colptr[r]:(A.colptr[r+1]-1)]
η_ = view(η, :, r) # use view because η is modified in-place

# diagonal elements
d[r] = oneunit(Tv) / sum(θ_)
Expand Down
2 changes: 0 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ else
using Test
end

include("../src/Tulip.jl")

# write your own tests here
const testdir = dirname(@__FILE__)

Expand Down