-
Notifications
You must be signed in to change notification settings - Fork 6
Fix for Distributed use of WrappedRNG #31
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ module RNGTest | |
| rng::RNG | ||
| cache::Vector{T} | ||
| fillarray::Bool | ||
| vals::Vector{UInt32} | ||
| vals::Union{Vector{UInt32}, Base.ReinterpretArray{UInt32, 1, T, Vector{T}, false}} | ||
| idx::Int | ||
| end | ||
|
|
||
|
|
@@ -45,7 +45,7 @@ module RNGTest | |
| end | ||
| cache = Vector{T}(undef, cache_size) | ||
| fillcache(WrappedRNG{T, RNG}(rng, cache, fillarray, | ||
| unsafe_wrap(Array, convert(Ptr{UInt32}, pointer(cache)), sizeof(cache)÷sizeof(UInt32)), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me why this pointer would become invalid. It is used right away so I don't see where a pointer would be transferred between processes. Is there something I'm missing here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem arises when the cache needs to be refilled. Presumably, the intention is for I don't have a deep understanding of Julia internals, but here's my best guess of what's happening. I suspect using The fix here is using An alternative fix might be to reassign Here's some test code that shows the problem.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. So the |
||
| reinterpret(UInt32, cache), | ||
| 0)) # 0 is a dummy value, which will be set correctly by fillcache | ||
| end | ||
|
|
||
|
|
||
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.
Can't this be made a
ReinterpretArrayunconditionally?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.
I was hoping so too, but when the cache itself is a Vector{UInt32}, reinterpreting it just returns the cache.
I'm not sure how to make this cleaner.