Skip to content

Commit f5418ac

Browse files
authored
Merge pull request #18022 from JuliaLang/tk/perffixes
Fix a row-indexing bug with sparse matrices that have non-Int indices
2 parents ff3656e + b1d5321 commit f5418ac

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

base/sparse/sparsevector.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ function Base.getindex{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, i::Integer, J::Abstract
426426
@inbounds for j = 1:nJ
427427
col = J[j]
428428
rowI = i
429-
ptrA = colptrA[col]
430-
stopA = colptrA[col+1]-1
429+
ptrA = Int(colptrA[col])
430+
stopA = Int(colptrA[col+1]-1)
431431
if ptrA <= stopA
432432
if rowvalA[ptrA] <= rowI
433433
ptrA = searchsortedfirst(rowvalA, rowI, ptrA, stopA, Base.Order.Forward)

test/perf/Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ all: micro kernel cat shootout blas lapack simd sort spell sparse
99

1010
micro kernel cat shootout blas lapack simd sort spell sparse:
1111
@$(MAKE) $(QUIET_MAKE) -C $(SRCDIR)/shootout
12-
ifneq ($(OS),WINNT)
13-
@$(call spawn,$(JULIA_EXECUTABLE)) $(SRCDIR)/$@/perf.jl | perl -nle '@_=split/,/; printf "%-18s %8.3f %8.3f %8.3f %8.3f\n", $$_[1], $$_[2], $$_[3], $$_[4], $$_[5]'
14-
else
15-
@$(call spawn,$(JULIA_EXECUTABLE)) $(SRCDIR)/$@/perf.jl 2> /dev/null
16-
endif
12+
@$(call spawn,$(JULIA_EXECUTABLE)) $(call cygpath_w,$(SRCDIR)/$@/perf.jl) | perl -nle '@_=split/,/; printf "%-18s %8.3f %8.3f %8.3f %8.3f\n", $$_[1], $$_[2], $$_[3], $$_[4], $$_[5]'
1713

1814
codespeed:
1915
@$(MAKE) $(QUIET_MAKE) -C $(SRCDIR)/shootout

test/perf/shootout/fasta.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const IA = 3877.0
2222
const IC = 29573.0
2323

2424
function gen_random()
25-
global rng_state::Float64 = ((rng_state::Float64 * IA + IC) % IM) / IM
25+
global rng_state = ((rng_state::Float64 * IA + IC) % IM) / IM
2626
end
2727
function repeat_fasta(src, n)
2828
k = length(src)
@@ -55,7 +55,7 @@ end
5555

5656
rng_state = 42.0
5757
function fasta(n=25000000)
58-
repeat_fasta(alu, 2n)
59-
random_fasta(iub1, iub2, 3n)
60-
random_fasta(homosapiens1, homosapiens2, 5n)
58+
repeat_fasta(alu, 2n)
59+
random_fasta(iub1, iub2, 3n)
60+
random_fasta(homosapiens1, homosapiens2, 5n)
6161
end

test/sparsedir/sparse.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,3 +1588,8 @@ end
15881588

15891589
# Test temporary fix for issue #16548 in PR #16979. Brittle. Expect to remove with `\` revisions.
15901590
@test which(\, (SparseMatrixCSC, AbstractVecOrMat)).module == Base.SparseArrays
1591+
1592+
# Row indexing a SparseMatrixCSC with non-Int integer type
1593+
let A = sparse(UInt32[1,2,3], UInt32[1,2,3], [1.0,2.0,3.0])
1594+
@test A[1,1:3] == A[1,:] == [1,0,0]
1595+
end

0 commit comments

Comments
 (0)