并行性新手,正在学习使用 C++ 进行 HPX 的入门知识。我正在查看将打印的特定 hello-word 示例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, 局部性到底是什么意思?我了解操作系统线程,但我不太确定该程序在哪个位置意味着什么。
里面的一些代码示例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();
}
根据我从他们的文档中了解到的信息 - 您可以将位置视为执行应用程序的进程数。
假设有 2 个服务器执行您的程序,第一个服务器将执行位置 0,第二个服务器将执行位置 1。
这样您就可以知道执行相同代码的哪个进程是服务器(位置 0),哪个是客户端(位置 1)。
另外,每个进程可以运行多个线程,这通过os_threads的数量可见。
按照这个例子:http://stellar.cct.lsu.edu/files/hpx_0.8.1/docs/hpx/tutorial/examples/hello_world.html http://stellar.cct.lsu.edu/files/hpx_0.8.1/docs/hpx/tutorial/examples/hello_world.html
以及这些命令行选项:http://stellar.cct.lsu.edu/files/hpx_0.8.1/docs/hpx/tutorial/getting_started/commandline.html http://stellar.cct.lsu.edu/files/hpx_0.8.1/docs/hpx/tutorial/getting_started/commandline.html
这是如何使用多个位置的说明:http://stellar.cct.lsu.edu/files/hpx_0.8.1/docs/hpx/tutorial/getting_started/unix_pbs.html http://stellar.cct.lsu.edu/files/hpx_0.8.1/docs/hpx/tutorial/getting_started/unix_pbs.html
我认为理解它的最好方法是使用 --hpx:node 和 --hpx:threads 的值。
另外 - 我认为 openmpi 文档更适合理解这些术语......
虽然不确定我是否有所帮助,但我希望我有所帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)