为什么我应该使用 Grand Central Dispatch 而不是 OpenMP?

发布于 2024-08-04 11:19:26 字数 151 浏览 3 评论 0原文

Apple 在 Snow Leopard 中引入了 Grand Central Dispatch(一种线程池),但没有深入探讨为什么应该在 OpenMP 上使用它,因为 OpenMP 是跨平台的,也可以在 Leopard 上运行。它们都非常易于使用并且功能看起来相似。那么,有什么想法吗?

Apple introduced Grand Central Dispatch (a thread pool) in Snow Leopard, but haven't gone into why one should use it over OpenMP, which is cross-platform and also works on Leopard. They're both pretty easy to use and look similar in capability. So, any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼泪淡了忧伤 2024-08-11 11:19:26

GCD 在运行时评估适当级别的资源以解决问题方面要好得多 - OpenMP 根据环境变量等信息决定为一组并行任务调用多少个线程。 GCD 会查看当前系统负载和可用核心数量,并允许运行适当数量的线程 - 随着资源使用情况的实时变化进行扩展和缩减。这意味着 GCD 程序应该在一般情况下获得更好的结果。当然,如果您购买了一组专用的盒子来运行您的代码,那么这是没有意义的,因为您的代码几乎不会与其他东西发生冲突。

GCD is much better at runtime evaluation of the appropriate level of resources to throw at a problem - OpenMP decides how many threads to invoke for a set of parallel tasks based on information like environment variables. GCD looks at the current system load and number of available cores and allows an appropriate number of threads to run - scaling up and back as the resource usage changes in real time. That means that a GCD program ought to get better results in the general case. Of course, if you've bought a cluster of dedicated boxes to run your code, then this is moot because there will be little else for your code to conflict with.

空城之時有危險 2024-08-11 11:19:26

现在 GCD 已经开源了,接下来的问题就是将这两种工具放在一起,看看谁能活到最后。

Now that GCD has been open sourced, it's a matter of putting both tools side by side and see who lives in the end.

○愚か者の日 2024-08-11 11:19:26

性能和操作系统级别集成?

Performance and OS Level Integration?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文