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

Remove &x convention in ccall in gmp #23289

Merged
merged 4 commits into from
Aug 26, 2017
Merged

Remove &x convention in ccall in gmp #23289

merged 4 commits into from
Aug 26, 2017

Conversation

musm
Copy link
Contributor

@musm musm commented Aug 17, 2017

No description provided.

@thofma
Copy link
Contributor

thofma commented Aug 17, 2017

Will the & synatx be deprecated in 0.7 and an error in 1.0?

@musm
Copy link
Contributor Author

musm commented Aug 17, 2017

yes for the ccall syntax

@thofma
Copy link
Contributor

thofma commented Aug 17, 2017

I remember someone telling me of performance issues between & and Ref. Have they been resolved?

@musm
Copy link
Contributor Author

musm commented Aug 17, 2017

Yes performance has been resolved thanks to @yuyichao 's work

base/gmp.jl Outdated
@@ -113,56 +113,54 @@ module MPZ
# and `add!(x, a) = add!(x, x, a)`.
using Base.GMP: BigInt, Limb

const mpz_t = Ref{BigInt}
Copy link
Member

Choose a reason for hiding this comment

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

Why do you remove mpz_t? I thought it helps reading tedious libgmp signatures, and comparing them to the GMP docs (which use mpz_t).

Copy link
Contributor

Choose a reason for hiding this comment

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

it's also good for conciseness in this file

base/gmp.jl Outdated
$op(a) = $op!(BigInt(), a)
end
end

popcount(a::BigInt) = ccall((:__gmpz_popcount, :libgmp), Culong, (mpz_t,), &a) % Int
popcount(a::BigInt) = ccall((:__gmpz_popcount, :libgmp), Culong, (Mpz_t,), a) % Int
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated but % Int seems dangerous here because of the Culong . Would be better to wrap in Int, even if a bit slower (which shouldn't be a concern because BigInt's are not used for performance). I can open a different PR for this.

@musm
Copy link
Contributor Author

musm commented Aug 17, 2017

Can anyone restart travis/circleci ?

base/gmp.jl Outdated
@@ -113,57 +115,56 @@ module MPZ
# and `add!(x, a) = add!(x, x, a)`.
using Base.GMP: BigInt, Limb

const mpz_t = Ptr{BigInt}
const bitcnt_t = Culong
const Mpz_t = Ref{BigInt}
Copy link
Member

Choose a reason for hiding this comment

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

I find Mpz_t a bit ugly as these are initials. I think this is an unrelated change, so you could do that in another PR, but if you really insist to change it now, I think I would prefer MPZ_t. Also I had introduced bitcnt_t to make it easier to match the signatures in this MPZ module with the GMP docs (as there had been some mistakes previously with using raw types like Culong), so I don't understand why you remove it now without giving motivation in an unrelated PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure will change. I initially found it confusing since it was not capitalized, same with the other alias.

Copy link
Member

Choose a reason for hiding this comment

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

No problem; I just picked the names from the GMP docs, but for other things I had been requested to use Julia naming style, like MPZ instead of mpz for the module name.

@tkelman
Copy link
Contributor

tkelman commented Aug 17, 2017

Can anyone restart travis/circleci ?

You'd need to rebase for circle to work, this branch doesn't contain a circle.yml.

base/gmp.jl Outdated
"does not correspond to the compile time version (version $GMP_VERSION with __gmp_bits_per_limb == $GMP_BITS_PER_LIMB).\n",
msg(string("The dynamically loaded GMP library (version $(gmp_version()),
with __gmp_bits_per_limb == $(gmp_bits_per_limb()))\n",
"does not correspond to the compile time version",
Copy link
Contributor

Choose a reason for hiding this comment

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

this will print as version(version , better to keep the space between

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

@tkelman tkelman Aug 18, 2017

Choose a reason for hiding this comment

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

doesn't look like it was? either this line should have a space before the close quote or the next line should have a space before after the open quote

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I missed this line, which also requires a space as well (I updated the other one that required a space)

@fredrikekre
Copy link
Member

@nanosoldier runbenchmarks(ALL,vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@musm
Copy link
Contributor Author

musm commented Aug 21, 2017

part of #6080 (ref)

@musm
Copy link
Contributor Author

musm commented Aug 26, 2017

Merge ?

limbs_write!(x::BigInt, a) = ccall((:__gmpz_limbs_write, :libgmp), Ptr{Limb}, (mpz_t, Clong), x, a)
limbs_finish!(x::BigInt, a) = ccall((:__gmpz_limbs_finish, :libgmp), Void, (mpz_t, Clong), x, a)
import!(x::BigInt, a, b, c, d, e, f) = ccall((:__gmpz_import, :libgmp), Void,
(mpz_t, Csize_t, Cint, Csize_t, Cint, Csize_t, Ptr{Void}), x, a, b, c, d, e, f)
Copy link
Member

Choose a reason for hiding this comment

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

I prefer the previous style but well, I'm biased since I wrote it :-p

@rfourquet rfourquet merged commit 119cf4c into JuliaLang:master Aug 26, 2017
@musm musm deleted the gmp branch August 26, 2017 16:35
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.

7 participants