新的并行和学习诀窍到HPX与C++。我正在查看一个具体的hello-word示例,它将在每个本地的每个OS线程上打印hello world,一些输出如下所示:
hello world from OS-thread 1 on locality 0
hello world from OS-thread 1 on locality 1
hello world from OS-thread 0 on locality 0
hello world from OS-thread 0 on locality 1我的问题是,当程序在局部性x,上的输出时,局部性到底是什么意思?我理解OS线程,但我不太确定程序是指哪个位置。
HPX main中某些代码的示例--这不一定是我的问题所要求的,但它确实包括多个调用来查找与主题相关的位置。
int hpx_main()
{
{
// Get a list of all available localities.
std::vector<hpx::naming::id_type> localities =
hpx::find_all_localities();
// Reserve storage space for futures, one for each locality.
std::vector<hpx::lcos::future<void> > futures;
futures.reserve(localities.size());
BOOST_FOREACH(hpx::naming::id_type const& node, localities)
{
// Asynchronously start a new task. The task is encapsulated in a
// future, which we can query to determine if the task has
// completed.
typedef hello_world_foreman_action action_type;
futures.push_back(hpx::async<action_type>(node));
}
// The non-callback version of hpx::lcos::wait takes a single parameter,
// a future of vectors to wait on. hpx::lcos::wait only returns when
// all of the futures have finished.
hpx::lcos::wait(futures);
}
// Initiate shutdown of the runtime system.
return hpx::finalize();
}发布于 2014-04-17 16:20:01
根据我从他们的文档中了解到的情况,您可以将本地视为执行应用程序的进程的数量。
假设有2台服务器执行您的程序,第一台将执行本地0,第二台将执行本地1。
这样,您就可以知道哪个进程执行相同的代码,比如服务器(locality 0)和客户机(locality 1)。
此外,每个进程都可以运行多个线程,这是可见的os_threads数量。
遵循这个示例:world.html
以及以下命令行选项:started/commandline.html
这是如何使用多个位置的说明:pbs.html
我认为理解它的最好方法是使用-hpx:节点和-hpx:线程的值。
另外-我认为openmpi文档对理解术语来说会更好一些.
虽然我不确定我帮了什么忙,但我希望我做到了。
https://stackoverflow.com/questions/23070413
复制相似问题