-
Notifications
You must be signed in to change notification settings - Fork 504
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
External sources alias sampler #3201
External sources alias sampler #3201
Conversation
Here are the results from some testing with 16 threads: 10^3 sources, 1e3 samples, original rate: 4.3e4 particles/s, accelerated rate: 3.3e4 particles/s |
Is there a logical place to include scripts that we can use for timing? I don't think it makes sense for CI, and they probably don't make sense after a PR is adopted because it's hard to test the old code. What's the best practice? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, the complexity for selecting the source is what goes O(N)->O(1). I see the testing varies number of sources and number of samples. What is the expected change in particles per second for varying the number of samples? It would be nice if the testing script printed the particles per second speedup as well.
Any idea why this case had a slow down?
10^3 sources, 1e3 samples, original rate: 4.3e4 particles/s, accelerated rate: 3.3e4 particles/s
It does seem that the cases with more sources and samples are accelerating more, so that is good.
The reason that there are changes for the number of samples is because with too few samples, the timing is affected by stochastic behavior and the particle rate will fluctuate with each time you perform the analysis. With the slower approach, the stochastic response goes away faster with number of samples because it simply takes longer. Because it's so fast, it requires many more samples to see the stochastic behavior converge with the faster approach. |
Has this been processed with |
Yes. |
This will need to be coordinated with #3195 as they overlap in their impact. That other PR appears poised to be merged first - once that's done, we can update this for review. |
@magnoxemo - please rebase this with #3195 for further review |
Co-authored-by: Paul Romano <[email protected]>
…late_volumes (openmc-dev#3190) Co-authored-by: Nicolas Linden <[email protected]> Co-authored-by: Paul Romano <[email protected]>
…enmc-dev#3168) Co-authored-by: Patrick Shriwise <[email protected]> Co-authored-by: Paul Romano <[email protected]>
Co-authored-by: Patrick Shriwise <[email protected]> Co-authored-by: Paul Romano <[email protected]>
…n openmc model namespace. ig it passes all the tests now
40dbb87
to
f0656bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @magnoxemo! I fixed one thing on your branch -- we require separate logic for sampling when settings::uniform_source_sampling
is true. It turns out that our existing tests didn't actually catch this case so I also added a test for this case.
Thanks @paulromano - we were going to tackle this update for |
Description
Rather than doing a linear search over the CDF for sampling an
external_sources_alias_sampler
ofDiscreteIndex
class was defined in thesource.cpp
in theopenmc model
namespace. Which then gets the source strengthsopenmc::model::external_sources_alias_sampler.assign(source_strengths)
and creates an alias table.and a seed is passed through the
model::external_sources_alias_sampler.sample(seed)
method to get the index of thei
th source.This reduces the time complexity from O(n) to O(1)
Thanks to @gonuke for help and guidelines.
Fixes #3104
Checklist