All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Set.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_INTRINSICS_SET_H_
23 #define _BLAZE_MATH_INTRINSICS_SET_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
32 #include <blaze/util/Assert.h>
34 #include <blaze/util/EnableIf.h>
35 
36 
37 namespace blaze {
38 
39 //=================================================================================================
40 //
41 // CLASS DEFINITION
42 //
43 //=================================================================================================
44 
45 //*************************************************************************************************
54 template< typename T // Type of the integral
55  , size_t N > // Size of the integral
56 struct Set;
58 //*************************************************************************************************
59 
60 
61 
62 
63 //=================================================================================================
64 //
65 // SPECIALIZATIONS OF THE SET CLASS TEMPLATE
66 //
67 //=================================================================================================
68 
69 //*************************************************************************************************
74 template< typename T > // Type of the integral
75 struct Set<T,2UL>
76 {
77  public:
78  //**Type definitions****************************************************************************
79  typedef sse_int16_t Type;
80  //**********************************************************************************************
81 
82  //**Set function********************************************************************************
83  static inline Type set( T value )
84  {
85 #if BLAZE_SSE2_MODE
86  return _mm_set1_epi16( value );
87 #else
88  return value;
89 #endif
90  }
91  //**********************************************************************************************
92 
93  private:
94  //**Compile time checks*************************************************************************
96  //**********************************************************************************************
97 };
99 //*************************************************************************************************
100 
101 
102 //*************************************************************************************************
107 template< typename T > // Type of the integral
108 struct Set<T,4UL>
109 {
110  public:
111  //**Type definitions****************************************************************************
112  typedef sse_int32_t Type;
113  //**********************************************************************************************
114 
115  //**Set function********************************************************************************
116  static inline Type set( T value )
117  {
118 #if BLAZE_MIC_MODE
119  return _mm512_set1_epi32( value );
120 #elif BLAZE_SSE2_MODE
121  return _mm_set1_epi32( value );
122 #else
123  return value;
124 #endif
125  }
126  //**********************************************************************************************
127 
128  private:
129  //**Compile time checks*************************************************************************
131  //**********************************************************************************************
132 };
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
142 template< typename T > // Type of the integral
143 struct Set<T,8UL>
144 {
145  public:
146  //**Type definitions****************************************************************************
147  typedef sse_int64_t Type;
148  //**********************************************************************************************
149 
150  //**Set function********************************************************************************
151  static inline Type set( T value )
152  {
153 #if BLAZE_MIC_MODE
154  return _mm512_set1_epi64( value );
155 #elif BLAZE_SSE2_MODE
156  return _mm_set1_epi64( value );
157 #else
158  return value;
159 #endif
160  }
161  //**********************************************************************************************
162 
163  private:
164  //**Compile time checks*************************************************************************
166  //**********************************************************************************************
167 };
169 //*************************************************************************************************
170 
171 
172 
173 
174 //=================================================================================================
175 //
176 // INTRINSIC SET FUNCTIONS
177 //
178 //=================================================================================================
179 
180 //*************************************************************************************************
187 template< typename T > // Type of the integral value
188 inline typename EnableIf< IsIntegral<T>, Set<T,sizeof(T)> >::Type::Type
189  set( T value )
190 {
191  return Set<T,sizeof(T)>::set( value );
192 }
193 //*************************************************************************************************
194 
195 
196 //*************************************************************************************************
203 inline sse_float_t set( float value )
204 {
205 #if BLAZE_MIC_MODE
206  return _mm512_set1_ps( value );
207 #elif BLAZE_AVX_MODE
208  return _mm256_set1_ps( value );
209 #elif BLAZE_SSE_MODE
210  return _mm_set1_ps( value );
211 #else
212  return value;
213 #endif
214 }
215 //*************************************************************************************************
216 
217 
218 //*************************************************************************************************
225 inline sse_double_t set( double value )
226 {
227 #if BLAZE_MIC_MODE
228  return _mm512_set1_pd( value );
229 #elif BLAZE_AVX_MODE
230  return _mm256_set1_pd( value );
231 #elif BLAZE_SSE2_MODE
232  return _mm_set1_pd( value );
233 #else
234  return value;
235 #endif
236 }
237 //*************************************************************************************************
238 
239 } // namespace blaze
240 
241 #endif