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

allow rand! with explicit SIMD to be used for various dense arrays #57101

Merged
merged 6 commits into from
Jan 21, 2025

Conversation

nsajko
Copy link
Contributor

@nsajko nsajko commented Jan 19, 2025

No description provided.

@nsajko nsajko added performance Must go faster arrays [a, r, r, a, y, s] randomness Random number generation and the Random stdlib labels Jan 19, 2025
@oscardssmith
Copy link
Member

Could this expand to DenseArray?

@nsajko nsajko changed the title allow the vectorized implementation of rand! to be used for Memory allow rand! with explicit SIMD to be used for various dense arrays Jan 20, 2025
@nsajko
Copy link
Contributor Author

nsajko commented Jan 20, 2025

expand to DenseArray

I don't think so, given that a DenseArray isn't necessarily mutable.

@nsajko
Copy link
Contributor Author

nsajko commented Jan 21, 2025

Speedups for rand!(::Memory)

rand!(::Memory{Float64})

using Random: rand!
using BenchmarkTools
const mem = Memory{Float64}(undef, 4096);
rand!(mem);
@btime rand!(mem);
  • master branch (2e6ffbc): 4.322 μs (0 allocations: 0 bytes)
  • PR branch (ed650ca): 4.132 μs (0 allocations: 0 bytes)

rand!(::Memory{UInt64})

using Random: rand!
using BenchmarkTools
const mem = Memory{UInt64}(undef, 4096);
rand!(mem);
@btime rand!(mem);
  • master branch (2e6ffbc): 3.967 μs (0 allocations: 0 bytes)
  • PR branch (ed650ca): 1.632 μs (0 allocations: 0 bytes)

rand!(::Memory{Bool})

using Random: rand!
using BenchmarkTools
const mem = Memory{Bool}(undef, 4096 * 8);
rand!(mem);
@btime rand!(mem);
  • master branch (2e6ffbc): 34.555 μs (0 allocations: 0 bytes)
  • PR branch (ed650ca): 701.401 ns (0 allocations: 0 bytes)

@oscardssmith oscardssmith merged commit b70761f into JuliaLang:master Jan 21, 2025
7 checks passed
@nsajko nsajko deleted the rand_memory branch January 21, 2025 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s] performance Must go faster randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants