HasSIMDMult.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_TYPETRAITS_HASSIMDMULT_H_
36 #define _BLAZE_MATH_TYPETRAITS_HASSIMDMULT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/util/Complex.h>
45 #include <blaze/util/EnableIf.h>
47 #include <blaze/util/mpl/And.h>
51 
52 
53 namespace blaze {
54 
55 //=================================================================================================
56 //
57 // CLASS DEFINITION
58 //
59 //=================================================================================================
60 
61 //*************************************************************************************************
63 template< typename T1 // Type of the left-hand side operand
64  , typename T2 // Type of the right-hand side operand
65  , typename = void > // Restricting condition
66 struct HasSIMDMultHelper
67 {
68  enum : bool { value = false };
69 };
71 //*************************************************************************************************
72 
73 
74 //*************************************************************************************************
76 template< typename T1, typename T2 >
77 struct HasSIMDMultHelper< T1, T2, EnableIf_< And< IsNumeric<T1>, IsIntegral<T1>
78  , IsNumeric<T2>, IsIntegral<T2>
79  , Bool< sizeof(T1) == sizeof(T2) > > > >
80 {
81  enum : bool { value = ( bool( BLAZE_SSE2_MODE ) && sizeof(T1) == 2UL ) ||
82  ( bool( BLAZE_SSE4_MODE ) && sizeof(T1) >= 2UL && sizeof(T1) <= 4UL ) ||
83  ( bool( BLAZE_AVX2_MODE ) && sizeof(T1) >= 2UL && sizeof(T1) <= 4UL ) ||
84  ( bool( BLAZE_MIC_MODE ) && sizeof(T1) == 4UL ) };
85 };
86 
87 template< typename T >
88 struct HasSIMDMultHelper< complex<T>, complex<T>, EnableIf_< And< IsNumeric<T>, IsIntegral<T> > > >
89 {
90  enum : bool { value = ( bool( BLAZE_SSE2_MODE ) && sizeof(T) == 2UL ) ||
91  ( bool( BLAZE_SSE4_MODE ) && sizeof(T) >= 2UL && sizeof(T) <= 4UL ) ||
92  ( bool( BLAZE_AVX2_MODE ) && sizeof(T) >= 2UL && sizeof(T) <= 4UL ) };
93 };
95 //*************************************************************************************************
96 
97 
98 //*************************************************************************************************
100 template<>
101 struct HasSIMDMultHelper< float, float >
102 {
103  enum : bool { value = bool( BLAZE_SSE_MODE ) ||
104  bool( BLAZE_AVX_MODE ) ||
105  bool( BLAZE_MIC_MODE ) };
106 };
107 
108 template<>
109 struct HasSIMDMultHelper< complex<float>, complex<float> >
110 {
111  enum : bool { value = ( bool( BLAZE_SSE3_MODE ) && !bool( BLAZE_MIC_MODE ) ) ||
112  ( bool( BLAZE_AVX_MODE ) && !bool( BLAZE_MIC_MODE ) ) };
113 };
115 //*************************************************************************************************
116 
117 
118 //*************************************************************************************************
120 template<>
121 struct HasSIMDMultHelper< double, double >
122 {
123  enum : bool { value = bool( BLAZE_SSE2_MODE ) ||
124  bool( BLAZE_AVX_MODE ) ||
125  bool( BLAZE_MIC_MODE ) };
126 };
127 
128 template<>
129 struct HasSIMDMultHelper< complex<double>, complex<double> >
130 {
131  enum : bool { value = ( bool( BLAZE_SSE3_MODE ) && !bool( BLAZE_MIC_MODE ) ) ||
132  ( bool( BLAZE_AVX_MODE ) && !bool( BLAZE_MIC_MODE ) ) };
133 };
135 //*************************************************************************************************
136 
137 
138 //*************************************************************************************************
159 template< typename T1 // Type of the left-hand side operand
160  , typename T2 // Type of the right-hand side operand
161  , typename = void > // Restricting condition
162 struct HasSIMDMult : public BoolConstant< HasSIMDMultHelper< Decay_<T1>, Decay_<T2> >::value >
163 {};
164 //*************************************************************************************************
165 
166 } // namespace blaze
167 
168 #endif
Generic wrapper for a compile time constant integral value.The IntegralConstant class template repres...
Definition: IntegralConstant.h:71
#define BLAZE_MIC_MODE
Compilation switch for the MIC mode.This compilation switch enables/disables the MIC mode...
Definition: Vectorization.h:248
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:162
Header file for the IsIntegral type trait.
Header file for the And class template.
#define BLAZE_AVX2_MODE
Compilation switch for the AVX2 mode.This compilation switch enables/disables the AVX2 mode...
Definition: Vectorization.h:231
Header file for the Decay type trait.
#define BLAZE_SSE3_MODE
Compilation switch for the SSE3 mode.This compilation switch enables/disables the SSE3 mode...
Definition: Vectorization.h:163
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_SSE_MODE
Compilation switch for the SSE mode.This compilation switch enables/disables the SSE mode...
Definition: Vectorization.h:129
Header file for the EnableIf class template.
Header file for the IsNumeric type trait.
#define BLAZE_SSE4_MODE
Compilation switch for the SSE4 mode.This compilation switch enables/disables the SSE4 mode...
Definition: Vectorization.h:197
#define BLAZE_AVX_MODE
Compilation switch for the AVX mode.This compilation switch enables/disables the AVX mode...
Definition: Vectorization.h:214
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the IntegralConstant class template.
System settings for the SSE mode.
Header file for the complex data type.
#define BLAZE_SSE2_MODE
Compilation switch for the SSE2 mode.This compilation switch enables/disables the SSE2 mode...
Definition: Vectorization.h:146