steve-the-bayesian / BOOM

A C++ library for Bayesian modeling, mainly through Markov chain Monte Carlo, but with a few other methods supported. BOOM = "Bayesian Object Oriented Modeling". It is also the sound your computer makes when it crashes.
GNU Lesser General Public License v2.1
35 stars 14 forks source link

Bundled Eigen is broken for Darwin PowerPC: either update to a newer version or at least disable Altivec for Darwin #78

Open barracuda156 opened 8 months ago

barracuda156 commented 8 months ago

Upstream eigen has merged a fix for Darwin PowerPC quite some time ago, AFAIK it should work, at least I use devel branch for building ports and nothing so far fails. However Boom uses, apparently, quite old eigen, which breaks the build, since unsupported VSX instructions are pulled in.

A quick-n-dirty fix will be disabling Altivec/VSX like this:

--- inst/include/Eigen/Core 2023-12-18 01:53:40.000000000 +0800
+++ inst/include/Eigen/Core 2023-12-19 02:58:58.000000000 +0800
@@ -206,7 +206,7 @@
   #include "src/Core/arch/SSE/TypeCasting.h"
   #include "src/Core/arch/SSE/MathFunctions.h"
   #include "src/Core/arch/SSE/Complex.h"
-#elif defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
+#elif (defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)) && !defined(__APPLE__)
   #include "src/Core/arch/AltiVec/PacketMath.h"
   #include "src/Core/arch/AltiVec/MathFunctions.h"
   #include "src/Core/arch/AltiVec/Complex.h"
@@ -346,7 +346,7 @@
 #include "src/Core/CoreIterators.h"
 #include "src/Core/ConditionEstimator.h"

-#if defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)
+#if (defined(EIGEN_VECTORIZE_ALTIVEC) || defined(EIGEN_VECTORIZE_VSX)) && !defined(__APPLE__)
   #include "src/Core/arch/AltiVec/MatrixProduct.h"
 #elif defined EIGEN_VECTORIZE_NEON
   #include "src/Core/arch/NEON/GeneralBlockPanelKernel.h"
barracuda156 commented 8 months ago

@steve-the-bayesian I could make a PR with this, if it makes it easier. Not using a bit of supported altivec on G5 is definitely better than having the build broken :)

As I recall, backporting may not be trivial, so until eigen is updated, rather disable simd on Darwin ppc.

barracuda156 commented 7 months ago

Or even better if there will be an option to use an external Eigen.

steve-the-bayesian commented 6 months ago

I tried updating Eigen to 3.4 on a recent build. No code changed? I'd be curious to see your PR.

On Sat, Feb 3, 2024 at 3:40 PM Sergey Fedorov @.***> wrote:

Or even better if there will be an option to use an external Eigen.

— Reply to this email directly, view it on GitHub https://github.com/steve-the-bayesian/BOOM/issues/78#issuecomment-1925487081, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMVDVLU2RL26L6ODUP44SLYR3DFPAVCNFSM6AAAAABA2D242SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVGQ4DOMBYGE . You are receiving this because you were mentioned.Message ID: @.***>

barracuda156 commented 6 months ago

I tried updating Eigen to 3.4 on a recent build. No code changed? I'd be curious to see your PR.

The issue was fixed in Eigen master in https://gitlab.com/libeigen/eigen/-/merge_requests/1150 So 3.4 still has the bug.