Skip to content

Performance for very small arrays #13

Answered by MasonProtter
mdmaas asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @mdmaas, sorry for the slow reply. The most important thing you can do to speed it up but would be to explicitly pass in the buffer you're using. Here's an example:

julia> @inline function sumArray_bumper_2(N, buf=default_buffer())
           @no_escape buf begin
               smallarray = alloc(Float64, buf, N) 
               @turbo for i  1:N
                   smallarray[i] = 1.0 / i^2
               end
               sum = 0.0
               @turbo for i  1:N
                   sum += smallarray[i]
               end
           end
           return sum
       end;

julia> let N = Ref(5)
           @btime sumArray_bumper($N[]) # Original version
           @btime sumArray_bump…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mdmaas
Comment options

@MasonProtter
Comment options

@mdmaas
Comment options

Answer selected by mdmaas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #12 on September 25, 2023 11:36.