-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add host/device compatible RNG #41
Conversation
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.
Two minor comments, and please add a very small unit test (as simple as just another TEST(
inside of RngEngine.test.cu
) showing that the initialization and sampling works for the RNG and generate_canonical
functions. Thanks!
test/random/cuda/RngEngine.test.cu
Outdated
int num_samples = 1024*1000; | ||
unsigned long seed = 12345u; | ||
|
||
RngEngine rng(new RngState); |
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.
This is a memory leak. For consistency with the other host tests, I suggest making a local RngState host_rng_state;
and passing it in.
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.
Changed accordingly.
@whokion Aside from the single comment, there are two minor metadata-type changes:
If you don't have clang-format installet, let me know and I can help reformat the commits. |
Tried to apply the clang-format. Please confirm. |
@whokion Something's still off... I'll just reformat on my end. By the way, what's the advantage of the
constructor? Is that only defined for the host unit test? |
Yes, the constructor is for the purpose of tests (for now), but may be served as a generic constructor used for both host and device depending on how RngEngine is instantiated. The current approach which is binding |
That's fair, but I'd prefer to keep the view construction homogenous (even across potential future architectures) and minimizing the code base (at the expense of adding one extra line to the CPU-only unit test). The downside to having the raw pointer constructor is making the interface more complex and easy to accidentally misuse (there's a missing I've clang-formatted the files, removed the raw-pointer constructor, and squashed the commits into a new branch |
Okay. Fine with me. I will consolidate your update and push the branch again. |
Make RngEngine work on both host and device. This PR addresses and replaces the issue #19.
After merged, need to add options to use other generators/random states such as
MRG32k3a/curandStateMRG32k3a_t, Random123/curandStatePhilox4_32_10_t and etc, which
should work out of box. Also, generalize RngEngine.test.cu which currently works only for curandStateXORWOW.