[sdiy] GCC vs Clang for Audio DSP

Eric Brombaugh ebrombaugh at gmail.com
Thu May 5 03:52:20 CEST 2022


Steve,

Thanks for the suggestion of adding -Ofast - I had neglected that option 
and it's good to have it in the results.

I also neglected to turn on Link Time Optimization (LTO) during the ARM 
Clang runs - that's unfair as this option had been set for the other 
three compiler cases. Enabling it made very little change in the CPU 
loading but did bring the binary size down noticeably.

I've updated the charts at the github repo with these new results if 
anyone cares to take another look.

Eric

On 5/4/22 13:13, Steve via Synth-diy wrote:
> 
> you could also try "Ofast", which both compilers seem to support. This
> adds some math optimizations to O3, IIRC assuming that no floats are NAN
> or infinity, maybe just the thing for your program, assuming the filters
> behave.
> 
> Brombaugh via Synth-diy:
>> In a previous thread we had some exchanges about the performance of
>> various compilers used in embedded ARM applications. I've been using
>> GCC for this over the course of the last decade and had seen some
>> remarkable improvements in its performance so I was somewhat surprised
>> that it was viewed as being substantially underperforming in
>> comparison to the proprietary toolchains based on LLVM/clang.
>>
>> I decided to try for myself and put together a quick DSP benchmark
>> that's representative of the sort of stuff that I often do in my
>> embedded work. I took some time to create build scripts for clang and
>> test out both the free and proprietary versions to compare them
>> against GCC for both execution speed and binary size. the results are
>> interesting so I summarized them with tables and charts over here:
>>
>> https://github.com/emeb/f303k8_nucleo
>>
>> The quick summary is that based on this one example it appears that
>> recent builds of GCC are not grossly out of line with the performance
>> of Clang in both the free and proprietary flavors. For all levels of
>> optimization greater than -O0 GCC performs roughly as well if not
>> better than either version of Clang. This test also shows very little
>> difference between the free and proprietary versions of Clang.
>>
>> I would like to emphasize that this is one particular use-case and by
>> no means representative of the performance you'd see in all
>> applications of these compilers. It does however provide an
>> alternative viewpoint backed by hard evidence to the notion that GCC
>> is generally sub-standard and not for professional use.
>>
>> If you have questions about the methodology I used here, the entire
>> source and build scripts are available at that github repo for your
>> inspection. I will admit that I'm not a clang power-user so there may
>> be some optimizations that I've overlooked and I'd appreciate any
>> suggestions on how to make this analysis more complete.
>> _______________________________________________
>> Synth-diy mailing list
>> Synth-diy at synth-diy.org
>> http://synth-diy.org/mailman/listinfo/synth-diy
>> Selling or trading? Use marketplace at synth-diy.org
>>
> 
> 
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy
> Selling or trading? Use marketplace at synth-diy.org


More information about the Synth-diy mailing list