-1

I am currently studying to become a computer engineer and I need to work with OpenMP. After some research, I'm still having trouble installing it (#include <omp.h> is still not recognized). I tried libomp and llvm (with homebrew), but I must have made a mistake along the way. Has anyone been able to use OpenMP on mac M1?

Théo Souchon

  • most libraries are split into two packages. The normal runtime library in one, and the headers in a separate dev or devel package. For development you need both. – stark Feb 10 '22 at 12:53

2 Answers2

0

A simple approach is to use brew https://brew.sh/ to install GCC or LLVM (clang), and then use that compiler. You need to tread carefully, though, since the MacOS environment includes X86 emulation which can be confusing.

https://cpufun.substack.com/p/setting-up-the-apple-m1-for-native might help, though it's now nearly a year old...

Jim Cownie
  • 2,124
  • 1
  • 10
  • 18
  • I forgot to mention it but when I tried to install libomp and llvm I did it using homebrew. They are installed fine but impossible to import omp.h. I can compile any kind of file in C but not with this library – Théo Souchon Feb 11 '22 at 08:50
  • If you install LLVM you should not need to separately install libomp. Are you completely sure that you are using the brew-installed clang? The Apple development environment also includes an alias that means it can appear as clang too... (You might also find the hack at the end of https://stackoverflow.com/questions/65293299/how-to-build-llvm-clang-clang-for-apple-m1 useful) – Jim Cownie Feb 14 '22 at 09:07
  • I have recently after several tests launched this command: "clang -Xpreprocessor -v -fopenmp fichier.c -lomp" and only -lomp could not be executed. I think that the post you sent me must contain the solution to my problem but I don't have the necessary knowledge to solve this problem. Is a flag, is a link that allows us to find some missing library at the origin. And yes it is clear that I must have problems between the clang provided by apple and that installed via homebrew. – Théo Souchon Feb 15 '22 at 15:41
  • First, work out which clang you are executing, `% which clang`. If it's not the brew installed one, then fix your `PATH` so that it is and try again. – Jim Cownie Feb 15 '22 at 16:11
  • theosouchon@MacBook-Pro-de-Theo ~ % which clang /opt/homebrew/opt/llvm/bin/clang – Théo Souchon Feb 15 '22 at 16:16
  • OK, so it is the right compiler. In which case forcing the library path (as outlined near the end of the previous answer where we create a shell script to invoke the compiler (tagged with "I am not recommending this particularly")) may be what you need to do. – Jim Cownie Feb 15 '22 at 16:20
  • When you say you don't particularly recommend it, are you referring to your post you shared your link to? Otherwise I don't really understand what I should do now. – Théo Souchon Feb 16 '22 at 09:20
  • In that post I am saying that using a script like that to force additional arguments to the compiler is a hack, and therefore not to be particularly recommended. However, it is a hack which works. So it can be useful, but remains a hack to be treated with care. – Jim Cownie Feb 16 '22 at 16:33
  • ok, so apart from this hack there is no viable solution that you know of? – Théo Souchon Feb 17 '22 at 10:11
  • The hack is all I need, so I stopped looking. (Which doesn't mean there isn't a better solution, just that I ran out of energy to look for one and got back to doing more interesting things) – Jim Cownie Feb 17 '22 at 16:34
0

M1 chip seems doesn't install llvm in the proper location.

brew install llvm
cd /opt/homebrew/opt/libomp/lib

if libomp.dylib is in the folder /opt/homebrew/opt/libomp/lib:

cd /usr/local/lib
sudo ln -s /opt/homebrew/opt/libomp/lib/libomp.dylib libomp.dylib
Qin
  • 1
  • 1