How to tell VS Code to use the fast math option?

Based on this thread and others, I have a feeling you may be fixating a bit too much on compiler flags. Julia already defaults to good performance—you should not need to mess around with optimization flags unless you are doing something pretty unusual. Frankly, the --math-mode=fast flag is a bad idea and you shouldn’t use it at all (sorry, @antoine-levitt, but that’s my honest opinion) and -O3 is basically the same as -O2 which is already the default. These options are not some magic wand to make your code faster—even if they do, it will only be by a very small margin. If your code is not fast enough, instead of messing with compiler flags, you should: profile it, look at allocation stats, make sure it’s type stable, make sure you don’t use non-constant globals, and put @inline and @simd annotations where appropriate. Or better still, use better algorithms—that’s where the most dramatic speed improvements come from. In all my time doing Julia consulting work helping people speed up their code, I have never once changed any compiler flags.

4 Likes