CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Openfoam v2106 on MacOS M1 chip

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 3 Post By LongGe
  • 1 Post By LongGe
  • 2 Post By gerlero

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 4, 2021, 18:19
Default Openfoam v2106 on MacOS M1 chip
  #1
New Member
 
Tural Mammadli
Join Date: Oct 2021
Posts: 1
Rep Power: 0
turalmammadli is on a distinguished road
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.
Attached Images
File Type: jpg Screen Shot 2021-09-22 at 18.14.10.jpg (69.0 KB, 66 views)
File Type: jpg Screen Shot 2021-09-23 at 17.07.17.jpg (144.8 KB, 40 views)
File Type: jpg Screen Shot 2021-09-23 at 17.05.25.jpg (135.7 KB, 39 views)
turalmammadli is offline   Reply With Quote

Old   October 17, 2021, 19:29
Default
  #2
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
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/
LongGe is offline   Reply With Quote

Old   October 29, 2021, 04:59
Default
  #3
tkr
New Member
 
Join Date: Nov 2020
Posts: 5
Rep Power: 6
tkr is on a distinguished road
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?
tkr is offline   Reply With Quote

Old   October 30, 2021, 01:43
Default
  #4
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
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)
sourav90, Ship Designer and tkr like this.
LongGe is offline   Reply With Quote

Old   November 2, 2021, 22:57
Default
  #5
Senior Member
 
Join Date: Jun 2016
Posts: 102
Rep Power: 10
xuegy is on a distinguished road
Quote:
Originally Posted by LongGe View Post
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/
Hello Tatsuya. I'm trying to utilize your feexceptErsatz.H in my build. The code can be built, but it doesn't trigger sigFpe like Intel.

