如何静态链接到TBB? [英] How to statically link to TBB?

查看:323
本文介绍了如何静态链接到TBB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 intel的TBB库静态链接到我的应用程序?
我知道所有警告,例如调度程序的不公平负载分配,但我不需要调度程序,只是容器,所以它的确定。

How can I statically link the intel's TBB libraries to my application? I know all the caveats such as unfair load distribution of the scheduler, but I don't need the scheduler, just the containers, so it's ok.

无论如何,我知道这可以做,虽然它没有文件,但我只是似乎找不到现在做的方式(虽然我看过它

Anyways I know this can be done, although its undocumented, however I just can't seem to find the way to do it right now (although I've seen it before somewhere).

$ b

推荐答案

强烈不建议这样做:


Is there a version of TBB that provides statically linked libraries?

TBB不是作为静态链接库提供的,原因如下:

TBB is not provided as a statically linked library, for the following reasons*:

大多数图书馆在本地经营。例如,Intel(R)MKL FFT变换阵列。它有多少个FFT副本是不相关的。多个副本和版本可以毫无困难地共存。但是一些库控制程序范围的资源,例如内存和处理器。例如,垃圾收集器控制整个程序的内存分配。类似地,TBB控制整个程序的任务调度。为了有效地完成他们的工作,每一个都必须是单身;也就是说,具有可以协调整个程序中的活动的唯一实例。在单个程序中允许TBB调度器的k个实例将导致有比硬件线程多k倍的软件线程。程序将无效率地操作,因为机器将被因子k超额订阅,导致更多的上下文切换,缓存争用和存储器消耗。此外,当嵌套并行化来自不同调度程序的嵌套调用时,TBB对嵌套并行性的有效支持将被否定。

Most libraries operate locally. For example, an Intel(R) MKL FFT transforms an array. It is irrelevant how many copies of the FFT there are. Multiple copies and versions can coexist without difficulty. But some libraries control program-wide resources, such as memory and processors. For example, garbage collectors control memory allocation across a program. Analogously, TBB controls scheduling of tasks across a program. To do their job effectively, each of these must be a singleton; that is, have a sole instance that can coordinate activities across the entire program. Allowing k instances of the TBB scheduler in a single program would cause there to be k times as many software threads as hardware threads. The program would operate inefficiently, because the machine would be oversubscribed by a factor of k, causing more context switching, cache contention, and memory consumption. Furthermore, TBB's efficient support for nested parallelism would be negated when nested parallelism arose from nested invocations of distinct schedulers.

创建程序范围单例的最实用的解决方案是动态共享库包含单例。当然,如果调度器可以合作,我们不需要单例。但是这种合作需要一个集中化的代理来沟通;

The most practical solution for creating a program-wide singleton is a dynamic shared library that contains the singleton. Of course if the schedulers could cooperate, we would not need a singleton. But that cooperation requires a centralized agent to communicate through; that is, a singleton!

我们决定忽略TBB的静态链接版本,这是我们的OpenMP经验的强烈影响。像TBB一样,OpenMP也尝试在整个程序中计划。 OpenMP运行时的静态版本曾经提供过,它一直是重复调度程序产生的常见问题源。我们认为最好不要重复这个历史。作为这些考虑的有效性的间接证明,我们可以指出这样的事实,Microsoft Visual C ++只通过动态库提供OpenMP支持。

Our decision to omit a statically linkable version of TBB was strongly influenced by our OpenMP experience. Like TBB, OpenMP also tries to schedule across a program. A static version of the OpenMP run-time was once provided, and it has been a constant source of problems arising from duplicate schedulers. We think it best not to repeat that history. As an indirect proof of the validity of these considerations, we could point to the fact that Microsoft Visual C++ only provides OpenMP support via dynamic libraries.

来源: http://www.threadingbuildingblocks.org/faq/11#sthash.t3BrizFQ.dpuf

这篇关于如何静态链接到TBB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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