Add EIGEN_RISCV64_DEFAULT_LMUL to control the default LMul for vectors.

This commit is contained in:
Chip Kerchner 2025-07-16 15:22:38 +00:00
parent 2489bc0d55
commit 322e087690
6 changed files with 14 additions and 7 deletions

View File

@ -65,8 +65,8 @@ struct copy_using_evaluator_traits {
// 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;

View File

@ -1370,7 +1370,7 @@ struct evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>>
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

View File

@ -534,8 +534,8 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape,
};
#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;

View File

@ -30,7 +30,7 @@ template <typename Func, typename Evaluator>
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

View File

@ -534,6 +534,13 @@ extern "C" {
#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"

View File

@ -108,7 +108,7 @@ struct vectorization_logic {
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