tomoto 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (347) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +8 -10
  4. data/ext/tomoto/extconf.rb +6 -2
  5. data/ext/tomoto/{ext.cpp → tomoto.cpp} +1 -1
  6. data/lib/tomoto/version.rb +1 -1
  7. data/lib/tomoto.rb +5 -1
  8. data/vendor/EigenRand/EigenRand/Core.h +10 -10
  9. data/vendor/EigenRand/EigenRand/Dists/Basic.h +208 -9
  10. data/vendor/EigenRand/EigenRand/Dists/Discrete.h +52 -31
  11. data/vendor/EigenRand/EigenRand/Dists/GammaPoisson.h +9 -8
  12. data/vendor/EigenRand/EigenRand/Dists/NormalExp.h +28 -21
  13. data/vendor/EigenRand/EigenRand/EigenRand +11 -6
  14. data/vendor/EigenRand/EigenRand/Macro.h +13 -7
  15. data/vendor/EigenRand/EigenRand/MorePacketMath.h +348 -740
  16. data/vendor/EigenRand/EigenRand/MvDists/Multinomial.h +5 -3
  17. data/vendor/EigenRand/EigenRand/MvDists/MvNormal.h +9 -3
  18. data/vendor/EigenRand/EigenRand/PacketFilter.h +11 -253
  19. data/vendor/EigenRand/EigenRand/PacketRandomEngine.h +21 -47
  20. data/vendor/EigenRand/EigenRand/RandUtils.h +50 -344
  21. data/vendor/EigenRand/EigenRand/arch/AVX/MorePacketMath.h +619 -0
  22. data/vendor/EigenRand/EigenRand/arch/AVX/PacketFilter.h +149 -0
  23. data/vendor/EigenRand/EigenRand/arch/AVX/RandUtils.h +228 -0
  24. data/vendor/EigenRand/EigenRand/arch/NEON/MorePacketMath.h +473 -0
  25. data/vendor/EigenRand/EigenRand/arch/NEON/PacketFilter.h +142 -0
  26. data/vendor/EigenRand/EigenRand/arch/NEON/RandUtils.h +126 -0
  27. data/vendor/EigenRand/EigenRand/arch/SSE/MorePacketMath.h +501 -0
  28. data/vendor/EigenRand/EigenRand/arch/SSE/PacketFilter.h +133 -0
  29. data/vendor/EigenRand/EigenRand/arch/SSE/RandUtils.h +120 -0
  30. data/vendor/EigenRand/EigenRand/doc.h +24 -12
  31. data/vendor/EigenRand/README.md +57 -4
  32. data/vendor/eigen/COPYING.APACHE +203 -0
  33. data/vendor/eigen/COPYING.BSD +1 -1
  34. data/vendor/eigen/COPYING.MINPACK +51 -52
  35. data/vendor/eigen/Eigen/Cholesky +0 -1
  36. data/vendor/eigen/Eigen/Core +112 -265
  37. data/vendor/eigen/Eigen/Eigenvalues +2 -3
  38. data/vendor/eigen/Eigen/Geometry +5 -8
  39. data/vendor/eigen/Eigen/Householder +0 -1
  40. data/vendor/eigen/Eigen/Jacobi +0 -1
  41. data/vendor/eigen/Eigen/KLUSupport +41 -0
  42. data/vendor/eigen/Eigen/LU +2 -5
  43. data/vendor/eigen/Eigen/OrderingMethods +0 -3
  44. data/vendor/eigen/Eigen/PaStiXSupport +1 -0
  45. data/vendor/eigen/Eigen/PardisoSupport +0 -0
  46. data/vendor/eigen/Eigen/QR +2 -3
  47. data/vendor/eigen/Eigen/QtAlignedMalloc +0 -1
  48. data/vendor/eigen/Eigen/SVD +0 -1
  49. data/vendor/eigen/Eigen/Sparse +0 -2
  50. data/vendor/eigen/Eigen/SparseCholesky +0 -8
  51. data/vendor/eigen/Eigen/SparseLU +4 -0
  52. data/vendor/eigen/Eigen/SparseQR +0 -1
  53. data/vendor/eigen/Eigen/src/Cholesky/LDLT.h +42 -27
  54. data/vendor/eigen/Eigen/src/Cholesky/LLT.h +39 -23
  55. data/vendor/eigen/Eigen/src/CholmodSupport/CholmodSupport.h +90 -47
  56. data/vendor/eigen/Eigen/src/Core/ArithmeticSequence.h +413 -0
  57. data/vendor/eigen/Eigen/src/Core/Array.h +99 -11
  58. data/vendor/eigen/Eigen/src/Core/ArrayBase.h +3 -3
  59. data/vendor/eigen/Eigen/src/Core/ArrayWrapper.h +21 -21
  60. data/vendor/eigen/Eigen/src/Core/Assign.h +1 -1
  61. data/vendor/eigen/Eigen/src/Core/AssignEvaluator.h +125 -50
  62. data/vendor/eigen/Eigen/src/Core/Assign_MKL.h +10 -10
  63. data/vendor/eigen/Eigen/src/Core/BandMatrix.h +16 -16
  64. data/vendor/eigen/Eigen/src/Core/Block.h +56 -60
  65. data/vendor/eigen/Eigen/src/Core/BooleanRedux.h +29 -31
  66. data/vendor/eigen/Eigen/src/Core/CommaInitializer.h +7 -3
  67. data/vendor/eigen/Eigen/src/Core/CoreEvaluators.h +325 -272
  68. data/vendor/eigen/Eigen/src/Core/CoreIterators.h +5 -0
  69. data/vendor/eigen/Eigen/src/Core/CwiseBinaryOp.h +21 -22
  70. data/vendor/eigen/Eigen/src/Core/CwiseNullaryOp.h +153 -18
  71. data/vendor/eigen/Eigen/src/Core/CwiseUnaryOp.h +6 -6
  72. data/vendor/eigen/Eigen/src/Core/CwiseUnaryView.h +14 -10
  73. data/vendor/eigen/Eigen/src/Core/DenseBase.h +132 -42
  74. data/vendor/eigen/Eigen/src/Core/DenseCoeffsBase.h +25 -21
  75. data/vendor/eigen/Eigen/src/Core/DenseStorage.h +153 -71
  76. data/vendor/eigen/Eigen/src/Core/Diagonal.h +21 -23
  77. data/vendor/eigen/Eigen/src/Core/DiagonalMatrix.h +50 -2
  78. data/vendor/eigen/Eigen/src/Core/DiagonalProduct.h +1 -1
  79. data/vendor/eigen/Eigen/src/Core/Dot.h +10 -10
  80. data/vendor/eigen/Eigen/src/Core/EigenBase.h +10 -9
  81. data/vendor/eigen/Eigen/src/Core/ForceAlignedAccess.h +8 -4
  82. data/vendor/eigen/Eigen/src/Core/Fuzzy.h +3 -3
  83. data/vendor/eigen/Eigen/src/Core/GeneralProduct.h +20 -10
  84. data/vendor/eigen/Eigen/src/Core/GenericPacketMath.h +599 -152
  85. data/vendor/eigen/Eigen/src/Core/GlobalFunctions.h +40 -33
  86. data/vendor/eigen/Eigen/src/Core/IO.h +40 -7
  87. data/vendor/eigen/Eigen/src/Core/IndexedView.h +237 -0
  88. data/vendor/eigen/Eigen/src/Core/Inverse.h +9 -10
  89. data/vendor/eigen/Eigen/src/Core/Map.h +7 -7
  90. data/vendor/eigen/Eigen/src/Core/MapBase.h +10 -3
  91. data/vendor/eigen/Eigen/src/Core/MathFunctions.h +767 -125
  92. data/vendor/eigen/Eigen/src/Core/MathFunctionsImpl.h +118 -19
  93. data/vendor/eigen/Eigen/src/Core/Matrix.h +131 -25
  94. data/vendor/eigen/Eigen/src/Core/MatrixBase.h +21 -3
  95. data/vendor/eigen/Eigen/src/Core/NestByValue.h +25 -50
  96. data/vendor/eigen/Eigen/src/Core/NoAlias.h +4 -3
  97. data/vendor/eigen/Eigen/src/Core/NumTraits.h +107 -20
  98. data/vendor/eigen/Eigen/src/Core/PartialReduxEvaluator.h +232 -0
  99. data/vendor/eigen/Eigen/src/Core/PermutationMatrix.h +3 -31
  100. data/vendor/eigen/Eigen/src/Core/PlainObjectBase.h +152 -59
  101. data/vendor/eigen/Eigen/src/Core/Product.h +30 -25
  102. data/vendor/eigen/Eigen/src/Core/ProductEvaluators.h +192 -125
  103. data/vendor/eigen/Eigen/src/Core/Random.h +37 -1
  104. data/vendor/eigen/Eigen/src/Core/Redux.h +180 -170
  105. data/vendor/eigen/Eigen/src/Core/Ref.h +121 -23
  106. data/vendor/eigen/Eigen/src/Core/Replicate.h +8 -8
  107. data/vendor/eigen/Eigen/src/Core/Reshaped.h +454 -0
  108. data/vendor/eigen/Eigen/src/Core/ReturnByValue.h +7 -5
  109. data/vendor/eigen/Eigen/src/Core/Reverse.h +18 -12
  110. data/vendor/eigen/Eigen/src/Core/Select.h +8 -6
  111. data/vendor/eigen/Eigen/src/Core/SelfAdjointView.h +33 -20
  112. data/vendor/eigen/Eigen/src/Core/Solve.h +14 -14
  113. data/vendor/eigen/Eigen/src/Core/SolveTriangular.h +16 -16
  114. data/vendor/eigen/Eigen/src/Core/SolverBase.h +41 -3
  115. data/vendor/eigen/Eigen/src/Core/StableNorm.h +100 -70
  116. data/vendor/eigen/Eigen/src/Core/StlIterators.h +463 -0
  117. data/vendor/eigen/Eigen/src/Core/Stride.h +9 -4
  118. data/vendor/eigen/Eigen/src/Core/Swap.h +5 -4
  119. data/vendor/eigen/Eigen/src/Core/Transpose.h +88 -27
  120. data/vendor/eigen/Eigen/src/Core/Transpositions.h +26 -47
  121. data/vendor/eigen/Eigen/src/Core/TriangularMatrix.h +93 -75
  122. data/vendor/eigen/Eigen/src/Core/VectorBlock.h +5 -5
  123. data/vendor/eigen/Eigen/src/Core/VectorwiseOp.h +159 -70
  124. data/vendor/eigen/Eigen/src/Core/Visitor.h +137 -29
  125. data/vendor/eigen/Eigen/src/Core/arch/AVX/Complex.h +50 -129
  126. data/vendor/eigen/Eigen/src/Core/arch/AVX/MathFunctions.h +126 -337
  127. data/vendor/eigen/Eigen/src/Core/arch/AVX/PacketMath.h +1092 -155
  128. data/vendor/eigen/Eigen/src/Core/arch/AVX/TypeCasting.h +65 -1
  129. data/vendor/eigen/Eigen/src/Core/arch/AVX512/Complex.h +422 -0
  130. data/vendor/eigen/Eigen/src/Core/arch/AVX512/MathFunctions.h +207 -236
  131. data/vendor/eigen/Eigen/src/Core/arch/AVX512/PacketMath.h +1482 -495
  132. data/vendor/eigen/Eigen/src/Core/arch/AVX512/TypeCasting.h +89 -0
  133. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/Complex.h +152 -165
  134. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MathFunctions.h +19 -251
  135. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MatrixProduct.h +2937 -0
  136. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductCommon.h +221 -0
  137. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/MatrixProductMMA.h +629 -0
  138. data/vendor/eigen/Eigen/src/Core/arch/AltiVec/PacketMath.h +2042 -392
  139. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Complex.h +235 -80
  140. data/vendor/eigen/Eigen/src/Core/arch/Default/BFloat16.h +700 -0
  141. data/vendor/eigen/Eigen/src/Core/arch/Default/ConjHelper.h +102 -14
  142. data/vendor/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +1649 -0
  143. data/vendor/eigen/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h +110 -0
  144. data/vendor/eigen/Eigen/src/Core/arch/Default/Half.h +942 -0
  145. data/vendor/eigen/Eigen/src/Core/arch/Default/Settings.h +1 -1
  146. data/vendor/eigen/Eigen/src/Core/arch/Default/TypeCasting.h +120 -0
  147. data/vendor/eigen/Eigen/src/Core/arch/{CUDA → GPU}/MathFunctions.h +16 -4
  148. data/vendor/eigen/Eigen/src/Core/arch/GPU/PacketMath.h +1685 -0
  149. data/vendor/eigen/Eigen/src/Core/arch/GPU/TypeCasting.h +80 -0
  150. data/vendor/eigen/Eigen/src/Core/arch/HIP/hcc/math_constants.h +23 -0
  151. data/vendor/eigen/Eigen/src/Core/arch/MSA/Complex.h +648 -0
  152. data/vendor/eigen/Eigen/src/Core/arch/MSA/MathFunctions.h +387 -0
  153. data/vendor/eigen/Eigen/src/Core/arch/MSA/PacketMath.h +1233 -0
  154. data/vendor/eigen/Eigen/src/Core/arch/NEON/Complex.h +313 -219
  155. data/vendor/eigen/Eigen/src/Core/arch/NEON/GeneralBlockPanelKernel.h +183 -0
  156. data/vendor/eigen/Eigen/src/Core/arch/NEON/MathFunctions.h +54 -70
  157. data/vendor/eigen/Eigen/src/Core/arch/NEON/PacketMath.h +4376 -549
  158. data/vendor/eigen/Eigen/src/Core/arch/NEON/TypeCasting.h +1419 -0
  159. data/vendor/eigen/Eigen/src/Core/arch/SSE/Complex.h +59 -179
  160. data/vendor/eigen/Eigen/src/Core/arch/SSE/MathFunctions.h +65 -428
  161. data/vendor/eigen/Eigen/src/Core/arch/SSE/PacketMath.h +893 -283
  162. data/vendor/eigen/Eigen/src/Core/arch/SSE/TypeCasting.h +65 -0
  163. data/vendor/eigen/Eigen/src/Core/arch/SVE/MathFunctions.h +44 -0
  164. data/vendor/eigen/Eigen/src/Core/arch/SVE/PacketMath.h +752 -0
  165. data/vendor/eigen/Eigen/src/Core/arch/SVE/TypeCasting.h +49 -0
  166. data/vendor/eigen/Eigen/src/Core/arch/SYCL/InteropHeaders.h +232 -0
  167. data/vendor/eigen/Eigen/src/Core/arch/SYCL/MathFunctions.h +301 -0
  168. data/vendor/eigen/Eigen/src/Core/arch/SYCL/PacketMath.h +670 -0
  169. data/vendor/eigen/Eigen/src/Core/arch/SYCL/SyclMemoryModel.h +694 -0
  170. data/vendor/eigen/Eigen/src/Core/arch/SYCL/TypeCasting.h +85 -0
  171. data/vendor/eigen/Eigen/src/Core/arch/ZVector/Complex.h +212 -183
  172. data/vendor/eigen/Eigen/src/Core/arch/ZVector/MathFunctions.h +101 -5
  173. data/vendor/eigen/Eigen/src/Core/arch/ZVector/PacketMath.h +510 -395
  174. data/vendor/eigen/Eigen/src/Core/functors/AssignmentFunctors.h +11 -2
  175. data/vendor/eigen/Eigen/src/Core/functors/BinaryFunctors.h +112 -46
  176. data/vendor/eigen/Eigen/src/Core/functors/NullaryFunctors.h +31 -30
  177. data/vendor/eigen/Eigen/src/Core/functors/StlFunctors.h +32 -2
  178. data/vendor/eigen/Eigen/src/Core/functors/UnaryFunctors.h +355 -16
  179. data/vendor/eigen/Eigen/src/Core/products/GeneralBlockPanelKernel.h +1075 -586
  180. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix.h +49 -24
  181. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +41 -35
  182. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_BLAS.h +6 -6
  183. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixMatrix_BLAS.h +4 -2
  184. data/vendor/eigen/Eigen/src/Core/products/GeneralMatrixVector.h +382 -483
  185. data/vendor/eigen/Eigen/src/Core/products/Parallelizer.h +22 -5
  186. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +53 -30
  187. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixMatrix_BLAS.h +16 -8
  188. data/vendor/eigen/Eigen/src/Core/products/SelfadjointMatrixVector.h +8 -6
  189. data/vendor/eigen/Eigen/src/Core/products/SelfadjointProduct.h +4 -4
  190. data/vendor/eigen/Eigen/src/Core/products/SelfadjointRank2Update.h +5 -4
  191. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix.h +33 -27
  192. data/vendor/eigen/Eigen/src/Core/products/TriangularMatrixMatrix_BLAS.h +14 -12
  193. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix.h +36 -34
  194. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverMatrix_BLAS.h +8 -4
  195. data/vendor/eigen/Eigen/src/Core/products/TriangularSolverVector.h +13 -10
  196. data/vendor/eigen/Eigen/src/Core/util/BlasUtil.h +304 -119
  197. data/vendor/eigen/Eigen/src/Core/util/ConfigureVectorization.h +512 -0
  198. data/vendor/eigen/Eigen/src/Core/util/Constants.h +25 -9
  199. data/vendor/eigen/Eigen/src/Core/util/DisableStupidWarnings.h +26 -3
  200. data/vendor/eigen/Eigen/src/Core/util/ForwardDeclarations.h +29 -9
  201. data/vendor/eigen/Eigen/src/Core/util/IndexedViewHelper.h +186 -0
  202. data/vendor/eigen/Eigen/src/Core/util/IntegralConstant.h +272 -0
  203. data/vendor/eigen/Eigen/src/Core/util/MKL_support.h +8 -1
  204. data/vendor/eigen/Eigen/src/Core/util/Macros.h +709 -246
  205. data/vendor/eigen/Eigen/src/Core/util/Memory.h +222 -52
  206. data/vendor/eigen/Eigen/src/Core/util/Meta.h +355 -77
  207. data/vendor/eigen/Eigen/src/Core/util/ReenableStupidWarnings.h +5 -1
  208. data/vendor/eigen/Eigen/src/Core/util/ReshapedHelper.h +51 -0
  209. data/vendor/eigen/Eigen/src/Core/util/StaticAssert.h +8 -5
  210. data/vendor/eigen/Eigen/src/Core/util/SymbolicIndex.h +293 -0
  211. data/vendor/eigen/Eigen/src/Core/util/XprHelper.h +65 -30
  212. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexEigenSolver.h +1 -1
  213. data/vendor/eigen/Eigen/src/Eigenvalues/ComplexSchur.h +7 -4
  214. data/vendor/eigen/Eigen/src/Eigenvalues/EigenSolver.h +2 -2
  215. data/vendor/eigen/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +1 -1
  216. data/vendor/eigen/Eigen/src/Eigenvalues/HessenbergDecomposition.h +2 -2
  217. data/vendor/eigen/Eigen/src/Eigenvalues/MatrixBaseEigenvalues.h +2 -2
  218. data/vendor/eigen/Eigen/src/Eigenvalues/RealQZ.h +9 -6
  219. data/vendor/eigen/Eigen/src/Eigenvalues/RealSchur.h +21 -9
  220. data/vendor/eigen/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +77 -43
  221. data/vendor/eigen/Eigen/src/Eigenvalues/Tridiagonalization.h +20 -15
  222. data/vendor/eigen/Eigen/src/Geometry/AlignedBox.h +99 -5
  223. data/vendor/eigen/Eigen/src/Geometry/AngleAxis.h +4 -4
  224. data/vendor/eigen/Eigen/src/Geometry/EulerAngles.h +3 -3
  225. data/vendor/eigen/Eigen/src/Geometry/Homogeneous.h +15 -11
  226. data/vendor/eigen/Eigen/src/Geometry/Hyperplane.h +1 -1
  227. data/vendor/eigen/Eigen/src/Geometry/OrthoMethods.h +3 -2
  228. data/vendor/eigen/Eigen/src/Geometry/ParametrizedLine.h +39 -2
  229. data/vendor/eigen/Eigen/src/Geometry/Quaternion.h +70 -14
  230. data/vendor/eigen/Eigen/src/Geometry/Rotation2D.h +3 -3
  231. data/vendor/eigen/Eigen/src/Geometry/Scaling.h +23 -5
  232. data/vendor/eigen/Eigen/src/Geometry/Transform.h +88 -67
  233. data/vendor/eigen/Eigen/src/Geometry/Translation.h +6 -12
  234. data/vendor/eigen/Eigen/src/Geometry/Umeyama.h +1 -1
  235. data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SIMD.h +168 -0
  236. data/vendor/eigen/Eigen/src/Householder/BlockHouseholder.h +9 -2
  237. data/vendor/eigen/Eigen/src/Householder/Householder.h +8 -4
  238. data/vendor/eigen/Eigen/src/Householder/HouseholderSequence.h +123 -48
  239. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +15 -15
  240. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +7 -23
  241. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +5 -22
  242. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteCholesky.h +41 -47
  243. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +51 -60
  244. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +70 -20
  245. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/LeastSquareConjugateGradient.h +2 -20
  246. data/vendor/eigen/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +11 -9
  247. data/vendor/eigen/Eigen/src/Jacobi/Jacobi.h +31 -10
  248. data/vendor/eigen/Eigen/src/KLUSupport/KLUSupport.h +358 -0
  249. data/vendor/eigen/Eigen/src/LU/Determinant.h +35 -19
  250. data/vendor/eigen/Eigen/src/LU/FullPivLU.h +29 -43
  251. data/vendor/eigen/Eigen/src/LU/InverseImpl.h +25 -8
  252. data/vendor/eigen/Eigen/src/LU/PartialPivLU.h +71 -58
  253. data/vendor/eigen/Eigen/src/LU/arch/InverseSize4.h +351 -0
  254. data/vendor/eigen/Eigen/src/OrderingMethods/Amd.h +7 -17
  255. data/vendor/eigen/Eigen/src/OrderingMethods/Eigen_Colamd.h +297 -277
  256. data/vendor/eigen/Eigen/src/OrderingMethods/Ordering.h +6 -10
  257. data/vendor/eigen/Eigen/src/PaStiXSupport/PaStiXSupport.h +1 -1
  258. data/vendor/eigen/Eigen/src/PardisoSupport/PardisoSupport.h +9 -7
  259. data/vendor/eigen/Eigen/src/QR/ColPivHouseholderQR.h +41 -20
  260. data/vendor/eigen/Eigen/src/QR/CompleteOrthogonalDecomposition.h +100 -27
  261. data/vendor/eigen/Eigen/src/QR/FullPivHouseholderQR.h +59 -22
  262. data/vendor/eigen/Eigen/src/QR/HouseholderQR.h +48 -23
  263. data/vendor/eigen/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +25 -3
  264. data/vendor/eigen/Eigen/src/SVD/BDCSVD.h +183 -63
  265. data/vendor/eigen/Eigen/src/SVD/JacobiSVD.h +22 -14
  266. data/vendor/eigen/Eigen/src/SVD/SVDBase.h +83 -22
  267. data/vendor/eigen/Eigen/src/SVD/UpperBidiagonalization.h +3 -3
  268. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky.h +17 -9
  269. data/vendor/eigen/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +12 -37
  270. data/vendor/eigen/Eigen/src/SparseCore/AmbiVector.h +3 -2
  271. data/vendor/eigen/Eigen/src/SparseCore/CompressedStorage.h +16 -0
  272. data/vendor/eigen/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +6 -6
  273. data/vendor/eigen/Eigen/src/SparseCore/SparseAssign.h +81 -27
  274. data/vendor/eigen/Eigen/src/SparseCore/SparseBlock.h +25 -57
  275. data/vendor/eigen/Eigen/src/SparseCore/SparseCompressedBase.h +40 -11
  276. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +11 -15
  277. data/vendor/eigen/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +4 -2
  278. data/vendor/eigen/Eigen/src/SparseCore/SparseDenseProduct.h +30 -8
  279. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrix.h +126 -11
  280. data/vendor/eigen/Eigen/src/SparseCore/SparseMatrixBase.h +5 -12
  281. data/vendor/eigen/Eigen/src/SparseCore/SparseProduct.h +13 -1
  282. data/vendor/eigen/Eigen/src/SparseCore/SparseRef.h +7 -7
  283. data/vendor/eigen/Eigen/src/SparseCore/SparseSelfAdjointView.h +5 -2
  284. data/vendor/eigen/Eigen/src/SparseCore/SparseUtil.h +8 -0
  285. data/vendor/eigen/Eigen/src/SparseCore/SparseVector.h +1 -1
  286. data/vendor/eigen/Eigen/src/SparseCore/SparseView.h +1 -0
  287. data/vendor/eigen/Eigen/src/SparseLU/SparseLU.h +162 -12
  288. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_Memory.h +1 -1
  289. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +76 -2
  290. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_column_dfs.h +2 -2
  291. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +1 -1
  292. data/vendor/eigen/Eigen/src/SparseLU/SparseLU_panel_bmod.h +1 -1
  293. data/vendor/eigen/Eigen/src/SparseQR/SparseQR.h +19 -6
  294. data/vendor/eigen/Eigen/src/StlSupport/StdDeque.h +2 -12
  295. data/vendor/eigen/Eigen/src/StlSupport/StdList.h +2 -2
  296. data/vendor/eigen/Eigen/src/StlSupport/StdVector.h +2 -2
  297. data/vendor/eigen/Eigen/src/SuperLUSupport/SuperLUSupport.h +6 -8
  298. data/vendor/eigen/Eigen/src/UmfPackSupport/UmfPackSupport.h +175 -39
  299. data/vendor/eigen/Eigen/src/misc/lapacke.h +5 -4
  300. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseBinaryOps.h +28 -2
  301. data/vendor/eigen/Eigen/src/plugins/ArrayCwiseUnaryOps.h +155 -11
  302. data/vendor/eigen/Eigen/src/plugins/BlockMethods.h +626 -242
  303. data/vendor/eigen/Eigen/src/plugins/CommonCwiseUnaryOps.h +14 -0
  304. data/vendor/eigen/Eigen/src/plugins/IndexedViewMethods.h +262 -0
  305. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseBinaryOps.h +4 -4
  306. data/vendor/eigen/Eigen/src/plugins/MatrixCwiseUnaryOps.h +10 -0
  307. data/vendor/eigen/Eigen/src/plugins/ReshapedMethods.h +149 -0
  308. data/vendor/eigen/README.md +2 -0
  309. data/vendor/eigen/bench/btl/README +1 -1
  310. data/vendor/eigen/bench/tensors/README +6 -7
  311. data/vendor/eigen/ci/README.md +56 -0
  312. data/vendor/eigen/demos/mix_eigen_and_c/README +1 -1
  313. data/vendor/eigen/unsupported/Eigen/CXX11/src/Tensor/README.md +213 -158
  314. data/vendor/eigen/unsupported/README.txt +1 -1
  315. data/vendor/tomotopy/README.kr.rst +21 -0
  316. data/vendor/tomotopy/README.rst +20 -0
  317. data/vendor/tomotopy/src/Labeling/FoRelevance.cpp +2 -2
  318. data/vendor/tomotopy/src/Labeling/Phraser.hpp +1 -1
  319. data/vendor/tomotopy/src/TopicModel/CTModel.hpp +2 -1
  320. data/vendor/tomotopy/src/TopicModel/DMRModel.hpp +2 -1
  321. data/vendor/tomotopy/src/TopicModel/DTModel.hpp +1 -1
  322. data/vendor/tomotopy/src/TopicModel/GDMRModel.hpp +2 -2
  323. data/vendor/tomotopy/src/TopicModel/HDP.h +1 -0
  324. data/vendor/tomotopy/src/TopicModel/HDPModel.hpp +53 -2
  325. data/vendor/tomotopy/src/TopicModel/HLDAModel.hpp +1 -1
  326. data/vendor/tomotopy/src/TopicModel/HPAModel.hpp +1 -0
  327. data/vendor/tomotopy/src/TopicModel/LDACVB0Model.hpp +2 -2
  328. data/vendor/tomotopy/src/TopicModel/LDAModel.hpp +16 -5
  329. data/vendor/tomotopy/src/TopicModel/LLDAModel.hpp +1 -0
  330. data/vendor/tomotopy/src/TopicModel/MGLDAModel.hpp +1 -0
  331. data/vendor/tomotopy/src/TopicModel/PLDAModel.hpp +1 -0
  332. data/vendor/tomotopy/src/TopicModel/PT.h +3 -1
  333. data/vendor/tomotopy/src/TopicModel/PTModel.hpp +31 -1
  334. data/vendor/tomotopy/src/TopicModel/SLDAModel.hpp +2 -2
  335. data/vendor/tomotopy/src/TopicModel/TopicModel.hpp +7 -5
  336. data/vendor/tomotopy/src/Utils/EigenAddonOps.hpp +36 -1
  337. data/vendor/tomotopy/src/Utils/exception.h +6 -0
  338. data/vendor/tomotopy/src/Utils/sample.hpp +14 -12
  339. data/vendor/tomotopy/src/Utils/sse_gamma.h +0 -3
  340. metadata +60 -14
  341. data/vendor/eigen/Eigen/CMakeLists.txt +0 -19
  342. data/vendor/eigen/Eigen/src/Core/arch/CUDA/Half.h +0 -674
  343. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMath.h +0 -333
  344. data/vendor/eigen/Eigen/src/Core/arch/CUDA/PacketMathHalf.h +0 -1124
  345. data/vendor/eigen/Eigen/src/Core/arch/CUDA/TypeCasting.h +0 -212
  346. data/vendor/eigen/Eigen/src/Geometry/arch/Geometry_SSE.h +0 -161
  347. data/vendor/eigen/Eigen/src/LU/arch/Inverse_SSE.h +0 -338
