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>
46 #include <blaze/util/FalseType.h>
51 
52 
53 namespace blaze {
54 
55 //=================================================================================================
56 //
57 // CLASS DEFINITION
58 //
59 //=================================================================================================
60 
61 //*************************************************************************************************
66 template< typename T1 // Type of the left-hand side operand
67  , typename T2 // Type of the right-hand side operand
68  , typename = void > // Restricting condition
69 struct HasSIMDMultHelper
70  : public FalseType
71 {};
73 //*************************************************************************************************
74 
75 
76 //*************************************************************************************************
78 template< typename T1, typename T2 >
79 struct HasSIMDMultHelper< T1, T2, EnableIf_t< IsNumeric_v<T1> && IsIntegral_v<T1> &&
80  IsNumeric_v<T2> && IsIntegral_v<T2> &&
81  sizeof(T1) == sizeof(T2) > >
82  : public BoolConstant< ( bool( BLAZE_SSE2_MODE ) && sizeof(T1) == 2UL ) ||
83  ( bool( BLAZE_SSE4_MODE ) && sizeof(T1) >= 2UL && sizeof(T1) <= 4UL ) ||
84  ( bool( BLAZE_AVX2_MODE ) && sizeof(T1) >= 2UL && sizeof(T1) <= 4UL ) ||
85  ( bool( BLAZE_MIC_MODE ) && sizeof(T1) == 4UL ) ||
86  ( bool( BLAZE_AVX512BW_MODE ) && sizeof(T1) == 2UL ) ||
87  ( bool( BLAZE_AVX512F_MODE ) && sizeof(T1) == 4UL ) ||
88  ( bool( BLAZE_AVX512DQ_MODE ) && sizeof(T1) == 8UL ) >
89 {};
90 
91 template< typename T >
92 struct HasSIMDMultHelper< complex<T>, complex<T>, EnableIf_t< IsNumeric_v<T> && IsIntegral_v<T> > >
93  : public BoolConstant< ( bool( BLAZE_SSE2_MODE ) && sizeof(T) == 2UL ) ||
94  ( bool( BLAZE_SSE4_MODE ) && sizeof(T) >= 2UL && sizeof(T) <= 4UL ) ||
95  ( bool( BLAZE_AVX2_MODE ) && sizeof(T) >= 2UL && sizeof(T) <= 4UL ) ||
96  ( bool( BLAZE_AVX512BW_MODE ) && sizeof(T) == 2UL ) ||
97  ( bool( BLAZE_AVX512F_MODE ) && sizeof(T) == 4UL ) ||
98  ( bool( BLAZE_AVX512DQ_MODE ) && sizeof(T) == 8UL ) >
99 {};
101 //*************************************************************************************************
102 
103 
104 //*************************************************************************************************
106 template<>
107 struct HasSIMDMultHelper< float, float >
108  : public BoolConstant< bool( BLAZE_SSE_MODE ) ||
109  bool( BLAZE_AVX_MODE ) ||
110  bool( BLAZE_MIC_MODE ) ||
111  bool( BLAZE_AVX512F_MODE ) >
112 {};
113 
114 template<>
115 struct HasSIMDMultHelper< complex<float>, complex<float> >
116  : public BoolConstant< ( bool( BLAZE_SSE3_MODE ) && !bool( BLAZE_MIC_MODE ) ) ||
117  ( bool( BLAZE_AVX_MODE ) && !bool( BLAZE_MIC_MODE ) ) ||
118  ( bool( BLAZE_AVX512F_MODE ) && !bool( BLAZE_MIC_MODE ) ) >
119 {};
121 //*************************************************************************************************
122 
123 
124 //*************************************************************************************************
126 template<>
127 struct HasSIMDMultHelper< double, double >
128  : public BoolConstant< bool( BLAZE_SSE2_MODE ) ||
129  bool( BLAZE_AVX_MODE ) ||
130  bool( BLAZE_MIC_MODE ) ||
131  bool( BLAZE_AVX512F_MODE ) >
132 {};
133 
134 template<>
135 struct HasSIMDMultHelper< complex<double>, complex<double> >
136  : public BoolConstant< ( bool( BLAZE_SSE3_MODE ) && !bool( BLAZE_MIC_MODE ) ) ||
137  ( bool( BLAZE_AVX_MODE ) && !bool( BLAZE_MIC_MODE ) ) ||
138  ( bool( BLAZE_AVX512F_MODE ) && !bool( BLAZE_MIC_MODE ) ) >
139 {};
141 //*************************************************************************************************
142 
143 
144 //*************************************************************************************************
165 template< typename T1 // Type of the left-hand side operand
166  , typename T2 // Type of the right-hand side operand
167  , typename = void > // Restricting condition
169  : public BoolConstant< HasSIMDMultHelper< Decay_t<T1>, Decay_t<T2> >::value >
170 {};
171 //*************************************************************************************************
172 
173 
174 //*************************************************************************************************
187 template< typename T1 // Type of the left-hand side operand
188  , typename T2 > // Type of the right-hand side operand
190 //*************************************************************************************************
191 
192 } // namespace blaze
193 
194 #endif
BoolConstant< false > FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
Header file for the FalseType type/value trait base class.
#define BLAZE_AVX512F_MODE
Compilation switch for the AVX512F mode.This compilation switch enables/disables the AVX512F mode...
Definition: Vectorization.h:246
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:299
Availability of a SIMD multiplication for the given data types.Depending on the available instruction...
Definition: HasSIMDMult.h:168
#define BLAZE_AVX512BW_MODE
Compilation switch for the AVX512BW mode.This compilation switch enables/disables the AVX512BW mode...
Definition: Vectorization.h:264
Header file for the IsIntegral type trait.
#define BLAZE_AVX2_MODE
Compilation switch for the AVX2 mode.This compilation switch enables/disables the AVX2 mode...
Definition: Vectorization.h:228
#define BLAZE_AVX512DQ_MODE
Compilation switch for the AVX512DQ mode.This compilation switch enables/disables the AVX512DQ mode...
Definition: Vectorization.h:282
Header file for the Decay type trait.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
constexpr bool HasSIMDMult_v
Auxiliary variable template for the HasSIMDMult type trait.The HasSIMDMult_v variable template provid...
Definition: HasSIMDMult.h:189
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
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:194
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:101
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:143