【发布时间】:2013-10-04 11:28:31
【问题描述】:
我使用具有许多 amd64 处理器和 Debian Squeeze 的虚拟机计算机集群。以前,我已经成功地在其上并行执行了 shell 脚本(使用 GNU Parallel)。现在,我想使用 boost::threads。我运行这个程序:
#include <boost/thread.hpp>
using namespace std;
boost::thread_group g;
void foo()
{
for(int i = 0; i < 1000000000; ++i)
for(int i = 0; i < 1000000000; ++i);
}
int main(int argc, char* argv[])
{
g.add_thread(new boost::thread(foo));
g.add_thread(new boost::thread(foo));
g.add_thread(new boost::thread(foo));
g.join_all();
}
所有这些线程都在单个处理器上运行,该处理器的使用率为 300%(根据top 命令)。如何让这三个线程在三个独立的处理器上运行? boost::threads 有可能吗?
注意:尽管有标题,这个Multiprocessor Boost::Thread? All threads running on one processor 是关于多核系统的,而我的真正是关于多处理器系统的。
【问题讨论】:
-
我假设您的意思是您有一个多插槽 SMP 系统。您的计算机使用 NUMA 吗?
-
@dai,这是一个虚拟机。我可以在其上并行执行 shell 脚本(使用 GNU Parallel)。我不知道 SMP 和 NUMA。
标签: c++ multithreading boost parallel-processing boost-thread