@@ -18,11 +18,11 @@ namespace internal {
18
18
  #define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD 8
19
19
  #endif
20
20
 
21
- #ifndef EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS
22
- #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS (2*sizeof(void*))
21
+ #if !defined(EIGEN_VECTORIZE_AVX512) && !defined(EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS)
22
+ #define EIGEN_ARCH_DEFAULT_NUMBER_OF_REGISTERS 16
23
23
  #endif
24
24
 
25
- #ifdef __FMA__
25
+ #ifdef EIGEN_VECTORIZE_FMA
26
26
  #ifndef EIGEN_HAS_SINGLE_INSTRUCTION_MADD
27
27
  #define EIGEN_HAS_SINGLE_INSTRUCTION_MADD
28
28
  #endif
@@ -31,10 +31,14 @@ namespace internal {
31
31
  typedef __m256 Packet8f;
32
32
  typedef __m256i Packet8i;
33
33
  typedef __m256d Packet4d;
34
+ typedef eigen_packet_wrapper<__m128i, 2> Packet8h;
35
+ typedef eigen_packet_wrapper<__m128i, 3> Packet8bf;
34
36
 
35
37
  template<> struct is_arithmetic<__m256> { enum { value = true }; };
36
38
  template<> struct is_arithmetic<__m256i> { enum { value = true }; };
37
39
  template<> struct is_arithmetic<__m256d> { enum { value = true }; };
40
+ template<> struct is_arithmetic<Packet8h> { enum { value = true }; };
41
+ template<> struct is_arithmetic<Packet8bf> { enum { value = true }; };
38
42
 
39
43
  #define _EIGEN_DECLARE_CONST_Packet8f(NAME,X) \
40
44
  const Packet8f p8f_##NAME = pset1<Packet8f>(X)
@@ -58,21 +62,28 @@ template<> struct packet_traits<float> : default_packet_traits
58
62
  enum {
59
63
  Vectorizable = 1,
60
64
  AlignedOnScalar = 1,
61
- size=8,
65
+ size = 8,
62
66
  HasHalfPacket = 1,
63
67
 
64
- HasDiv = 1,
65
- HasSin = EIGEN_FAST_MATH,
66
- HasCos = 0,
67
- HasLog = 1,
68
- HasExp = 1,
68
+ HasCmp = 1,
69
+ HasDiv = 1,
70
+ HasSin = EIGEN_FAST_MATH,
71
+ HasCos = EIGEN_FAST_MATH,
72
+ HasLog = 1,
73
+ HasLog1p = 1,
74
+ HasExpm1 = 1,
75
+ HasExp = 1,
76
+ HasNdtri = 1,
77
+ HasBessel = 1,
69
78
  HasSqrt = 1,
70
79
  HasRsqrt = 1,
71
- HasTanh = EIGEN_FAST_MATH,
80
+ HasTanh = EIGEN_FAST_MATH,
81
+ HasErf = EIGEN_FAST_MATH,
72
82
  HasBlend = 1,
73
83
  HasRound = 1,
74
84
  HasFloor = 1,
75
- HasCeil = 1
85
+ HasCeil = 1,
86
+ HasRint = 1
76
87
  };
77
88
  };
78
89
  template<> struct packet_traits<double> : default_packet_traits
@@ -85,14 +96,104 @@ template<> struct packet_traits<double> : default_packet_traits
85
96
  size=4,
86
97
  HasHalfPacket = 1,
87
98
 
99
+ HasCmp = 1,
88
100
  HasDiv = 1,
101
+ HasLog = 1,
89
102
  HasExp = 1,
90
103
  HasSqrt = 1,
91
104
  HasRsqrt = 1,
92
105
  HasBlend = 1,
93
106
  HasRound = 1,
94
107
  HasFloor = 1,
95
- HasCeil = 1
108
+ HasCeil = 1,
109
+ HasRint = 1
110
+ };
111
+ };
112
+
113
+ template <>
114
+ struct packet_traits<Eigen::half> : default_packet_traits {
115
+ typedef Packet8h type;
116
+ // There is no half-size packet for Packet8h.
117
+ typedef Packet8h half;
118
+ enum {
119
+ Vectorizable = 1,
120
+ AlignedOnScalar = 1,
121
+ size = 8,
122
+ HasHalfPacket = 0,
123
+
124
+ HasCmp = 1,
125
+ HasAdd = 1,
126
+ HasSub = 1,
127
+ HasMul = 1,
128
+ HasDiv = 1,
129
+ HasSin = EIGEN_FAST_MATH,
130
+ HasCos = EIGEN_FAST_MATH,
131
+ HasNegate = 1,
132
+ HasAbs = 1,
133
+ HasAbs2 = 0,
134
+ HasMin = 1,
135
+ HasMax = 1,
136
+ HasConj = 1,
137
+ HasSetLinear = 0,
138
+ HasLog = 1,
139
+ HasLog1p = 1,
140
+ HasExpm1 = 1,
141
+ HasExp = 1,
142
+ HasSqrt = 1,
143
+ HasRsqrt = 1,
144
+ HasTanh = EIGEN_FAST_MATH,
145
+ HasErf = EIGEN_FAST_MATH,
146
+ HasBlend = 0,
147
+ HasRound = 1,
148
+ HasFloor = 1,
149
+ HasCeil = 1,
150
+ HasRint = 1,
151
+ HasBessel = 1,
152
+ HasNdtri = 1
153
+ };
154
+ };
155
+
156
+ template <>
157
+ struct packet_traits<bfloat16> : default_packet_traits {
158
+ typedef Packet8bf type;
159
+ // There is no half-size packet for current Packet8bf.
160
+ // TODO: support as SSE path.
161
+ typedef Packet8bf half;
162
+ enum {
163
+ Vectorizable = 1,
164
+ AlignedOnScalar = 1,
165
+ size = 8,
166
+ HasHalfPacket = 0,
167
+
168
+ HasCmp = 1,
169
+ HasAdd = 1,
170
+ HasSub = 1,
171
+ HasMul = 1,
172
+ HasDiv = 1,
173
+ HasSin = EIGEN_FAST_MATH,
174
+ HasCos = EIGEN_FAST_MATH,
175
+ HasNegate = 1,
176
+ HasAbs = 1,
177
+ HasAbs2 = 0,
178
+ HasMin = 1,
179
+ HasMax = 1,
180
+ HasConj = 1,
181
+ HasSetLinear = 0,
182
+ HasLog = 1,
183
+ HasLog1p = 1,
184
+ HasExpm1 = 1,
185
+ HasExp = 1,
186
+ HasSqrt = 1,
187
+ HasRsqrt = 1,
188
+ HasTanh = EIGEN_FAST_MATH,
189
+ HasErf = EIGEN_FAST_MATH,
190
+ HasBlend = 0,
191
+ HasRound = 1,
192
+ HasFloor = 1,
193
+ HasCeil = 1,
194
+ HasRint = 1,
195
+ HasBessel = 1,
196
+ HasNdtri = 1
96
197
  };
97
198
  };
