Lennart Augustsson mentioned on his blog that he got substantial performance
improvements by conveying to LLVM when external functions (e.g. tanh) were
pure.
How is this done?
Lennart Augustsson mentioned on his blog that he got substantial performance
improvements by conveying to LLVM when external functions (e.g. tanh) were
pure.
How is this done?
Hi,
Lennart Augustsson mentioned on his blog that he got substantial performance
improvements by conveying to LLVM when external functions (e.g. tanh) were
pure.
first note that tanh is not pure, because the result depends on the current
floating point rounding mode. However, if you are willing to sacrifice
complete numerical correctness, you can give llvm-gcc the -ffast-math flag
and, voila!, tanh becomes pure.
Ciao,
Duncan.
Hi,
> Lennart Augustsson mentioned on his blog that he got substantial
> performance improvements by conveying to LLVM when external functions
> (e.g. tanh) were pure.first note that tanh is not pure, because the result depends on the current
floating point rounding mode.
Ugh.
However, if you are willing to sacrifice
complete numerical correctness, you can give llvm-gcc the -ffast-math flag
and, voila!, tanh becomes pure.
How do you do the equivalent from the JIT?
How do you do the equivalent from the JIT?
In the IR, give tanh the readnone attribute.
If you want it to pay attention to the floating
point rounding mode, give it the readonly attribute.
Best performance, ignores rounding mode:
declare double @tanh(double) nounwind readnone
Pays attention to rounding mode; optimizers can still do something though:
declare double @tanh(double) nounwind readonly
Ciao,
Duncan.
You need to set the readnone attribute. I set it on the call instruction.
-- Lennart