@smake/eigen 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/eigen/Eigen/AccelerateSupport +52 -0
- package/eigen/Eigen/Cholesky +18 -21
- package/eigen/Eigen/CholmodSupport +28 -28
- package/eigen/Eigen/Core +235 -326
- package/eigen/Eigen/Eigenvalues +16 -14
- package/eigen/Eigen/Geometry +21 -24
- package/eigen/Eigen/Householder +9 -8
- package/eigen/Eigen/IterativeLinearSolvers +8 -4
- package/eigen/Eigen/Jacobi +14 -14
- package/eigen/Eigen/KLUSupport +43 -0
- package/eigen/Eigen/LU +16 -20
- package/eigen/Eigen/MetisSupport +12 -12
- package/eigen/Eigen/OrderingMethods +54 -54
- package/eigen/Eigen/PaStiXSupport +23 -20
- package/eigen/Eigen/PardisoSupport +17 -14
- package/eigen/Eigen/QR +18 -21
- package/eigen/Eigen/QtAlignedMalloc +5 -13
- package/eigen/Eigen/SPQRSupport +21 -14
- package/eigen/Eigen/SVD +23 -18
- package/eigen/Eigen/Sparse +1 -4
- package/eigen/Eigen/SparseCholesky +18 -23
- package/eigen/Eigen/SparseCore +18 -17
- package/eigen/Eigen/SparseLU +12 -8
- package/eigen/Eigen/SparseQR +16 -14
- package/eigen/Eigen/StdDeque +5 -2
- package/eigen/Eigen/StdList +5 -2
- package/eigen/Eigen/StdVector +5 -2
- package/eigen/Eigen/SuperLUSupport +30 -24
- package/eigen/Eigen/ThreadPool +80 -0
- package/eigen/Eigen/UmfPackSupport +19 -17
- package/eigen/Eigen/Version +14 -0
- package/eigen/Eigen/src/AccelerateSupport/AccelerateSupport.h +423 -0
- package/eigen/Eigen/src/AccelerateSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Cholesky/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Cholesky/LDLT.h +377 -401
- package/eigen/Eigen/src/Cholesky/LLT.h +332 -360
- package/eigen/Eigen/src/Cholesky/LLT_LAPACKE.h +81 -56
- package/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +620 -521
- package/eigen/Eigen/src/CholmodSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Core/ArithmeticSequence.h +239 -0
- package/eigen/Eigen/src/Core/Array.h +341 -294
- package/eigen/Eigen/src/Core/ArrayBase.h +190 -203
- package/eigen/Eigen/src/Core/ArrayWrapper.h +127 -171
- package/eigen/Eigen/src/Core/Assign.h +30 -40
- package/eigen/Eigen/src/Core/AssignEvaluator.h +711 -589
- package/eigen/Eigen/src/Core/Assign_MKL.h +130 -125
- package/eigen/Eigen/src/Core/BandMatrix.h +268 -283
- package/eigen/Eigen/src/Core/Block.h +375 -398
- package/eigen/Eigen/src/Core/CommaInitializer.h +86 -97
- package/eigen/Eigen/src/Core/ConditionEstimator.h +51 -53
- package/eigen/Eigen/src/Core/CoreEvaluators.h +1356 -1026
- package/eigen/Eigen/src/Core/CoreIterators.h +73 -59
- package/eigen/Eigen/src/Core/CwiseBinaryOp.h +114 -132
- package/eigen/Eigen/src/Core/CwiseNullaryOp.h +726 -617
- package/eigen/Eigen/src/Core/CwiseTernaryOp.h +77 -103
- package/eigen/Eigen/src/Core/CwiseUnaryOp.h +56 -68
- package/eigen/Eigen/src/Core/CwiseUnaryView.h +132 -95
- package/eigen/Eigen/src/Core/DenseBase.h +632 -571
- package/eigen/Eigen/src/Core/DenseCoeffsBase.h +511 -624
- package/eigen/Eigen/src/Core/DenseStorage.h +512 -509
- package/eigen/Eigen/src/Core/DeviceWrapper.h +153 -0
- package/eigen/Eigen/src/Core/Diagonal.h +169 -210
- package/eigen/Eigen/src/Core/DiagonalMatrix.h +351 -274
- package/eigen/Eigen/src/Core/DiagonalProduct.h +12 -10
- package/eigen/Eigen/src/Core/Dot.h +172 -222
- package/eigen/Eigen/src/Core/EigenBase.h +75 -85
- package/eigen/Eigen/src/Core/Fill.h +138 -0
- package/eigen/Eigen/src/Core/FindCoeff.h +464 -0
- package/eigen/Eigen/src/Core/ForceAlignedAccess.h +90 -109
- package/eigen/Eigen/src/Core/Fuzzy.h +82 -105
- package/eigen/Eigen/src/Core/GeneralProduct.h +327 -263
- package/eigen/Eigen/src/Core/GenericPacketMath.h +1472 -360
- package/eigen/Eigen/src/Core/GlobalFunctions.h +194 -151
- package/eigen/Eigen/src/Core/IO.h +147 -139
- package/eigen/Eigen/src/Core/IndexedView.h +321 -0
- package/eigen/Eigen/src/Core/InnerProduct.h +260 -0
- package/eigen/Eigen/src/Core/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Core/Inverse.h +56 -66
- package/eigen/Eigen/src/Core/Map.h +124 -142
- package/eigen/Eigen/src/Core/MapBase.h +256 -281
- package/eigen/Eigen/src/Core/MathFunctions.h +1620 -938
- package/eigen/Eigen/src/Core/MathFunctionsImpl.h +233 -71
- package/eigen/Eigen/src/Core/Matrix.h +491 -416
- package/eigen/Eigen/src/Core/MatrixBase.h +468 -453
- package/eigen/Eigen/src/Core/NestByValue.h +66 -85
- package/eigen/Eigen/src/Core/NoAlias.h +79 -85
- package/eigen/Eigen/src/Core/NumTraits.h +235 -148
- package/eigen/Eigen/src/Core/PartialReduxEvaluator.h +253 -0
- package/eigen/Eigen/src/Core/PermutationMatrix.h +461 -511
- package/eigen/Eigen/src/Core/PlainObjectBase.h +871 -894
- package/eigen/Eigen/src/Core/Product.h +260 -139
- package/eigen/Eigen/src/Core/ProductEvaluators.h +863 -714
- package/eigen/Eigen/src/Core/Random.h +161 -136
- package/eigen/Eigen/src/Core/RandomImpl.h +262 -0
- package/eigen/Eigen/src/Core/RealView.h +250 -0
- package/eigen/Eigen/src/Core/Redux.h +366 -336
- package/eigen/Eigen/src/Core/Ref.h +308 -209
- package/eigen/Eigen/src/Core/Replicate.h +94 -106
- package/eigen/Eigen/src/Core/Reshaped.h +398 -0
- package/eigen/Eigen/src/Core/ReturnByValue.h +49 -55
- package/eigen/Eigen/src/Core/Reverse.h +136 -145
- package/eigen/Eigen/src/Core/Select.h +70 -140
- package/eigen/Eigen/src/Core/SelfAdjointView.h +262 -285
- package/eigen/Eigen/src/Core/SelfCwiseBinaryOp.h +23 -20
- package/eigen/Eigen/src/Core/SkewSymmetricMatrix3.h +382 -0
- package/eigen/Eigen/src/Core/Solve.h +97 -111
- package/eigen/Eigen/src/Core/SolveTriangular.h +131 -129
- package/eigen/Eigen/src/Core/SolverBase.h +138 -101
- package/eigen/Eigen/src/Core/StableNorm.h +156 -160
- package/eigen/Eigen/src/Core/StlIterators.h +619 -0
- package/eigen/Eigen/src/Core/Stride.h +91 -88
- package/eigen/Eigen/src/Core/Swap.h +70 -38
- package/eigen/Eigen/src/Core/Transpose.h +295 -273
- package/eigen/Eigen/src/Core/Transpositions.h +272 -317
- package/eigen/Eigen/src/Core/TriangularMatrix.h +670 -755
- package/eigen/Eigen/src/Core/VectorBlock.h +59 -72
- package/eigen/Eigen/src/Core/VectorwiseOp.h +668 -630
- package/eigen/Eigen/src/Core/Visitor.h +480 -216
- package/eigen/Eigen/src/Core/arch/AVX/Complex.h +407 -293
- package/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +79 -388
- package/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +2935 -491
- package/eigen/Eigen/src/Core/arch/AVX/Reductions.h +353 -0
- package/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +279 -22
- package/eigen/Eigen/src/Core/arch/AVX512/Complex.h +472 -0
- package/eigen/Eigen/src/Core/arch/AVX512/GemmKernel.h +1245 -0
- package/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +85 -333
- package/eigen/Eigen/src/Core/arch/AVX512/MathFunctionsFP16.h +75 -0
- package/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +2490 -649
- package/eigen/Eigen/src/Core/arch/AVX512/PacketMathFP16.h +1413 -0
- package/eigen/Eigen/src/Core/arch/AVX512/Reductions.h +297 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TrsmKernel.h +1167 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TrsmUnrolls.inc +1219 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +277 -0
- package/eigen/Eigen/src/Core/arch/AVX512/TypeCastingFP16.h +130 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +521 -298
- package/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +39 -280
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +3686 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +205 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +901 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMAbfloat16.h +742 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/MatrixVectorProduct.inc +2818 -0
- package/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +3391 -723
- package/eigen/Eigen/src/Core/arch/AltiVec/TypeCasting.h +153 -0
- package/eigen/Eigen/src/Core/arch/Default/BFloat16.h +866 -0
- package/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +113 -14
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +2634 -0
- package/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +227 -0
- package/eigen/Eigen/src/Core/arch/Default/Half.h +1091 -0
- package/eigen/Eigen/src/Core/arch/Default/Settings.h +11 -13
- package/eigen/Eigen/src/Core/arch/GPU/Complex.h +244 -0
- package/eigen/Eigen/src/Core/arch/GPU/MathFunctions.h +104 -0
- package/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1712 -0
- package/eigen/Eigen/src/Core/arch/GPU/Tuple.h +268 -0
- package/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +77 -0
- package/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
- package/eigen/Eigen/src/Core/arch/HVX/PacketMath.h +1088 -0
- package/eigen/Eigen/src/Core/arch/LSX/Complex.h +520 -0
- package/eigen/Eigen/src/Core/arch/LSX/GeneralBlockPanelKernel.h +23 -0
- package/eigen/Eigen/src/Core/arch/LSX/MathFunctions.h +43 -0
- package/eigen/Eigen/src/Core/arch/LSX/PacketMath.h +2866 -0
- package/eigen/Eigen/src/Core/arch/LSX/TypeCasting.h +526 -0
- package/eigen/Eigen/src/Core/arch/MSA/Complex.h +620 -0
- package/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +379 -0
- package/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1237 -0
- package/eigen/Eigen/src/Core/arch/NEON/Complex.h +531 -289
- package/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +243 -0
- package/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +50 -73
- package/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +5915 -579
- package/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1642 -0
- package/eigen/Eigen/src/Core/arch/NEON/UnaryFunctors.h +57 -0
- package/eigen/Eigen/src/Core/arch/SSE/Complex.h +366 -334
- package/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +40 -514
- package/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +2164 -675
- package/eigen/Eigen/src/Core/arch/SSE/Reductions.h +324 -0
- package/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +188 -35
- package/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +48 -0
- package/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +674 -0
- package/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +52 -0
- package/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +227 -0
- package/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +303 -0
- package/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +576 -0
- package/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +83 -0
- package/eigen/Eigen/src/Core/arch/ZVector/Complex.h +434 -261
- package/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +160 -53
- package/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +1073 -605
- package/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +123 -117
- package/eigen/Eigen/src/Core/functors/BinaryFunctors.h +594 -322
- package/eigen/Eigen/src/Core/functors/NullaryFunctors.h +204 -118
- package/eigen/Eigen/src/Core/functors/StlFunctors.h +110 -97
- package/eigen/Eigen/src/Core/functors/TernaryFunctors.h +34 -7
- package/eigen/Eigen/src/Core/functors/UnaryFunctors.h +1158 -530
- package/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +2329 -1333
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +328 -364
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +191 -178
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +85 -82
- package/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +154 -73
- package/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +396 -542
- package/eigen/Eigen/src/Core/products/GeneralMatrixVector_BLAS.h +80 -77
- package/eigen/Eigen/src/Core/products/Parallelizer.h +208 -92
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +331 -375
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +206 -224
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +139 -146
- package/eigen/Eigen/src/Core/products/SelfadjointMatrixVector_BLAS.h +58 -61
- package/eigen/Eigen/src/Core/products/SelfadjointProduct.h +71 -71
- package/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +48 -46
- package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +294 -369
- package/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +246 -238
- package/eigen/Eigen/src/Core/products/TriangularMatrixVector.h +244 -247
- package/eigen/Eigen/src/Core/products/TriangularMatrixVector_BLAS.h +212 -192
- package/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +328 -275
- package/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +108 -109
- package/eigen/Eigen/src/Core/products/TriangularSolverVector.h +70 -93
- package/eigen/Eigen/src/Core/util/Assert.h +158 -0
- package/eigen/Eigen/src/Core/util/BlasUtil.h +413 -290
- package/eigen/Eigen/src/Core/util/ConfigureVectorization.h +543 -0
- package/eigen/Eigen/src/Core/util/Constants.h +314 -263
- package/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +130 -78
- package/eigen/Eigen/src/Core/util/EmulateArray.h +270 -0
- package/eigen/Eigen/src/Core/util/ForwardDeclarations.h +450 -224
- package/eigen/Eigen/src/Core/util/GpuHipCudaDefines.inc +101 -0
- package/eigen/Eigen/src/Core/util/GpuHipCudaUndefines.inc +45 -0
- package/eigen/Eigen/src/Core/util/IndexedViewHelper.h +487 -0
- package/eigen/Eigen/src/Core/util/IntegralConstant.h +279 -0
- package/eigen/Eigen/src/Core/util/MKL_support.h +39 -30
- package/eigen/Eigen/src/Core/util/Macros.h +939 -646
- package/eigen/Eigen/src/Core/util/MaxSizeVector.h +139 -0
- package/eigen/Eigen/src/Core/util/Memory.h +1042 -650
- package/eigen/Eigen/src/Core/util/Meta.h +618 -426
- package/eigen/Eigen/src/Core/util/MoreMeta.h +638 -0
- package/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +32 -19
- package/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
- package/eigen/Eigen/src/Core/util/Serializer.h +209 -0
- package/eigen/Eigen/src/Core/util/StaticAssert.h +51 -164
- package/eigen/Eigen/src/Core/util/SymbolicIndex.h +445 -0
- package/eigen/Eigen/src/Core/util/XprHelper.h +793 -538
- package/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +246 -277
- package/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +299 -319
- package/eigen/Eigen/src/Eigenvalues/ComplexSchur_LAPACKE.h +52 -48
- package/eigen/Eigen/src/Eigenvalues/EigenSolver.h +413 -456
- package/eigen/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +309 -325
- package/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +157 -171
- package/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +292 -310
- package/eigen/Eigen/src/Eigenvalues/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +91 -107
- package/eigen/Eigen/src/Eigenvalues/RealQZ.h +539 -606
- package/eigen/Eigen/src/Eigenvalues/RealSchur.h +348 -382
- package/eigen/Eigen/src/Eigenvalues/RealSchur_LAPACKE.h +41 -35
- package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +579 -600
- package/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver_LAPACKE.h +47 -44
- package/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +434 -461
- package/eigen/Eigen/src/Geometry/AlignedBox.h +307 -214
- package/eigen/Eigen/src/Geometry/AngleAxis.h +135 -137
- package/eigen/Eigen/src/Geometry/EulerAngles.h +163 -74
- package/eigen/Eigen/src/Geometry/Homogeneous.h +289 -333
- package/eigen/Eigen/src/Geometry/Hyperplane.h +152 -161
- package/eigen/Eigen/src/Geometry/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Geometry/OrthoMethods.h +168 -145
- package/eigen/Eigen/src/Geometry/ParametrizedLine.h +141 -104
- package/eigen/Eigen/src/Geometry/Quaternion.h +595 -497
- package/eigen/Eigen/src/Geometry/Rotation2D.h +110 -108
- package/eigen/Eigen/src/Geometry/RotationBase.h +148 -145
- package/eigen/Eigen/src/Geometry/Scaling.h +115 -90
- package/eigen/Eigen/src/Geometry/Transform.h +896 -953
- package/eigen/Eigen/src/Geometry/Translation.h +100 -98
- package/eigen/Eigen/src/Geometry/Umeyama.h +79 -84
- package/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +154 -0
- package/eigen/Eigen/src/Householder/BlockHouseholder.h +54 -42
- package/eigen/Eigen/src/Householder/Householder.h +104 -122
- package/eigen/Eigen/src/Householder/HouseholderSequence.h +416 -382
- package/eigen/Eigen/src/Householder/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +153 -166
- package/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +127 -138
- package/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +95 -124
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +269 -267
- package/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +246 -259
- package/eigen/Eigen/src/IterativeLinearSolvers/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +218 -217
- package/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +80 -103
- package/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +59 -63
- package/eigen/Eigen/src/Jacobi/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/Jacobi/Jacobi.h +256 -291
- package/eigen/Eigen/src/KLUSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/KLUSupport/KLUSupport.h +339 -0
- package/eigen/Eigen/src/LU/Determinant.h +60 -63
- package/eigen/Eigen/src/LU/FullPivLU.h +561 -626
- package/eigen/Eigen/src/LU/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/LU/InverseImpl.h +213 -275
- package/eigen/Eigen/src/LU/PartialPivLU.h +407 -435
- package/eigen/Eigen/src/LU/PartialPivLU_LAPACKE.h +54 -40
- package/eigen/Eigen/src/LU/arch/InverseSize4.h +353 -0
- package/eigen/Eigen/src/MetisSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/MetisSupport/MetisSupport.h +81 -93
- package/eigen/Eigen/src/OrderingMethods/Amd.h +250 -282
- package/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +950 -1103
- package/eigen/Eigen/src/OrderingMethods/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/OrderingMethods/Ordering.h +111 -122
- package/eigen/Eigen/src/PaStiXSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +524 -570
- package/eigen/Eigen/src/PardisoSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +385 -429
- package/eigen/Eigen/src/QR/ColPivHouseholderQR.h +494 -473
- package/eigen/Eigen/src/QR/ColPivHouseholderQR_LAPACKE.h +120 -56
- package/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +223 -137
- package/eigen/Eigen/src/QR/FullPivHouseholderQR.h +517 -460
- package/eigen/Eigen/src/QR/HouseholderQR.h +412 -278
- package/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h +32 -23
- package/eigen/Eigen/src/QR/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SPQRSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +263 -261
- package/eigen/Eigen/src/SVD/BDCSVD.h +872 -679
- package/eigen/Eigen/src/SVD/BDCSVD_LAPACKE.h +174 -0
- package/eigen/Eigen/src/SVD/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SVD/JacobiSVD.h +585 -543
- package/eigen/Eigen/src/SVD/JacobiSVD_LAPACKE.h +85 -49
- package/eigen/Eigen/src/SVD/SVDBase.h +281 -160
- package/eigen/Eigen/src/SVD/UpperBidiagonalization.h +202 -237
- package/eigen/Eigen/src/SparseCholesky/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +769 -590
- package/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +318 -129
- package/eigen/Eigen/src/SparseCore/AmbiVector.h +202 -251
- package/eigen/Eigen/src/SparseCore/CompressedStorage.h +184 -236
- package/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +140 -184
- package/eigen/Eigen/src/SparseCore/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseCore/SparseAssign.h +174 -111
- package/eigen/Eigen/src/SparseCore/SparseBlock.h +408 -477
- package/eigen/Eigen/src/SparseCore/SparseColEtree.h +100 -112
- package/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +531 -280
- package/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +559 -347
- package/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +100 -108
- package/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +185 -191
- package/eigen/Eigen/src/SparseCore/SparseDiagonalProduct.h +71 -71
- package/eigen/Eigen/src/SparseCore/SparseDot.h +49 -47
- package/eigen/Eigen/src/SparseCore/SparseFuzzy.h +13 -11
- package/eigen/Eigen/src/SparseCore/SparseMap.h +243 -253
- package/eigen/Eigen/src/SparseCore/SparseMatrix.h +1614 -1142
- package/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +403 -357
- package/eigen/Eigen/src/SparseCore/SparsePermutation.h +186 -115
- package/eigen/Eigen/src/SparseCore/SparseProduct.h +100 -91
- package/eigen/Eigen/src/SparseCore/SparseRedux.h +22 -24
- package/eigen/Eigen/src/SparseCore/SparseRef.h +268 -295
- package/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +371 -414
- package/eigen/Eigen/src/SparseCore/SparseSolverBase.h +78 -87
- package/eigen/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +81 -95
- package/eigen/Eigen/src/SparseCore/SparseTranspose.h +62 -71
- package/eigen/Eigen/src/SparseCore/SparseTriangularView.h +132 -144
- package/eigen/Eigen/src/SparseCore/SparseUtil.h +146 -115
- package/eigen/Eigen/src/SparseCore/SparseVector.h +426 -372
- package/eigen/Eigen/src/SparseCore/SparseView.h +164 -193
- package/eigen/Eigen/src/SparseCore/TriangularSolver.h +129 -170
- package/eigen/Eigen/src/SparseLU/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseLU/SparseLU.h +814 -618
- package/eigen/Eigen/src/SparseLU/SparseLUImpl.h +61 -48
- package/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +102 -118
- package/eigen/Eigen/src/SparseLU/SparseLU_Structs.h +38 -35
- package/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +273 -255
- package/eigen/Eigen/src/SparseLU/SparseLU_Utils.h +44 -49
- package/eigen/Eigen/src/SparseLU/SparseLU_column_bmod.h +104 -108
- package/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +90 -101
- package/eigen/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +57 -58
- package/eigen/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +43 -55
- package/eigen/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +74 -71
- package/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +125 -133
- package/eigen/Eigen/src/SparseLU/SparseLU_panel_dfs.h +136 -159
- package/eigen/Eigen/src/SparseLU/SparseLU_pivotL.h +51 -52
- package/eigen/Eigen/src/SparseLU/SparseLU_pruneL.h +67 -73
- package/eigen/Eigen/src/SparseLU/SparseLU_relax_snode.h +24 -26
- package/eigen/Eigen/src/SparseQR/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SparseQR/SparseQR.h +451 -490
- package/eigen/Eigen/src/StlSupport/StdDeque.h +28 -105
- package/eigen/Eigen/src/StlSupport/StdList.h +28 -84
- package/eigen/Eigen/src/StlSupport/StdVector.h +28 -108
- package/eigen/Eigen/src/StlSupport/details.h +48 -50
- package/eigen/Eigen/src/SuperLUSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +634 -732
- package/eigen/Eigen/src/ThreadPool/Barrier.h +70 -0
- package/eigen/Eigen/src/ThreadPool/CoreThreadPoolDevice.h +336 -0
- package/eigen/Eigen/src/ThreadPool/EventCount.h +241 -0
- package/eigen/Eigen/src/ThreadPool/ForkJoin.h +140 -0
- package/eigen/Eigen/src/ThreadPool/InternalHeaderCheck.h +4 -0
- package/eigen/Eigen/src/ThreadPool/NonBlockingThreadPool.h +587 -0
- package/eigen/Eigen/src/ThreadPool/RunQueue.h +230 -0
- package/eigen/Eigen/src/ThreadPool/ThreadCancel.h +21 -0
- package/eigen/Eigen/src/ThreadPool/ThreadEnvironment.h +43 -0
- package/eigen/Eigen/src/ThreadPool/ThreadLocal.h +289 -0
- package/eigen/Eigen/src/ThreadPool/ThreadPoolInterface.h +50 -0
- package/eigen/Eigen/src/ThreadPool/ThreadYield.h +16 -0
- package/eigen/Eigen/src/UmfPackSupport/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +480 -380
- package/eigen/Eigen/src/misc/Image.h +41 -43
- package/eigen/Eigen/src/misc/InternalHeaderCheck.h +3 -0
- package/eigen/Eigen/src/misc/Kernel.h +39 -41
- package/eigen/Eigen/src/misc/RealSvd2x2.h +19 -21
- package/eigen/Eigen/src/misc/blas.h +83 -426
- package/eigen/Eigen/src/misc/lapacke.h +9976 -16182
- package/eigen/Eigen/src/misc/lapacke_helpers.h +163 -0
- package/eigen/Eigen/src/misc/lapacke_mangling.h +4 -5
- package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.inc +344 -0
- package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.inc +544 -0
- package/eigen/Eigen/src/plugins/BlockMethods.inc +1370 -0
- package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.inc +116 -0
- package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.inc +167 -0
- package/eigen/Eigen/src/plugins/IndexedViewMethods.inc +192 -0
- package/eigen/Eigen/src/plugins/InternalHeaderCheck.inc +3 -0
- package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.inc +331 -0
- package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.inc +118 -0
- package/eigen/Eigen/src/plugins/ReshapedMethods.inc +133 -0
- package/lib/LibEigen.d.ts +4 -0
- package/lib/LibEigen.js +14 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +7 -3
- package/package.json +2 -10
- package/eigen/Eigen/CMakeLists.txt +0 -19
- package/eigen/Eigen/src/Core/BooleanRedux.h +0 -164
- package/eigen/Eigen/src/Core/arch/CUDA/Complex.h +0 -103
- package/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -675
- package/eigen/Eigen/src/Core/arch/CUDA/MathFunctions.h +0 -91
- package/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
- package/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
- package/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
- package/eigen/Eigen/src/Core/util/NonMPL2.h +0 -3
- package/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
- package/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
- package/eigen/Eigen/src/SparseCore/MappedSparseMatrix.h +0 -67
- package/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +0 -280
- package/eigen/Eigen/src/misc/lapack.h +0 -152
- package/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +0 -332
- package/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +0 -552
- package/eigen/Eigen/src/plugins/BlockMethods.h +0 -1058
- package/eigen/Eigen/src/plugins/CommonCwiseBinaryOps.h +0 -115
- package/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +0 -163
- package/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +0 -152
- package/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +0 -85
- package/lib/eigen.d.ts +0 -2
- package/lib/eigen.js +0 -15
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2018 Rasmus Munk Larsen <rmlarsen@google.com>
|
|
5
|
+
//
|
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
|
|
10
|
+
// Barrier is an object that allows one or more threads to wait until
|
|
11
|
+
// Notify has been called a specified number of times.
|
|
12
|
+
|
|
13
|
+
#ifndef EIGEN_CXX11_THREADPOOL_BARRIER_H
|
|
14
|
+
#define EIGEN_CXX11_THREADPOOL_BARRIER_H
|
|
15
|
+
|
|
16
|
+
// IWYU pragma: private
|
|
17
|
+
#include "./InternalHeaderCheck.h"
|
|
18
|
+
|
|
19
|
+
namespace Eigen {
|
|
20
|
+
|
|
21
|
+
class Barrier {
|
|
22
|
+
public:
|
|
23
|
+
Barrier(unsigned int count) : state_(count << 1), notified_(false) {
|
|
24
|
+
eigen_plain_assert(((count << 1) >> 1) == count);
|
|
25
|
+
}
|
|
26
|
+
~Barrier() { eigen_plain_assert((state_ >> 1) == 0); }
|
|
27
|
+
|
|
28
|
+
void Notify() {
|
|
29
|
+
unsigned int v = state_.fetch_sub(2, std::memory_order_acq_rel) - 2;
|
|
30
|
+
if (v != 1) {
|
|
31
|
+
// Clear the lowest bit (waiter flag) and check that the original state
|
|
32
|
+
// value was not zero. If it was zero, it means that notify was called
|
|
33
|
+
// more times than the original count.
|
|
34
|
+
eigen_plain_assert(((v + 2) & ~1) != 0);
|
|
35
|
+
return; // either count has not dropped to 0, or waiter is not waiting
|
|
36
|
+
}
|
|
37
|
+
EIGEN_MUTEX_LOCK l(mu_);
|
|
38
|
+
eigen_plain_assert(!notified_);
|
|
39
|
+
notified_ = true;
|
|
40
|
+
cv_.notify_all();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void Wait() {
|
|
44
|
+
unsigned int v = state_.fetch_or(1, std::memory_order_acq_rel);
|
|
45
|
+
if ((v >> 1) == 0) return;
|
|
46
|
+
EIGEN_MUTEX_LOCK l(mu_);
|
|
47
|
+
while (!notified_) {
|
|
48
|
+
cv_.wait(l);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private:
|
|
53
|
+
EIGEN_MUTEX mu_;
|
|
54
|
+
EIGEN_CONDVAR cv_;
|
|
55
|
+
std::atomic<unsigned int> state_; // low bit is waiter flag
|
|
56
|
+
bool notified_;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Notification is an object that allows a user to to wait for another
|
|
60
|
+
// thread to signal a notification that an event has occurred.
|
|
61
|
+
//
|
|
62
|
+
// Multiple threads can wait on the same Notification object,
|
|
63
|
+
// but only one caller must call Notify() on the object.
|
|
64
|
+
struct Notification : Barrier {
|
|
65
|
+
Notification() : Barrier(1){};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace Eigen
|
|
69
|
+
|
|
70
|
+
#endif // EIGEN_CXX11_THREADPOOL_BARRIER_H
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2023 Charlie Schlosser <cs.schlosser@gmail.com>
|
|
5
|
+
//
|
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
|
|
10
|
+
#ifndef EIGEN_CORE_THREAD_POOL_DEVICE_H
|
|
11
|
+
#define EIGEN_CORE_THREAD_POOL_DEVICE_H
|
|
12
|
+
|
|
13
|
+
namespace Eigen {
|
|
14
|
+
|
|
15
|
+
// CoreThreadPoolDevice provides an easy-to-understand Device for parallelizing Eigen Core expressions with
|
|
16
|
+
// Threadpool. Expressions are recursively split evenly until the evaluation cost is less than the threshold for
|
|
17
|
+
// delegating the task to a thread.
|
|
18
|
+
/*
|
|
19
|
+
a
|
|
20
|
+
/ \
|
|
21
|
+
/ \
|
|
22
|
+
/ \
|
|
23
|
+
/ \
|
|
24
|
+
/ \
|
|
25
|
+
/ \
|
|
26
|
+
/ \
|
|
27
|
+
a e
|
|
28
|
+
/ \ / \
|
|
29
|
+
/ \ / \
|
|
30
|
+
/ \ / \
|
|
31
|
+
a c e g
|
|
32
|
+
/ \ / \ / \ / \
|
|
33
|
+
/ \ / \ / \ / \
|
|
34
|
+
a b c d e f g h
|
|
35
|
+
*/
|
|
36
|
+
// Each task descends the binary tree to the left, delegates the right task to a new thread, and continues to the
|
|
37
|
+
// left. This ensures that work is evenly distributed to the thread pool as quickly as possible and minimizes the number
|
|
38
|
+
// of tasks created during the evaluation. Consider an expression that is divided into 8 chunks. The
|
|
39
|
+
// primary task 'a' creates tasks 'e' 'c' and 'b', and executes its portion of the expression at the bottom of the
|
|
40
|
+
// tree. Likewise, task 'e' creates tasks 'g' and 'f', and executes its portion of the expression.
|
|
41
|
+
|
|
42
|
+
struct CoreThreadPoolDevice {
|
|
43
|
+
using Task = std::function<void()>;
|
|
44
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoreThreadPoolDevice(ThreadPool& pool, float threadCostThreshold = 3e-5f)
|
|
45
|
+
: m_pool(pool) {
|
|
46
|
+
eigen_assert(threadCostThreshold >= 0.0f && "threadCostThreshold must be non-negative");
|
|
47
|
+
m_costFactor = threadCostThreshold;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
template <int PacketSize>
|
|
51
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE int calculateLevels(Index size, float cost) const {
|
|
52
|
+
eigen_assert(cost >= 0.0f && "cost must be non-negative");
|
|
53
|
+
Index numOps = size / PacketSize;
|
|
54
|
+
int actualThreads = numOps < m_pool.NumThreads() ? static_cast<int>(numOps) : m_pool.NumThreads();
|
|
55
|
+
float totalCost = static_cast<float>(numOps) * cost;
|
|
56
|
+
float idealThreads = totalCost * m_costFactor;
|
|
57
|
+
if (idealThreads < static_cast<float>(actualThreads)) {
|
|
58
|
+
idealThreads = numext::maxi(idealThreads, 1.0f);
|
|
59
|
+
actualThreads = numext::mini(actualThreads, static_cast<int>(idealThreads));
|
|
60
|
+
}
|
|
61
|
+
int maxLevel = internal::log2_ceil(actualThreads);
|
|
62
|
+
return maxLevel;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// MSVC does not like inlining parallelForImpl
|
|
66
|
+
#if EIGEN_COMP_MSVC && !EIGEN_COMP_CLANG
|
|
67
|
+
#define EIGEN_PARALLEL_FOR_INLINE
|
|
68
|
+
#else
|
|
69
|
+
#define EIGEN_PARALLEL_FOR_INLINE EIGEN_STRONG_INLINE
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
template <typename UnaryFunctor, int PacketSize>
|
|
73
|
+
EIGEN_DEVICE_FUNC EIGEN_PARALLEL_FOR_INLINE void parallelForImpl(Index begin, Index end, UnaryFunctor& f,
|
|
74
|
+
Barrier& barrier, int level) {
|
|
75
|
+
while (level > 0) {
|
|
76
|
+
level--;
|
|
77
|
+
Index size = end - begin;
|
|
78
|
+
eigen_assert(size % PacketSize == 0 && "this function assumes size is a multiple of PacketSize");
|
|
79
|
+
Index mid = begin + numext::round_down(size >> 1, PacketSize);
|
|
80
|
+
Task right = [this, mid, end, &f, &barrier, level]() {
|
|
81
|
+
parallelForImpl<UnaryFunctor, PacketSize>(mid, end, f, barrier, level);
|
|
82
|
+
};
|
|
83
|
+
m_pool.Schedule(std::move(right));
|
|
84
|
+
end = mid;
|
|
85
|
+
}
|
|
86
|
+
for (Index i = begin; i < end; i += PacketSize) f(i);
|
|
87
|
+
barrier.Notify();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
template <typename BinaryFunctor, int PacketSize>
|
|
91
|
+
EIGEN_DEVICE_FUNC EIGEN_PARALLEL_FOR_INLINE void parallelForImpl(Index outerBegin, Index outerEnd, Index innerBegin,
|
|
92
|
+
Index innerEnd, BinaryFunctor& f, Barrier& barrier,
|
|
93
|
+
int level) {
|
|
94
|
+
while (level > 0) {
|
|
95
|
+
level--;
|
|
96
|
+
Index outerSize = outerEnd - outerBegin;
|
|
97
|
+
if (outerSize > 1) {
|
|
98
|
+
Index outerMid = outerBegin + (outerSize >> 1);
|
|
99
|
+
Task right = [this, &f, &barrier, outerMid, outerEnd, innerBegin, innerEnd, level]() {
|
|
100
|
+
parallelForImpl<BinaryFunctor, PacketSize>(outerMid, outerEnd, innerBegin, innerEnd, f, barrier, level);
|
|
101
|
+
};
|
|
102
|
+
m_pool.Schedule(std::move(right));
|
|
103
|
+
outerEnd = outerMid;
|
|
104
|
+
} else {
|
|
105
|
+
Index innerSize = innerEnd - innerBegin;
|
|
106
|
+
eigen_assert(innerSize % PacketSize == 0 && "this function assumes innerSize is a multiple of PacketSize");
|
|
107
|
+
Index innerMid = innerBegin + numext::round_down(innerSize >> 1, PacketSize);
|
|
108
|
+
Task right = [this, &f, &barrier, outerBegin, outerEnd, innerMid, innerEnd, level]() {
|
|
109
|
+
parallelForImpl<BinaryFunctor, PacketSize>(outerBegin, outerEnd, innerMid, innerEnd, f, barrier, level);
|
|
110
|
+
};
|
|
111
|
+
m_pool.Schedule(std::move(right));
|
|
112
|
+
innerEnd = innerMid;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (Index outer = outerBegin; outer < outerEnd; outer++)
|
|
116
|
+
for (Index inner = innerBegin; inner < innerEnd; inner += PacketSize) f(outer, inner);
|
|
117
|
+
barrier.Notify();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#undef EIGEN_PARALLEL_FOR_INLINE
|
|
121
|
+
|
|
122
|
+
template <typename UnaryFunctor, int PacketSize>
|
|
123
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void parallelFor(Index begin, Index end, UnaryFunctor& f, float cost) {
|
|
124
|
+
Index size = end - begin;
|
|
125
|
+
int maxLevel = calculateLevels<PacketSize>(size, cost);
|
|
126
|
+
Barrier barrier(1 << maxLevel);
|
|
127
|
+
parallelForImpl<UnaryFunctor, PacketSize>(begin, end, f, barrier, maxLevel);
|
|
128
|
+
barrier.Wait();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
template <typename BinaryFunctor, int PacketSize>
|
|
132
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void parallelFor(Index outerBegin, Index outerEnd, Index innerBegin,
|
|
133
|
+
Index innerEnd, BinaryFunctor& f, float cost) {
|
|
134
|
+
Index outerSize = outerEnd - outerBegin;
|
|
135
|
+
Index innerSize = innerEnd - innerBegin;
|
|
136
|
+
Index size = outerSize * innerSize;
|
|
137
|
+
int maxLevel = calculateLevels<PacketSize>(size, cost);
|
|
138
|
+
Barrier barrier(1 << maxLevel);
|
|
139
|
+
parallelForImpl<BinaryFunctor, PacketSize>(outerBegin, outerEnd, innerBegin, innerEnd, f, barrier, maxLevel);
|
|
140
|
+
barrier.Wait();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
ThreadPool& m_pool;
|
|
144
|
+
// costFactor is the cost of delegating a task to a thread
|
|
145
|
+
// the inverse is used to avoid a floating point division
|
|
146
|
+
float m_costFactor;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// specialization of coefficient-wise assignment loops for CoreThreadPoolDevice
|
|
150
|
+
|
|
151
|
+
namespace internal {
|
|
152
|
+
|
|
153
|
+
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
|
154
|
+
struct Kernel;
|
|
155
|
+
#endif
|
|
156
|
+
|
|
157
|
+
template <typename Kernel>
|
|
158
|
+
struct cost_helper {
|
|
159
|
+
using SrcEvaluatorType = typename Kernel::SrcEvaluatorType;
|
|
160
|
+
using DstEvaluatorType = typename Kernel::DstEvaluatorType;
|
|
161
|
+
using SrcXprType = typename SrcEvaluatorType::XprType;
|
|
162
|
+
using DstXprType = typename DstEvaluatorType::XprType;
|
|
163
|
+
static constexpr Index Cost = functor_cost<SrcXprType>::Cost + functor_cost<DstXprType>::Cost;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
template <typename Kernel>
|
|
167
|
+
struct dense_assignment_loop_with_device<Kernel, CoreThreadPoolDevice, DefaultTraversal, NoUnrolling> {
|
|
168
|
+
static constexpr Index XprEvaluationCost = cost_helper<Kernel>::Cost;
|
|
169
|
+
struct AssignmentFunctor : public Kernel {
|
|
170
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
171
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index outer, Index inner) {
|
|
172
|
+
this->assignCoeffByOuterInner(outer, inner);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Kernel& kernel, CoreThreadPoolDevice& device) {
|
|
177
|
+
const Index innerSize = kernel.innerSize();
|
|
178
|
+
const Index outerSize = kernel.outerSize();
|
|
179
|
+
constexpr float cost = static_cast<float>(XprEvaluationCost);
|
|
180
|
+
AssignmentFunctor functor(kernel);
|
|
181
|
+
device.template parallelFor<AssignmentFunctor, 1>(0, outerSize, 0, innerSize, functor, cost);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
template <typename Kernel>
|
|
186
|
+
struct dense_assignment_loop_with_device<Kernel, CoreThreadPoolDevice, DefaultTraversal, InnerUnrolling> {
|
|
187
|
+
using DstXprType = typename Kernel::DstEvaluatorType::XprType;
|
|
188
|
+
static constexpr Index XprEvaluationCost = cost_helper<Kernel>::Cost, InnerSize = DstXprType::InnerSizeAtCompileTime;
|
|
189
|
+
struct AssignmentFunctor : public Kernel {
|
|
190
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
191
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index outer) {
|
|
192
|
+
copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, 0, InnerSize>::run(*this, outer);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Kernel& kernel, CoreThreadPoolDevice& device) {
|
|
196
|
+
const Index outerSize = kernel.outerSize();
|
|
197
|
+
AssignmentFunctor functor(kernel);
|
|
198
|
+
constexpr float cost = static_cast<float>(XprEvaluationCost) * static_cast<float>(InnerSize);
|
|
199
|
+
device.template parallelFor<AssignmentFunctor, 1>(0, outerSize, functor, cost);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
template <typename Kernel>
|
|
204
|
+
struct dense_assignment_loop_with_device<Kernel, CoreThreadPoolDevice, InnerVectorizedTraversal, NoUnrolling> {
|
|
205
|
+
using PacketType = typename Kernel::PacketType;
|
|
206
|
+
static constexpr Index XprEvaluationCost = cost_helper<Kernel>::Cost, PacketSize = unpacket_traits<PacketType>::size,
|
|
207
|
+
SrcAlignment = Kernel::AssignmentTraits::SrcAlignment,
|
|
208
|
+
DstAlignment = Kernel::AssignmentTraits::DstAlignment;
|
|
209
|
+
struct AssignmentFunctor : public Kernel {
|
|
210
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
211
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index outer, Index inner) {
|
|
212
|
+
this->template assignPacketByOuterInner<Unaligned, Unaligned, PacketType>(outer, inner);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Kernel& kernel, CoreThreadPoolDevice& device) {
|
|
216
|
+
const Index innerSize = kernel.innerSize();
|
|
217
|
+
const Index outerSize = kernel.outerSize();
|
|
218
|
+
const float cost = static_cast<float>(XprEvaluationCost) * static_cast<float>(innerSize);
|
|
219
|
+
AssignmentFunctor functor(kernel);
|
|
220
|
+
device.template parallelFor<AssignmentFunctor, PacketSize>(0, outerSize, 0, innerSize, functor, cost);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
template <typename Kernel>
|
|
225
|
+
struct dense_assignment_loop_with_device<Kernel, CoreThreadPoolDevice, InnerVectorizedTraversal, InnerUnrolling> {
|
|
226
|
+
using PacketType = typename Kernel::PacketType;
|
|
227
|
+
using DstXprType = typename Kernel::DstEvaluatorType::XprType;
|
|
228
|
+
static constexpr Index XprEvaluationCost = cost_helper<Kernel>::Cost, PacketSize = unpacket_traits<PacketType>::size,
|
|
229
|
+
SrcAlignment = Kernel::AssignmentTraits::SrcAlignment,
|
|
230
|
+
DstAlignment = Kernel::AssignmentTraits::DstAlignment,
|
|
231
|
+
InnerSize = DstXprType::InnerSizeAtCompileTime;
|
|
232
|
+
struct AssignmentFunctor : public Kernel {
|
|
233
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
234
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index outer) {
|
|
235
|
+
copy_using_evaluator_innervec_InnerUnrolling<Kernel, 0, InnerSize, SrcAlignment, DstAlignment>::run(*this, outer);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Kernel& kernel, CoreThreadPoolDevice& device) {
|
|
239
|
+
const Index outerSize = kernel.outerSize();
|
|
240
|
+
constexpr float cost = static_cast<float>(XprEvaluationCost) * static_cast<float>(InnerSize);
|
|
241
|
+
AssignmentFunctor functor(kernel);
|
|
242
|
+
device.template parallelFor<AssignmentFunctor, PacketSize>(0, outerSize, functor, cost);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
template <typename Kernel>
|
|
247
|
+
struct dense_assignment_loop_with_device<Kernel, CoreThreadPoolDevice, SliceVectorizedTraversal, NoUnrolling> {
|
|
248
|
+
using Scalar = typename Kernel::Scalar;
|
|
249
|
+
using PacketType = typename Kernel::PacketType;
|
|
250
|
+
static constexpr Index XprEvaluationCost = cost_helper<Kernel>::Cost, PacketSize = unpacket_traits<PacketType>::size;
|
|
251
|
+
struct PacketAssignmentFunctor : public Kernel {
|
|
252
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketAssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
253
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index outer, Index inner) {
|
|
254
|
+
this->template assignPacketByOuterInner<Unaligned, Unaligned, PacketType>(outer, inner);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
struct ScalarAssignmentFunctor : public Kernel {
|
|
258
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ScalarAssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
259
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index outer) {
|
|
260
|
+
const Index innerSize = this->innerSize();
|
|
261
|
+
const Index packetAccessSize = numext::round_down(innerSize, PacketSize);
|
|
262
|
+
for (Index inner = packetAccessSize; inner < innerSize; inner++) this->assignCoeffByOuterInner(outer, inner);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Kernel& kernel, CoreThreadPoolDevice& device) {
|
|
266
|
+
const Index outerSize = kernel.outerSize();
|
|
267
|
+
const Index innerSize = kernel.innerSize();
|
|
268
|
+
const Index packetAccessSize = numext::round_down(innerSize, PacketSize);
|
|
269
|
+
constexpr float packetCost = static_cast<float>(XprEvaluationCost);
|
|
270
|
+
const float scalarCost = static_cast<float>(XprEvaluationCost) * static_cast<float>(innerSize - packetAccessSize);
|
|
271
|
+
PacketAssignmentFunctor packetFunctor(kernel);
|
|
272
|
+
ScalarAssignmentFunctor scalarFunctor(kernel);
|
|
273
|
+
device.template parallelFor<PacketAssignmentFunctor, PacketSize>(0, outerSize, 0, packetAccessSize, packetFunctor,
|
|
274
|
+
packetCost);
|
|
275
|
+
device.template parallelFor<ScalarAssignmentFunctor, 1>(0, outerSize, scalarFunctor, scalarCost);
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
template <typename Kernel>
|
|
280
|
+
struct dense_assignment_loop_with_device<Kernel, CoreThreadPoolDevice, LinearTraversal, NoUnrolling> {
|
|
281
|
+
static constexpr Index XprEvaluationCost = cost_helper<Kernel>::Cost;
|
|
282
|
+
struct AssignmentFunctor : public Kernel {
|
|
283
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
284
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index index) { this->assignCoeff(index); }
|
|
285
|
+
};
|
|
286
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Kernel& kernel, CoreThreadPoolDevice& device) {
|
|
287
|
+
const Index size = kernel.size();
|
|
288
|
+
constexpr float cost = static_cast<float>(XprEvaluationCost);
|
|
289
|
+
AssignmentFunctor functor(kernel);
|
|
290
|
+
device.template parallelFor<AssignmentFunctor, 1>(0, size, functor, cost);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
template <typename Kernel>
|
|
295
|
+
struct dense_assignment_loop_with_device<Kernel, CoreThreadPoolDevice, LinearVectorizedTraversal, NoUnrolling> {
|
|
296
|
+
using Scalar = typename Kernel::Scalar;
|
|
297
|
+
using PacketType = typename Kernel::PacketType;
|
|
298
|
+
static constexpr Index XprEvaluationCost = cost_helper<Kernel>::Cost,
|
|
299
|
+
RequestedAlignment = Kernel::AssignmentTraits::LinearRequiredAlignment,
|
|
300
|
+
PacketSize = unpacket_traits<PacketType>::size,
|
|
301
|
+
DstIsAligned = Kernel::AssignmentTraits::DstAlignment >= RequestedAlignment,
|
|
302
|
+
DstAlignment = packet_traits<Scalar>::AlignedOnScalar ? RequestedAlignment
|
|
303
|
+
: Kernel::AssignmentTraits::DstAlignment,
|
|
304
|
+
SrcAlignment = Kernel::AssignmentTraits::JointAlignment;
|
|
305
|
+
struct AssignmentFunctor : public Kernel {
|
|
306
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AssignmentFunctor(Kernel& kernel) : Kernel(kernel) {}
|
|
307
|
+
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void operator()(Index index) {
|
|
308
|
+
this->template assignPacket<DstAlignment, SrcAlignment, PacketType>(index);
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
static constexpr bool UsePacketSegment = Kernel::AssignmentTraits::UsePacketSegment;
|
|
312
|
+
using head_loop =
|
|
313
|
+
unaligned_dense_assignment_loop<PacketType, DstAlignment, SrcAlignment, UsePacketSegment, DstIsAligned>;
|
|
314
|
+
using tail_loop = unaligned_dense_assignment_loop<PacketType, DstAlignment, SrcAlignment, UsePacketSegment, false>;
|
|
315
|
+
|
|
316
|
+
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Kernel& kernel, CoreThreadPoolDevice& device) {
|
|
317
|
+
const Index size = kernel.size();
|
|
318
|
+
const Index alignedStart =
|
|
319
|
+
DstIsAligned ? 0 : internal::first_aligned<RequestedAlignment>(kernel.dstDataPtr(), size);
|
|
320
|
+
const Index alignedEnd = alignedStart + numext::round_down(size - alignedStart, PacketSize);
|
|
321
|
+
|
|
322
|
+
head_loop::run(kernel, 0, alignedStart);
|
|
323
|
+
|
|
324
|
+
constexpr float cost = static_cast<float>(XprEvaluationCost);
|
|
325
|
+
AssignmentFunctor functor(kernel);
|
|
326
|
+
device.template parallelFor<AssignmentFunctor, PacketSize>(alignedStart, alignedEnd, functor, cost);
|
|
327
|
+
|
|
328
|
+
tail_loop::run(kernel, alignedEnd, size);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
} // namespace internal
|
|
333
|
+
|
|
334
|
+
} // namespace Eigen
|
|
335
|
+
|
|
336
|
+
#endif // EIGEN_CORE_THREAD_POOL_DEVICE_H
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// This file is part of Eigen, a lightweight C++ template library
|
|
2
|
+
// for linear algebra.
|
|
3
|
+
//
|
|
4
|
+
// Copyright (C) 2016 Dmitry Vyukov <dvyukov@google.com>
|
|
5
|
+
//
|
|
6
|
+
// This Source Code Form is subject to the terms of the Mozilla
|
|
7
|
+
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
8
|
+
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
9
|
+
|
|
10
|
+
#ifndef EIGEN_CXX11_THREADPOOL_EVENTCOUNT_H
|
|
11
|
+
#define EIGEN_CXX11_THREADPOOL_EVENTCOUNT_H
|
|
12
|
+
|
|
13
|
+
// IWYU pragma: private
|
|
14
|
+
#include "./InternalHeaderCheck.h"
|
|
15
|
+
|
|
16
|
+
namespace Eigen {
|
|
17
|
+
|
|
18
|
+
// EventCount allows to wait for arbitrary predicates in non-blocking
|
|
19
|
+
// algorithms. Think of condition variable, but wait predicate does not need to
|
|
20
|
+
// be protected by a mutex. Usage:
|
|
21
|
+
// Waiting thread does:
|
|
22
|
+
//
|
|
23
|
+
// if (predicate)
|
|
24
|
+
// return act();
|
|
25
|
+
// EventCount::Waiter& w = waiters[my_index];
|
|
26
|
+
// ec.Prewait(&w);
|
|
27
|
+
// if (predicate) {
|
|
28
|
+
// ec.CancelWait(&w);
|
|
29
|
+
// return act();
|
|
30
|
+
// }
|
|
31
|
+
// ec.CommitWait(&w);
|
|
32
|
+
//
|
|
33
|
+
// Notifying thread does:
|
|
34
|
+
//
|
|
35
|
+
// predicate = true;
|
|
36
|
+
// ec.Notify(true);
|
|
37
|
+
//
|
|
38
|
+
// Notify is cheap if there are no waiting threads. Prewait/CommitWait are not
|
|
39
|
+
// cheap, but they are executed only if the preceding predicate check has
|
|
40
|
+
// failed.
|
|
41
|
+
//
|
|
42
|
+
// Algorithm outline:
|
|
43
|
+
// There are two main variables: predicate (managed by user) and state_.
|
|
44
|
+
// Operation closely resembles Dekker mutual algorithm:
|
|
45
|
+
// https://en.wikipedia.org/wiki/Dekker%27s_algorithm
|
|
46
|
+
// Waiting thread sets state_ then checks predicate, Notifying thread sets
|
|
47
|
+
// predicate then checks state_. Due to seq_cst fences in between these
|
|
48
|
+
// operations it is guaranteed than either waiter will see predicate change
|
|
49
|
+
// and won't block, or notifying thread will see state_ change and will unblock
|
|
50
|
+
// the waiter, or both. But it can't happen that both threads don't see each
|
|
51
|
+
// other changes, which would lead to deadlock.
|
|
52
|
+
class EventCount {
|
|
53
|
+
public:
|
|
54
|
+
class Waiter;
|
|
55
|
+
|
|
56
|
+
EventCount(MaxSizeVector<Waiter>& waiters) : state_(kStackMask), waiters_(waiters) {
|
|
57
|
+
eigen_plain_assert(waiters.size() < (1 << kWaiterBits) - 1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
EventCount(const EventCount&) = delete;
|
|
61
|
+
void operator=(const EventCount&) = delete;
|
|
62
|
+
|
|
63
|
+
~EventCount() {
|
|
64
|
+
// Ensure there are no waiters.
|
|
65
|
+
eigen_plain_assert(state_.load() == kStackMask);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Prewait prepares for waiting.
|
|
69
|
+
// After calling Prewait, the thread must re-check the wait predicate
|
|
70
|
+
// and then call either CancelWait or CommitWait.
|
|
71
|
+
void Prewait() {
|
|
72
|
+
uint64_t state = state_.load(std::memory_order_relaxed);
|
|
73
|
+
for (;;) {
|
|
74
|
+
CheckState(state);
|
|
75
|
+
uint64_t newstate = state + kWaiterInc;
|
|
76
|
+
CheckState(newstate);
|
|
77
|
+
if (state_.compare_exchange_weak(state, newstate, std::memory_order_seq_cst)) return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// CommitWait commits waiting after Prewait.
|
|
82
|
+
void CommitWait(Waiter* w) {
|
|
83
|
+
eigen_plain_assert((w->epoch & ~kEpochMask) == 0);
|
|
84
|
+
w->state = Waiter::kNotSignaled;
|
|
85
|
+
const uint64_t me = (w - &waiters_[0]) | w->epoch;
|
|
86
|
+
uint64_t state = state_.load(std::memory_order_seq_cst);
|
|
87
|
+
for (;;) {
|
|
88
|
+
CheckState(state, true);
|
|
89
|
+
uint64_t newstate;
|
|
90
|
+
if ((state & kSignalMask) != 0) {
|
|
91
|
+
// Consume the signal and return immediately.
|
|
92
|
+
newstate = state - kWaiterInc - kSignalInc;
|
|
93
|
+
} else {
|
|
94
|
+
// Remove this thread from pre-wait counter and add to the waiter stack.
|
|
95
|
+
newstate = ((state & kWaiterMask) - kWaiterInc) | me;
|
|
96
|
+
w->next.store(state & (kStackMask | kEpochMask), std::memory_order_relaxed);
|
|
97
|
+
}
|
|
98
|
+
CheckState(newstate);
|
|
99
|
+
if (state_.compare_exchange_weak(state, newstate, std::memory_order_acq_rel)) {
|
|
100
|
+
if ((state & kSignalMask) == 0) {
|
|
101
|
+
w->epoch += kEpochInc;
|
|
102
|
+
Park(w);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// CancelWait cancels effects of the previous Prewait call.
|
|
110
|
+
void CancelWait() {
|
|
111
|
+
uint64_t state = state_.load(std::memory_order_relaxed);
|
|
112
|
+
for (;;) {
|
|
113
|
+
CheckState(state, true);
|
|
114
|
+
uint64_t newstate = state - kWaiterInc;
|
|
115
|
+
// We don't know if the thread was also notified or not,
|
|
116
|
+
// so we should not consume a signal unconditionally.
|
|
117
|
+
// Only if number of waiters is equal to number of signals,
|
|
118
|
+
// we know that the thread was notified and we must take away the signal.
|
|
119
|
+
if (((state & kWaiterMask) >> kWaiterShift) == ((state & kSignalMask) >> kSignalShift)) newstate -= kSignalInc;
|
|
120
|
+
CheckState(newstate);
|
|
121
|
+
if (state_.compare_exchange_weak(state, newstate, std::memory_order_acq_rel)) return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Notify wakes one or all waiting threads.
|
|
126
|
+
// Must be called after changing the associated wait predicate.
|
|
127
|
+
void Notify(bool notifyAll) {
|
|
128
|
+
std::atomic_thread_fence(std::memory_order_seq_cst);
|
|
129
|
+
uint64_t state = state_.load(std::memory_order_acquire);
|
|
130
|
+
for (;;) {
|
|
131
|
+
CheckState(state);
|
|
132
|
+
const uint64_t waiters = (state & kWaiterMask) >> kWaiterShift;
|
|
133
|
+
const uint64_t signals = (state & kSignalMask) >> kSignalShift;
|
|
134
|
+
// Easy case: no waiters.
|
|
135
|
+
if ((state & kStackMask) == kStackMask && waiters == signals) return;
|
|
136
|
+
uint64_t newstate;
|
|
137
|
+
if (notifyAll) {
|
|
138
|
+
// Empty wait stack and set signal to number of pre-wait threads.
|
|
139
|
+
newstate = (state & kWaiterMask) | (waiters << kSignalShift) | kStackMask;
|
|
140
|
+
} else if (signals < waiters) {
|
|
141
|
+
// There is a thread in pre-wait state, unblock it.
|
|
142
|
+
newstate = state + kSignalInc;
|
|
143
|
+
} else {
|
|
144
|
+
// Pop a waiter from list and unpark it.
|
|
145
|
+
Waiter* w = &waiters_[state & kStackMask];
|
|
146
|
+
uint64_t next = w->next.load(std::memory_order_relaxed);
|
|
147
|
+
newstate = (state & (kWaiterMask | kSignalMask)) | next;
|
|
148
|
+
}
|
|
149
|
+
CheckState(newstate);
|
|
150
|
+
if (state_.compare_exchange_weak(state, newstate, std::memory_order_acq_rel)) {
|
|
151
|
+
if (!notifyAll && (signals < waiters)) return; // unblocked pre-wait thread
|
|
152
|
+
if ((state & kStackMask) == kStackMask) return;
|
|
153
|
+
Waiter* w = &waiters_[state & kStackMask];
|
|
154
|
+
if (!notifyAll) w->next.store(kStackMask, std::memory_order_relaxed);
|
|
155
|
+
Unpark(w);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private:
|
|
162
|
+
// State_ layout:
|
|
163
|
+
// - low kWaiterBits is a stack of waiters committed wait
|
|
164
|
+
// (indexes in waiters_ array are used as stack elements,
|
|
165
|
+
// kStackMask means empty stack).
|
|
166
|
+
// - next kWaiterBits is count of waiters in prewait state.
|
|
167
|
+
// - next kWaiterBits is count of pending signals.
|
|
168
|
+
// - remaining bits are ABA counter for the stack.
|
|
169
|
+
// (stored in Waiter node and incremented on push).
|
|
170
|
+
static const uint64_t kWaiterBits = 14;
|
|
171
|
+
static const uint64_t kStackMask = (1ull << kWaiterBits) - 1;
|
|
172
|
+
static const uint64_t kWaiterShift = kWaiterBits;
|
|
173
|
+
static const uint64_t kWaiterMask = ((1ull << kWaiterBits) - 1) << kWaiterShift;
|
|
174
|
+
static const uint64_t kWaiterInc = 1ull << kWaiterShift;
|
|
175
|
+
static const uint64_t kSignalShift = 2 * kWaiterBits;
|
|
176
|
+
static const uint64_t kSignalMask = ((1ull << kWaiterBits) - 1) << kSignalShift;
|
|
177
|
+
static const uint64_t kSignalInc = 1ull << kSignalShift;
|
|
178
|
+
static const uint64_t kEpochShift = 3 * kWaiterBits;
|
|
179
|
+
static const uint64_t kEpochBits = 64 - kEpochShift;
|
|
180
|
+
static const uint64_t kEpochMask = ((1ull << kEpochBits) - 1) << kEpochShift;
|
|
181
|
+
static const uint64_t kEpochInc = 1ull << kEpochShift;
|
|
182
|
+
|
|
183
|
+
public:
|
|
184
|
+
class Waiter {
|
|
185
|
+
friend class EventCount;
|
|
186
|
+
|
|
187
|
+
enum State {
|
|
188
|
+
kNotSignaled,
|
|
189
|
+
kWaiting,
|
|
190
|
+
kSignaled,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
EIGEN_ALIGN_TO_AVOID_FALSE_SHARING std::atomic<uint64_t> next{kStackMask};
|
|
194
|
+
EIGEN_MUTEX mu;
|
|
195
|
+
EIGEN_CONDVAR cv;
|
|
196
|
+
uint64_t epoch{0};
|
|
197
|
+
unsigned state{kNotSignaled};
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
private:
|
|
201
|
+
static void CheckState(uint64_t state, bool waiter = false) {
|
|
202
|
+
static_assert(kEpochBits >= 20, "not enough bits to prevent ABA problem");
|
|
203
|
+
const uint64_t waiters = (state & kWaiterMask) >> kWaiterShift;
|
|
204
|
+
const uint64_t signals = (state & kSignalMask) >> kSignalShift;
|
|
205
|
+
eigen_plain_assert(waiters >= signals);
|
|
206
|
+
eigen_plain_assert(waiters < (1 << kWaiterBits) - 1);
|
|
207
|
+
eigen_plain_assert(!waiter || waiters > 0);
|
|
208
|
+
(void)waiters;
|
|
209
|
+
(void)signals;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
void Park(Waiter* w) {
|
|
213
|
+
EIGEN_MUTEX_LOCK lock(w->mu);
|
|
214
|
+
while (w->state != Waiter::kSignaled) {
|
|
215
|
+
w->state = Waiter::kWaiting;
|
|
216
|
+
w->cv.wait(lock);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void Unpark(Waiter* w) {
|
|
221
|
+
for (Waiter* next; w; w = next) {
|
|
222
|
+
uint64_t wnext = w->next.load(std::memory_order_relaxed) & kStackMask;
|
|
223
|
+
next = wnext == kStackMask ? nullptr : &waiters_[internal::convert_index<size_t>(wnext)];
|
|
224
|
+
unsigned state;
|
|
225
|
+
{
|
|
226
|
+
EIGEN_MUTEX_LOCK lock(w->mu);
|
|
227
|
+
state = w->state;
|
|
228
|
+
w->state = Waiter::kSignaled;
|
|
229
|
+
}
|
|
230
|
+
// Avoid notifying if it wasn't waiting.
|
|
231
|
+
if (state == Waiter::kWaiting) w->cv.notify_one();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
std::atomic<uint64_t> state_;
|
|
236
|
+
MaxSizeVector<Waiter>& waiters_;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
} // namespace Eigen
|
|
240
|
+
|
|
241
|
+
#endif // EIGEN_CXX11_THREADPOOL_EVENTCOUNT_H
|