98
199
  #endif
@@ -113,14 +214,45 @@ template<> struct packet_traits<int> : default_packet_traits
113
214
  };
114
215
  */
115
216
 
116
- template<> struct unpacket_traits<Packet8f> { typedef float type; typedef Packet4f half; enum {size=8, alignment=Aligned32}; };
117
- template<> struct unpacket_traits<Packet4d> { typedef double type; typedef Packet2d half; enum {size=4, alignment=Aligned32}; };
118
- template<> struct unpacket_traits<Packet8i> { typedef int type; typedef Packet4i half; enum {size=8, alignment=Aligned32}; };
217
+ template<> struct unpacket_traits<Packet8f> {
218
+ typedef float type;
219
+ typedef Packet4f half;
220
+ typedef Packet8i integer_packet;
221
+ typedef uint8_t mask_t;
222
+ enum {size=8, alignment=Aligned32, vectorizable=true, masked_load_available=true, masked_store_available=true};
223
+ };
224
+ template<> struct unpacket_traits<Packet4d> {
225
+ typedef double type;
226
+ typedef Packet2d half;
227
+ enum {size=4, alignment=Aligned32, vectorizable=true, masked_load_available=false, masked_store_available=false};
228
+ };
229
+ template<> struct unpacket_traits<Packet8i> { typedef int type; typedef Packet4i half; enum {size=8, alignment=Aligned32, vectorizable=false, masked_load_available=false, masked_store_available=false}; };
230
+ template<> struct unpacket_traits<Packet8bf> { typedef bfloat16 type; typedef Packet8bf half; enum {size=8, alignment=Aligned16, vectorizable=true, masked_load_available=false, masked_store_available=false}; };
231
+
232
+ // Helper function for bit packing snippet of low precision comparison.
233
+ // It packs the flags from 16x16 to 8x16.
234
+ EIGEN_STRONG_INLINE __m128i Pack16To8(Packet8f rf) {
235
+ return _mm_packs_epi32(_mm256_extractf128_si256(_mm256_castps_si256(rf), 0),
236
+ _mm256_extractf128_si256(_mm256_castps_si256(rf), 1));
237
+ }
238
+
119
239
 
120
240
  template<> EIGEN_STRONG_INLINE Packet8f pset1<Packet8f>(const float& from) { return _mm256_set1_ps(from); }
121
241
  template<> EIGEN_STRONG_INLINE Packet4d pset1<Packet4d>(const double& from) { return _mm256_set1_pd(from); }
122
242
  template<> EIGEN_STRONG_INLINE Packet8i pset1<Packet8i>(const int& from) { return _mm256_set1_epi32(from); }
123
243
 
244
+ template<> EIGEN_STRONG_INLINE Packet8f pset1frombits<Packet8f>(unsigned int from) { return _mm256_castsi256_ps(pset1<Packet8i>(from)); }
245
+ template<> EIGEN_STRONG_INLINE Packet4d pset1frombits<Packet4d>(uint64_t from) { return _mm256_castsi256_pd(_mm256_set1_epi64x(from)); }
246
+
247
+ template<> EIGEN_STRONG_INLINE Packet8f pzero(const Packet8f& /*a*/) { return _mm256_setzero_ps(); }
248
+ template<> EIGEN_STRONG_INLINE Packet4d pzero(const Packet4d& /*a*/) { return _mm256_setzero_pd(); }
249
+ template<> EIGEN_STRONG_INLINE Packet8i pzero(const Packet8i& /*a*/) { return _mm256_setzero_si256(); }
250
+
251
+
252
+ template<> EIGEN_STRONG_INLINE Packet8f peven_mask(const Packet8f& /*a*/) { return _mm256_castsi256_ps(_mm256_set_epi32(0, -1, 0, -1, 0, -1, 0, -1)); }
253
+ template<> EIGEN_STRONG_INLINE Packet8i peven_mask(const Packet8i& /*a*/) { return _mm256_set_epi32(0, -1, 0, -1, 0, -1, 0, -1); }
254
+ template<> EIGEN_STRONG_INLINE Packet4d peven_mask(const Packet4d& /*a*/) { return _mm256_castsi256_pd(_mm256_set_epi32(0, 0, -1, -1, 0, 0, -1, -1)); }
255
+
124
256
  template<> EIGEN_STRONG_INLINE Packet8f pload1<Packet8f>(const float* from) { return _mm256_broadcast_ss(from); }
125
257
  template<> EIGEN_STRONG_INLINE Packet4d pload1<Packet4d>(const double* from) { return _mm256_broadcast_sd(from); }
126
258
 
@@ -129,9 +261,27 @@ template<> EIGEN_STRONG_INLINE Packet4d plset<Packet4d>(const double& a) { retur
129
261
 
130
262
  template<> EIGEN_STRONG_INLINE Packet8f padd<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_add_ps(a,b); }
131
263
  template<> EIGEN_STRONG_INLINE Packet4d padd<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_add_pd(a,b); }
264
+ template<> EIGEN_STRONG_INLINE Packet8i padd<Packet8i>(const Packet8i& a, const Packet8i& b) {
265
+ #ifdef EIGEN_VECTORIZE_AVX2
266
+ return _mm256_add_epi32(a,b);
267
+ #else
268
+ __m128i lo = _mm_add_epi32(_mm256_extractf128_si256(a, 0), _mm256_extractf128_si256(b, 0));
269
+ __m128i hi = _mm_add_epi32(_mm256_extractf128_si256(a, 1), _mm256_extractf128_si256(b, 1));
270
+ return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);
271
+ #endif
272
+ }
132
273
 
133
274
  template<> EIGEN_STRONG_INLINE Packet8f psub<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_sub_ps(a,b); }
134
275
  template<> EIGEN_STRONG_INLINE Packet4d psub<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_sub_pd(a,b); }
276
+ template<> EIGEN_STRONG_INLINE Packet8i psub<Packet8i>(const Packet8i& a, const Packet8i& b) {
277
+ #ifdef EIGEN_VECTORIZE_AVX2
278
+ return _mm256_sub_epi32(a,b);
279
+ #else
280
+ __m128i lo = _mm_sub_epi32(_mm256_extractf128_si256(a, 0), _mm256_extractf128_si256(b, 0));
281
+ __m128i hi = _mm_sub_epi32(_mm256_extractf128_si256(a, 1), _mm256_extractf128_si256(b, 1));
282
+ return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);
283
+ #endif
284
+ }
135
285
 
136
286
  template<> EIGEN_STRONG_INLINE Packet8f pnegate(const Packet8f& a)
137
287
  {
@@ -148,7 +298,15 @@ template<> EIGEN_STRONG_INLINE Packet8i pconj(const Packet8i& a) { return a; }
148
298
 
149
299
  template<> EIGEN_STRONG_INLINE Packet8f pmul<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_mul_ps(a,b); }
150
300
  template<> EIGEN_STRONG_INLINE Packet4d pmul<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_mul_pd(a,b); }
151
-
301
+ template<> EIGEN_STRONG_INLINE Packet8i pmul<Packet8i>(const Packet8i& a, const Packet8i& b) {
302
+ #ifdef EIGEN_VECTORIZE_AVX2
303
+ return _mm256_mullo_epi32(a,b);
304
+ #else
305
+ const __m128i lo = _mm_mullo_epi32(_mm256_extractf128_si256(a, 0), _mm256_extractf128_si256(b, 0));
306
+ const __m128i hi = _mm_mullo_epi32(_mm256_extractf128_si256(a, 1), _mm256_extractf128_si256(b, 1));
307
+ return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);
308
+ #endif
309
+ }
152
310
 
153
311
  template<> EIGEN_STRONG_INLINE Packet8f pdiv<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_div_ps(a,b); }
154
312
  template<> EIGEN_STRONG_INLINE Packet4d pdiv<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_div_pd(a,b); }
@@ -157,7 +315,7 @@ template<> EIGEN_STRONG_INLINE Packet8i pdiv<Packet8i>(const Packet8i& /*a*/, co
157
315
  return pset1<Packet8i>(0);
158
316
  }
159
317
 
