From a962a27594eae6c6fb0bf93dd82fd5352f8db3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=C3=A1nchez?= Date: Tue, 27 Feb 2024 23:26:06 +0000 Subject: [PATCH] Fix MSVC GPU build. --- Eigen/src/Core/MathFunctions.h | 4 ++++ Eigen/src/SVD/JacobiSVD.h | 27 ++++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 1bb57bbc4..bb553e778 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -847,6 +847,9 @@ struct random_longdouble_impl { return result; } }; + +// GPUs treat long double as double. +#ifndef EIGEN_GPU_COMPILE_PHASE template <> struct random_longdouble_impl { using Impl = random_impl; @@ -863,6 +866,7 @@ struct random_impl { } static EIGEN_DEVICE_FUNC inline long double run() { return random_longdouble_impl<>::run(); } }; +#endif template struct random_default_impl { diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index ebb97344e..086d750a3 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -612,7 +612,18 @@ class JacobiSVD : public SVDBase > { using Base::rows; private: - void allocate(Index rows, Index cols, unsigned int computationOptions); + void allocate(Index rows_, Index cols_, unsigned int computationOptions) { + if (Base::allocate(rows_, cols_, computationOptions)) return; + eigen_assert(!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) && + !(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) && + "JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. " + "Use the ColPivHouseholderQR preconditioner instead."); + + m_workMatrix.resize(diagSize(), diagSize()); + if (cols() > rows()) m_qr_precond_morecols.allocate(*this); + if (rows() > cols()) m_qr_precond_morerows.allocate(*this); + } + JacobiSVD& compute_impl(const MatrixType& matrix, unsigned int computationOptions); protected: @@ -650,20 +661,6 @@ class JacobiSVD : public SVDBase > { WorkMatrixType m_workMatrix; }; -template -void JacobiSVD::allocate(Index rows_, Index cols_, unsigned int computationOptions_) { - if (Base::allocate(rows_, cols_, computationOptions_)) return; - - eigen_assert(!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) && - !(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) && - "JacobiSVD: can't compute thin U or thin V with the FullPivHouseholderQR preconditioner. " - "Use the ColPivHouseholderQR preconditioner instead."); - - m_workMatrix.resize(diagSize(), diagSize()); - if (cols() > rows()) m_qr_precond_morecols.allocate(*this); - if (rows() > cols()) m_qr_precond_morerows.allocate(*this); -} - template JacobiSVD& JacobiSVD::compute_impl(const MatrixType& matrix, unsigned int computationOptions) {