Skip to content

[RFC] Use of Random API #196

Description

@kimikage

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingMajor breaking change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions