Blaze
3.9
Toggle main menu visibility
Loading...
Searching...
No Matches
blaze
math
simd
Reduce.h
Go to the documentation of this file.
1
//=================================================================================================
33
//=================================================================================================
34
35
#ifndef _BLAZE_MATH_SIMD_REDUCE_H_
36
#define _BLAZE_MATH_SIMD_REDUCE_H_
37
38
39
//*************************************************************************************************
40
// Includes
41
//*************************************************************************************************
42
43
#include <
blaze/math/functors/Forward.h
>
44
#include <
blaze/math/simd/Prod.h
>
45
#include <
blaze/math/simd/SIMDPack.h
>
46
#include <
blaze/math/simd/Sum.h
>
47
#include <
blaze/math/simd/Storea.h
>
48
#include <
blaze/util/typetraits/AlignmentOf.h
>
49
50
51
namespace
blaze {
52
53
//=================================================================================================
54
//
55
// SIMD REDUCTION
56
//
57
//=================================================================================================
58
59
//*************************************************************************************************
67
template
<
typename
T,
typename
OP >
68
inline
decltype
(
auto
)
reduce
(
const
SIMDPack<T>
& a, OP op )
69
{
70
using
ValueType =
typename
T::ValueType;
71
72
alignas
(
AlignmentOf_v<ValueType>
) ValueType array[T::size];
73
storea
( array, *a );
74
75
ValueType redux( array[0UL] );
76
for
(
size_t
k=1UL; k<T::size; ++k ) {
77
redux = op( redux, array[k] );
78
}
79
80
return
redux;
81
}
82
//*************************************************************************************************
83
84
85
//*************************************************************************************************
93
template
<
typename
T >
94
inline
decltype
(
auto
)
reduce
(
const
SIMDPack<T>& a,
const
Add&
/*op*/
)
95
{
96
return
sum
( *a );
97
}
99
//*************************************************************************************************
100
101
102
//*************************************************************************************************
110
template
<
typename
T >
111
inline
decltype
(
auto
)
reduce
(
const
SIMDPack<T>
& a,
const
Mult
&
/*op*/
)
112
{
113
return
prod
( *a );
114
}
116
//*************************************************************************************************
117
118
}
// namespace blaze
119
120
#endif
AlignmentOf.h
Header file for the AlignmentOf type trait.
Prod.h
Header file for the SIMD multiplication reduction functionality.
Storea.h
Header file for the SIMD aligned store functionality.
Sum.h
Header file for the SIMD addition reduction functionality.
blaze::SIMDPack
Base class for all SIMD data types.
Definition
SIMDPack.h:64
blaze::prod
decltype(auto) prod(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of multiplication.
Definition
DMatReduceExpr.h:2229
blaze::reduce
decltype(auto) reduce(const DenseMatrix< MT, SO > &dm, OP op)
Performs a custom reduction operation on the given dense matrix.
Definition
DMatReduceExpr.h:2025
blaze::sum
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition
DMatReduceExpr.h:2156
blaze::storea
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition
Storea.h:78
blaze::AlignmentOf_v
constexpr size_t AlignmentOf_v
Auxiliary variable template for the AlignmentOf type trait.
Definition
AlignmentOf.h:239
Forward.h
Header file for all functor forward declarations.
SIMDPack.h
Header file for the SIMDPack base class.
blaze::Mult
Generic wrapper for the multiplication operator.
Definition
Mult.h:82
Generated by
1.18.0