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

Broadcasting doesn't seem to be vectorised #63

Open
giordano opened this issue Sep 8, 2024 · 1 comment
Open

Broadcasting doesn't seem to be vectorised #63

giordano opened this issue Sep 8, 2024 · 1 comment

Comments

@giordano
Copy link
Collaborator

giordano commented Sep 8, 2024

On c14fbe8:

julia> using BenchmarkTools, FixedSizeArrays

julia> @benchmark B .= a .* A setup=(A = FixedSizeVector(randn(16)); B = similar(A); a = randn())
BenchmarkTools.Trial: 10000 samples with 980 evaluations.
 Range (min … max):  63.871 ns … 93.812 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     64.097 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   65.218 ns ±  3.136 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

  █▅▄▄ ▃▂▁▁                                                   ▁
  ██████████▅▇▇▄▄▅▄▅▄▄▅▆▅▆▇▇▇▆▅▆▅▅▄▅▅▆▇▅▆▅▄▅▅▄▃▃▅▅▇██▇▇▇▇█▇▆▇ █
  63.9 ns      Histogram: log(frequency) by time      78.1 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> @benchmark B .= a .* A setup=(A = randn(16); B = similar(A); a = randn())
BenchmarkTools.Trial: 10000 samples with 999 evaluations.
 Range (min … max):  9.765 ns … 34.962 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     9.789 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   9.895 ns ±  0.860 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

  █▂  ▁▁                                                     ▁
  ██▇▇██▆▆▆▄▅▄▅▅▄▁▄▄▅▃▅▁▄▄▃▁▃▃▃▁▃▃▃▄▁▅▄▃▃▁▃▃▅▃▁▄▅▄▄▃▁▃▄▄▄▄▁▃ █
  9.76 ns      Histogram: log(frequency) by time     13.9 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> versioninfo()
Julia Version 1.12.0-DEV.1170
Commit 95c643a6892 (2024-09-08 12:42 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, haswell)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
@nsajko
Copy link
Collaborator

nsajko commented Sep 9, 2024

julia> using BenchmarkTools, FixedSizeArrays

julia> (@benchmark B .= a .* A setup=(A = randn(16); B = similar(A); a = randn()));

julia> median(ans).time
6.713

julia> (@benchmark B .= a .* A setup=(A = FixedSizeVector(randn(16)); B = similar(A); a = randn()));

julia> median(ans).time
51.17933130699088

julia> Base.dataids(a::FixedSizeArray) = Base.dataids(a.mem)

julia> (@benchmark B .= a .* A setup=(A = FixedSizeVector(randn(16)); B = similar(A); a = randn()));

julia> median(ans).time
7.661661661661662

xref #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants