{"action":"created","issue":{"url":"https://api.github.com/repos/symengine/symengine/issues/477","labels_url":"https://api.github.com/repos/symengine/symengine/issues/477/labels{/name}","comments_url":"https://api.github.com/repos/symengine/symengine/issues/477/comments","events_url":"https://api.github.com/repos/symengine/symengine/issues/477/events","html_url":"https://github.com/symengine/symengine/issues/477","id":89962510,"number":477,"title":"Implement faster low level integer class","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?v=3","gravatar_id":"","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-21T21:19:41Z","updated_at":"2015-11-05T15:45:47Z","closed_at":null,"body":"Currently we use `mpz_class`, but it is possible to speed it up further by automatically switching between a machine integer and a `mpz`. One such implementation is `piranha::integer`. We should either use `piranha::integer` or write our own implementation and use it everywhere instead of `mpz_class`. That will speed things up considerably.\r\n\r\nThere are couple of decisions to be made:\r\n\r\n* `piranha::integer` is using 128 bit machine integer. One can instead use 64bit, which is faster up to 64bit, i.e. it depends on the size of integers that the user needs. For a general CAS use, perhaps 64bit is more common, thus it will be faster for smaller integers, slower than `piranha::integer` up to 128bits, and the same fast for bigger ints (since `mpz` must be used).\r\n\r\n* `piranha::integer` is using a union and is strictly following the C++ standard. It is possible to speed things up by not strictly following a C++ standard by using a pointer to `mpz` and overload the upper bit (i.e. requiring the pointer to be always at least 8 bit aligned, which seems to always be the case in practice on all current architectures), and use machine integer instead of the pointer. This is what FLINT does.\r\n\r\nUltimately I think we can implement all of the above, and allow the user to choose, or perhaps pick one default, but have the other implementations in the code, so that the user can use them as building blocks."},"comment":{"url":"https://api.github.com/repos/symengine/symengine/issues/comments/154098396","html_url":"https://github.com/symengine/symengine/issues/477#issuecomment-154098396","issue_url":"https://api.github.com/repos/symengine/symengine/issues/477","id":154098396,"user":{"login":"bluescarni","id":623038,"avatar_url":"https://avatars.githubusercontent.com/u/623038?v=3","gravatar_id":"","url":"https://api.github.com/users/bluescarni","html_url":"https://github.com/bluescarni","followers_url":"https://api.github.com/users/bluescarni/followers","following_url":"https://api.github.com/users/bluescarni/following{/other_user}","gists_url":"https://api.github.com/users/bluescarni/gists{/gist_id}","starred_url":"https://api.github.com/users/bluescarni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluescarni/subscriptions","organizations_url":"https://api.github.com/users/bluescarni/orgs","repos_url":"https://api.github.com/users/bluescarni/repos","events_url":"https://api.github.com/users/bluescarni/events{/privacy}","received_events_url":"https://api.github.com/users/bluescarni/received_events","type":"User","site_admin":false},"created_at":"2015-11-05T15:45:47Z","updated_at":"2015-11-05T15:45:47Z","body":"@certik Keep in mind that Piranha's small integer optimisation stores 2 limbs. So you can do what you propose and it would certainly be the best way to go, but you will need something more sophisticated than just long int arithmetic in order to implement the various GMP functions."}}