[petsc-dev] fix needed for PETSc's use of _mm_prefetch

Barry Smith bsmith at mcs.anl.gov
Thu Aug 26 08:50:37 CDT 2010


   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)

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.

  Barry


On Aug 26, 2010, at 4:26 AM, Jed Brown wrote:

> On Wed, 25 Aug 2010 18:19:50 -0500, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>> libfast in: /users/nyevik/MANUALBUILD/petsc-3.1-p4/src/mat/impls/aij/seq
>> inode.c: In function 'PetscErrorCode MatMult_SeqAIJ_Inode(_p_Mat*, _p_Vec*, _p_Vec*)':
>> inode.c:426: error: invalid conversion from 'int' to '_mm_hint'
>> inode.c:426: error:   initializing argument 2 of 'void _mm_prefetch(const void*, _mm_hint)'
>> inode.c:427: error: invalid conversion from 'int' to '_mm_hint'
>> inode.c:427: error:   initializing argument 2 of 'void _mm_prefetch(const void*, _mm_hint)'
>> 
>> The PETSc code currently handles all this as the second argument is an int. This has to be fixed in petsc-dev to handle the case when int cannot be cast to _mm_hint
> 
> The Intel Intrinsics manual [1] specifies that the prototype is
> 
>  void _mm_prefetch(char const *a, int sel)
> 
> so this compiler is non-conforming.  What is it?  We may still need a
> workaround, but should confirm that it has been filed as a bug.
> 
> Jed
> 
> [1] see page 77 of http://software.intel.com/file/6373




More information about the petsc-dev mailing list