msokalski / delabella

2D Delaunay triangulation (dela) - super stable (bella!)
Other
213 stars 24 forks source link

Illegal hardware instruction #14

Open ramcdona opened 11 months ago

ramcdona commented 11 months ago

It appears that Delabella does not work in Rosetta2 on M1 Macs.

At present, some unrelated issues prevent me from compiling my application as a native aarch64 application for M1 Macs. Instead, I rely on the emulator Rosetta2 to run an X86-64 build on the M1 Mac. This has always worked before.

Now with Delabella, the program crashes on load with 'illegal hardware instruction'.

It appears that Rosetta2 does not support any AVX instructions. I suspect the problem may be the FMA instruction, I will try to build without it and report back. Unfortunately, I seem to recall running into other problems if I built without FMA before...

msokalski commented 11 months ago

Oh, I felt in my guts it will come back. I'll fix it as soon as I can, probably after the weekend.

ramcdona commented 11 months ago

Previously, when I was discussing a M1 build, it was a native M1 build. Although my program requires x86-64 for everything to work, I do most of my development on a M1 (and I just don't use the parts that don't work there).

I had never had a problem with Rosetta2 before, so I hadn't adequately tested it until I made my release builds (using a GitHub Actions build server automated process) that builds x86-64 binaries for Mac. Those binaries are the ones that give the illegal hardware instruction when running on an M1.

As a test, I changed the -mfma to -mno-fma in the CMakeLists.txt and re-built a x86-64 binary. It runs (without the illegal hardware instruction) on my M1 Mac.

It also seems to work for certain simple cases. However, for a more complex test case, it sends Delabella into an infinite loop on both M1 and x86-64.

I will try to isolate a case that exhibits this behavior.

ramcdona commented 11 months ago

This test file (using the test application from before) will go into an infinite loop when Delabella is built with -mno-fma on clang/xcode. The infinite loop is actually in constrain edges, not the main triangulation.

dlbtest_367.txt