160
- #ifdef __FMA__
318
+ #ifdef EIGEN_VECTORIZE_FMA
161
319
  template<> EIGEN_STRONG_INLINE Packet8f pmadd(const Packet8f& a, const Packet8f& b, const Packet8f& c) {
162
320
  #if ( (EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC<80) || (EIGEN_COMP_CLANG) )
163
321
  // Clang stupidly generates a vfmadd213ps instruction plus some vmovaps on registers,
@@ -184,14 +342,112 @@ template<> EIGEN_STRONG_INLINE Packet4d pmadd(const Packet4d& a, const Packet4d&
184
342
  }
185
343
  #endif
186
344
 
187
- template<> EIGEN_STRONG_INLINE Packet8f pmin<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_min_ps(a,b); }
188
- template<> EIGEN_STRONG_INLINE Packet4d pmin<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_min_pd(a,b); }
345
+ template<> EIGEN_STRONG_INLINE Packet8f pcmp_le(const Packet8f& a, const Packet8f& b) { return _mm256_cmp_ps(a,b,_CMP_LE_OQ); }
346
+ template<> EIGEN_STRONG_INLINE Packet8f pcmp_lt(const Packet8f& a, const Packet8f& b) { return _mm256_cmp_ps(a,b,_CMP_LT_OQ); }
347
+ template<> EIGEN_STRONG_INLINE Packet8f pcmp_lt_or_nan(const Packet8f& a, const Packet8f& b) { return _mm256_cmp_ps(a, b, _CMP_NGE_UQ); }
348
+ template<> EIGEN_STRONG_INLINE Packet8f pcmp_eq(const Packet8f& a, const Packet8f& b) { return _mm256_cmp_ps(a,b,_CMP_EQ_OQ); }
349
+
350
+ template<> EIGEN_STRONG_INLINE Packet4d pcmp_le(const Packet4d& a, const Packet4d& b) { return _mm256_cmp_pd(a,b,_CMP_LE_OQ); }
351
+ template<> EIGEN_STRONG_INLINE Packet4d pcmp_lt(const Packet4d& a, const Packet4d& b) { return _mm256_cmp_pd(a,b,_CMP_LT_OQ); }
352
+ template<> EIGEN_STRONG_INLINE Packet4d pcmp_lt_or_nan(const Packet4d& a, const Packet4d& b) { return _mm256_cmp_pd(a, b, _CMP_NGE_UQ); }
353
+ template<> EIGEN_STRONG_INLINE Packet4d pcmp_eq(const Packet4d& a, const Packet4d& b) { return _mm256_cmp_pd(a,b,_CMP_EQ_OQ); }
354
+
355
+
356
+ template<> EIGEN_STRONG_INLINE Packet8i pcmp_eq(const Packet8i& a, const Packet8i& b) {
357
+ #ifdef EIGEN_VECTORIZE_AVX2
358
+ return _mm256_cmpeq_epi32(a,b);
359
+ #else
360
+ __m128i lo = _mm_cmpeq_epi32(_mm256_extractf128_si256(a, 0), _mm256_extractf128_si256(b, 0));
361
+ __m128i hi = _mm_cmpeq_epi32(_mm256_extractf128_si256(a, 1), _mm256_extractf128_si256(b, 1));
362
+ return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);
363
+ #endif
364
+ }
365
+
366
+ template<> EIGEN_STRONG_INLINE Packet8f pmin<Packet8f>(const Packet8f& a, const Packet8f& b) {
367
+ #if EIGEN_COMP_GNUC && EIGEN_COMP_GNUC < 63
368
+ // There appears to be a bug in GCC, by which the optimizer may flip
369
+ // the argument order in calls to _mm_min_ps/_mm_max_ps, so we have to
370
+ // resort to inline ASM here. This is supposed to be fixed in gcc6.3,
371
+ // see also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72867
372
+ Packet8f res;
373
+ asm("vminps %[a], %[b], %[res]" : [res] "=x" (res) : [a] "x" (a), [b] "x" (b));
374
+ return res;
375
+ #else
376
+ // Arguments are swapped to match NaN propagation behavior of std::min.
377
+ return _mm256_min_ps(b,a);
378
+ #endif
379
+ }
380
+ template<> EIGEN_STRONG_INLINE Packet4d pmin<Packet4d>(const Packet4d& a, const Packet4d& b) {
381
+ #if EIGEN_COMP_GNUC && EIGEN_COMP_GNUC < 63
382
+ // See pmin above
383
+ Packet4d res;
384
+ asm("vminpd %[a], %[b], %[res]" : [res] "=x" (res) : [a] "x" (a), [b] "x" (b));
385
+ return res;
386
+ #else
387
+ // Arguments are swapped to match NaN propagation behavior of std::min.
388
+ return _mm256_min_pd(b,a);
389
+ #endif
390
+ }
391
+
392
+ template<> EIGEN_STRONG_INLINE Packet8f pmax<Packet8f>(const Packet8f& a, const Packet8f& b) {
393
+ #if EIGEN_COMP_GNUC && EIGEN_COMP_GNUC < 63
394
+ // See pmin above
395
+ Packet8f res;
396
+ asm("vmaxps %[a], %[b], %[res]" : [res] "=x" (res) : [a] "x" (a), [b] "x" (b));
397
+ return res;
398
+ #else
399
+ // Arguments are swapped to match NaN propagation behavior of std::max.
400
+ return _mm256_max_ps(b,a);
401
+ #endif
402
+ }
403
+ template<> EIGEN_STRONG_INLINE Packet4d pmax<Packet4d>(const Packet4d& a, const Packet4d& b) {
404
+ #if EIGEN_COMP_GNUC && EIGEN_COMP_GNUC < 63
405
+ // See pmin above
406
+ Packet4d res;
407
+ asm("vmaxpd %[a], %[b], %[res]" : [res] "=x" (res) : [a] "x" (a), [b] "x" (b));
408
+ return res;
409
+ #else
410
+ // Arguments are swapped to match NaN propagation behavior of std::max.
411
+ return _mm256_max_pd(b,a);
412
+ #endif
413
+ }
189
414
 
190
- template<> EIGEN_STRONG_INLINE Packet8f pmax<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_max_ps(a,b); }
191
- template<> EIGEN_STRONG_INLINE Packet4d pmax<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_max_pd(a,b); }
415
+ // Add specializations for min/max with prescribed NaN progation.
416
+ template<>
417
+ EIGEN_STRONG_INLINE Packet8f pmin<PropagateNumbers, Packet8f>(const Packet8f& a, const Packet8f& b) {
418
+ return pminmax_propagate_numbers(a, b, pmin<Packet8f>);
419
+ }
420
+ template<>
421
+ EIGEN_STRONG_INLINE Packet4d pmin<PropagateNumbers, Packet4d>(const Packet4d& a, const Packet4d& b) {
422
+ return pminmax_propagate_numbers(a, b, pmin<Packet4d>);
423
+ }
424
+ template<>
425
+ EIGEN_STRONG_INLINE Packet8f pmax<PropagateNumbers, Packet8f>(const Packet8f& a, const Packet8f& b) {
426
+ return pminmax_propagate_numbers(a, b, pmax<Packet8f>);
427
+ }
428
+ template<>
429
+ EIGEN_STRONG_INLINE Packet4d pmax<PropagateNumbers, Packet4d>(const Packet4d& a, const Packet4d& b) {
430
+ return pminmax_propagate_numbers(a, b, pmax<Packet4d>);
431
+ }
432
+ template<>
433
+ EIGEN_STRONG_INLINE Packet8f pmin<PropagateNaN, Packet8f>(const Packet8f& a, const Packet8f& b) {
434
+ return pminmax_propagate_nan(a, b, pmin<Packet8f>);
435
+ }
436
+ template<>
437
+ EIGEN_STRONG_INLINE Packet4d pmin<PropagateNaN, Packet4d>(const Packet4d& a, const Packet4d& b) {
438
+ return pminmax_propagate_nan(a, b, pmin<Packet4d>);
439
+ }
440
+ template<>
441
+ EIGEN_STRONG_INLINE Packet8f pmax<PropagateNaN, Packet8f>(const Packet8f& a, const Packet8f& b) {
442
+ return pminmax_propagate_nan(a, b, pmax<Packet8f>);
443
+ }
444
+ template<>
445
+ EIGEN_STRONG_INLINE Packet4d pmax<PropagateNaN, Packet4d>(const Packet4d& a, const Packet4d& b) {
446
+ return pminmax_propagate_nan(a, b, pmax<Packet4d>);
447
+ }
192
448
 
193
- template<> EIGEN_STRONG_INLINE Packet8f pround<Packet8f>(const Packet8f& a) { return _mm256_round_ps(a, _MM_FROUND_CUR_DIRECTION); }
194
- template<> EIGEN_STRONG_INLINE Packet4d pround<Packet4d>(const Packet4d& a) { return _mm256_round_pd(a, _MM_FROUND_CUR_DIRECTION); }
449
+ template<> EIGEN_STRONG_INLINE Packet8f print<Packet8f>(const Packet8f& a) { return _mm256_round_ps(a, _MM_FROUND_CUR_DIRECTION); }
450
+ template<> EIGEN_STRONG_INLINE Packet4d print<Packet4d>(const Packet4d& a) { return _mm256_round_pd(a, _MM_FROUND_CUR_DIRECTION); }
195
451
 
196
452
  template<> EIGEN_STRONG_INLINE Packet8f pceil<Packet8f>(const Packet8f& a) { return _mm256_ceil_ps(a); }
197
453
  template<> EIGEN_STRONG_INLINE Packet4d pceil<Packet4d>(const Packet4d& a) { return _mm256_ceil_pd(a); }
@@ -199,17 +455,124 @@ template<> EIGEN_STRONG_INLINE Packet4d pceil<Packet4d>(const Packet4d& a) { ret
199
455
  template<> EIGEN_STRONG_INLINE Packet8f pfloor<Packet8f>(const Packet8f& a) { return _mm256_floor_ps(a); }
200
456
  template<> EIGEN_STRONG_INLINE Packet4d pfloor<Packet4d>(const Packet4d& a) { return _mm256_floor_pd(a); }
201
457
 
458
+
459
+ template<> EIGEN_STRONG_INLINE Packet8i ptrue<Packet8i>(const Packet8i& a) {
460
+ #ifdef EIGEN_VECTORIZE_AVX2
461
+ // vpcmpeqd has lower latency than the more general vcmpps
462
+ return _mm256_cmpeq_epi32(a,a);
463
+ #else
464
+ const __m256 b = _mm256_castsi256_ps(a);
465
+ return _mm256_castps_si256(_mm256_cmp_ps(b,b,_CMP_TRUE_UQ));
466
+ #endif
467
+ }
468
+
469
+ template<> EIGEN_STRONG_INLINE Packet8f ptrue<Packet8f>(const Packet8f& a) {
470
+ #ifdef EIGEN_VECTORIZE_AVX2
471
+ // vpcmpeqd has lower latency than the more general vcmpps
472
+ const __m256i b = _mm256_castps_si256(a);
473
+ return _mm256_castsi256_ps(_mm256_cmpeq_epi32(b,b));
474
+ #else
475
+ return _mm256_cmp_ps(a,a,_CMP_TRUE_UQ);
476
+ #endif
477
+ }
478
+
479
+ template<> EIGEN_STRONG_INLINE Packet4d ptrue<Packet4d>(const Packet4d& a) {
480
+ #ifdef EIGEN_VECTORIZE_AVX2
481
+ // vpcmpeqq has lower latency than the more general vcmppd
482
+ const __m256i b = _mm256_castpd_si256(a);
483
+ return _mm256_castsi256_pd(_mm256_cmpeq_epi64(b,b));
484
+ #else
485
+ return _mm256_cmp_pd(a,a,_CMP_TRUE_UQ);
486
+ #endif
487
+ }
488
+
202
489
  template<> EIGEN_STRONG_INLINE Packet8f pand<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_and_ps(a,b); }
203
490
  template<> EIGEN_STRONG_INLINE Packet4d pand<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_and_pd(a,b); }
491
+ template<> EIGEN_STRONG_INLINE Packet8i pand<Packet8i>(const Packet8i& a, const Packet8i& b) {
492
+ #ifdef EIGEN_VECTORIZE_AVX2
493
+ return _mm256_and_si256(a,b);
494
+ #else
495
+ return _mm256_castps_si256(_mm256_and_ps(_mm256_castsi256_ps(a),_mm256_castsi256_ps(b)));
496
+ #endif
497
+ }
204
498
 
205
499
  template<> EIGEN_STRONG_INLINE Packet8f por<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_or_ps(a,b); }
206
500
  template<> EIGEN_STRONG_INLINE Packet4d por<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_or_pd(a,b); }
501
+ template<> EIGEN_STRONG_INLINE Packet8i por<Packet8i>(const Packet8i& a, const Packet8i& b) {
502
+ #ifdef EIGEN_VECTORIZE_AVX2
503
+ return _mm256_or_si256(a,b);
504
+ #else
505
+ return _mm256_castps_si256(_mm256_or_ps(_mm256_castsi256_ps(a),_mm256_castsi256_ps(b)));
506
+ #endif
507
+ }
207
508
 
208
509
  template<> EIGEN_STRONG_INLINE Packet8f pxor<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_xor_ps(a,b); }
209
510
  template<> EIGEN_STRONG_INLINE Packet4d pxor<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_xor_pd(a,b); }
511
+ template<> EIGEN_STRONG_INLINE Packet8i pxor<Packet8i>(const Packet8i& a, const Packet8i& b) {
512
+ #ifdef EIGEN_VECTORIZE_AVX2
513
+ return _mm256_xor_si256(a,b);
514
+ #else
515
+ return _mm256_castps_si256(_mm256_xor_ps(_mm256_castsi256_ps(a),_mm256_castsi256_ps(b)));
516
+ #endif
517
+ }
210
518
 
