algebramix_doc 0.3
|
00001 00002 /****************************************************************************** 00003 * MODULE : matrix_simd.hpp 00004 * DESCRIPTION: matrices using SIMD instructions 00005 * COPYRIGHT : (C) 2007 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__MATRIX_SIMD__HPP 00014 #define __MMX__MATRIX_SIMD__HPP 00015 #include <algebramix/vector_simd.hpp> 00016 #include <algebramix/matrix_unrolled.hpp> 00017 #include <algebramix/matrix_aligned.hpp> 00018 #include <algebramix/matrix_sse.hpp> 00019 00020 namespace mmx { 00021 00022 /****************************************************************************** 00023 * SIMD matrix variant 00024 ******************************************************************************/ 00025 00026 template<nat len1, nat len2, typename V=matrix_naive> 00027 struct matrix_simd: public matrix_aligned< 00028 matrix_unrolled<len1, V>, 00029 matrix_unrolled<len2, V> > 00030 { 00031 typedef vector_simd<len1,len2,typename V::Vec> Vec; 00032 typedef matrix_simd<len1,len2,typename V::Naive> Naive; 00033 typedef matrix_simd<len1,len2,typename V::Positive> Positive; 00034 typedef matrix_unrolled<len1,typename V::No_simd> No_simd; 00035 typedef matrix_simd<len1,len2,typename V::No_thread> No_thread; 00036 typedef matrix_simd<len1,len2,typename V::No_scaled> No_scaled; 00037 }; 00038 00039 template<typename F, typename V, nat len1, nat len2, typename W> 00040 struct implementation<F,V,matrix_simd<len1,len2,W> >: 00041 public implementation<F,V,matrix_aligned< 00042 matrix_unrolled<len1, W>, 00043 matrix_unrolled<len2, W> > > {}; 00044 00045 /****************************************************************************** 00046 * Suggested specializations 00047 ******************************************************************************/ 00048 00049 #define Matrix_simd_variant(C) matrix_simd_variant_helper<C>::MV 00050 00051 template<typename C> 00052 struct matrix_simd_variant_helper { 00053 typedef matrix_simd<4,4> MV; }; 00054 00055 STMPL 00056 struct matrix_simd_variant_helper<double> { 00057 typedef matrix_simd<8,4> MV; }; 00058 00059 STMPL 00060 struct matrix_simd_variant_helper<char> { 00061 typedef matrix_simd<16,8> MV; }; 00062 00063 STMPL 00064 struct matrix_simd_variant_helper<signed char> { 00065 typedef matrix_simd<16,8> MV; }; 00066 00067 STMPL 00068 struct matrix_simd_variant_helper<unsigned char> { 00069 typedef matrix_simd<16,4> MV; }; 00070 00071 STMPL 00072 struct matrix_simd_variant_helper<short int> { 00073 typedef matrix_simd<16,4 > MV; }; 00074 00075 STMPL 00076 struct matrix_simd_variant_helper<short unsigned int> { 00077 typedef matrix_simd<32, 4> MV; }; 00078 00079 STMPL 00080 struct matrix_simd_variant_helper<int> { 00081 typedef matrix_simd<16, 4> MV; }; 00082 00083 STMPL 00084 struct matrix_simd_variant_helper<unsigned int> { 00085 typedef matrix_simd<16, 4> MV; }; 00086 00087 STMPL 00088 struct matrix_simd_variant_helper<long int> { 00089 typedef matrix_simd<16, 4> MV; }; 00090 00091 STMPL 00092 struct matrix_simd_variant_helper<long unsigned int> { 00093 typedef matrix_simd<16, 4> MV; }; 00094 00095 STMPL 00096 struct matrix_simd_variant_helper<long long int> { 00097 typedef matrix_simd<8,4> MV; }; 00098 00099 STMPL 00100 struct matrix_simd_variant_helper<long long unsigned int> { 00101 typedef matrix_simd<8,4> MV; 00102 }; 00103 00104 } // namespace mmx 00105 #endif // __MMX__MATRIX_SIMD__HPP