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

Deterministic Rayon monte carlo example #1236

Merged
merged 4 commits into from
Jul 7, 2022
Merged

Conversation

masonk
Copy link
Contributor

@masonk masonk commented Jul 5, 2022

It wasn't straightforward to understand how to use Rayon in conjunction with Rand to construct a monte-carlo simulation that

  1. Given the same seed, always produces the same output
  2. Is efficient. In particular, does not require creating a new RNG per work item.

Spawned from this discussion: #399

@masonk
Copy link
Contributor Author

masonk commented Jul 5, 2022

Sadly, the ST version of this program using ChaCha8 runs in 686ms, whereas the MT version calling set_word_pos runs in 480ms. Hardly an impressive speedup on my 16-core machine.

For comparison, the MT version without set_word_pos runs in 50ms, giving me a 14x speedup factor.

set_word_pos increases runtime by about 10x.

@masonk masonk changed the title Deterministic Rayon monte carlo Deterministic Rayon monte carlo example Jul 5, 2022
@dhardy dhardy mentioned this pull request Jul 6, 2022
@dhardy
Copy link
Member

dhardy commented Jul 6, 2022

This example doesn't need to be deterministic — in fact, you don't

@dhardy dhardy closed this Jul 6, 2022
@dhardy
Copy link
Member

dhardy commented Jul 6, 2022

Mis-click.

...you don't even discuss determinism here — a little comment would be good.

@dhardy dhardy reopened this Jul 6, 2022
@masonk
Copy link
Contributor Author

masonk commented Jul 6, 2022

It looks like there's a problem with simd on unbuntu-latest. Could it be due to the rayon dep in dev-dependencies, or is that already failing?

@dhardy
Copy link
Member

dhardy commented Jul 7, 2022

The problem is that packed_simd_2 breaks periodically since it uses nightly features.

Can you bump its version to the latest (0.3.8)?

Copy link
Member

@dhardy dhardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent documentation, thanks!

@dhardy dhardy merged commit 330efe9 into rust-random:master Jul 7, 2022
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

Successfully merging this pull request may close these issues.

2 participants