Xcode 4.5 and OpenMP with Clang (Apple LLVM) uses only one core

风流意气都作罢 提交于 2019-12-22 05:48:13

问题


We are using Xcode 4.5 on a C++11 project where we use OpenMP to speed up our computation:

#pragma omp parallel for
for (uint x=1; x<grid.width()-1; ++x) {
    for (uint y=1; y<grid.height()-1; ++y) {
         // code
    }
}

Although the Activity Monitor shows multiple threads being used by the program we observed that only one core is used:

We also run the same code on Ubuntu using GCC 4.7 and we observed contention on all cores. Could it be that the OpenMP support has been removed in the Apple LLVM? Is there an alternative to OpenMP? We can't switch to GCC since we use C++11 features.


回答1:


Clang does not yet support OpenMP (it has not been removed - it never existed in the first place). You could use Apple's Grand Central Dispatch (GCD) tasking system or you could use Intel's Threading Building Blocks (TBB) instead.



来源:https://stackoverflow.com/questions/13720234/xcode-4-5-and-openmp-with-clang-apple-llvm-uses-only-one-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!