[GiNaC-list] [PATCH] add configure option to enable deterministic sorting

Valery Yundin yuvalery at gmail.com
Thu May 29 14:10:10 CEST 2014


On 29 May 2014 07:31, Alexei Sheplyakov <alexei.sheplyakov at gmail.com> wrote:
> I'm terribly sorry, but everything which makes the hash function worse
> (slower or produces more collisions) is not acceptable.
If you insist on that regardless of how it affects overall
performance, it is not a technical problem and cannot be fixed with a

In any case, if my previous patches are not acceptable for whatever
reasons GiNaC developers might have, I suggest to close this
discussion by adding a configure option. So users can decide for
themselves if (non-)determinism is worth few per-cent speed
difference. Below is the simplest patch one can imagine.

By default it keeps things as they are now. If user specifies
--enable-determinism then make_hash_seed simply returns 0. Objects
with the same calchash() implementation *and* the same contents *but*
different types will have a hash collision, which be resolved in
base::compare by using typeid_1.before(typeid_2) (on Linux it is a
simple strcmp). Since it happens quite rarely (depends on a particular
code of course), it is better than always using crc32 as in windows
version of your code. In fact it can sometimes be faster than current
"fast" hash.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: conf-deterministic.patch
Type: text/x-patch
Size: 1864 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20140529/87f6c2c5/attachment.patch>

More information about the GiNaC-list mailing list