Xcode 4.5和OpenMP with Clang(Apple LLVM)只使用一个核心 [英] Xcode 4.5 and OpenMP with Clang (Apple LLVM) uses only one core

查看:148
本文介绍了Xcode 4.5和OpenMP with Clang(Apple LLVM)只使用一个核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在C ++ 11项目上使用Xcode 4.5,我们使用OpenMP加快计算速度:

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:

我们还使用GCC 4.7在Ubuntu上运行相同的代码观察到对所有核的争用。是否已经在Apple LLVM中删除了OpenMP支持?有没有替代OpenMP?
我们不能切换到GCC,因为我们使用C ++ 11的功能。

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.

推荐答案

Clang 不是,但支持OpenMP(它没有被删除 - 它从来不存在于第一位)。您可以使用Apple的Grand Central Dispatch(GCD)任务系统,或者改用英特尔的线程构建模块(TBB)。

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.

这篇关于Xcode 4.5和OpenMP with Clang(Apple LLVM)只使用一个核心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