Apple Silicon M1 Pro 上的 MPI 和 OpenMP
所以,不得不有人提出这样一个关于苹果硅的问题。长话短说,我需要编译并运行一个 C++
代码,该代码在 MBP M1 pro(使用基于 ARM 的架构)上与 MPI 和 OpenMP 混合运行。该代码在典型的 Intel x86 架构上运行得非常好。另外,为了完整起见,Mac 操作系统是 Monterey。此外,我不通过 IDE(例如 XCode)编译/运行,而是直接从终端通过 Makefile 进行编译/运行。
对于这样的问题我还没有找到明确的答案。我尝试自己进行设置,但这远远超出了我的舒适区。此外,我相信回答这样的问题将有助于未来使用这些 Mac 进行工作的开发人员:)
到目前为止,我了解到 Xcode 附带的安装的 Clang 编译器不支持 OpenMP (-fopenmp
)或识别 MPI (mpirun
)。因此,我安装了“brew”和“llvm
”版本,它应该通过 OpenMP 支持多线程指令。至于MPI库,我通过“brew
”安装了“libomp
”库。这些都应该在 Apple Silicon 上本地运行。
然而,现在环境已经乱七八糟了,因为系统有 2 个 Clang 编译器:
- 一个预装了 Xcode(默认)
- ,一个通过 brew 安装,位于:
/opt/homebrew/opt/llvm
我不知道如何继续。简单的解决方案可能是将编译器的路径更改为 /opt/homebrew/ 目录中的路径,但我怀疑这可能会弄乱系统中的很多东西。
如果您能提供帮助,我(和许多其他人)将非常感激,以防有人以前有过类似的经历。
So, someone has to initiate such a question regarding apple silicon. Long story short, I need to compile and run a C++
code that runs hybrid with both MPI and OpenMP on a MBP M1 pro (which uses arm-based architecture). The code runs perfectly fine on a typical Intel x86 architecture. Also, for completion sake, the Mac OS is Monterey. Additionally, I do not compile/run via an IDE (e.g. XCode), I do so via a Makefile, directly from the terminal.
I haven't found a clear answer to such a question. I tried setting things up myself, but this is way above my comfort zone. Moreover, I trust answering such a question would help future developers that are using these Macs for work :)
So far, I understood that the installed Clang compiler that comes with Xcode does not support OpenMP (-fopenmp
) or recognizes MPI (mpirun
). So, I installed "brew" and the "llvm
" version which should support the multi-threading instructions via OpenMP. As for the MPI library, I installed the "libomp
" library through "brew
". These all should run natively on Apple Silicon.
However, now the environment is all over the place, since the system has 2 Clang compilers:
- one preinstalled with Xcode (the default)
- one installed via brew, situated in:
/opt/homebrew/opt/llvm
I do not know how to proceed. The simple solution might be to change the path of the compiler to that in the /opt/homebrew/
directory, however I suspect that might mess a lot of things in the system.
I would (and many others) be very thankful if you could help, in case someone has prior experience with something like this before.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用 Homebrew 的 Clang,您需要相应地设置 PATH 和编译器标志。
实际上,一旦您安装了 llvm(或尝试
brew info llvm
),Homebrew 就已经为您提供了相应的建议和提示:您需要将这些标志转发到您的构建设置中,即,如果您有来自以下位置的构建文件: CMake/Make/无论您需要确保使用或转发相应的标志。
To use Homebrew's Clang you will need set up your PATH and compiler flags accordingly.
Actually, Homebrew gives you the respective advice and hints already once you install llvm (or try
brew info llvm
):You will need to forward those flags into your build setup, i.e., if you have build files from CMake/Make/whatsoever you will need to make sure that the respective flags are used or forwarded.