Openfoam v2106 on MacOS M1 chip
3 Attachment(s)
Hi everyone,
Have anyone been able to install v2106 version on M1 chip MacOS? I have been trying to get this v2106 on my laptop for two days but havent been succesfull yet. On my laptop i already have a version of openfoam8 but in some cases there have been some errors appearing in which some functions are not matching properly. Here I put the errors that I came across running "Allrun". So the solution seems like either I have to install v2106 version or correct these errors according to Openfoam 8 syntax. Below I attach the "Allrun", and log files that errors appeared in. Any help would be highly appreciated.:) |
Hello All
I am able to use OpenFOAM-v2106 on my M1 Mac. Here are the build instructions for your reference. https://ttsyshmz.github.io/howtoFoam...2106-on-m1mac/ |
Could you give us more information, please? How did you build the OpenFOAM environment on the M1?
@LongGe Do you have any information about the performance on the M1 chip? How fast does OpenFOAM work on the Mac? |
Hello All
My development environment is M1 Mac mini and M1 Macbook Air. Here is the development environment in which I built the OpenCFD-ESI version of OpenFOAM-v2106. All 3rdParties have the arm64 version installed in brew. I usually do a code development on a Mac, but I don't care about the computational speed of the M1 Mac because I put calculation into the Xeon cluster. For your reference, here are the results of the tutorial case calculated on an M1 Mac, so you can compare them with the results on your machine. OS: Darwin 20.6.0 Darwin Kernel Version 20.6.0: arm64 Disk: /Volumes/home3 Case-sensitive APFS XCode Command Line Tools: Apple clang version 12.0.5 (clang-1205.0.22.11) Target: arm64-apple-darwin20.6.0 3rdParty: /opt/homebrew/Cellar/cgal/5.3 /opt/homebrew/Cellar/fftw/3.3.10 /opt/homebrew/Cellar/adios2/2.7.1_1 /opt/homebrew/Cellar/cmake/3.21.3_1 /opt/homebrew/Cellar/kahip/3.11 /opt/homebrew/Cellar/metis/5.1.0 /opt/homebrew/Cellar/open-mpi/4.1.1_2 /opt/homebrew/Cellar/scotch/6.1.1 Benchmark test: case: OpenFOAM-v2106/tutorials/incompressible/simpleFoam/backwardFacingStep2D 1 core: ExecutionTime = 58.18 s ClockTime = 59 s (simpleFoam only) 4 cores: ExecutionTime = 23.51 s ClockTime = 25 s (simpleFoam only) |
Quote:
Also, for third-party path, you can use /opt/homebrew/opt/*** so it won't change after updates. |
Quote:
The sigFpe is different in these two versions. And I only use OpenCFD-ESI, and this is the only version I have tested. |
Quote:
Shall we move to this page to discuss? https://github.com/mrklein/openfoam-os-x/issues/68 |
Quote:
In other words, if you use M1 Mac + clang, you will need to implement the FPCR access functions yourself. It may or may not work, but you will need at least the following accessors. __attribute__((always_inline)) uint64_t getFpcr(){ uint64_t fpcr; asm volatile("mrs %0, fpcr" : "=r"(fpcr)); return fpcr; } __attribute__((always_inline)) void setFpcr(uint64_t x){ asm volatile("msr fpcr, %0" : : "r"(x)); } |
Hello xuegy
Here is some additional information for your reference. If you put "#pragma STDC FENV_ACCESS ON" in "feexceptErsatz.H", "feexceptErsatz.H" will work correctly. This is a common practice for everyone. Build this "feexceptErsatz.H" with clang. Then you will see the following message, which means that you have to implement the accessor yourself. POSIX % ./Allwmake wmake libo (POSIX) ....... ....... In file included from signals/sigFpe.C:48: signals/feexceptErsatz.H:28:14: warning: pragma STDC FENV_ACCESS ON is not supported, ignoring pragma [-Wunknown-pragmas] There are two philosophies when implementing an accessor. One is to put it in fenv.h as a macro, and the other is to put it in feexceptErsatz.H. There is a non-zero chance that clang will support it in the near future, so implementing it in feexceptErsatz.H is also delicate. Therefore, I am aiming to make v2106 buildable first, and then include a mechanism to trap floating point exceptions. |
Thanks for the information. I've already made it buildable by totally disabling sigfpe. Let me try gcc first then go for clang.
|
I've managed to build with gcc (homebrew gcc can't find flex, gmp & mpfr) but still got this error message when running
Code:
dyld[2145]: symbol not found in flat namespace '__ZN4Foam9Function1IiE30dictionaryConstructorTablePtr_B5cxx11E' |
Quote:
https://stackoverflow.com/questions/...-actually-mean |
Could you please share your compiler flags of gcc? Also is that from homebrew or you compiled it yourself?
|
Quote:
Thanks so much for sharing this instruction. I am quite new with code developing and currently trying to compile OF on my M1 chip following your instruction. When I did ./Allwamke, it somehow returns: Code:
/Users/zhxutong/OpenFOAM-v2106/src/OpenFOAM/lnInclude/wchar.h:65:45: error: no type named 'wstring' in namespace 'std' Code:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/iosfwd:219:14: error: reference to unresolved using declaration Here is my clang version Code:
clang++ --version |
Hello Zhong
My guess is that it's either a clang version or a case-sensitive issue. |
Working (partially at the moment) in M1Pro
With the help of the helpful volunteers in the community I am able to run v2106 in M1Pro, posting here the link, thinking it might help some people who might face similar issues:
OpenFOAM-AppleM1-issues |
If you're willing to use Docker, I've made pre-built images of OpenFOAM for ARM, which I make available here in this GitHub project. They run just fine on my M1 Mac, and much faster than the official OpenFOAM x86 Docker images due to the lack of emulation.
|
All times are GMT -4. The time now is 10:13. |