00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 #ifndef __MMX__MATRIX_SSE__HPP
00014 #define __MMX__MATRIX_SSE__HPP
00015 #include <algebramix/vector_sse.hpp>
00016 #include <algebramix/matrix_aligned.hpp>
00017 
00018 namespace mmx {
00019 #if defined (ALGEBRAMIX_ENABLE_SIMD) & defined (__SSE2__)
00020 
00021 
00022 
00023 
00024 
00025 template<bool b, typename V, typename W, typename Op, typename C>
00026 struct mat_mul_simd_helper {
00027   static inline void
00028   mul (C* d, const C* s1, const C* s2,
00029        nat r, nat rr, nat l, nat ll, nat c, nat cc)
00030   {
00031     typedef implementation<matrix_multiply,V> Mat;
00032     Mat::template mul<Op> (d, s1, s2, r, rr, l, ll, c, cc);
00033   }
00034 };
00035   
00036 template<typename V, typename W, typename Op, typename C>
00037 struct mat_mul_simd_helper<true,V,W,Op,C> {
00038   static inline void
00039   mul (C* d, const C* s1, const C* s2,
00040        nat r, nat rr, nat l, nat ll, nat c, nat cc)
00041   {
00042     typedef typename Simd_type (C) simd_C;
00043     typedef implementation<matrix_multiply,W> SMat;
00044     static const nat m= Simd_size (C);
00045     VERIFY (r % m == 0, "alignment problem");
00046     VERIFY (rr % m == 0, "alignment problem");
00047     SMat::template mul<Op> ((simd_C*) d, (simd_C*) s1, s2,
00048                             r / m, rr / m, l, ll, c, cc);
00049   }
00050 };
00051 
00052 template<typename V, typename W,
00053          typename Op, typename C>
00054 struct mat_mul_aligned_helper<V,W,Op,C,C,C> {
00055   static inline void
00056   mul (C* d, const C* s1, const C* s2,
00057        nat r, nat rr, nat l, nat ll, nat c, nat cc)
00058   {
00059     mat_mul_simd_helper<sse_has_helper<Op, C>::value,V,W,Op,C>
00060       ::mul (d, s1, s2, r, rr, l, ll, c, cc);
00061   }
00062 };
00063 
00064 #endif // ALGEBRAMIX_ENABLE_SIMD && __SSE2__
00065 } 
00066 #endif // __MMX__MATRIX_SIMD__HPP