Pthreads中对OpenMP的 [英] Pthreads vs. OpenMP

查看:159
本文介绍了Pthreads中对OpenMP的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建使用Linux在C多线程应用程序。

I'm creating a multi-threaded application in C using Linux.

我不确定我是否应该使用POSIX线程API或OpenMP API的。

I'm unsure whether I should use the POSIX thread API or the OpenMP API.

什么是赞成&放大器;无论使用的利弊?

What are the pros & cons of using either?

编辑:

有人能澄清这两个API是否创建内核级用户级的主题?

Could someone clarify whether both APIs create kernel-level or user-level threads?

推荐答案

的Pthreads和OpenMP重新present两个完全不同的范式多

Pthreads and OpenMP represent two totally different multiprocessing paradigms.

Pthreads的是一个与线程的工作非常低级的API。因此,你有超过线程管理(创建/加入/等),互斥等极细粒度的控制。这是相当裸机。

Pthreads is a very low-level API for working with threads. Thus, you have extremely fine-grained control over thread management (create/join/etc), mutexes, and so on. It's fairly bare-bones.

在另一方面, OpenMP的是<青霉>多的更高的水平,更便于携带和没有按'T限制你使用C.它也更容易比pthreads的缩放。这方面的一个具体的例子是OpenMP的工作共享结构,让您的工作分割在多个线程相对容易。 (参见维基百科的利弊列表。)

On the other hand, OpenMP is much higher level, is more portable and doesn't limit you to using C. It's also much more easily scaled than pthreads. One specific example of this is OpenMP's work-sharing constructs, which let you divide work across multiple threads with relative ease. (See also Wikipedia's pros and cons list.)

这是说,你真的没有提供关于你正在实施具体方案,或如何计划使用它的细节,所以这是相当不可能推荐一个API比其他。

That said, you've really provided no detail about the specific program you're implementing, or how you plan on using it, so it's fairly impossible to recommend one API over the other.

这篇关于Pthreads中对OpenMP的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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