Re: [Cython] OS X 10.7 Lion: GCC __builtin_expect unrecognized inside OpenMP blocks
Lisandro Dalcin, 11.03.2012 09:26:
> On 11 March 2012 09:46, mark florisson wrote:
>> On 10 March 2012 14:00, Stefan Behnel wrote:
>>> Lisandro Dalcin, 10.03.2012 10:51:
>>>> Perhaps switching to use a "omp_likely"/"omp_unlikely" macros inside
>>>> OpenMP blocks would be nicer than defining/undefining?
>>> Could that be coded into the macro or would it require to change the
>>> generated code? But at least it sounds like it would not impact code in
>>> functions that are being called from within the OpenMP blocks, would it?
>>> Just the code straight inside the block. A work-around could still have a
>>> substantial impact if it requires changes to the generated code.
>> Yeah, that's why I suggested the undef/re-def approach around OpenMP
>> blocks. It's some code bloat, but only for the C preprocessor, so it
>> should be fine.
> I still feel bad about this. What about just disabling branch
> prediction if OpenMP is ever used? Or perhaps just protect the
> definitions of likely/unlikely with some guard, such as users can
> disable them using a -D definition?
There's a Cython compiler switch for it already. The problem is that it's
not used everywhere where branch prediction hints are being generated.
Would be worth fixing IMHO. There's already an unlikely() method in the
code generator, a likely() method should be added and both should be used
appropriately. That would allow us to a) switch the hints on and off
properly in the compiler and b) generate different code for the hints based
on the code environment.