Currently, the random number array of the FixedPoint is generated by reinterpreting the random number array of its rawtype.
The generation is very fast, but the use of ReinterpretArray brings poor performance. (cf. #125)
Julia v1.0 and later, the sampler-based Random API is provided. By using the Random API, we can generate random numbers more flexibly. The disadvantage is that the generation of random arrays is much slower.
Current:
julia> @btime rand(N0f8, 1000, 1000); # ReinterpretArray
139.100 μs (3 allocations: 976.73 KiB)
julia> @btime collect(rand(N0f8, 1000, 1000));
2.479 ms (5 allocations: 1.91 MiB)
julia> @btime replace!(_->rand(N0f8), Array{N0f8}(undef, 1000, 1000));
2.744 ms (2 allocations: 976.70 KiB)
Using the newer Random API:
julia> @btime rand(rng, N0f8, 1000, 1000) setup=(rng=Random.MersenneTwister(1234)); # we can specify the RNG
1.231 ms (2 allocations: 976.70 KiB)
Do you have any thoughts?
Currently, the random number array of the
FixedPointis generated byreinterpreting the random number array of its rawtype.The generation is very fast, but the use of
ReinterpretArraybrings poor performance. (cf. #125)Julia v1.0 and later, the sampler-based Random API is provided. By using the Random API, we can generate random numbers more flexibly. The disadvantage is that the generation of random arrays is much slower.
Current:
Using the newer Random API:
Do you have any thoughts?