c++ - 如何静态链接到 TBB?

标签 c++ linker tbb

如何静态链接 intel's TBB libraries我的申请? 我知道all the caveats比如调度器的负载分配不公平,但是我不需要调度器,只需要容器,所以没关系。

无论如何我都知道这是可以做到的,虽然它没有记录,但是我现在似乎无法找到这样做的方法(尽管我以前在某个地方见过它)。

那么有谁知道或有任何线索吗?

谢谢

最佳答案

强烈不建议这样做:

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

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

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!

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

关于c++ - 如何静态链接到 TBB?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/638278/

相关文章:

c++ - 使用 ISAPI 过滤器将 header 放入文件

c++ - 在程序中创建一个值的界限

c++ - VS2015 链接器寻找旧的,无处提及的文件

c - gcc 在 mac OS X 上默认在 C 中链接数学库?

c++ - TBB:可能获得线程ID?

c++ - 如何在 Linux 上从源代码安装 TBB 并使其工作

c++ - 在 C++ 中的运行时声明对命名空间的引用

c++ - 如何告诉 C 或 C++ 编译器指针没有别名

c++ - 编译/链接过程如何工作?

c++ - tbb::concurrent_unordered_map::unsafe_erase 是否会使任何现有的迭代器失效?