英特尔 TBB 和微软 PPL 有什么区别?
我打算开始玩"一个跨平台项目的基于任务的并行性.我想使用英特尔线程构建块.我从 Windows 和 Visual Studio 开始.
I'm planning to start "playing" with task-based parallelism for a cross-platform project. I wanted to use Intel Threading Building Blocks. I'm starting with Windows and Visual Studio.
因为我现在只想做原型,所以我想只在 Windows 上玩",然后有足够的知识在所有兼容平台上使用该库.
As I just want to prototype for the moment, I'm thinking about "playing" only on windows, then have enough knowledge to use the library on all compatible platforms.
我了解到,自 VS2010 以来,Microsoft 提供了一个类似的库,即并行处理库,其接口(几乎)与英特尔 TBB 相同.
I've learned that since VS2010, Microsoft provide a similar library, Parallel Processing Library, that have (almost) the same interface than Intel TBB.
一些消息来源(包括 TBB 的团队博客)表明,他们是一起构建的,并且是同一个库.
Some sources suggest, including TBB's team blog, that they build it together and that it's the same library.
然而,它并不是很明确,因为人们经常认为这两个库之间存在细微差别.
However its not really explicit because it's often suggested that there are minor differences between the two libraries.
那么,如果有的话,那些差异是什么?我应该直接从最后一个稳定的 ITBB 开始,还是只在原型中使用 Microsoft PPL 并在跨平台上使用 ITBB 的风险低真正的"项目?
So, what are those differences, if any? Should I start directly with last stable ITBB or is it low-risk to just play with Microsoft PPL in prototypes and use ITBB on the cross-platform "real" project?
推荐答案
TBB 是 PPL(如在 VS2010 中),因此它提供了所有 PPL API 以及 PPL 没有的自己的 API.
TBB is a superset of PPL (as in VS2010), so it provides all PPL API plus its own APIs that PPL does not have.
请注意,VS2010 中的namespace Concurrency
还包含以下 API并发运行时(ConcRT,在其上构建了 PPL)、异步代理等.TBB 没有大部分,尽管它有一些(例如 critical_section
).作为异步代理的替代方案,TBB 的最新版本具有新的流图 API.
Note that namespace Concurrency
in VS2010 also contains APIs of Concurrency Runtime (ConcRT, on top of which PPL is built), Asynchronous Agents and etc. TBB does not have most of that, though it has some (e.g. critical_section
). As an alternative to Asynchronous Agents, the recent version of TBB features the new flow graph API.
理论上,要从 PPL 切换到 TBB,您只需要替换您获取 ppl.h 的路径(使用 TBB,标题位于 <tbbdir>/include/tbb/compat代码>),当然还有与 TBB DLL 的链接.但是,在这种情况下,您将仅限于 PPL API.要使用 PPL 中不存在的额外"TBB API(例如
parallel_pipeline
、parallel_reduce
、concurrent_priority_queue
等),您需要从一开始就与 TBB 合作.
In theory, to switch from PPL to TBB, you just need to replace a path from where you take ppl.h (with TBB, the header comes in <tbbdir>/include/tbb/compat
) and of course link with the TBB DLL. However in this case you will be limited to PPL API. To use the "extra" TBB API that does not exist in PPL (such as parallel_pipeline
, parallel_reduce
, concurrent_priority_queue
and other), you need to work with TBB from the very beginning.
相关文章