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 
45 #include <blaze/util/Assert.h>
47 #include <blaze/util/EnableIf.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // CLASS DEFINITION
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
68 template< typename T // Type of the integral
69  , size_t N > // Size of the integral
70 struct Set;
72 //*************************************************************************************************
73 
74 
75 
76 
77 //=================================================================================================
78 //
79 // SPECIALIZATIONS OF THE SET CLASS TEMPLATE
80 //
81 //=================================================================================================
82 
83 //*************************************************************************************************
88 template< typename T > // Type of the integral
89 struct Set<T,2UL>
90 {
91  public:
92  //**Type definitions****************************************************************************
93  typedef sse_int16_t Type;
94  //**********************************************************************************************
95 
96  //**Set function********************************************************************************
97  static inline Type set( T value )
98  {
99 #if BLAZE_AVX2_MODE
100  return _mm256_set1_epi16( value );
101 #elif BLAZE_SSE2_MODE
102  return _mm_set1_epi16( value );
103 #else
104  return value;
105 #endif
106  }
107  //**********************************************************************************************
108 
109  private:
110  //**Compile time checks*************************************************************************
112  //**********************************************************************************************
113 };
115 //*************************************************************************************************
116 
117 
118 //*************************************************************************************************
123 template< typename T > // Type of the integral
124 struct Set<T,4UL>
125 {
126  public:
127  //**Type definitions****************************************************************************
128  typedef sse_int32_t Type;
129  //**********************************************************************************************
130 
131  //**Set function********************************************************************************
132  static inline Type set( T value )
133  {
134 #if BLAZE_MIC_MODE
135  return _mm512_set1_epi32( value );
136 #elif BLAZE_AVX2_MODE
137  return _mm256_set1_epi32( value );
138 #elif BLAZE_SSE2_MODE
139  return _mm_set1_epi32( value );
140 #else
141  return value;
142 #endif
143  }
144  //**********************************************************************************************
145 
146  private:
147  //**Compile time checks*************************************************************************
149  //**********************************************************************************************
150 };
152 //*************************************************************************************************
153 
154 
155 //*************************************************************************************************
160 template< typename T > // Type of the integral
161 struct Set<T,8UL>
162 {
163  public:
164  //**Type definitions****************************************************************************
165  typedef sse_int64_t Type;
166  //**********************************************************************************************
167 
168  //**Set function********************************************************************************
169  static inline Type set( T value )
170  {
171 #if BLAZE_MIC_MODE
172  return _mm512_set1_epi64( value );
173 #elif BLAZE_AVX2_MODE
174  return _mm256_set1_epi64x( value );
175 #elif BLAZE_SSE2_MODE
176  return _mm_set1_epi64( value );
177 #else
178  return value;
179 #endif
180  }
181  //**********************************************************************************************
182 
183  private:
184  //**Compile time checks*************************************************************************
186  //**********************************************************************************************
187 };
189 //*************************************************************************************************
190 
191 
192 
193 
194 //=================================================================================================
195 //
196 // INTRINSIC SET FUNCTIONS
197 //
198 //=================================================================================================
199 
200 //*************************************************************************************************
207 template< typename T > // Type of the integral value
208 inline typename EnableIf< IsIntegral<T>, Set<T,sizeof(T)> >::Type::Type
209  set( T value )
210 {
211  return Set<T,sizeof(T)>::set( value );
212 }
213 //*************************************************************************************************
214 
215 
216 //*************************************************************************************************
223 inline sse_float_t set( float value )
224 {
225 #if BLAZE_MIC_MODE
226  return _mm512_set1_ps( value );
227 #elif BLAZE_AVX_MODE
228  return _mm256_set1_ps( value );
229 #elif BLAZE_SSE_MODE
230  return _mm_set1_ps( value );
231 #else
232  return value;
233 #endif
234 }
235 //*************************************************************************************************
236 
237 
238 //*************************************************************************************************
245 inline sse_double_t set( double value )
246 {
247 #if BLAZE_MIC_MODE
248  return _mm512_set1_pd( value );
249 #elif BLAZE_AVX_MODE
250  return _mm256_set1_pd( value );
251 #elif BLAZE_SSE2_MODE
252  return _mm_set1_pd( value );
253 #else
254  return value;
255 #endif
256 }
257 //*************************************************************************************************
258 
259 
260 //*************************************************************************************************
267 inline sse_cfloat_t set( const complex<float>& value )
268 {
269 #if BLAZE_MIC_MODE
270  return _mm512_set_ps( value.imag(), value.real(), value.imag(), value.real(),
271  value.imag(), value.real(), value.imag(), value.real(),
272  value.imag(), value.real(), value.imag(), value.real(),
273  value.imag(), value.real(), value.imag(), value.real() );
274 #elif BLAZE_AVX_MODE
275  return _mm256_set_ps( value.imag(), value.real(), value.imag(), value.real(),
276  value.imag(), value.real(), value.imag(), value.real() );
277 #elif BLAZE_SSE_MODE
278  return _mm_set_ps( value.imag(), value.real(), value.imag(), value.real() );
279 #else
280  return value;
281 #endif
282  BLAZE_STATIC_ASSERT( sizeof( complex<float> ) == 2UL*sizeof( float ) );
283 }
284 //*************************************************************************************************
285 
286 
287 //*************************************************************************************************
294 inline sse_cdouble_t set( const complex<double>& value )
295 {
296 #if BLAZE_MIC_MODE
297  return _mm512_set_pd( value.imag(), value.real(), value.imag(), value.real(),
298  value.imag(), value.real(), value.imag(), value.real() );
299 #elif BLAZE_AVX_MODE
300  return _mm256_set_pd( value.imag(), value.real(), value.imag(), value.real() );
301 #elif BLAZE_SSE2_MODE
302  return _mm_set_pd( value.imag(), value.real() );
303 #else
304  return value;
305 #endif
306  BLAZE_STATIC_ASSERT( sizeof( complex<double> ) == 2UL*sizeof( double ) );
307 }
308 //*************************************************************************************************
309 
310 } // namespace blaze
311 
312 #endif
Intrinsic type for 32-bit single precision complex values.
sse_cdouble_t set(const complex< double > &value)
Sets all values in the vector to the given 'complex' value.
Definition: Set.h:294
#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
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.
Header file for run time assertion macros.
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
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:209