blender/build_files/build_environment/patches/eigen_tbb_support.diff
Thomas Dinges f7d920a89b Build: Library changes for Blender 5.1
This commit includes new minimum compiler requirements for Blender 5.1 as well as updated and new libraries.

**New compiler requirements**
* Windows x64: Visual Studio 2022 (17.14.14 or newer)
* Windows arm64: Visual Studio 2022 (17.14.23 or newer)
* Linux x64: gcc 14 (when used with our libraries)

**New libraries**
Abseil 20250814.1
ThorVG 1.0.0-pre31
OpenJPH 0.25.2

**Updated libraries**
AOM 3.13.1
Expat 2.7.2
FFI 3.5.2
HIPRT 606b4886efabce918dd0634ef71c06615a47c83b
Imath 3.2.2
ISPC 1.29.1
libheif 1.20.2
MaterialX 1.39.4
MESON 1.9.0
minizip-ng  4.0.10
Numpy 2.3.4
oneAPI Level Zero 1.21.9
OneTBB 2022.3.0
OpenColorIO 2.5.0
OpenEXR 3.4.3
OpenImageDenoise 2.4.1
OpenImageIO 3.1.7
OpenSubDiv 3.7.0
OpenVDB 13.0.0
OpenXR 1.1.53
PIP 25.2
Python 3.13.9
ShaderC 2025.4
Vulkan 1.4.328
webp 1.6.0
Yaml CPP 0.8.0
ZSTD 1.5.7 (z-standard 0.25.0)

**Library changes**
FMT (moved from /extern to libs)
Ceres (updated version in lib, will be removed from /extern in a later commit)
Eigen (updated version in lib, will be removed from /extern in a later commit))

Ref #147201

Co-authored-by: Nikita Sirgienko <nikita.sirgienko@intel.com>
Co-authored-by: Ray Molenkamp <github@lazydodo.com>
Co-authored-by: Sebastian Parborg <sebastian@blender.org>
Co-authored-by: Anthony Roberts <anthony.roberts@linaro.org>
Co-authored-by: Jonas Holzman <jonas@holzman.fr>
Co-authored-by: Bart van der Braak <bart@blender.org>

Pull Request: https://projects.blender.org/blender/blender/pulls/149852
2026-01-22 18:49:15 +01:00

70 lines
2.8 KiB
Diff

diff -Naur eigen.base/Eigen/src/SparseCore/SparseDenseProduct.h external_eigen/Eigen/src/SparseCore/SparseDenseProduct.h
--- eigen.base/Eigen/src/SparseCore/SparseDenseProduct.h 2026-01-12 11:46:25.135745600 -0800
+++ external_eigen/Eigen/src/SparseCore/SparseDenseProduct.h 2026-01-15 11:02:49.671711500 -0800
@@ -13,6 +13,10 @@
// IWYU pragma: private
#include "./InternalHeaderCheck.h"
+#ifdef EIGEN_HAS_TBB
+#include <tbb/parallel_for.h>
+#endif
+
namespace Eigen {
namespace internal {
@@ -49,6 +53,15 @@
#endif
for (Index c = 0; c < rhs.cols(); ++c) {
+#ifdef EIGEN_HAS_TBB
+ if(lhsEval.nonZerosEstimate() > 20000) {
+ tbb::parallel_for(tbb::blocked_range<Index>(0, n, 1024),
+ [&](const tbb::blocked_range<Index>& range) {
+ for(Index i=range.begin(); i<range.end(); ++i)
+ processRow(lhsEval,rhs,res,alpha,i,c);
+ });
+ } else
+#else
#ifdef EIGEN_HAS_OPENMP
// This 20000 threshold has been found experimentally on 2D and 3D Poisson problems.
// It basically represents the minimal amount of work to be done to be worth it.
@@ -57,6 +70,7 @@
for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i, c);
} else
#endif
+#endif
{
for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i, c);
}
@@ -123,14 +137,24 @@
Index n = lhs.rows();
LhsEval lhsEval(lhs);
-#ifdef EIGEN_HAS_OPENMP
- Index threads = Eigen::nbThreads();
- // This 20000 threshold has been found experimentally on 2D and 3D Poisson problems.
- // It basically represents the minimal amount of work to be done to be worth it.
- if (threads > 1 && lhsEval.nonZerosEstimate() * rhs.cols() > 20000) {
-#pragma omp parallel for schedule(dynamic, (n + threads * 4 - 1) / (threads * 4)) num_threads(threads)
- for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i);
+#ifdef EIGEN_HAS_TBB
+ if(lhsEval.nonZerosEstimate()*rhs.cols() > 20000) {
+ tbb::parallel_for(tbb::blocked_range<Index>(0, n, 1024),
+ [&](const tbb::blocked_range<Index>& range) {
+ for(Index i=range.begin(); i<range.end(); ++i)
+ processRow(lhsEval,rhs,res,alpha,i);
+ });
} else
+#else
+ #ifdef EIGEN_HAS_OPENMP
+ Index threads = Eigen::nbThreads();
+ // This 20000 threshold has been found experimentally on 2D and 3D Poisson problems.
+ // It basically represents the minimal amount of work to be done to be worth it.
+ if (threads > 1 && lhsEval.nonZerosEstimate() * rhs.cols() > 20000) {
+ #pragma omp parallel for schedule(dynamic, (n + threads * 4 - 1) / (threads * 4)) num_threads(threads)
+ for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i);
+ } else
+ #endif
#endif
{
for (Index i = 0; i < n; ++i) processRow(lhsEval, rhs, res, alpha, i);