All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Set.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INTRINSICS_SET_H_
36 #define _BLAZE_MATH_INTRINSICS_SET_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/system/Inline.h>
46 #include <blaze/util/Assert.h>
48 #include <blaze/util/EnableIf.h>
50 #include <blaze/util/Types.h>
51 
52 
53 namespace blaze {
54 
55 //=================================================================================================
56 //
57 // CLASS DEFINITION
58 //
59 //=================================================================================================
60 
61 //*************************************************************************************************
70 template< typename T // Type of the integral
71  , size_t N > // Size of the integral
72 struct Set;
74 //*************************************************************************************************
75 
76 
77 
78 
79 //=================================================================================================
80 //
81 // SPECIALIZATIONS OF THE SET CLASS TEMPLATE
82 //
83 //=================================================================================================
84 
85 //*************************************************************************************************
90 template< typename T > // Type of the integral
91 struct Set<T,2UL>
92 {
93  public:
94  //**Type definitions****************************************************************************
95  typedef sse_int16_t Type;
96  //**********************************************************************************************
97 
98  //**Set function********************************************************************************
99  static BLAZE_ALWAYS_INLINE Type set( T value )
100  {
101 #if BLAZE_AVX2_MODE
102  return _mm256_set1_epi16( value );
103 #elif BLAZE_SSE2_MODE
104  return _mm_set1_epi16( value );
105 #else
106  return value;
107 #endif
108  }
109  //**********************************************************************************************
110 
111  private:
112  //**Compile time checks*************************************************************************
114  //**********************************************************************************************
115 };
117 //*************************************************************************************************
118 
119 
120 //*************************************************************************************************
125 template< typename T > // Type of the integral
126 struct Set<T,4UL>
127 {
128  public:
129  //**Type definitions****************************************************************************
130  typedef sse_int32_t Type;
131  //**********************************************************************************************
132 
133  //**Set function********************************************************************************
134  static BLAZE_ALWAYS_INLINE Type set( T value )
135  {
136 #if BLAZE_MIC_MODE
137  return _mm512_set1_epi32( value );
138 #elif BLAZE_AVX2_MODE
139  return _mm256_set1_epi32( value );
140 #elif BLAZE_SSE2_MODE
141  return _mm_set1_epi32( value );
142 #else
143  return value;
144 #endif
145  }
146  //**********************************************************************************************
147 
148  private:
149  //**Compile time checks*************************************************************************
151  //**********************************************************************************************
152 };
154 //*************************************************************************************************
155 
156 
157 //*************************************************************************************************
162 template< typename T > // Type of the integral
163 struct Set<T,8UL>
164 {
165  public:
166  //**Type definitions****************************************************************************
167  typedef sse_int64_t Type;
168  //**********************************************************************************************
169 
170  //**Set function********************************************************************************
171  static BLAZE_ALWAYS_INLINE Type set( T value )
172  {
173 #if BLAZE_MIC_MODE
174  return _mm512_set1_epi64( value );
175 #elif BLAZE_AVX2_MODE
176  return _mm256_set1_epi64x( value );
177 #elif BLAZE_SSE2_MODE
178  return _mm_set1_epi64( value );
179 #else
180  return value;
181 #endif
182  }
183  //**********************************************************************************************
184 
185  private:
186  //**Compile time checks*************************************************************************
188  //**********************************************************************************************
189 };
191 //*************************************************************************************************
192 
193 
194 
195 
196 //=================================================================================================
197 //
198 // INTRINSIC SET FUNCTIONS
199 //
200 //=================================================================================================
201 
202 //*************************************************************************************************
209 template< typename T > // Type of the integral value
210 BLAZE_ALWAYS_INLINE typename EnableIf< IsIntegral<T>, Set<T,sizeof(T)> >::Type::Type
211  set( T value )
212 {
213  return Set<T,sizeof(T)>::set( value );
214 }
215 //*************************************************************************************************
216 
217 
218 //*************************************************************************************************
226 {
227 #if BLAZE_MIC_MODE
228  return _mm512_set1_ps( value );
229 #elif BLAZE_AVX_MODE
230  return _mm256_set1_ps( value );
231 #elif BLAZE_SSE_MODE
232  return _mm_set1_ps( value );
233 #else
234  return value;
235 #endif
236 }
237 //*************************************************************************************************
238 
239 
240 //*************************************************************************************************
248 {
249 #if BLAZE_MIC_MODE
250  return _mm512_set1_pd( value );
251 #elif BLAZE_AVX_MODE
252  return _mm256_set1_pd( value );
253 #elif BLAZE_SSE2_MODE
254  return _mm_set1_pd( value );
255 #else
256  return value;
257 #endif
258 }
259 //*************************************************************************************************
260 
261 
262 //*************************************************************************************************
269 BLAZE_ALWAYS_INLINE sse_cfloat_t set( const complex<float>& value )
270 {
271 #if BLAZE_MIC_MODE
272  return _mm512_set_ps( value.imag(), value.real(), value.imag(), value.real(),
273  value.imag(), value.real(), value.imag(), value.real(),
274  value.imag(), value.real(), value.imag(), value.real(),
275  value.imag(), value.real(), value.imag(), value.real() );
276 #elif BLAZE_AVX_MODE
277  return _mm256_set_ps( value.imag(), value.real(), value.imag(), value.real(),
278  value.imag(), value.real(), value.imag(), value.real() );
279 #elif BLAZE_SSE_MODE
280  return _mm_set_ps( value.imag(), value.real(), value.imag(), value.real() );
281 #else
282  return value;
283 #endif
284  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
285 }
286 //*************************************************************************************************
287 
288 
289 //*************************************************************************************************
296 BLAZE_ALWAYS_INLINE sse_cdouble_t set( const complex<double>& value )
297 {
298 #if BLAZE_MIC_MODE
299  return _mm512_set_pd( value.imag(), value.real(), value.imag(), value.real(),
300  value.imag(), value.real(), value.imag(), value.real() );
301 #elif BLAZE_AVX_MODE
302  return _mm256_set_pd( value.imag(), value.real(), value.imag(), value.real() );
303 #elif BLAZE_SSE2_MODE
304  return _mm_set_pd( value.imag(), value.real() );
305 #else
306  return value;
307 #endif
308  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
309 }
310 //*************************************************************************************************
311 
312 } // namespace blaze
313 
314 #endif
Intrinsic type for 32-bit single precision complex values.
BLAZE_ALWAYS_INLINE sse_cdouble_t set(const complex< double > &value)
Sets all values in the vector to the given 'complex' value.
Definition: Set.h:296
#define BLAZE_CONSTRAINT_MUST_BE_INTEGRAL_TYPE(T)
Constraint on the data type.In case the given data type T is not an integral data type...
Definition: Integral.h:78
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Compile time assertion.
Intrinsic type for 32-bit single precision floating point data values.
Intrinsic type for 64-bit double precision complex values.
Constraint on the data type.
Header file for the EnableIf class template.
Intrinsic type for 64-bit double precision floating point data values.
Header file for the basic intrinsic types.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:211
Header file for run time assertion macros.
Header file for basic type definitions.
System settings for the SSE mode.
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
System settings for the inline keywords.