These are chat archives for symengine/symengine

22nd
Feb 2016
Isuru Fernando
@isuruf
Feb 22 2016 14:04
@certik, are you here?
Shivam Vats
@shivamvats
Feb 22 2016 14:43
@irislq Thanks a lot!
Isuru Fernando
@isuruf
Feb 22 2016 16:09

@certik, I started on the wrapper for flint. One problem I faced is that flint assumes a canonical form for the integers. If an integer is stored in a mpz_t, then it is bigger than the numbers stored directly.

So, if we use gmp api to calculate values, then the value has to be demoted as well. I can add demote calls after each gmp api call, or what we can do is wrap all the gmp routines that we use. I think the 2nd approach is better. what do you think?

Btw, using flint is faster. around 10% more than piranha
Francesco Biscani
@bluescarni
Feb 22 2016 16:17
@isuruf do you have a pointer to the benchmark?
Isuru Fernando
@isuruf
Feb 22 2016 16:27

It's benchmarks/expand2
cmake -DWITH_FLINT=yes -DINTEGER_CLASS=flintxx .
cmake -DWITH_PIRANHA=yes -DINTEGER_CLASS=piranha .

You'll need to use this branch, https://github.com/isuruf/symengine/tree/int

Francesco Biscani
@bluescarni
Feb 22 2016 16:33
ok cheers... you have any idea on the size of the coefficients?
Isuru Fernando
@isuruf
Feb 22 2016 16:35
around 40 bits
Francesco Biscani
@bluescarni
Feb 22 2016 16:36
ok so flint uses hardware integers for that
Isuru Fernando
@isuruf
Feb 22 2016 16:36
yes
more like 40-50 bits, but still within the range that flint has an advantage
Francesco Biscani
@bluescarni
Feb 22 2016 16:38
I see, I am happy that for that benchmark the delta is in the order of 10%
Ondřej Čertík
@certik
Feb 22 2016 17:30
@isuruf I am here now.
Ondřej Čertík
@certik
Feb 22 2016 17:31
@isuruf are you sure that flint is demoting values?
I know Piranha isn't.
If it is, then we have to as well. I would first handle this in our wrapper.
I guess I don't understand how you would wrap all our gmp calls, i.e. the demotion only makes sense for Flint, doesn't it?
Isuru Fernando
@isuruf
Feb 22 2016 17:33
for most of the gmp functions, there are corresponding flint functions as well. we could use them
Demotion happens in flint. For ex, see how equal is implemented, https://github.com/wbhart/flint2/blob/trunk/fmpz/equal.c
Ondřej Čertík
@certik
Feb 22 2016 17:36
I think it boils down to how we design the integer class.
I think our integer class API must come with the class + the non member methods to do things with integers (e.g. all the low level GMP methods).
Then Flint, Piranha, pure GMP override this API.
Which means that in Flint, you override the low level operations with calls to GMP + demotion.
pure GMP just calls GMP. In Piranha you currently probably just call GMP, but that can change in the future.
So what I am trying to say is that we need to abstract the direct calls to GMP as we do currently, and allow to override things.
Isuru Fernando
@isuruf
Feb 22 2016 17:40
That was my idea as well. #651 doesn't abstract all the direct calls. Only a subset. We should do it for all calls
Ondřej Čertík
@certik
Feb 22 2016 17:40
That's why I was asking here https://github.com/symengine/symengine/pull/651#issuecomment-186830336 about the design.
Isuru Fernando
@isuruf
Feb 22 2016 17:43
Now I understand more about what you were saying there.