00001 #ifndef CVD_CPU_HACKS_H
00002 #define CVD_CPU_HACKS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <cvd/config.h>
00026
00027 #if CVD_HAVE_FENV_H
00028 #include <fenv.h>
00029 #endif
00030
00031 #if CVD_HAVE_MMXEXT
00032 #include <xmmintrin.h>
00033 #endif
00034
00035 namespace CVD
00036 {
00037
00038
00041 inline void enableFPE();
00042
00043 #ifndef DOXYGEN_IGNORE_INTERNAL
00044 #ifdef CVD_HAVE_FENV_H
00045 inline void enableFPE()
00046 {
00047 feclearexcept(FE_ALL_EXCEPT);
00048 feenableexcept(FE_DIVBYZERO|FE_INVALID);
00049 }
00050 #else
00053 inline void enableFPE()
00054 {
00055 }
00056 #endif
00057 #endif
00058
00071 template<int I> inline void prefetch(const void* ptr);
00072
00073 inline void prefetch(const void* ptr);
00074
00075
00076 #ifndef DOXYGEN_IGNORE_INTERNAL
00077 #ifdef CVD_HAVE_MMXEXT
00078 template<int I> inline void prefetch(const void* ptr)
00079 {
00080 _mm_prefetch((char *)ptr, _MM_HINT_NTA);
00081 }
00082
00083 template<> inline void prefetch<0>(const void* ptr)
00084 {
00085 _mm_prefetch((char *)ptr, _MM_HINT_T0);
00086 }
00087
00088 template<> inline void prefetch<1>(const void* ptr)
00089 {
00090 _mm_prefetch((char *)ptr, _MM_HINT_T1);
00091 }
00092
00093 template<> inline void prefetch<2>(const void* ptr)
00094 {
00095 _mm_prefetch((char *)ptr, _MM_HINT_T2);
00096 }
00097
00098 inline void prefetch(const void* ptr)
00099 {
00100 prefetch<-1>(ptr);
00101 }
00102
00103 #else
00104 template<int i> inline void prefetch(const void*){}
00105 inline void prefetch(const void*){}
00106
00107 #endif
00108 #endif
00109 }
00110 #endif
00111
00112