Mac OS 使用OpenMP

今天做高性能作业,发现OS X的GCC(其实是clang,对编译器了解不多,今天又沉浸在wiki百科的大牛故事中)没有包含openmp,不支持-fopenmp编译选项,所以查了一下MAC OS上使用Open MP的简便方案。参见StackOverflow

homebrew安装libomp

brew install libomp

编译时增加选项

g++ -Xpreprocessor -fopenmp main.cpp -o main -lomp -std=c++11

-Xpreprocessor选项将参数-fopenmp传递给openmp预处理程序。

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.