algebramix_doc 0.3
|
00001 00002 /****************************************************************************** 00003 * MODULE : vector_simd.hpp 00004 * DESCRIPTION: vectors using SIMD instructions 00005 * COPYRIGHT : (C) 2008 Joris van der Hoeven and Gregoire Lecerf 00006 ******************************************************************************* 00007 * This software falls under the GNU general public license and comes WITHOUT 00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details. 00009 * If you don't have this file, write to the Free Software Foundation, Inc., 00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00011 ******************************************************************************/ 00012 00013 #ifndef __MMX__VECTOR_SIMD__HPP 00014 #define __MMX__VECTOR_SIMD__HPP 00015 #include <numerix/simd.hpp> 00016 #include <algebramix/vector_unrolled.hpp> 00017 #include <algebramix/vector_aligned.hpp> 00018 #include <algebramix/vector_sse.hpp> 00019 00020 namespace mmx { 00021 00022 /****************************************************************************** 00023 * Variant for SIMD support 00024 ******************************************************************************/ 00025 00026 template<nat len1, nat len2, typename V= vector_naive> 00027 struct vector_simd: public vector_aligned< 00028 vector_unrolled<len1,V>, 00029 vector_unrolled<len2,V> > 00030 { 00031 typedef vector_simd<len1,len2,typename V::Naive> Naive; 00032 typedef vector_simd<len1,len2,typename V::Aligned> Aligned; 00033 typedef vector_unrolled<len1,typename V::No_simd> No_simd; 00034 typedef vector_simd<len1,len2,typename V::No_thread> No_thread; 00035 }; 00036 00037 template<typename F, typename V, nat len1, nat len2, typename W> 00038 struct implementation<F,V,vector_simd<len1,len2,W> >: 00039 public implementation<F,V,vector_aligned< 00040 vector_unrolled<len1,W>, 00041 vector_unrolled<len2,W> > > {}; 00042 00043 /****************************************************************************** 00044 * Suggested specilizations for an Intel plateform supporting SSE2 00045 ******************************************************************************/ 00046 00047 #define Vector_simd_variant(C) vector_simd_variant_helper<C>::VV 00048 00049 template<typename C> 00050 struct vector_simd_variant_helper { 00051 typedef vector_simd<4,4> VV; }; 00052 00053 STMPL 00054 struct vector_simd_variant_helper<double> { 00055 typedef vector_simd<8,4> VV; }; 00056 00057 STMPL 00058 struct vector_simd_variant_helper<char> { 00059 typedef vector_simd<32,4> VV; }; 00060 00061 STMPL 00062 struct vector_simd_variant_helper<signed char> { 00063 typedef vector_simd<32,4> VV; }; 00064 00065 STMPL 00066 struct vector_simd_variant_helper<unsigned char> { 00067 typedef vector_simd<32,4> VV; }; 00068 00069 STMPL 00070 struct vector_simd_variant_helper<short int> { 00071 typedef vector_simd<32,4 > VV; }; 00072 00073 STMPL 00074 struct vector_simd_variant_helper<short unsigned int> { 00075 typedef vector_simd<32, 4> VV; }; 00076 00077 STMPL 00078 struct vector_simd_variant_helper<int> { 00079 typedef vector_simd<16, 4> VV; }; 00080 00081 STMPL 00082 struct vector_simd_variant_helper<unsigned int> { 00083 typedef vector_simd<16, 4> VV; }; 00084 00085 STMPL 00086 struct vector_simd_variant_helper<long int> { 00087 typedef vector_simd<16, 4> VV; }; 00088 00089 STMPL 00090 struct vector_simd_variant_helper<long unsigned int> { 00091 typedef vector_simd<16, 4> VV; }; 00092 00093 STMPL 00094 struct vector_simd_variant_helper<long long int> { 00095 typedef vector_simd<8,4> VV; }; 00096 00097 STMPL 00098 struct vector_simd_variant_helper<long long unsigned int> { 00099 typedef vector_simd<8,4> VV; 00100 }; 00101 00102 } // namespace mmx 00103 00104 #endif // __MMX__VECTOR_SIMD__HPP