These are chat archives for symengine/symengine

13th
Jun 2015
Sumith Kulal
@Sumith1896
Jun 13 2015 13:08
Any idea on how to construct mpz_class from piranha::integer?
Francesco Biscani
@bluescarni
Jun 13 2015 14:01
@Sumith1896 in the integer class there is an implicit conversion operator to const mpz_struct_t *
actually scratch that
let me dig a concrete example
so you need to use this method from the integer class:
it returns an mpz_view class which is a read-only view of the integer object in GMP format
it is implicitly convertible to const mpz_struct_t *, so you should be able to use it in the GMP API whenever you have a function accepting a const mpz_t as parameter
Francesco Biscani
@bluescarni
Jun 13 2015 14:07
for instance, something like this works:
auto n = integer(1);
mpz_t m;
mpz_init_set(m,...); (just some initialization of m here)
auto v = n.get_mpz_view(); (get the mpz_view from the integer)
mpz_cmp(v,m); --> now you can call GMP functions passing the view directly
note that the view is read-only, you cannot call any GMP function that would modify it
and the lifetime of the view is tied to the integer object from which it was generated - if n is destroyed, the view is invalidated
Francesco Biscani
@bluescarni
Jun 13 2015 14:19
@Sumith1896 according to this:
you should be able to construct an mpz_class directly from the view object
Sumith Kulal
@Sumith1896
Jun 13 2015 15:08
Yes this should work, let me give it a try.
Sumith Kulal
@Sumith1896
Jun 13 2015 15:29
Thanks @bluescarni. It's working.
Francesco Biscani
@bluescarni
Jun 13 2015 15:30
@Sumith1896 np, cool!
Sumith Kulal
@Sumith1896
Jun 13 2015 15:31
And we are averaging 28ms now, still not close
Francesco Biscani
@bluescarni
Jun 13 2015 15:31
I am working on the constructor of integer from mpz_t
for the poly benchmarks you mean?
Sumith Kulal
@Sumith1896
Jun 13 2015 15:31
Yes
Francesco Biscani
@bluescarni
Jun 13 2015 15:31
this is fateman1 righT?
or something smaller?
Sumith Kulal
@Sumith1896
Jun 13 2015 15:33
f = (x + y + z + w)^15 
f*(f + w)
Francesco Biscani
@bluescarni
Jun 13 2015 15:33
ah ok, I see
what is the timing from Piranha? and is it being run with 1 thread or in parallel?
Sumith Kulal
@Sumith1896
Jun 13 2015 15:34
this is the benchmark, modified a bit, I'll create a same for Piranha and check, still will be 2x faster
Sumith Kulal
@Sumith1896
Jun 13 2015 15:39
Piranha averages 13.4 ms on my machine
Will put a detailed report soon
Francesco Biscani
@bluescarni
Jun 13 2015 15:40
ok
I am interested to see it
I have mainly focused on optimising very large multiplications in the past, so I am sure there is some room for improvement in Piranha for smaller operands
getting within 2x is good at this stage I think
Harsh Gupta
@hargup
Jun 13 2015 17:00
@Sumith1896 benchmark results of expand2b looks interesting, can you add more background in the wiki entry
Sumith Kulal
@Sumith1896
Jun 13 2015 17:07
@hargup Background in the sense?
Okay I can add more info on the differences between expand2,expand2b and expand2c
Sumith Kulal
@Sumith1896
Jun 13 2015 17:23
@hargup Let me know if you have anything specific in mind
Ondřej Čertík
@certik
Jun 13 2015 22:46
Thanks @Sumith1896 , very good job. 2x is not bad. Let's see what other differences there are. One is the length of the integer, perhaps Piranha is using a smaller integer for the packed exponents. The other option is the faster hashtable in Piranha.
I think now when we are so close, I think it would make sense to see if we can get identical timings with a faster hashtable. I don't know how easy it is to try using the Piranha's hashtable
Ondřej Čertík
@certik
Jun 13 2015 23:02
@bluescarni, what exactly is Piranha using to store the coefficients? I found piranha::hash_set but I don't think that's it.
Francesco Biscani
@bluescarni
Jun 13 2015 23:08
@certik it's hash set indeed. The set stores coefficient-monomial pairs, and only the monomial is used for hashing the term
term --> piranha::term
for the packed exponents I am using the signed counterpart of std::size_t, which is typically the largest "fast" int on the system
long or long long usually
I think it is long on Linux 32/64 and Win32, and long long on Win64
Francesco Biscani
@bluescarni
Jun 13 2015 23:16
the set is semantically similar to a std::unordered_set<term> essentially