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

Coordination: changes to PRNG libraries #23

Open
6 of 8 tasks
curiousleo opened this issue Mar 6, 2020 · 6 comments
Open
6 of 8 tasks

Coordination: changes to PRNG libraries #23

curiousleo opened this issue Mar 6, 2020 · 6 comments

Comments

@curiousleo
Copy link
Collaborator

curiousleo commented Mar 6, 2020

To avoid duplication of work, let's track work we've done to make PRNG libraries compatible with the interface-to-performance branch here.

Feel free to edit this description directly.


splitmix: https://github.com/lehins/splitmix/tree/new-random (diff)

  • implement RandomGen
  • implement Prim

pcgen: https://github.com/curiousleo/pcgen/tree/new-random (diff)

  • implement RandomGen
  • implement Prim

mwc-random: WIP https://github.com/curiousleo/mwc-random/tree/random-v1.2-compat (diff)

  • implement MonadRandom
  • get tests to build (depend on QuickCheck)

random-fu: does not depend on random; uses random-source to abstract over concrete PRNGs


QuickCheck: builds with StdGen from random v1.1 on non-GHC platforms. That won't work with random v1.2.


hedgehog: requires instance UniformRange Integer which is currently missing.

  • builds against random v1.2
  • test suite runs against random v1.2: missing instance UniformRange Integer
@curiousleo
Copy link
Collaborator Author

curiousleo commented Mar 24, 2020

https://github.com/bos/mwc-random/compare/master...curiousleo:random-v1.2-compat?expand=1 fails to build with

mwc-random/System/Random/MWC.hs:414:28: error:  
    Multiple declarations of ‘Seed’  
    Declared at: System/Random/MWC.hs:389:16  
                 System/Random/MWC.hs:414:28  
    |  
414 |   newtype Frozen (Gen s) = Seed  
    |                            ^^^^  

I don't know how to fix that.

@lehins
Copy link
Collaborator

lehins commented Mar 24, 2020

@curiousleo It is a newtype, so you need to wrap with a constructor.

@curiousleo
Copy link
Collaborator Author

@curiousleo It is a newtype, so you need to wrap with a constructor.

Fixed. Thanks!

@idontgetoutmuch
Copy link
Owner

idontgetoutmuch commented Apr 3, 2020

Should we close this or use it to track

@lehins
Copy link
Collaborator

lehins commented Apr 15, 2020

Alright gentleman, I implemented some benchmarks for all pure RNGs available in Haskell and results are pretty impressive. Here is a PR and a branch that you can use to run benchmarks for both random-1.1 and random-1.2: lehins/haskell-benchmarks#7

Here are also all the repo's with fixed RandomGen instances:

It is pretty cool that changes were incredibly minimal and all of them are backwards compatible.

To run benchmarks:

$ cd haskell-benchmarks/new-random-benchmarks/
$ stack bench --ba '--output old-random-word16.html --match prefix Pure/Word16' --stack-yaml stack-old-random.yaml
$ stack bench --ba '--output new-random-word16.html --match prefix Pure/Word16'

And so on for other types. (It's possible to run them all at once, but I find the plots bit noisy that way)

Next in line are stateful RNGs, but those I think I'll do some time later.

@curiousleo
Copy link
Collaborator Author

Alright gentleman, I implemented some benchmarks for all pure RNGs available in Haskell and results are pretty impressive. Here is a PR and a branch that you can use to run benchmarks for both random-1.1 and random-1.2: lehins/haskell-benchmarks#7

Here are also all the repo's with fixed RandomGen instances:

* [lehins/Xorshift#1](https://github.com/lehins/Xorshift/pull/1)

* [lehins/mersenne-random-pure64#1](https://github.com/lehins/mersenne-random-pure64/pull/1)

* [lehins/tf-random#1](https://github.com/lehins/tf-random/pull/1)

* [lehins/pcg-random#1](https://github.com/lehins/pcg-random/pull/1)

* [lehins/pcgen#1](https://github.com/lehins/pcgen/pull/1)

It is pretty cool that changes were incredibly minimal and all of them are backwards compatible.

This is fantastic!

Next in line are stateful RNGs, but those I think I'll do some time later.

I would also be interested in benchmarks for uniformRM since we put a lot of effort into optimising the range algorithms.

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

3 participants