On Thu, 26 Aug 2010 08:50:37 -0500, Barry Smith <bsmith at mcs.anl.gov> wrote:
> 
>    Well the PGI compiler has
> 
> enum _mm_hint
> {
>   _MM_HINT_T0 = 3,
>   _MM_HINT_T1 = 2,
>   _MM_HINT_T2 = 1,
>   _MM_HINT_NTA = 0
> };
> extern  void _mm_prefetch (const void *__P, enum _mm_hint __I);
> 
>   Intel on my Mac has
> 
> /* constants for use with _mm_prefetch */
> #define _MM_HINT_T0   1
> #define _MM_HINT_T1   2
> #define _MM_HINT_T2   3
> #define _MM_HINT_NTA  0
> extern void __cdecl _mm_prefetch(char const*a, int sel);
> 
>  clang on my mac has
> 
> #define _MM_HINT_T0 1
> #define _MM_HINT_T1 2
> #define _MM_HINT_T2 3
> #define _MM_HINT_NTA 0
> 
> /* FIXME: We have to #define this because "sel" must be a constant integer, 
> and 
>    Sema doesn't do any form of constant propagation yet. */
> 
> #define _mm_prefetch(a, sel) (__builtin_prefetch((void *)a, 0, sel))
> 
>    Some GNU headers I found on the web have
> 
> /* Constants for use with _mm_prefetch.  */
> enum _mm_hint
> {
>   _MM_HINT_T0 = 3,
>   _MM_HINT_T1 = 2,
>   _MM_HINT_T2 = 1,
>   _MM_HINT_NTA = 0
> };
> static __inline void
> _mm_prefetch (void *__P, enum _mm_hint __I)

Urgh, I hadn't noticed that T0,T1,T2 were defined to different values by
different hardware.  We usually only use NTA (and the others hints are
sometimes all equivalent), but it's not ideal.

> Though it may be non-conforming I think it still needs to be
> supported. It seems _MM_HINT* etc and friends always exist, what about
> just not using 1, 2 3 etc but consistently using the macros would work
> and not require adding to configure.

The problem is that PetscPrefetch is also for non-Intel architectures,
in which case it calls __builtin_prefetch or something else.  Kinda
looks like we're obliged to have configure define
PETSC_PREFETCH_HINT_{T0,T1,T2,NTA} so that it can work correctly in all
cases.  Note that T0,T1,T2 are sometimes equivalent and could all be
defined to the same thing if necessary.

Jed

Reply via email to