Also, for third-party path, you can use /opt/homebrew/opt/*** so it won't change after updates.
xuegy is offline   Reply With Quote

Old   November 3, 2021, 21:51
Default
  #6
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
Quote:
Originally Posted by xuegy View Post
Hello Tatsuya. I'm trying to utilize your feexceptErsatz.H in my build. The code can be built, but it doesn't trigger sigFpe like Intel.

Also, for third-party path, you can use /opt/homebrew/opt/*** so it won't change after updates.
Which OpenFOAM are you talking about? I mean OpenCFD-ESI or Foundation Edition.

The sigFpe is different in these two versions. And I only use OpenCFD-ESI, and this is the only version I have tested.
LongGe is offline   Reply With Quote

Old   November 3, 2021, 22:01
Default
  #7
Senior Member
 
Join Date: Jun 2016
Posts: 102
Rep Power: 10
xuegy is on a distinguished road
Quote:
Originally Posted by LongGe View Post
Which OpenFOAM are you talking about? I mean OpenCFD-ESI or Foundation Edition.

The sigFpe is different in these two versions. And I only use OpenCFD-ESI, and this is the only version I have tested.
It's OpenFOAM-v2106. I need some help to catch sigfpe in M1.
Shall we move to this page to discuss? https://github.com/mrklein/openfoam-os-x/issues/68
xuegy is offline   Reply With Quote

Old   November 4, 2021, 21:22
Default
  #8
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
Quote:
Originally Posted by xuegy View Post
It's OpenFOAM-v2106. I need some help to catch sigfpe in M1.
Shall we move to this page to discuss? https://github.com/mrklein/openfoam-os-x/issues/68
I have seen the thread in the link. You want to implement floating point exception traps in clang. floating point exception traps are implemented in M1 Mac, but clang doesn't have a built-in function to access FPCR. M1 Mac+gcc can access FPCR with "__builtin_aarch64_get_fpcr / __builtin_aarch64_set_fpcr".

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));
}
LongGe is offline   Reply With Quote

Old   November 5, 2021, 05:08
Default
  #9
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
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.
LongGe is offline   Reply With Quote

Old   November 5, 2021, 10:26
Default
  #10
Senior Member
 
Join Date: Jun 2016
Posts: 102
Rep Power: 10
xuegy is on a distinguished road
Thanks for the information. I've already made it buildable by totally disabling sigfpe. Let me try gcc first then go for clang.
xuegy is offline   Reply With Quote

Old   November 9, 2021, 00:52
Default
  #11
Senior Member
 
Join Date: Jun 2016
Posts: 102
Rep Power: 10
xuegy is on a distinguished road
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'
[1]    2145 abort      blockMesh
I've never seen this type of error on Linux. Which compiler option should I add to gcc?
xuegy is offline   Reply With Quote

Old   November 9, 2021, 01:20
Default
  #12
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
Quote:
Originally Posted by xuegy View Post
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'
[1]    2145 abort      blockMesh
I've never seen this type of error on Linux. Which compiler option should I add to gcc?
The reason is described in the following link.

https://stackoverflow.com/questions/...-actually-mean
LongGe is offline   Reply With Quote

Old   November 9, 2021, 02:12
Default
  #13
Senior Member
 
Join Date: Jun 2016
Posts: 102
Rep Power: 10
xuegy is on a distinguished road
Could you please share your compiler flags of gcc? Also is that from homebrew or you compiled it yourself?
xuegy is offline   Reply With Quote

Old   December 14, 2021, 05:23
Default
  #14
New Member
 
Xutong
Join Date: Nov 2018
Posts: 3
Rep Power: 8
zhxutong is on a distinguished road
Quote:
Originally Posted by LongGe View Post
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/
Hi Tastuya,

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'
Ostream& operator<<(Ostream& os, const std::wstring& wstr);
followed by

Code:
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/iosfwd:219:14: error: reference to unresolved using declaration
typedef fpos<mbstate_t>    streampos;
             ^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/cwchar:117:1: note: using declaration annotated with 'using_if_exists' here
_LIBCPP_USING_IF_EXISTS(::mbstate_t);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/__config:232:39: note: expanded from macro '_LIBCPP_USING_IF_EXISTS'
# define _LIBCPP_USING_IF_EXISTS(...) using __VA_ARGS__ __attribute__((using_if_exists))
Does this suggest that some packages missed?

Here is my clang version
Code:
clang++ --version 
Apple clang version 13.0.0 (clang-1300.0.27.3)
Target: arm64-apple-darwin21.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Thanks a lot for your attention! Looking forward to hearing back from you.
zhxutong is offline   Reply With Quote

Old   December 15, 2021, 01:07
Default
  #15
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 14
LongGe is on a distinguished road
Hello Zhong

My guess is that it's either a clang version or a case-sensitive issue.
zhxutong likes this.
LongGe is offline   Reply With Quote

Old   January 1, 2022, 15:45
Default Working (partially at the moment) in M1Pro
  #16
Member
 
Sourav Mandal
Join Date: Jul 2019
Posts: 55
Rep Power: 7
sourav90 is on a distinguished road
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

Last edited by sourav90; January 1, 2022 at 19:46.
sourav90 is offline   Reply With Quote

Old   January 3, 2022, 13:58
Default
  #17
New Member
 
Gabriel Gerlero
Join Date: Jan 2022
Posts: 21
Rep Power: 4
gerlero is on a distinguished road
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.
zhxutong and sourav90 like this.
gerlero is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 3 November 14, 2023 12:58
UNIGE February 13th-17th - 2107. OpenFOAM advaced training days joegi.geo OpenFOAM Announcements from Other Sources 0 October 1, 2016 20:20
[OpenFOAM.org] paraFoam, for OpenFOAM 2.3.x on MacOS X? ajmas OpenFOAM Installation 3 March 15, 2015 19:27
OpenFOAM Foundation releases OpenFOAM 2.2.2 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 October 14, 2013 08:18
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 19:07


All times are GMT -4. The time now is 17:20.