Add EIGEN_RISCV64_DEFAULT_LMUL to control the default LMul for vectors.
diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h
index 093ceb4..4673475 100644
--- a/Eigen/src/Core/AssignEvaluator.h
+++ b/Eigen/src/Core/AssignEvaluator.h
@@ -65,8 +65,8 @@
// TODO distinguish between linear traversal and inner-traversals
#ifdef EIGEN_RISCV64_USE_RVV10
- using LinearPacketType = typename find_best_packet<DstScalar, RestrictedLinearSize, 4>::type;
- using InnerPacketType = typename find_best_packet<DstScalar, RestrictedInnerSize, 4>::type;
+ using LinearPacketType = typename find_best_packet<DstScalar, RestrictedLinearSize, EIGEN_RISCV64_DEFAULT_LMUL>::type;
+ using InnerPacketType = typename find_best_packet<DstScalar, RestrictedInnerSize, EIGEN_RISCV64_DEFAULT_LMUL>::type;
#else
using LinearPacketType = typename find_best_packet<DstScalar, RestrictedLinearSize>::type;
using InnerPacketType = typename find_best_packet<DstScalar, RestrictedInnerSize>::type;
diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h
index 87df2b3..162175e 100644
--- a/Eigen/src/Core/CoreEvaluators.h
+++ b/Eigen/src/Core/CoreEvaluators.h
@@ -1370,7 +1370,7 @@
typedef typename XprType::Scalar Scalar;
// TODO: should check for smaller packet types once we can handle multi-sized packet types
#ifdef EIGEN_RISCV64_USE_RVV10
- typedef typename packet_traits<Scalar, 4>::type PacketScalar;
+ typedef typename packet_traits<Scalar, EIGEN_RISCV64_DEFAULT_LMUL>::type PacketScalar;
#else
typedef typename packet_traits<Scalar>::type PacketScalar;
#endif
diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h
index 8da7e03..1051e77 100644
--- a/Eigen/src/Core/ProductEvaluators.h
+++ b/Eigen/src/Core/ProductEvaluators.h
@@ -534,8 +534,8 @@
};
#ifdef EIGEN_RISCV64_USE_RVV10
- typedef typename find_best_packet<Scalar, RowsAtCompileTime, 4>::type LhsVecPacketType;
- typedef typename find_best_packet<Scalar, ColsAtCompileTime, 4>::type RhsVecPacketType;
+ typedef typename find_best_packet<Scalar, RowsAtCompileTime, EIGEN_RISCV64_DEFAULT_LMUL>::type LhsVecPacketType;
+ typedef typename find_best_packet<Scalar, ColsAtCompileTime, EIGEN_RISCV64_DEFAULT_LMUL>::type RhsVecPacketType;
#else
typedef typename find_best_packet<Scalar, RowsAtCompileTime>::type LhsVecPacketType;
typedef typename find_best_packet<Scalar, ColsAtCompileTime>::type RhsVecPacketType;
diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h
index 716a7c0..b4a3d8f 100644
--- a/Eigen/src/Core/Redux.h
+++ b/Eigen/src/Core/Redux.h
@@ -30,7 +30,7 @@
struct redux_traits {
public:
#ifdef EIGEN_RISCV64_USE_RVV10
- typedef typename find_best_packet<typename Evaluator::Scalar, Evaluator::SizeAtCompileTime, 4>::type PacketType;
+ typedef typename find_best_packet<typename Evaluator::Scalar, Evaluator::SizeAtCompileTime, EIGEN_RISCV64_DEFAULT_LMUL>::type PacketType;
#else
typedef typename find_best_packet<typename Evaluator::Scalar, Evaluator::SizeAtCompileTime>::type PacketType;
#endif
diff --git a/Eigen/src/Core/util/ConfigureVectorization.h b/Eigen/src/Core/util/ConfigureVectorization.h
index 5be3e80..b8e63e4 100644
--- a/Eigen/src/Core/util/ConfigureVectorization.h
+++ b/Eigen/src/Core/util/ConfigureVectorization.h
@@ -534,6 +534,13 @@
#include <hip/hip_bfloat16.h>
#endif
+#if defined(__riscv)
+// Defines the default LMUL for RISC-V
+#ifndef EIGEN_RISCV64_DEFAULT_LMUL
+#define EIGEN_RISCV64_DEFAULT_LMUL 4
+#endif
+#endif
+
/** \brief Namespace containing all symbols from the %Eigen library. */
// IWYU pragma: private
#include "../InternalHeaderCheck.h"
diff --git a/test/vectorization_logic.cpp b/test/vectorization_logic.cpp
index 02d46ce..7f34681 100644
--- a/test/vectorization_logic.cpp
+++ b/test/vectorization_logic.cpp
@@ -108,7 +108,7 @@
typedef internal::packet_traits<Scalar> PacketTraits;
#ifdef EIGEN_RISCV64_USE_RVV10
- typedef typename internal::packet_traits<Scalar, 4>::type PacketType;
+ typedef typename internal::packet_traits<Scalar, EIGEN_RISCV64_DEFAULT_LMUL>::type PacketType;
#else
typedef typename internal::packet_traits<Scalar>::type PacketType;
#endif