211
- template<> EIGEN_STRONG_INLINE Packet8f pandnot<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_andnot_ps(a,b); }
212
- template<> EIGEN_STRONG_INLINE Packet4d pandnot<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_andnot_pd(a,b); }
519
+ template<> EIGEN_STRONG_INLINE Packet8f pandnot<Packet8f>(const Packet8f& a, const Packet8f& b) { return _mm256_andnot_ps(b,a); }
520
+ template<> EIGEN_STRONG_INLINE Packet4d pandnot<Packet4d>(const Packet4d& a, const Packet4d& b) { return _mm256_andnot_pd(b,a); }
521
+ template<> EIGEN_STRONG_INLINE Packet8i pandnot<Packet8i>(const Packet8i& a, const Packet8i& b) {
522
+ #ifdef EIGEN_VECTORIZE_AVX2
523
+ return _mm256_andnot_si256(b,a);
524
+ #else
525
+ return _mm256_castps_si256(_mm256_andnot_ps(_mm256_castsi256_ps(b),_mm256_castsi256_ps(a)));
526
+ #endif
527
+ }
528
+
529
+ template<> EIGEN_STRONG_INLINE Packet8f pround<Packet8f>(const Packet8f& a)
530
+ {
531
+ const Packet8f mask = pset1frombits<Packet8f>(static_cast<numext::uint32_t>(0x80000000u));
532
+ const Packet8f prev0dot5 = pset1frombits<Packet8f>(static_cast<numext::uint32_t>(0x3EFFFFFFu));
533
+ return _mm256_round_ps(padd(por(pand(a, mask), prev0dot5), a), _MM_FROUND_TO_ZERO);
534
+ }
535
+ template<> EIGEN_STRONG_INLINE Packet4d pround<Packet4d>(const Packet4d& a)
536
+ {
537
+ const Packet4d mask = pset1frombits<Packet4d>(static_cast<numext::uint64_t>(0x8000000000000000ull));
538
+ const Packet4d prev0dot5 = pset1frombits<Packet4d>(static_cast<numext::uint64_t>(0x3FDFFFFFFFFFFFFFull));
539
+ return _mm256_round_pd(padd(por(pand(a, mask), prev0dot5), a), _MM_FROUND_TO_ZERO);
540
+ }
541
+
542
+ template<> EIGEN_STRONG_INLINE Packet8f pselect<Packet8f>(const Packet8f& mask, const Packet8f& a, const Packet8f& b)
543
+ { return _mm256_blendv_ps(b,a,mask); }
544
+ template<> EIGEN_STRONG_INLINE Packet4d pselect<Packet4d>(const Packet4d& mask, const Packet4d& a, const Packet4d& b)
545
+ { return _mm256_blendv_pd(b,a,mask); }
546
+
547
+ template<int N> EIGEN_STRONG_INLINE Packet8i parithmetic_shift_right(Packet8i a) {
548
+ #ifdef EIGEN_VECTORIZE_AVX2
549
+ return _mm256_srai_epi32(a, N);
550
+ #else
551
+ __m128i lo = _mm_srai_epi32(_mm256_extractf128_si256(a, 0), N);
552
+ __m128i hi = _mm_srai_epi32(_mm256_extractf128_si256(a, 1), N);
553
+ return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);
554
+ #endif
555
+ }
556
+
557
+ template<int N> EIGEN_STRONG_INLINE Packet8i plogical_shift_right(Packet8i a) {
558
+ #ifdef EIGEN_VECTORIZE_AVX2
559
+ return _mm256_srli_epi32(a, N);
560
+ #else
561
+ __m128i lo = _mm_srli_epi32(_mm256_extractf128_si256(a, 0), N);
562
+ __m128i hi = _mm_srli_epi32(_mm256_extractf128_si256(a, 1), N);
563
+ return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);
564
+ #endif
565
+ }
566
+
567
+ template<int N> EIGEN_STRONG_INLINE Packet8i plogical_shift_left(Packet8i a) {
568
+ #ifdef EIGEN_VECTORIZE_AVX2
569
+ return _mm256_slli_epi32(a, N);
570
+ #else
571
+ __m128i lo = _mm_slli_epi32(_mm256_extractf128_si256(a, 0), N);
572
+ __m128i hi = _mm_slli_epi32(_mm256_extractf128_si256(a, 1), N);
573
+ return _mm256_insertf128_si256(_mm256_castsi128_si256(lo), (hi), 1);
574
+ #endif
575
+ }
213
576
 
214
577
  template<> EIGEN_STRONG_INLINE Packet8f pload<Packet8f>(const float* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_ps(from); }
215
578
  template<> EIGEN_STRONG_INLINE Packet4d pload<Packet4d>(const double* from) { EIGEN_DEBUG_ALIGNED_LOAD return _mm256_load_pd(from); }
@@ -219,6 +582,14 @@ template<> EIGEN_STRONG_INLINE Packet8f ploadu<Packet8f>(const float* from) { EI
219
582
  template<> EIGEN_STRONG_INLINE Packet4d ploadu<Packet4d>(const double* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_pd(from); }
220
583
  template<> EIGEN_STRONG_INLINE Packet8i ploadu<Packet8i>(const int* from) { EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_loadu_si256(reinterpret_cast<const __m256i*>(from)); }
221
584
 
585
+ template<> EIGEN_STRONG_INLINE Packet8f ploadu<Packet8f>(const float* from, uint8_t umask) {
586
+ Packet8i mask = _mm256_set1_epi8(static_cast<char>(umask));
587
+ const Packet8i bit_mask = _mm256_set_epi32(0xffffff7f, 0xffffffbf, 0xffffffdf, 0xffffffef, 0xfffffff7, 0xfffffffb, 0xfffffffd, 0xfffffffe);
588
+ mask = por<Packet8i>(mask, bit_mask);
589
+ mask = pcmp_eq<Packet8i>(mask, _mm256_set1_epi32(0xffffffff));
590
+ EIGEN_DEBUG_UNALIGNED_LOAD return _mm256_maskload_ps(from, mask);
591
+ }
592
+
222
593
  // Loads 4 floats from memory a returns the packet {a0, a0 a1, a1, a2, a2, a3, a3}
223
594
  template<> EIGEN_STRONG_INLINE Packet8f ploaddup<Packet8f>(const float* from)
224
595
  {
@@ -226,7 +597,7 @@ template<> EIGEN_STRONG_INLINE Packet8f ploaddup<Packet8f>(const float* from)
226
597
  // Packet8f tmp = _mm256_castps128_ps256(_mm_loadu_ps(from));
227
598
  // tmp = _mm256_insertf128_ps(tmp, _mm_movehl_ps(_mm256_castps256_ps128(tmp),_mm256_castps256_ps128(tmp)), 1);
228
599
  // return _mm256_unpacklo_ps(tmp,tmp);
229
-
600
+
230
601
  // _mm256_insertf128_ps is very slow on Haswell, thus:
231
602
  Packet8f tmp = _mm256_broadcast_ps((const __m128*)(const void*)from);
232
603
  // mimic an "inplace" permutation of the lower 128bits using a blend
@@ -256,6 +627,14 @@ template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet8f&
256
627
  template<> EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet4d& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_pd(to, from); }
257
628
  template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet8i& from) { EIGEN_DEBUG_UNALIGNED_STORE _mm256_storeu_si256(reinterpret_cast<__m256i*>(to), from); }
258
629
 
630
+ template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet8f& from, uint8_t umask) {
631
+ Packet8i mask = _mm256_set1_epi8(static_cast<char>(umask));
632
+ const Packet8i bit_mask = _mm256_set_epi32(0xffffff7f, 0xffffffbf, 0xffffffdf, 0xffffffef, 0xfffffff7, 0xfffffffb, 0xfffffffd, 0xfffffffe);
633
+ mask = por<Packet8i>(mask, bit_mask);
634
+ mask = pcmp_eq<Packet8i>(mask, _mm256_set1_epi32(0xffffffff));
635
+ EIGEN_DEBUG_UNALIGNED_STORE return _mm256_maskstore_ps(to, mask, from);
636
+ }
637
+
259
638
  // NOTE: leverage _mm256_i32gather_ps and _mm256_i32gather_pd if AVX2 instructions are available
260
639
  // NOTE: for the record the following seems to be slower: return _mm256_i32gather_ps(from, _mm256_set1_epi32(stride), 4);
261
640
  template<> EIGEN_DEVICE_FUNC inline Packet8f pgather<float, Packet8f>(const float* from, Index stride)
@@ -354,47 +733,66 @@ template<> EIGEN_STRONG_INLINE Packet4d pabs(const Packet4d& a)
354
733
  return _mm256_and_pd(a,mask);
355
734
  }
356
735
 
357
- // preduxp should be ok
358
- // FIXME: why is this ok? why isn't the simply implementation working as expected?
359
- template<> EIGEN_STRONG_INLINE Packet8f preduxp<Packet8f>(const Packet8f* vecs)
360
- {
361
- __m256 hsum1 = _mm256_hadd_ps(vecs[0], vecs[1]);
362
- __m256 hsum2 = _mm256_hadd_ps(vecs[2], vecs[3]);
363
- __m256 hsum3 = _mm256_hadd_ps(vecs[4], vecs[5]);
364
- __m256 hsum4 = _mm256_hadd_ps(vecs[6], vecs[7]);
365
-
366
- __m256 hsum5 = _mm256_hadd_ps(hsum1, hsum1);
367
- __m256 hsum6 = _mm256_hadd_ps(hsum2, hsum2);
368
- __m256 hsum7 = _mm256_hadd_ps(hsum3, hsum3);
369
- __m256 hsum8 = _mm256_hadd_ps(hsum4, hsum4);
370
-
371
- __m256 perm1 = _mm256_permute2f128_ps(hsum5, hsum5, 0x23);
372
- __m256 perm2 = _mm256_permute2f128_ps(hsum6, hsum6, 0x23);
373
- __m256 perm3 = _mm256_permute2f128_ps(hsum7, hsum7, 0x23);
374
- __m256 perm4 = _mm256_permute2f128_ps(hsum8, hsum8, 0x23);
736
+ template<> EIGEN_STRONG_INLINE Packet8f pfrexp<Packet8f>(const Packet8f& a, Packet8f& exponent) {
737
+ return pfrexp_generic(a,exponent);
738
+ }
375
739
 
376
- __m256 sum1 = _mm256_add_ps(perm1, hsum5);
377
- __m256 sum2 = _mm256_add_ps(perm2, hsum6);
378
- __m256 sum3 = _mm256_add_ps(perm3, hsum7);
379
- __m256 sum4 = _mm256_add_ps(perm4, hsum8);
740
+ // Extract exponent without existence of Packet4l.
741
+ template<>
742
+ EIGEN_STRONG_INLINE
743
+ Packet4d pfrexp_generic_get_biased_exponent(const Packet4d& a) {
744
+ const Packet4d cst_exp_mask = pset1frombits<Packet4d>(static_cast<uint64_t>(0x7ff0000000000000ull));
745
+ __m256i a_expo = _mm256_castpd_si256(pand(a, cst_exp_mask));
746
+ #ifdef EIGEN_VECTORIZE_AVX2
747
+ a_expo = _mm256_srli_epi64(a_expo, 52);
748
+ __m128i lo = _mm256_extractf128_si256(a_expo, 0);
749
+ __m128i hi = _mm256_extractf128_si256(a_expo, 1);
750
+ #else
751
+ __m128i lo = _mm256_extractf128_si256(a_expo, 0);
752
+ __m128i hi = _mm256_extractf128_si256(a_expo, 1);
753
+ lo = _mm_srli_epi64(lo, 52);
754
+ hi = _mm_srli_epi64(hi, 52);
755
+ #endif
756
+ Packet2d exponent_lo = _mm_cvtepi32_pd(vec4i_swizzle1(lo, 0, 2, 1, 3));
757
+ Packet2d exponent_hi = _mm_cvtepi32_pd(vec4i_swizzle1(hi, 0, 2, 1, 3));
758
+ Packet4d exponent = _mm256_insertf128_pd(_mm256_setzero_pd(), exponent_lo, 0);
759
+ exponent = _mm256_insertf128_pd(exponent, exponent_hi, 1);
760
+ return exponent;
761
+ }
380
762
 
381
- __m256 blend1 = _mm256_blend_ps(sum1, sum2, 0xcc);
382
- __m256 blend2 = _mm256_blend_ps(sum3, sum4, 0xcc);
383
763
 
384
- __m256 final = _mm256_blend_ps(blend1, blend2, 0xf0);
385
- return final;
764
+ template<> EIGEN_STRONG_INLINE Packet4d pfrexp<Packet4d>(const Packet4d& a, Packet4d& exponent) {
765
+ return pfrexp_generic(a, exponent);
386
766
  }
387
- template<> EIGEN_STRONG_INLINE Packet4d preduxp<Packet4d>(const Packet4d* vecs)
388
- {
389
- Packet4d tmp0, tmp1;
390
767
 
391
- tmp0 = _mm256_hadd_pd(vecs[0], vecs[1]);
392
- tmp0 = _mm256_add_pd(tmp0, _mm256_permute2f128_pd(tmp0, tmp0, 1));
393
-
394
- tmp1 = _mm256_hadd_pd(vecs[2], vecs[3]);
395
- tmp1 = _mm256_add_pd(tmp1, _mm256_permute2f128_pd(tmp1, tmp1, 1));
768
+ template<> EIGEN_STRONG_INLINE Packet8f pldexp<Packet8f>(const Packet8f& a, const Packet8f& exponent) {
769
+ return pldexp_generic(a, exponent);
770
+ }
396
771
 
397
- return _mm256_blend_pd(tmp0, tmp1, 0xC);
772
+ template<> EIGEN_STRONG_INLINE Packet4d pldexp<Packet4d>(const Packet4d& a, const Packet4d& exponent) {
773
+ // Clamp exponent to [-2099, 2099]
774
+ const Packet4d max_exponent = pset1<Packet4d>(2099.0);
775
+ const Packet4i e = _mm256_cvtpd_epi32(pmin(pmax(exponent, pnegate(max_exponent)), max_exponent));
776
+
777
+ // Split 2^e into four factors and multiply.
778
+ const Packet4i bias = pset1<Packet4i>(1023);
779
+ Packet4i b = parithmetic_shift_right<2>(e); // floor(e/4)
780
+
781
+ // 2^b
782
+ Packet4i hi = vec4i_swizzle1(padd(b, bias), 0, 2, 1, 3);
783
+ Packet4i lo = _mm_slli_epi64(hi, 52);
784
+ hi = _mm_slli_epi64(_mm_srli_epi64(hi, 32), 52);
785
+ Packet4d c = _mm256_castsi256_pd(_mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1));
786
+ Packet4d out = pmul(pmul(pmul(a, c), c), c); // a * 2^(3b)
787
+
788
+ // 2^(e - 3b)
789
+ b = psub(psub(psub(e, b), b), b); // e - 3b
790
+ hi = vec4i_swizzle1(padd(b, bias), 0, 2, 1, 3);
791
+ lo = _mm_slli_epi64(hi, 52);
792
+ hi = _mm_slli_epi64(_mm_srli_epi64(hi, 32), 52);
793
+ c = _mm256_castsi256_pd(_mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1));
794
+ out = pmul(out, c); // a * 2^e
795
+ return out;
398
796
  }
399
797
 
400
798
  template<> EIGEN_STRONG_INLINE float predux<Packet8f>(const Packet8f& a)
@@ -406,7 +804,7 @@ template<> EIGEN_STRONG_INLINE double predux<Packet4d>(const Packet4d& a)
406
804
  return predux(Packet2d(_mm_add_pd(_mm256_castpd256_pd128(a),_mm256_extractf128_pd(a,1))));
407
805
  }
408
806
 
409
- template<> EIGEN_STRONG_INLINE Packet4f predux_downto4<Packet8f>(const Packet8f& a)
807
+ template<> EIGEN_STRONG_INLINE Packet4f predux_half_dowto4<Packet8f>(const Packet8f& a)
410
808
  {
411
809
  return _mm_add_ps(_mm256_castps256_ps128(a),_mm256_extractf128_ps(a,1));
412
810
  }
@@ -450,93 +848,16 @@ template<> EIGEN_STRONG_INLINE double predux_max<Packet4d>(const Packet4d& a)
450
848
  return pfirst(_mm256_max_pd(tmp, _mm256_shuffle_pd(tmp, tmp, 1)));
451
849
  }
452
850
 
851
+ // not needed yet
852
+ // template<> EIGEN_STRONG_INLINE bool predux_all(const Packet8f& x)
853
+ // {
854
+ // return _mm256_movemask_ps(x)==0xFF;
855
+ // }
453
856
 
