00001 #ifndef CVD_CPU_HACKS_H 00002 #define CVD_CPU_HACKS_H 00003 /* 00004 This file is part of the CVD Library. 00005 00006 Copyright (C) 2005 The Authors 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 00021 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 00051 00052 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