Re: [eigen] Fix for ARM __builtin_prefetch fails

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Nov 18, 2013, at 15:23 , Christoph Hertzberg <chtz@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> On 18.11.2013 23:54, Rick Mann wrote:
>> It seems that the GCC preprocessor chokes because it attempts to evaluate the entire expression.
>> 
>> You may want to #define HAS_BUILTIN_PREFETCH or something as a separate step, but you can't combine the __has_builtin with the defined(__GNUC__).
> 
> Ok, so the issue is that __has_builtin(__builtin_prefetch)
> is syntactically incorrect if __has_builtin is not defined. That means your patch resolves the issue only for GCC and the fix is to separate the && expression into two preprocessor lines.
> 
> Maybe something like this:
> 
> #ifdef __has_builtin
> #  if __has_builtin(__builtin_prefectch)
> #    define EIGEN_ARM_PREFETCH(ADDR) __builtin_prefetch(ADDR)
> #  endif
> #endif
> 
> #ifndef EIGEN_ARM_PREFETCH
> #  ifdef __GNUC__
> #    define EIGEN_ARM_PREFETCH(ADDR) __builtin_prefetch(ADDR);
> #  elif defined __pld
> #    define EIGEN_ARM_PREFETCH(ADDR) __pld(ADDR)
> #  elif !defined(__aarch64__)
> #    define EIGEN_ARM_PREFETCH(ADDR) asm volatile ( "   pld [%[addr]]\n" :: [addr] "r" (ADDR) : "cc" );
> #  else
>   // by default no explicit prefetching
> #    define EIGEN_ARM_PREFETCH(ADDR)
> #  endif
> #endif

Yes, I think that might be better. The engineer who found this is not around to ask right now if this change would work for him.



-- 
Rick



Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/