454
- template<int Offset>
455
- struct palign_impl<Offset,Packet8f>
857
+ template<> EIGEN_STRONG_INLINE bool predux_any(const Packet8f& x)
456
858
  {
457
- static EIGEN_STRONG_INLINE void run(Packet8f& first, const Packet8f& second)
458
- {
459
- if (Offset==1)
460
- {
461
- first = _mm256_blend_ps(first, second, 1);
462
- Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(0,3,2,1));
463
- Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);
464
- first = _mm256_blend_ps(tmp1, tmp2, 0x88);
465
- }
466
- else if (Offset==2)
467
- {
468
- first = _mm256_blend_ps(first, second, 3);
469
- Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(1,0,3,2));
470
- Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);
471
- first = _mm256_blend_ps(tmp1, tmp2, 0xcc);
472
- }
473
- else if (Offset==3)
474
- {
475
- first = _mm256_blend_ps(first, second, 7);
476
- Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(2,1,0,3));
477
- Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);
478
- first = _mm256_blend_ps(tmp1, tmp2, 0xee);
479
- }
480
- else if (Offset==4)
481
- {
482
- first = _mm256_blend_ps(first, second, 15);
483
- Packet8f tmp1 = _mm256_permute_ps (first, _MM_SHUFFLE(3,2,1,0));
484
- Packet8f tmp2 = _mm256_permute2f128_ps (tmp1, tmp1, 1);
485
- first = _mm256_permute_ps(tmp2, _MM_SHUFFLE(3,2,1,0));
486
- }
487
- else if (Offset==5)
488
- {
489
- first = _mm256_blend_ps(first, second, 31);
490
- first = _mm256_permute2f128_ps(first, first, 1);
491
- Packet8f tmp = _mm256_permute_ps (first, _MM_SHUFFLE(0,3,2,1));
492
- first = _mm256_permute2f128_ps(tmp, tmp, 1);
493
- first = _mm256_blend_ps(tmp, first, 0x88);
494
- }
495
- else if (Offset==6)
496
- {
497
- first = _mm256_blend_ps(first, second, 63);
498
- first = _mm256_permute2f128_ps(first, first, 1);
499
- Packet8f tmp = _mm256_permute_ps (first, _MM_SHUFFLE(1,0,3,2));
500
- first = _mm256_permute2f128_ps(tmp, tmp, 1);
501
- first = _mm256_blend_ps(tmp, first, 0xcc);
502
- }
503
- else if (Offset==7)
504
- {
505
- first = _mm256_blend_ps(first, second, 127);
506
- first = _mm256_permute2f128_ps(first, first, 1);
507
- Packet8f tmp = _mm256_permute_ps (first, _MM_SHUFFLE(2,1,0,3));
508
- first = _mm256_permute2f128_ps(tmp, tmp, 1);
509
- first = _mm256_blend_ps(tmp, first, 0xee);
510
- }
511
- }
512
- };
513
-
514
- template<int Offset>
515
- struct palign_impl<Offset,Packet4d>
516
- {
517
- static EIGEN_STRONG_INLINE void run(Packet4d& first, const Packet4d& second)
518
- {
519
- if (Offset==1)
520
- {
521
- first = _mm256_blend_pd(first, second, 1);
522
- __m256d tmp = _mm256_permute_pd(first, 5);
523
- first = _mm256_permute2f128_pd(tmp, tmp, 1);
524
- first = _mm256_blend_pd(tmp, first, 0xA);
525
- }
526
- else if (Offset==2)
527
- {
528
- first = _mm256_blend_pd(first, second, 3);
529
- first = _mm256_permute2f128_pd(first, first, 1);
530
- }
531
- else if (Offset==3)
532
- {
533
- first = _mm256_blend_pd(first, second, 7);
534
- __m256d tmp = _mm256_permute_pd(first, 5);
535
- first = _mm256_permute2f128_pd(tmp, tmp, 1);
536
- first = _mm256_blend_pd(tmp, first, 5);
537
- }
538
- }
539
- };
859
+ return _mm256_movemask_ps(x)!=0;
860
+ }
540
861
 
541
862
  EIGEN_DEVICE_FUNC inline void
542
863
  ptranspose(PacketBlock<Packet8f,8>& kernel) {
@@ -610,24 +931,640 @@ template<> EIGEN_STRONG_INLINE Packet4d pblend(const Selector<4>& ifPacket, cons
610
931
  return _mm256_blendv_pd(thenPacket, elsePacket, false_mask);
611
932
  }
612
933
 
613
- template<> EIGEN_STRONG_INLINE Packet8f pinsertfirst(const Packet8f& a, float b)
934
+ // Packet math for Eigen::half
935
+
936
+ template<> struct unpacket_traits<Packet8h> { typedef Eigen::half type; enum {size=8, alignment=Aligned16, vectorizable=true, masked_load_available=false, masked_store_available=false}; typedef Packet8h half; };
937
+
938
+ template<> EIGEN_STRONG_INLINE Packet8h pset1<Packet8h>(const Eigen::half& from) {
939
+ return _mm_set1_epi16(numext::bit_cast<numext::uint16_t>(from));
940
+ }
941
+
942
+ template<> EIGEN_STRONG_INLINE Eigen::half pfirst<Packet8h>(const Packet8h& from) {
943
+ return numext::bit_cast<Eigen::half>(static_cast<numext::uint16_t>(_mm_extract_epi16(from, 0)));
944
+ }
945
+
946
+ template<> EIGEN_STRONG_INLINE Packet8h pload<Packet8h>(const Eigen::half* from) {
947
+ return _mm_load_si128(reinterpret_cast<const __m128i*>(from));
948
+ }
949
+
950
+ template<> EIGEN_STRONG_INLINE Packet8h ploadu<Packet8h>(const Eigen::half* from) {
951
+ return _mm_loadu_si128(reinterpret_cast<const __m128i*>(from));
952
+ }
953
+
954
+ template<> EIGEN_STRONG_INLINE void pstore<Eigen::half>(Eigen::half* to, const Packet8h& from) {
955
+ _mm_store_si128(reinterpret_cast<__m128i*>(to), from);
956
+ }
957
+
958
+ template<> EIGEN_STRONG_INLINE void pstoreu<Eigen::half>(Eigen::half* to, const Packet8h& from) {
959
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(to), from);
960
+ }
961
+
962
+ template<> EIGEN_STRONG_INLINE Packet8h
963
+ ploaddup<Packet8h>(const Eigen::half* from) {
964
+ const numext::uint16_t a = numext::bit_cast<numext::uint16_t>(from[0]);
965
+ const numext::uint16_t b = numext::bit_cast<numext::uint16_t>(from[1]);
966
+ const numext::uint16_t c = numext::bit_cast<numext::uint16_t>(from[2]);
967
+ const numext::uint16_t d = numext::bit_cast<numext::uint16_t>(from[3]);
968
+ return _mm_set_epi16(d, d, c, c, b, b, a, a);
969
+ }
970
+
971
+ template<> EIGEN_STRONG_INLINE Packet8h
972
+ ploadquad<Packet8h>(const Eigen::half* from) {
973
+ const numext::uint16_t a = numext::bit_cast<numext::uint16_t>(from[0]);
974
+ const numext::uint16_t b = numext::bit_cast<numext::uint16_t>(from[1]);
975
+ return _mm_set_epi16(b, b, b, b, a, a, a, a);
976
+ }
977
+
978
+ template<> EIGEN_STRONG_INLINE Packet8h ptrue(const Packet8h& a) {
979
+ return _mm_cmpeq_epi32(a, a);
980
+ }
981
+
982
+ template <>
983
+ EIGEN_STRONG_INLINE Packet8h pabs(const Packet8h& a) {
984
+ const __m128i sign_mask = _mm_set1_epi16(static_cast<numext::uint16_t>(0x8000));
985
+ return _mm_andnot_si128(sign_mask, a);
986
+ }
987
+
988
+ EIGEN_STRONG_INLINE Packet8f half2float(const Packet8h& a) {
989
+ #ifdef EIGEN_HAS_FP16_C
990
+ return _mm256_cvtph_ps(a);
991
+ #else
992
+ EIGEN_ALIGN32 Eigen::half aux[8];
993
+ pstore(aux, a);
994
+ float f0(aux[0]);
995
+ float f1(aux[1]);
996
+ float f2(aux[2]);
997
+ float f3(aux[3]);
998
+ float f4(aux[4]);
999
+ float f5(aux[5]);
1000
+ float f6(aux[6]);
1001
+ float f7(aux[7]);
1002
+
1003
+ return _mm256_set_ps(f7, f6, f5, f4, f3, f2, f1, f0);
1004
+ #endif
1005
+ }
1006
+
1007
+ EIGEN_STRONG_INLINE Packet8h float2half(const Packet8f& a) {
1008
+ #ifdef EIGEN_HAS_FP16_C
1009
+ return _mm256_cvtps_ph(a, _MM_FROUND_TO_NEAREST_INT|_MM_FROUND_NO_EXC);
1010
+ #else
1011
+ EIGEN_ALIGN32 float aux[8];
1012
+ pstore(aux, a);
1013
+ const numext::uint16_t s0 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[0]));
1014
+ const numext::uint16_t s1 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[1]));
1015
+ const numext::uint16_t s2 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[2]));
1016
+ const numext::uint16_t s3 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[3]));
1017
+ const numext::uint16_t s4 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[4]));
1018
+ const numext::uint16_t s5 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[5]));
1019
+ const numext::uint16_t s6 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[6]));
1020
+ const numext::uint16_t s7 = numext::bit_cast<numext::uint16_t>(Eigen::half(aux[7]));
1021
+ return _mm_set_epi16(s7, s6, s5, s4, s3, s2, s1, s0);
1022
+ #endif
1023
+ }
1024
+
1025
+ template <>
1026
+ EIGEN_STRONG_INLINE Packet8h pmin<Packet8h>(const Packet8h& a,
1027
+ const Packet8h& b) {
1028
+ return float2half(pmin<Packet8f>(half2float(a), half2float(b)));
1029
+ }
1030
+
1031
+ template <>
1032
+ EIGEN_STRONG_INLINE Packet8h pmax<Packet8h>(const Packet8h& a,
1033
+ const Packet8h& b) {
1034
+ return float2half(pmax<Packet8f>(half2float(a), half2float(b)));
1035
+ }
1036
+
1037
+ template <>
1038
+ EIGEN_STRONG_INLINE Packet8h plset<Packet8h>(const half& a) {
1039
+ return float2half(plset<Packet8f>(static_cast<float>(a)));
1040
+ }
1041
+
1042
+ template<> EIGEN_STRONG_INLINE Packet8h por(const Packet8h& a,const Packet8h& b) {
1043
+ // in some cases Packet4i is a wrapper around __m128i, so we either need to
1044
+ // cast to Packet4i to directly call the intrinsics as below:
1045
+ return _mm_or_si128(a,b);
1046
+ }
1047
+ template<> EIGEN_STRONG_INLINE Packet8h pxor(const Packet8h& a,const Packet8h& b) {
1048
+ return _mm_xor_si128(a,b);
1049
+ }
1050
+ template<> EIGEN_STRONG_INLINE Packet8h pand(const Packet8h& a,const Packet8h& b) {
1051
+ return _mm_and_si128(a,b);
1052
+ }
1053
+ template<> EIGEN_STRONG_INLINE Packet8h pandnot(const Packet8h& a,const Packet8h& b) {
1054
+ return _mm_andnot_si128(b,a);
1055
+ }
1056
+
1057
+ template<> EIGEN_STRONG_INLINE Packet8h pselect(const Packet8h& mask, const Packet8h& a, const Packet8h& b) {
1058
+ return _mm_blendv_epi8(b, a, mask);
1059
+ }
1060
+
1061
+ template<> EIGEN_STRONG_INLINE Packet8h pround<Packet8h>(const Packet8h& a) {
1062
+ return float2half(pround<Packet8f>(half2float(a)));
1063
+ }
1064
+
1065
+ template<> EIGEN_STRONG_INLINE Packet8h print<Packet8h>(const Packet8h& a) {
1066
+ return float2half(print<Packet8f>(half2float(a)));
1067
+ }
1068
+
1069
+ template<> EIGEN_STRONG_INLINE Packet8h pceil<Packet8h>(const Packet8h& a) {
1070
+ return float2half(pceil<Packet8f>(half2float(a)));
1071
+ }
1072
+
1073
+ template<> EIGEN_STRONG_INLINE Packet8h pfloor<Packet8h>(const Packet8h& a) {
1074
+ return float2half(pfloor<Packet8f>(half2float(a)));
1075
+ }
1076
+
1077
+ template<> EIGEN_STRONG_INLINE Packet8h pcmp_eq(const Packet8h& a,const Packet8h& b) {
1078
+ return Pack16To8(pcmp_eq(half2float(a), half2float(b)));
1079
+ }
1080
+
1081
+ template<> EIGEN_STRONG_INLINE Packet8h pcmp_le(const Packet8h& a,const Packet8h& b) {
1082
+ return Pack16To8(pcmp_le(half2float(a), half2float(b)));
1083
+ }
1084
+
1085
+ template<> EIGEN_STRONG_INLINE Packet8h pcmp_lt(const Packet8h& a,const Packet8h& b) {
1086
+ return Pack16To8(pcmp_lt(half2float(a), half2float(b)));
1087
+ }
1088
+
1089
+ template<> EIGEN_STRONG_INLINE Packet8h pcmp_lt_or_nan(const Packet8h& a,const Packet8h& b) {
1090
+ return Pack16To8(pcmp_lt_or_nan(half2float(a), half2float(b)));
1091
+ }
1092
+
1093
+ template<> EIGEN_STRONG_INLINE Packet8h pconj(const Packet8h& a) { return a; }
1094
+
1095
+ template<> EIGEN_STRONG_INLINE Packet8h pnegate(const Packet8h& a) {
1096
+ Packet8h sign_mask = _mm_set1_epi16(static_cast<numext::uint16_t>(0x8000));
1097
+ return _mm_xor_si128(a, sign_mask);
1098
+ }
1099
+
1100
+ template<> EIGEN_STRONG_INLINE Packet8h padd<Packet8h>(const Packet8h& a, const Packet8h& b) {
1101
+ Packet8f af = half2float(a);
1102
+ Packet8f bf = half2float(b);
1103
+ Packet8f rf = padd(af, bf);
1104
+ return float2half(rf);
1105
+ }
1106
+
1107
+ template<> EIGEN_STRONG_INLINE Packet8h psub<Packet8h>(const Packet8h& a, const Packet8h& b) {
1108
+ Packet8f af = half2float(a);
1109
+ Packet8f bf = half2float(b);
1110
+ Packet8f rf = psub(af, bf);
1111
+ return float2half(rf);
1112
+ }
1113
+
1114
+ template<> EIGEN_STRONG_INLINE Packet8h pmul<Packet8h>(const Packet8h& a, const Packet8h& b) {
1115
+ Packet8f af = half2float(a);
1116
+ Packet8f bf = half2float(b);
1117
+ Packet8f rf = pmul(af, bf);
1118
+ return float2half(rf);
1119
+ }
1120
+
1121
+ template<> EIGEN_STRONG_INLINE Packet8h pdiv<Packet8h>(const Packet8h& a, const Packet8h& b) {
1122
+ Packet8f af = half2float(a);
1123
+ Packet8f bf = half2float(b);
1124
+ Packet8f rf = pdiv(af, bf);
1125
+ return float2half(rf);
1126
+ }
1127
+
1128
+ template<> EIGEN_STRONG_INLINE Packet8h pgather<Eigen::half, Packet8h>(const Eigen::half* from, Index stride)
614
1129
  {
615
- return _mm256_blend_ps(a,pset1<Packet8f>(b),1);
1130
+ const numext::uint16_t s0 = numext::bit_cast<numext::uint16_t>(from[0*stride]);
1131
+ const numext::uint16_t s1 = numext::bit_cast<numext::uint16_t>(from[1*stride]);
1132
+ const numext::uint16_t s2 = numext::bit_cast<numext::uint16_t>(from[2*stride]);
1133
+ const numext::uint16_t s3 = numext::bit_cast<numext::uint16_t>(from[3*stride]);
1134
+ const numext::uint16_t s4 = numext::bit_cast<numext::uint16_t>(from[4*stride]);
1135
+ const numext::uint16_t s5 = numext::bit_cast<numext::uint16_t>(from[5*stride]);
1136
+ const numext::uint16_t s6 = numext::bit_cast<numext::uint16_t>(from[6*stride]);
1137
+ const numext::uint16_t s7 = numext::bit_cast<numext::uint16_t>(from[7*stride]);
1138
+ return _mm_set_epi16(s7, s6, s5, s4, s3, s2, s1, s0);
616
1139
  }
