Blaze 3.9
MAC.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_FUNCTORS_MAC_H_
36#define _BLAZE_MATH_FUNCTORS_MAC_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
60#include <blaze/system/Inline.h>
62
63
64namespace blaze {
65
66//=================================================================================================
67//
68// CLASS DEFINITION
69//
70//=================================================================================================
71
72//*************************************************************************************************
76struct MAC
77{
78 //**********************************************************************************************
86 template< typename T1, typename T2, typename T3 >
88 operator()( T1&& a, T2&& b, T3&& c ) const
89 {
90 return ( std::forward<T1>( a ) * std::forward<T2>( b ) ) + std::forward<T3>( c );
91 }
92 //**********************************************************************************************
93
94 //**********************************************************************************************
99 template< typename T1, typename T2, typename T3 >
100 static constexpr bool simdEnabled() { return HasSIMDMult_v<T1,T2> && HasSIMDAdd_v<T1,T3>; }
101 //**********************************************************************************************
102
103 //**********************************************************************************************
108 static constexpr bool paddingEnabled() { return true; }
109 //**********************************************************************************************
110
111 //**********************************************************************************************
119 template< typename T1, typename T2, typename T3 >
120 BLAZE_ALWAYS_INLINE decltype(auto) load( const T1& a, const T2& b, const T3& c ) const
121 {
125 return ( a * b ) + c;
126 }
127 //**********************************************************************************************
128};
129//*************************************************************************************************
130
131
132
133
134//=================================================================================================
135//
136// YIELDSUNIFORM SPECIALIZATIONS
137//
138//=================================================================================================
139
140//*************************************************************************************************
142template< typename T1, typename T2, typename T3 >
143struct YieldsUniform<MAC,T1,T2,T3>
144 : public BoolConstant< IsUniform_v<T1> && IsUniform_v<T2> && IsUniform_v<T3> >
145{};
147//*************************************************************************************************
148
149
150
151
152//=================================================================================================
153//
154// YIELDSLOWER SPECIALIZATIONS
155//
156//=================================================================================================
157
158//*************************************************************************************************
160template< typename MT1, typename MT2, typename MT3 >
161struct YieldsLower<MAC,MT1,MT2,MT3>
162 : public BoolConstant< IsLower_v<MT1> && IsLower_v<MT2> && IsLower_v<MT3> >
163{};
165//*************************************************************************************************
166
167
168
169
170//=================================================================================================
171//
172// YIELDSSTRICTLYLOWER SPECIALIZATIONS
173//
174//=================================================================================================
175
176//*************************************************************************************************
178template< typename MT1, typename MT2, typename MT3 >
179struct YieldsStrictlyLower<MAC,MT1,MT2,MT3>
180 : public BoolConstant< IsStrictlyLower_v<MT1> && IsStrictlyLower_v<MT2> && IsStrictlyLower_v<MT3> >
181{};
183//*************************************************************************************************
184
185
186
187
188//=================================================================================================
189//
190// YIELDSUPPER SPECIALIZATIONS
191//
192//=================================================================================================
193
194//*************************************************************************************************
196template< typename MT1, typename MT2, typename MT3 >
197struct YieldsUpper<MAC,MT1,MT2,MT3>
198 : public BoolConstant< IsUpper_v<MT1> && IsUpper_v<MT2> && IsUpper_v<MT3> >
199{};
201//*************************************************************************************************
202
203
204
205
206//=================================================================================================
207//
208// YIELDSSTRICTLYUPPER SPECIALIZATIONS
209//
210//=================================================================================================
211
212//*************************************************************************************************
214template< typename MT1, typename MT2, typename MT3 >
215struct YieldsStrictlyUpper<MAC,MT1,MT2,MT3>
216 : public BoolConstant< IsStrictlyUpper_v<MT1> && IsStrictlyUpper_v<MT2> && IsStrictlyUpper_v<MT3> >
217{};
219//*************************************************************************************************
220
221
222
223
224//=================================================================================================
225//
226// YIELDSZERO SPECIALIZATIONS
227//
228//=================================================================================================
229
230//*************************************************************************************************
232template< typename T1, typename T2, typename T3 >
233struct YieldsZero<MAC,T1,T2,T3>
234 : public BoolConstant< IsZero_v<T1> && IsZero_v<T2> && IsZero_v<T3> >
235{};
237//*************************************************************************************************
238
239} // namespace blaze
240
241#endif
Header file for the HasSIMDAdd type trait.
Header file for the HasSIMDMult type trait.
Macro for CUDA compatibility.
Header file for the IntegralConstant class template.
Header file for the IsLower type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsUniform type trait.
Header file for the IsUpper type trait.
Header file for the YieldsLower type trait.
Header file for the YieldsStrictlyLower type trait.
Header file for the YieldsStrictlyUpper type trait.
Header file for the YieldsUniform type trait.
Header file for the YieldsUpper type trait.
Header file for the YieldsZero type trait.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_SIMD_PACK(T)
Constraint on the data type.
Definition: SIMDPack.h:60
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.
Definition: IntegralConstant.h:110
Generic wrapper for the multiply-accumulate ( ; MAC) operation.
Definition: MAC.h:77
static constexpr bool paddingEnabled()
Returns whether the operation supports padding, i.e. whether it can deal with zeros.
Definition: MAC.h:108
BLAZE_ALWAYS_INLINE decltype(auto) load(const T1 &a, const T2 &b, const T3 &c) const
Returns the result of the MAC operation for the given SIMD vectors.
Definition: MAC.h:120
static constexpr bool simdEnabled()
Returns whether SIMD is enabled for the specified data types T1, T2, and T3.
Definition: MAC.h:100
System settings for the inline keywords.
Header file for the IsZero type trait.