Enable fill_n and memset optimizations for construction and assignment

This commit is contained in:
Charles Schlosser
2024-12-14 14:25:04 +00:00
parent af59ada0ac
commit c01ff45312
7 changed files with 105 additions and 22 deletions

View File

@@ -19,7 +19,6 @@ namespace internal {
template <typename Scalar>
struct scalar_constant_op {
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_constant_op(const scalar_constant_op& other) : m_other(other.m_other) {}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_constant_op(const Scalar& other) : m_other(other) {}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()() const { return m_other; }
template <typename PacketType>
@@ -37,6 +36,18 @@ struct functor_traits<scalar_constant_op<Scalar> > {
};
};
template <typename Scalar>
struct scalar_zero_op {
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE scalar_zero_op() = default;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator()() const { return Scalar(0); }
template <typename PacketType>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const PacketType packetOp() const {
return internal::pzero<PacketType>(PacketType());
}
};
template <typename Scalar>
struct functor_traits<scalar_zero_op<Scalar>> : functor_traits<scalar_constant_op<Scalar>> {};
template <typename Scalar>
struct scalar_identity_op {
template <typename IndexType>