617
1140
 
618
- template<> EIGEN_STRONG_INLINE Packet4d pinsertfirst(const Packet4d& a, double b)
1141
+ template<> EIGEN_STRONG_INLINE void pscatter<Eigen::half, Packet8h>(Eigen::half* to, const Packet8h& from, Index stride)
619
1142
  {
620
- return _mm256_blend_pd(a,pset1<Packet4d>(b),1);
1143
+ EIGEN_ALIGN32 Eigen::half aux[8];
1144
+ pstore(aux, from);
1145
+ to[stride*0] = aux[0];
1146
+ to[stride*1] = aux[1];
1147
+ to[stride*2] = aux[2];
1148
+ to[stride*3] = aux[3];
1149
+ to[stride*4] = aux[4];
1150
+ to[stride*5] = aux[5];
1151
+ to[stride*6] = aux[6];
1152
+ to[stride*7] = aux[7];
1153
+ }
1154
+
1155
+ template<> EIGEN_STRONG_INLINE Eigen::half predux<Packet8h>(const Packet8h& a) {
1156
+ Packet8f af = half2float(a);
1157
+ float reduced = predux<Packet8f>(af);
1158
+ return Eigen::half(reduced);
1159
+ }
1160
+
1161
+ template<> EIGEN_STRONG_INLINE Eigen::half predux_max<Packet8h>(const Packet8h& a) {
1162
+ Packet8f af = half2float(a);
1163
+ float reduced = predux_max<Packet8f>(af);
1164
+ return Eigen::half(reduced);
1165
+ }
1166
+
1167
+ template<> EIGEN_STRONG_INLINE Eigen::half predux_min<Packet8h>(const Packet8h& a) {
1168
+ Packet8f af = half2float(a);
1169
+ float reduced = predux_min<Packet8f>(af);
1170
+ return Eigen::half(reduced);
621
1171
  }
622
1172
 
623
- template<> EIGEN_STRONG_INLINE Packet8f pinsertlast(const Packet8f& a, float b)
1173
+ template<> EIGEN_STRONG_INLINE Eigen::half predux_mul<Packet8h>(const Packet8h& a) {
1174
+ Packet8f af = half2float(a);
1175
+ float reduced = predux_mul<Packet8f>(af);
1176
+ return Eigen::half(reduced);
1177
+ }
1178
+
1179
+ template<> EIGEN_STRONG_INLINE Packet8h preverse(const Packet8h& a)
624
1180
  {
625
- return _mm256_blend_ps(a,pset1<Packet8f>(b),(1<<7));
1181
+ __m128i m = _mm_setr_epi8(14,15,12,13,10,11,8,9,6,7,4,5,2,3,0,1);
1182
+ return _mm_shuffle_epi8(a,m);
1183
+ }
1184
+
1185
+ EIGEN_STRONG_INLINE void
1186
+ ptranspose(PacketBlock<Packet8h,8>& kernel) {
1187
+ __m128i a = kernel.packet[0];
1188
+ __m128i b = kernel.packet[1];
1189
+ __m128i c = kernel.packet[2];
1190
+ __m128i d = kernel.packet[3];
1191
+ __m128i e = kernel.packet[4];
1192
+ __m128i f = kernel.packet[5];
1193
+ __m128i g = kernel.packet[6];
1194
+ __m128i h = kernel.packet[7];
1195
+
1196
+ __m128i a03b03 = _mm_unpacklo_epi16(a, b);
1197
+ __m128i c03d03 = _mm_unpacklo_epi16(c, d);
1198
+ __m128i e03f03 = _mm_unpacklo_epi16(e, f);
1199
+ __m128i g03h03 = _mm_unpacklo_epi16(g, h);
1200
+ __m128i a47b47 = _mm_unpackhi_epi16(a, b);
1201
+ __m128i c47d47 = _mm_unpackhi_epi16(c, d);
1202
+ __m128i e47f47 = _mm_unpackhi_epi16(e, f);
1203
+ __m128i g47h47 = _mm_unpackhi_epi16(g, h);
1204
+
1205
+ __m128i a01b01c01d01 = _mm_unpacklo_epi32(a03b03, c03d03);
1206
+ __m128i a23b23c23d23 = _mm_unpackhi_epi32(a03b03, c03d03);
1207
+ __m128i e01f01g01h01 = _mm_unpacklo_epi32(e03f03, g03h03);
1208
+ __m128i e23f23g23h23 = _mm_unpackhi_epi32(e03f03, g03h03);
1209
+ __m128i a45b45c45d45 = _mm_unpacklo_epi32(a47b47, c47d47);
1210
+ __m128i a67b67c67d67 = _mm_unpackhi_epi32(a47b47, c47d47);
1211
+ __m128i e45f45g45h45 = _mm_unpacklo_epi32(e47f47, g47h47);
1212
+ __m128i e67f67g67h67 = _mm_unpackhi_epi32(e47f47, g47h47);
1213
+
1214
+ __m128i a0b0c0d0e0f0g0h0 = _mm_unpacklo_epi64(a01b01c01d01, e01f01g01h01);
1215
+ __m128i a1b1c1d1e1f1g1h1 = _mm_unpackhi_epi64(a01b01c01d01, e01f01g01h01);
1216
+ __m128i a2b2c2d2e2f2g2h2 = _mm_unpacklo_epi64(a23b23c23d23, e23f23g23h23);
1217
+ __m128i a3b3c3d3e3f3g3h3 = _mm_unpackhi_epi64(a23b23c23d23, e23f23g23h23);
1218
+ __m128i a4b4c4d4e4f4g4h4 = _mm_unpacklo_epi64(a45b45c45d45, e45f45g45h45);
1219
+ __m128i a5b5c5d5e5f5g5h5 = _mm_unpackhi_epi64(a45b45c45d45, e45f45g45h45);
1220
+ __m128i a6b6c6d6e6f6g6h6 = _mm_unpacklo_epi64(a67b67c67d67, e67f67g67h67);
1221
+ __m128i a7b7c7d7e7f7g7h7 = _mm_unpackhi_epi64(a67b67c67d67, e67f67g67h67);
1222
+
1223
+ kernel.packet[0] = a0b0c0d0e0f0g0h0;
1224
+ kernel.packet[1] = a1b1c1d1e1f1g1h1;
1225
+ kernel.packet[2] = a2b2c2d2e2f2g2h2;
1226
+ kernel.packet[3] = a3b3c3d3e3f3g3h3;
1227
+ kernel.packet[4] = a4b4c4d4e4f4g4h4;
1228
+ kernel.packet[5] = a5b5c5d5e5f5g5h5;
1229
+ kernel.packet[6] = a6b6c6d6e6f6g6h6;
1230
+ kernel.packet[7] = a7b7c7d7e7f7g7h7;
1231
+ }
1232
+
1233
+ EIGEN_STRONG_INLINE void
1234
+ ptranspose(PacketBlock<Packet8h,4>& kernel) {
1235
+ EIGEN_ALIGN32 Eigen::half in[4][8];
1236
+ pstore<Eigen::half>(in[0], kernel.packet[0]);
1237
+ pstore<Eigen::half>(in[1], kernel.packet[1]);
1238
+ pstore<Eigen::half>(in[2], kernel.packet[2]);
1239
+ pstore<Eigen::half>(in[3], kernel.packet[3]);
1240
+
1241
+ EIGEN_ALIGN32 Eigen::half out[4][8];
1242
+
1243
+ for (int i = 0; i < 4; ++i) {
1244
+ for (int j = 0; j < 4; ++j) {
1245
+ out[i][j] = in[j][2*i];
1246
+ }
1247
+ for (int j = 0; j < 4; ++j) {
1248
+ out[i][j+4] = in[j][2*i+1];
1249
+ }
1250
+ }
1251
+
1252
+ kernel.packet[0] = pload<Packet8h>(out[0]);
1253
+ kernel.packet[1] = pload<Packet8h>(out[1]);
1254
+ kernel.packet[2] = pload<Packet8h>(out[2]);
1255
+ kernel.packet[3] = pload<Packet8h>(out[3]);
1256
+ }
1257
+
1258
+ // BFloat16 implementation.
1259
+
1260
+ EIGEN_STRONG_INLINE Packet8f Bf16ToF32(const Packet8bf& a) {
1261
+ #ifdef EIGEN_VECTORIZE_AVX2
1262
+ __m256i extend = _mm256_cvtepu16_epi32(a);
1263
+ return _mm256_castsi256_ps(_mm256_slli_epi32(extend, 16));
1264
+ #else
1265
+ __m128i lo = _mm_cvtepu16_epi32(a);
1266
+ __m128i hi = _mm_cvtepu16_epi32(_mm_srli_si128(a, 8));
1267
+ __m128i lo_shift = _mm_slli_epi32(lo, 16);
1268
+ __m128i hi_shift = _mm_slli_epi32(hi, 16);
1269
+ return _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(lo_shift), hi_shift, 1));
1270
+ #endif
626
1271
  }
627
1272
 
