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

Missing optimization for findmax/findmin on SparseVector #42823

Closed
kulowf opened this issue Oct 27, 2021 · 0 comments · Fixed by #42825
Closed

Missing optimization for findmax/findmin on SparseVector #42823

kulowf opened this issue Oct 27, 2021 · 0 comments · Fixed by #42825
Labels
performance Must go faster sparse Sparse arrays

Comments

@kulowf
Copy link

kulowf commented Oct 27, 2021

using SparseArrays

a = spzeros(2^32)
a[rand(UInt16,6)] = rand(6)

# this variant is very slow, on bigger Arrays error
@time (m,i)=findmax(a)

# this variant is quick, also on bigger Arrays
#   todo correct result if only negative values in a
@time begin
    (m1,tmp) = findmax(findnz(a)[2])
    i1 = findnz(a)[1][tmp]        
end
@show m i m1 i1

versioninfo()

Output:

21.400888 seconds (9 allocations: 224 bytes)
0.000028 seconds (14 allocations: 784 bytes)
m = 0.8275944812507452
i = 51128
m1 = 0.8275944812507452
i1 = 51128
51128

Julia Version 1.6.0
Commit f9720dc (2021-03-24 12:55 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS =

@fredrikekre fredrikekre changed the title findmax on SparseArray works bad or not (on big Arrays) Missing optimization for findmax/findmin on SparseVector Oct 27, 2021
@fredrikekre fredrikekre added performance Must go faster sparse Sparse arrays labels Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster sparse Sparse arrays
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants