On Tuesday, 9 June 2015 at 16:45:33 UTC, Manu wrote:
On 10 June 2015 at 02:32, John Colvin via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
On Tuesday, 9 June 2015 at 16:18:06 UTC, Manu wrote:

On 10 June 2015 at 01:26, Ilya Yaroshenko via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
[...]


A complication for linear algebra (or other mathsy things in general)
is the inability to detect and implement compound operations.
We don't declare mathematical operators to be algebraic operations,
which I think is a lost opportunity.
If we defined the properties along with their properties
(commutativity, transitivity, invertibility, etc), then the compiler could potentially do an algebraic simplification on expressions before
performing codegen and optimisation.
There are a lot of situations where the optimiser can't simplify expressions because it runs into an arbitrary function call, and I've never seen an optimiser that understands exp/log/roots, etc, to the point where it can reduce those expressions properly. To compete with maths benchmarks, we need some means to simplify expressions properly.


Optimising floating point is a massive pain because of precision concerns and IEEE-754 conformance. Just because something is analytically the same doesn't mean you want the optimiser to go ahead and make the switch for you.

We have flags to control this sort of thing (fast-math, strict ieee, etc). I will worry about my precision, I just want the optimiser to do its
job and do the very best it possibly can. In the case of linear
algebra, the optimiser generally fails and I must manually simplify
expressions as much as possible.

If the compiler is free to rewrite by analytical rules then "I will worry about my precision" is equivalent to either "I don't care about my precision" or "I have checked the codegen". A simple rearrangement of an expression can easily turn a perfectly good result in to complete garbage. It would be great if compilers were even better at fast-math mode, but an awful lot of applications can't use it.

Reply via email to