628
- template<> EIGEN_STRONG_INLINE Packet4d pinsertlast(const Packet4d& a, double b)
1273
+ // Convert float to bfloat16 according to round-to-nearest-even/denormals algorithm.
1274
+ EIGEN_STRONG_INLINE Packet8bf F32ToBf16(const Packet8f& a) {
1275
+ Packet8bf r;
1276
+
1277
+ __m256i input = _mm256_castps_si256(a);
1278
+
1279
+ #ifdef EIGEN_VECTORIZE_AVX2
1280
+ // uint32_t lsb = (input >> 16);
1281
+ __m256i t = _mm256_srli_epi32(input, 16);
1282
+ // uint32_t lsb = lsb & 1;
1283
+ t = _mm256_and_si256(t, _mm256_set1_epi32(1));
1284
+ // uint32_t rounding_bias = 0x7fff + lsb;
1285
+ t = _mm256_add_epi32(t, _mm256_set1_epi32(0x7fff));
1286
+ // input += rounding_bias;
1287
+ t = _mm256_add_epi32(t, input);
1288
+ // input = input >> 16;
1289
+ t = _mm256_srli_epi32(t, 16);
1290
+ // Check NaN before converting back to bf16
1291
+ __m256 mask = _mm256_cmp_ps(a, a, _CMP_ORD_Q);
1292
+ __m256i nan = _mm256_set1_epi32(0x7fc0);
1293
+ t = _mm256_blendv_epi8(nan, t, _mm256_castps_si256(mask));
1294
+ // output = numext::bit_cast<uint16_t>(input);
1295
+ return _mm_packus_epi32(_mm256_extractf128_si256(t, 0),
1296
+ _mm256_extractf128_si256(t, 1));
1297
+ #else
1298
+ // uint32_t lsb = (input >> 16);
1299
+ __m128i lo = _mm_srli_epi32(_mm256_extractf128_si256(input, 0), 16);
1300
+ __m128i hi = _mm_srli_epi32(_mm256_extractf128_si256(input, 1), 16);
1301
+ // uint32_t lsb = lsb & 1;
1302
+ lo = _mm_and_si128(lo, _mm_set1_epi32(1));
1303
+ hi = _mm_and_si128(hi, _mm_set1_epi32(1));
1304
+ // uint32_t rounding_bias = 0x7fff + lsb;
1305
+ lo = _mm_add_epi32(lo, _mm_set1_epi32(0x7fff));
1306
+ hi = _mm_add_epi32(hi, _mm_set1_epi32(0x7fff));
1307
+ // input += rounding_bias;
1308
+ lo = _mm_add_epi32(lo, _mm256_extractf128_si256(input, 0));
1309
+ hi = _mm_add_epi32(hi, _mm256_extractf128_si256(input, 1));
1310
+ // input = input >> 16;
1311
+ lo = _mm_srli_epi32(lo, 16);
1312
+ hi = _mm_srli_epi32(hi, 16);
1313
+ // Check NaN before converting back to bf16
1314
+ __m256 mask = _mm256_cmp_ps(a, a, _CMP_ORD_Q);
1315
+ __m128i nan = _mm_set1_epi32(0x7fc0);
1316
+ lo = _mm_blendv_epi8(nan, lo, _mm_castps_si128(_mm256_castps256_ps128(mask)));
1317
+ hi = _mm_blendv_epi8(nan, hi, _mm_castps_si128(_mm256_extractf128_ps(mask, 1)));
1318
+ // output = numext::bit_cast<uint16_t>(input);
1319
+ return _mm_packus_epi32(lo, hi);
1320
+ #endif
1321
+ }
1322
+
1323
+ template<> EIGEN_STRONG_INLINE Packet8bf pset1<Packet8bf>(const bfloat16& from) {
1324
+ return _mm_set1_epi16(numext::bit_cast<numext::uint16_t>(from));
1325
+ }
1326
+
1327
+ template<> EIGEN_STRONG_INLINE bfloat16 pfirst<Packet8bf>(const Packet8bf& from) {
1328
+ return numext::bit_cast<bfloat16>(static_cast<numext::uint16_t>(_mm_extract_epi16(from, 0)));
1329
+ }
1330
+
1331
+ template<> EIGEN_STRONG_INLINE Packet8bf pload<Packet8bf>(const bfloat16* from) {
1332
+ return _mm_load_si128(reinterpret_cast<const __m128i*>(from));
1333
+ }
1334
+
1335
+ template<> EIGEN_STRONG_INLINE Packet8bf ploadu<Packet8bf>(const bfloat16* from) {
1336
+ return _mm_loadu_si128(reinterpret_cast<const __m128i*>(from));
1337
+ }
1338
+
1339
+ template<> EIGEN_STRONG_INLINE void pstore<bfloat16>(bfloat16* to, const Packet8bf& from) {
1340
+ _mm_store_si128(reinterpret_cast<__m128i*>(to), from);
1341
+ }
1342
+
1343
+ template<> EIGEN_STRONG_INLINE void pstoreu<bfloat16>(bfloat16* to, const Packet8bf& from) {
1344
+ _mm_storeu_si128(reinterpret_cast<__m128i*>(to), from);
1345
+ }
1346
+
1347
+ template<> EIGEN_STRONG_INLINE Packet8bf
1348
+ ploaddup<Packet8bf>(const bfloat16* from) {
1349
+ const numext::uint16_t a = numext::bit_cast<numext::uint16_t>(from[0]);
1350
+ const numext::uint16_t b = numext::bit_cast<numext::uint16_t>(from[1]);
1351
+ const numext::uint16_t c = numext::bit_cast<numext::uint16_t>(from[2]);
1352
+ const numext::uint16_t d = numext::bit_cast<numext::uint16_t>(from[3]);
1353
+ return _mm_set_epi16(d, d, c, c, b, b, a, a);
1354
+ }
1355
+
1356
+ template<> EIGEN_STRONG_INLINE Packet8bf
1357
+ ploadquad<Packet8bf>(const bfloat16* from) {
1358
+ const numext::uint16_t a = numext::bit_cast<numext::uint16_t>(from[0]);
1359
+ const numext::uint16_t b = numext::bit_cast<numext::uint16_t>(from[1]);
1360
+ return _mm_set_epi16(b, b, b, b, a, a, a, a);
1361
+ }
1362
+
1363
+ template<> EIGEN_STRONG_INLINE Packet8bf ptrue(const Packet8bf& a) {
1364
+ return _mm_cmpeq_epi32(a, a);
1365
+ }
1366
+
1367
+ template <>
1368
+ EIGEN_STRONG_INLINE Packet8bf pabs(const Packet8bf& a) {
1369
+ const __m128i sign_mask = _mm_set1_epi16(static_cast<numext::uint16_t>(0x8000));
1370
+ return _mm_andnot_si128(sign_mask, a);
1371
+ }
1372
+
1373
+ template <>
1374
+ EIGEN_STRONG_INLINE Packet8bf pmin<Packet8bf>(const Packet8bf& a,
1375
+ const Packet8bf& b) {
1376
+ return F32ToBf16(pmin<Packet8f>(Bf16ToF32(a), Bf16ToF32(b)));
1377
+ }
1378
+
1379
+ template <>
1380
+ EIGEN_STRONG_INLINE Packet8bf pmax<Packet8bf>(const Packet8bf& a,
1381
+ const Packet8bf& b) {
1382
+ return F32ToBf16(pmax<Packet8f>(Bf16ToF32(a), Bf16ToF32(b)));
1383
+ }
1384
+
1385
+ template <>
1386
+ EIGEN_STRONG_INLINE Packet8bf plset<Packet8bf>(const bfloat16& a) {
1387
+ return F32ToBf16(plset<Packet8f>(static_cast<float>(a)));
1388
+ }
1389
+
1390
+ template<> EIGEN_STRONG_INLINE Packet8bf por(const Packet8bf& a,const Packet8bf& b) {
1391
+ return _mm_or_si128(a,b);
1392
+ }
1393
+ template<> EIGEN_STRONG_INLINE Packet8bf pxor(const Packet8bf& a,const Packet8bf& b) {
1394
+ return _mm_xor_si128(a,b);
1395
+ }
1396
+ template<> EIGEN_STRONG_INLINE Packet8bf pand(const Packet8bf& a,const Packet8bf& b) {
1397
+ return _mm_and_si128(a,b);
1398
+ }
1399
+ template<> EIGEN_STRONG_INLINE Packet8bf pandnot(const Packet8bf& a,const Packet8bf& b) {
1400
+ return _mm_andnot_si128(b,a);
1401
+ }
1402
+
1403
+ template<> EIGEN_STRONG_INLINE Packet8bf pselect(const Packet8bf& mask, const Packet8bf& a, const Packet8bf& b) {
1404
+ return _mm_blendv_epi8(b, a, mask);
1405
+ }
1406
+
1407
+ template<> EIGEN_STRONG_INLINE Packet8bf pround<Packet8bf>(const Packet8bf& a)
629
1408
  {
630
- return _mm256_blend_pd(a,pset1<Packet4d>(b),(1<<3));
1409
+ return F32ToBf16(pround<Packet8f>(Bf16ToF32(a)));
1410
+ }
1411
+
1412
+ template<> EIGEN_STRONG_INLINE Packet8bf print<Packet8bf>(const Packet8bf& a) {
1413
+ return F32ToBf16(print<Packet8f>(Bf16ToF32(a)));
1414
+ }
1415
+
1416
+ template<> EIGEN_STRONG_INLINE Packet8bf pceil<Packet8bf>(const Packet8bf& a) {
1417
+ return F32ToBf16(pceil<Packet8f>(Bf16ToF32(a)));
1418
+ }
1419
+
1420
+ template<> EIGEN_STRONG_INLINE Packet8bf pfloor<Packet8bf>(const Packet8bf& a) {
1421
+ return F32ToBf16(pfloor<Packet8f>(Bf16ToF32(a)));
1422
+ }
1423
+
1424
+ template<> EIGEN_STRONG_INLINE Packet8bf pcmp_eq(const Packet8bf& a,const Packet8bf& b) {
1425
+ return Pack16To8(pcmp_eq(Bf16ToF32(a), Bf16ToF32(b)));
1426
+ }
1427
+
1428
+ template<> EIGEN_STRONG_INLINE Packet8bf pcmp_le(const Packet8bf& a,const Packet8bf& b) {
1429
+ return Pack16To8(pcmp_le(Bf16ToF32(a), Bf16ToF32(b)));
1430
+ }
1431
+
1432
+ template<> EIGEN_STRONG_INLINE Packet8bf pcmp_lt(const Packet8bf& a,const Packet8bf& b) {
1433
+ return Pack16To8(pcmp_lt(Bf16ToF32(a), Bf16ToF32(b)));
1434
+ }
1435
+
1436
+ template<> EIGEN_STRONG_INLINE Packet8bf pcmp_lt_or_nan(const Packet8bf& a,const Packet8bf& b) {
1437
+ return Pack16To8(pcmp_lt_or_nan(Bf16ToF32(a), Bf16ToF32(b)));
1438
+ }
1439
+
1440
+ template<> EIGEN_STRONG_INLINE Packet8bf pconj(const Packet8bf& a) { return a; }
1441
+
1442
+ template<> EIGEN_STRONG_INLINE Packet8bf pnegate(const Packet8bf& a) {
1443
+ Packet8bf sign_mask = _mm_set1_epi16(static_cast<numext::uint16_t>(0x8000));
1444
+ return _mm_xor_si128(a, sign_mask);
1445
+ }
1446
+
1447
+ template<> EIGEN_STRONG_INLINE Packet8bf padd<Packet8bf>(const Packet8bf& a, const Packet8bf& b) {
1448
+ return F32ToBf16(padd<Packet8f>(Bf16ToF32(a), Bf16ToF32(b)));
1449
+ }
1450
+
1451
+ template<> EIGEN_STRONG_INLINE Packet8bf psub<Packet8bf>(const Packet8bf& a, const Packet8bf& b) {
1452
+ return F32ToBf16(psub<Packet8f>(Bf16ToF32(a), Bf16ToF32(b)));
1453
+ }
1454
+
1455
+ template<> EIGEN_STRONG_INLINE Packet8bf pmul<Packet8bf>(const Packet8bf& a, const Packet8bf& b) {
1456
+ return F32ToBf16(pmul<Packet8f>(Bf16ToF32(a), Bf16ToF32(b)));
1457
+ }
1458
+
1459
+ template<> EIGEN_STRONG_INLINE Packet8bf pdiv<Packet8bf>(const Packet8bf& a, const Packet8bf& b) {
1460
+ return F32ToBf16(pdiv<Packet8f>(Bf16ToF32(a), Bf16ToF32(b)));
1461
+ }
1462
+
1463
+
1464
+ template<> EIGEN_STRONG_INLINE Packet8bf pgather<bfloat16, Packet8bf>(const bfloat16* from, Index stride)
1465
+ {
1466
+ const numext::uint16_t s0 = numext::bit_cast<numext::uint16_t>(from[0*stride]);
1467
+ const numext::uint16_t s1 = numext::bit_cast<numext::uint16_t>(from[1*stride]);
1468
+ const numext::uint16_t s2 = numext::bit_cast<numext::uint16_t>(from[2*stride]);
1469
+ const numext::uint16_t s3 = numext::bit_cast<numext::uint16_t>(from[3*stride]);
1470
+ const numext::uint16_t s4 = numext::bit_cast<numext::uint16_t>(from[4*stride]);
1471
+ const numext::uint16_t s5 = numext::bit_cast<numext::uint16_t>(from[5*stride]);
1472
+ const numext::uint16_t s6 = numext::bit_cast<numext::uint16_t>(from[6*stride]);
1473
+ const numext::uint16_t s7 = numext::bit_cast<numext::uint16_t>(from[7*stride]);
1474
+ return _mm_set_epi16(s7, s6, s5, s4, s3, s2, s1, s0);
1475
+ }
1476
+
1477
+ template<> EIGEN_STRONG_INLINE void pscatter<bfloat16, Packet8bf>(bfloat16* to, const Packet8bf& from, Index stride)
1478
+ {
1479
+ EIGEN_ALIGN32 bfloat16 aux[8];
1480
+ pstore(aux, from);
1481
+ to[stride*0] = aux[0];
1482
+ to[stride*1] = aux[1];
1483
+ to[stride*2] = aux[2];
1484
+ to[stride*3] = aux[3];
1485
+ to[stride*4] = aux[4];
1486
+ to[stride*5] = aux[5];
1487
+ to[stride*6] = aux[6];
1488
+ to[stride*7] = aux[7];
1489
+ }
1490
+
1491
+ template<> EIGEN_STRONG_INLINE bfloat16 predux<Packet8bf>(const Packet8bf& a) {
1492
+ return static_cast<bfloat16>(predux<Packet8f>(Bf16ToF32(a)));
1493
+ }
1494
+
1495
+ template<> EIGEN_STRONG_INLINE bfloat16 predux_max<Packet8bf>(const Packet8bf& a) {
1496
+ return static_cast<bfloat16>(predux_max<Packet8f>(Bf16ToF32(a)));
1497
+ }
1498
+
1499
+ template<> EIGEN_STRONG_INLINE bfloat16 predux_min<Packet8bf>(const Packet8bf& a) {
1500
+ return static_cast<bfloat16>(predux_min<Packet8f>(Bf16ToF32(a)));
1501
+ }
1502
+
1503
+ template<> EIGEN_STRONG_INLINE bfloat16 predux_mul<Packet8bf>(const Packet8bf& a) {
1504
+ return static_cast<bfloat16>(predux_mul<Packet8f>(Bf16ToF32(a)));
1505
+ }
1506
+
1507
+ template<> EIGEN_STRONG_INLINE Packet8bf preverse(const Packet8bf& a)
1508
+ {
1509
+ __m128i m = _mm_setr_epi8(14,15,12,13,10,11,8,9,6,7,4,5,2,3,0,1);
1510
+ return _mm_shuffle_epi8(a,m);
1511
+ }
1512
+
1513
+ EIGEN_STRONG_INLINE void
1514
+ ptranspose(PacketBlock<Packet8bf,8>& kernel) {
1515
+ __m128i a = kernel.packet[0];
1516
+ __m128i b = kernel.packet[1];
1517
+ __m128i c = kernel.packet[2];
1518
+ __m128i d = kernel.packet[3];
1519
+ __m128i e = kernel.packet[4];
1520
+ __m128i f = kernel.packet[5];
1521
+ __m128i g = kernel.packet[6];
1522
+ __m128i h = kernel.packet[7];
1523
+
1524
+ __m128i a03b03 = _mm_unpacklo_epi16(a, b);
1525
+ __m128i c03d03 = _mm_unpacklo_epi16(c, d);
1526
+ __m128i e03f03 = _mm_unpacklo_epi16(e, f);
1527
+ __m128i g03h03 = _mm_unpacklo_epi16(g, h);
1528
+ __m128i a47b47 = _mm_unpackhi_epi16(a, b);
1529
+ __m128i c47d47 = _mm_unpackhi_epi16(c, d);
1530
+ __m128i e47f47 = _mm_unpackhi_epi16(e, f);
1531
+ __m128i g47h47 = _mm_unpackhi_epi16(g, h);
1532
+
1533
+ __m128i a01b01c01d01 = _mm_unpacklo_epi32(a03b03, c03d03);
1534
+ __m128i a23b23c23d23 = _mm_unpackhi_epi32(a03b03, c03d03);
1535
+ __m128i e01f01g01h01 = _mm_unpacklo_epi32(e03f03, g03h03);
1536
+ __m128i e23f23g23h23 = _mm_unpackhi_epi32(e03f03, g03h03);
1537
+ __m128i a45b45c45d45 = _mm_unpacklo_epi32(a47b47, c47d47);
1538
+ __m128i a67b67c67d67 = _mm_unpackhi_epi32(a47b47, c47d47);
1539
+ __m128i e45f45g45h45 = _mm_unpacklo_epi32(e47f47, g47h47);
1540
+ __m128i e67f67g67h67 = _mm_unpackhi_epi32(e47f47, g47h47);
1541
+
1542
+ kernel.packet[0] = _mm_unpacklo_epi64(a01b01c01d01, e01f01g01h01);
1543
+ kernel.packet[1] = _mm_unpackhi_epi64(a01b01c01d01, e01f01g01h01);
1544
+ kernel.packet[2] = _mm_unpacklo_epi64(a23b23c23d23, e23f23g23h23);
1545
+ kernel.packet[3] = _mm_unpackhi_epi64(a23b23c23d23, e23f23g23h23);
1546
+ kernel.packet[4] = _mm_unpacklo_epi64(a45b45c45d45, e45f45g45h45);
1547
+ kernel.packet[5] = _mm_unpackhi_epi64(a45b45c45d45, e45f45g45h45);
1548
+ kernel.packet[6] = _mm_unpacklo_epi64(a67b67c67d67, e67f67g67h67);
1549
+ kernel.packet[7] = _mm_unpackhi_epi64(a67b67c67d67, e67f67g67h67);
1550
+ }
1551
+
1552
+ EIGEN_STRONG_INLINE void
1553
+ ptranspose(PacketBlock<Packet8bf,4>& kernel) {
1554
+ __m128i a = kernel.packet[0];
1555
+ __m128i b = kernel.packet[1];
1556
+ __m128i c = kernel.packet[2];
1557
+ __m128i d = kernel.packet[3];
1558
+
1559
+ __m128i ab_03 = _mm_unpacklo_epi16(a, b);
1560
+ __m128i cd_03 = _mm_unpacklo_epi16(c, d);
1561
+ __m128i ab_47 = _mm_unpackhi_epi16(a, b);
1562
+ __m128i cd_47 = _mm_unpackhi_epi16(c, d);
1563
+
1564
+ kernel.packet[0] = _mm_unpacklo_epi32(ab_03, cd_03);
1565
+ kernel.packet[1] = _mm_unpackhi_epi32(ab_03, cd_03);
1566
+ kernel.packet[2] = _mm_unpacklo_epi32(ab_47, cd_47);
1567
+ kernel.packet[3] = _mm_unpackhi_epi32(ab_47, cd_47);
631
1568
  }
632
1569
 
633
1570
  } // end namespace internal