-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Implement rand(::Range{BigInt}) #9122
Conversation
No, currently we require GMP (>= 5.0) in the README. Not sure about the situation in other parts of Julia, but from the discussion in #7957 it seems likely that we can bump the requirement. Packagers on Linux systems seem to have problems with updating dependencies, so we should probably be carefull. |
OK, so GMP 6 may not be a requirement for Julia 0.4 in the end? in this case I would see if I can implement this using only GMP 5. |
If you need it I guess we'll deal with that dependency when building packages, but if that's not really needed it would be easier for packagers not to use it. :-) |
I think that given julia 0.4 is going to release after a few months, we can go with GMP 6 as a dependency. All the distros will have it by then. |
I changed the title to |
@nalimilan Would it be crazy to require GMP 6 for julia 0.4? |
Absolutely not, it's already in the upcoming Fedora 21 (but generally speaking, raising requirements should only happen with relatively strong reasons). |
So there was a solution in GMP5, which is no less efficient despite having to copy data instead of generating it directly into the BigInt. |
Here is the link to the doc of |
@rfourquet Can you squash these commits? |
Also, in the squashed commits, can you give a slightly more detailed explanation of the commits? |
opened #9176 for the travis failure - it actually looks like it's in bitarray |
3f19fc1
to
beff573
Compare
This is squashed now, with some explanations added in the commit. |
A few points as I look through this and other related code:
|
|
622c530
to
e209872
Compare
Updated:
|
It seems that the Windows 64-bit has failed. The worker running the random test is the one that never came back - but there are no error messages. https://ci.appveyor.com/project/StefanKarpinski/julia/build/1.0.133/job/yhkll194gvedibs9 @tkelman How do we figure this one out? Can you try this branch? |
@rfourquet The PR looks good otherwise. |
@ViralBShah sure I'm building this branch now, will let you know what I see |
This does seem to freeze or go into an infinite loop of some kind:
|
On master at fd531ed that same sequence of inputs gives |
Thanks @tkelman. The stack overflow on master is expected, but I don't see anything that could cause the freeze, I believe it happens in the |
|
I'm not sure about endianness (I don't think it's that different on Windows?) but I have seen in the past that GMP and MPFR tend to use C |
The other AppVeyor build seems to succeed on a pentium 4 32-bits machine... I read again the code without finding any bug. Would you accept to make another test after adding prints around line 457:
and then run
? |
https://gist.github.com/2e22f8b016fda3d35c76 That was terminated by me with ctrl-C, didn't show any signs of stopping. Make sure you're not assuming |
The code seems to use |
Thanks a lot! The manual says indeed that |
I pushed a new commit replacing the use of |
Since you are squashing, could you also update the comments with a bit about the type of |
* Previously, calling e.g. rand(big(1:4)) caused a stack overflow, because rand(mt::MersenneTwister, r::AbstractArray) was calling itself recursively. This is fixed here, but a mecanism handling not-implemented types should be added. * RandIntGen is renamed to RangeGeneratorInt. * A type RangeGeneratorBigInt similar to RangeGeneratorInt (both subtypes of RangeGenerator) is introduced to handle rand on BigInt ranges. RangeGenerator is the generic constructor of such objects, taking a range as parameter. Note: two different versions are implemented depending on the GMP version (it is faster with version 6 on big ranges). * BigInt tests from commit bf8c452 are re-added.
8b0921c
to
79e4104
Compare
@ViralBShah I added some comment above the |
Referencing squashed commit to record discussion. |
Implement rand(::Range{BigInt})
Thanks - this got done nicely. |
Good catch @rfourquet. I don't think we're specifically asking for this configuration item but it's probably buried somewhere in |
@tkelman and it was a good configuration as far as tests are concerned! |
Now the runtime version of GMP is checked against the compile time version, as suggested by @JeffBezanson. He also noted that the limbs field of RangeGeneratorBigInt was not specific enough.
This is a rebase of #8255, with minor modifications.
The travis test doesn't pass on linux because functions only available in GMP 6 are used, but isn't version 6 a requirement now? (cf. #7957).