- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在不同的机器(包括 Linux 和 Windows,以及 Intel 和 AMD CPU 以及 clang++、GNU 和 MSVC)中使用线程库。在所有这些中,std::thread::hardware_concurrency() 返回 Windows 中所谓的逻辑处理器或包括超线程在内的最大线程数,但是在具有 AMD Ryzen threadripper 3990x CPU 的新机器中,它只返回数字核心数是最大线程数的一半(64 而不是 128)。我在 c++ 引用中读到返回值取决于实现,这只是一个提示,但我的问题是如何找到实现,或者该函数返回的线程数是否存在上限。由于我在测试的所有机器上都出现了类似的行为,我不知道这种不同行为的原因是什么。
最佳答案
std::thread::hardware_concurrency
的思想是告诉你std::thread
可以体验到什么样的并发。由于 std::thread
只能将线程放入您的默认处理器组,因此您将获得默认 processor group 中的逻辑处理器数.除非您采取极端措施,否则这在 Windows 上不会大于 64。
"[A] system with 128 logical processors would have two processor groups with 64 processors in each group[.]"
"An application that requires the use of multiple groups so that it can run on more than 64 processors must explicitly determine where to run its threads and is responsible for setting the threads' processor affinities to the desired groups."
关于c++ - std::thread::hardware_concurrency() 未在 AMD Ryzen threadripper 3990x 中返回正确数量的逻辑处理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70704458/
问题本身的描述很简单。我正在测试 C++11 中 std::thread 库和 boost::thread 库的区别。 这些的输出: #include #include #include int
我有一个模板类,它有一个用于线程数的无符号整型参数。我想用它为线程创建一个静态数组。 我不能使用 std::thread::hardware_concurrency() 作为默认值, template
我正在使用 RHEL 6 64 位并在四核处理器上的虚拟机上运行。我编写了以下程序来检查硬件可以处理的线程数。 #include #include using namespace std; int
这个全局函数是否会遭受静态初始化失败? template void ParallelFor(int iIni,int iFin,TFn Fn) { static const unsigne
在我的question关于 std::thread,有人建议我使用 std::thread::hardware_concurrency()。我在某处读到(我找不到它,看起来像是本地代码存储库或其他东西
当我 cout std::thread::hardware_concurrency 它给出 1。 但来自cppreference Returns the number of concurrent th
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: Programmatically find the number of cores on a machine
我在不同的机器(包括 Linux 和 Windows,以及 Intel 和 AMD CPU 以及 clang++、GNU 和 MSVC)中使用线程库。在所有这些中,std::thread::hardw
我是一名优秀的程序员,十分优秀!