Bad interaction of XML handling and -ftree-vectorize


#1

Hi all,

I am using XML for a number of aspects of my plugin (PropertySet, my presets, etc.). However, I am running into an old bug, where if I enable auto-vectorization (-ftree-vectorize in GCC 4.0), my plugin crashes when loading the host.

The relevant part of the error message:

[code]Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000024
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libSystem.B.dylib 0x98162a34 pthread_mutex_lock + 24
1 com.ValhallaDSP.ValhallaRoom 0x17208b61 juce::CriticalSection::enter() const + 17
2 com.ValhallaDSP.ValhallaRoom 0x16fda448 juce::PropertySet::setValue(juce::String const&, juce::var const&) + 88[/code]

I think that I ran into a similar issue on the PC when I was creating ValhallaShimmer. I also ran into a similar issue in the past when I wasn’t using PropertySets, and had some other XML handling code at initialization time. Using auto-vectorization would be useful, as I have the feeling it would create far more optimal code (I am going to test this with a GUI-less AudioUnit to see if this is the case).

Thanks,

Sean Costello


#2

OK, solved my own issue, as I was able to enable per-file optimization in GCC 4.0. So I optimized my audio library with the desired flags, and left Juce alone.

In Xcode, you can enable this by selecting the file(s) you want to optimize, right-mouse clicking for “Get Info,” and then adding the flags in the Build tab under “Additional Compiler Flags.”

For whatever it’s worth, setting additional flags didn’t help my CPU significantly. I think using the -O3 optimization level sets a lot of these flags already, and my audio code is largely vectorized by hand, so any additional vectorizing made a very subtle difference if any.

Sean Costello