线程安全的TBB可扩展分配器
Thread-safe TBB scalable allocator
最近我从系统内存管理(malloc/free)切换到英特尔的TBB可扩展分配器。问题是我找不到任何信息,如果它是线程安全的。整个TBB是围绕线程构建的,所以它看起来是合乎逻辑的,但没有具体的证据,我不想假设这样的事情。但是,我也不想进行任何不必要的同步。有人知道这方面的信息吗?
那么这个源代码英特尔线程构建块听起来更直接(参见"TBB可伸缩分配器"页)-
每个线程都有自己的私有堆
-尺寸隔离箱改善局部性
私有堆减少同步开销和错误共享
Update: And from here-
TBB为每个线程池提供了一个可伸缩的分配器。它可能仍然存在虚假分享。
example: false sharing could matter in pipelining. TBB also provides a cache-aligned allocator, which guarantees that any two things you've allocated will never experience false sharing. The downside is that it has larger memory pressure. This is accomplished by making the minimum allocation N cache lines, where N is a small integer. In the book, the conventional wisdom is to start with the scalable allocator and see if switching to the cache-aligned allocator speeds things up.
根据您所链接的手册:
除非另有说明,库的线程安全规则为如下:
两个线程可以并发地调用一个方法或函数对象,但不是同一个对象。两个线程同时使用是不安全的在同一对象上并发调用方法或函数。类的描述说明了与此惯例的背离。为例如,并发容器更自由。就其本质而言,它们确实允许在同一容器上进行一些并发操作对象。
对于可伸缩分配器,这意味着两个线程不能同时释放相同的内存,这应该不足为奇。
相关文章:
- 我想通过带有C++和Python的插件创建一个可扩展的应用程序
- 简化可扩展的"Perform Operation X on Data Y"框架
- 传递 std::array 参数,其大小限制为可扩展的大小集
- 在 c++ 中构建封装但可扩展的动画库
- 将ADA API暴露于C/C (可扩展方式)
- 集成多态可扩展排序顺序
- 具有可扩展矢量扩展(SVE)的ARM V-8
- C++可扩展的工厂方法
- 可扩展的 SFINAE 条件覆盖
- C 中的可扩展队列
- C++中可扩展的自动类注册
- NUMA体系结构上大(8MB)内存区域的可扩展分配
- C++中的可扩展类型特征
- 无需reinterpret_cast的可扩展库接口
- 在 C++ 中具有用户可扩展类型参数的类型化类
- QTreeView-删除某些元素的可扩展外观
- 用于C++的快速、大且可扩展的几何图形库
- hdf5多个可扩展表
- 可扩展条件语句的机制
- 线程安全的TBB可扩展分配器