[GiNaC-list] [PATCH] fix bug/feature causing non-deterministic output
Valery Yundin
yuvalery at gmail.com
Wed May 21 18:17:44 CEST 2014
Hi,
Please see attached patch which fixes rather peculiar "feature" of GiNaC -
non-determinism.
One can think of many arguments why non-determinism of CAS is a bad idea.
Shortly speaking, it is simply unacceptable. Especially when there is no
good reason for it (and I can hardly think of a good reason anyway).
At the moment GiNaC relies on OS-assigned memory addresses of type-names to
define its term-ordering, which results in different output from the same
program. When this bug was brought up in the mailing list (several times)
the developers called it a "design decision".
Well, it is time to stop the insanity. The attached patch fixes the bug at
zero cost to the performance.
Here are the results of "/usr/bin/time make check" (second run with
pre-warmed caches)
unpatched non-deterministic: 132.57 s
fixed deterministic: 132.62 s
Keep in mind that it wouldn't make GiNaC canonical ordering entirely
predictable, since it still depends on the order of symbol declaration and
such (btw, fixing that wouldn't be too hard either). But at least for the
same program and compiler the result must be identical.
PS I added FNV1a hash, one could just keep using crc32 which is already
there. It makes no difference since the hash function is now called only
once for each type (before it was called for every object).
PPS I'm attaching patches against master and release_1-6-2 since I hope
that developers recognize it as a bug and update stable releases as well.
With best regards, Valery Yundin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20140521/24205771/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: master-Make-hash-values-deterministic.patch
Type: text/x-patch
Size: 6492 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20140521/24205771/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: release-1.6.2-Make-hash-values-deterministic.patch
Type: text/x-patch
Size: 6397 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20140521/24205771/attachment-0001.patch>
More information about the GiNaC-list
mailing list