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

We use Xcode 4.5 in a C ++ 11 project, where we use OpenMP to speed up our calculations:

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

Despite the fact that several threads used by the program are shown in the activity monitor, we noticed that only one core is used:

Screenshot of the Activity Monitor running my code

We also run the same code on Ubuntu using GCC 4.7, and we observe competition on all cores. Maybe OpenMP support was removed in Apple LLVM? Is there an alternative to OpenMP? We cannot switch to GCC, since we are using the features of C ++ 11.

+6
source share
1 answer

Clang does not support , but supports OpenMP (it was not deleted - it never existed in the first place). You can use the target system Apple Grand Central Dispatch (GCD), otherwise you can use Intel Threading Building Blocks (TBB).

+11
source

All Articles