并行性的地方 [英] Localities in parallelism

查看:173
本文介绍了并行性的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的并行性和使用C ++学习HPX的绳索。我正在查看一个特定的hello-word示例,将在每个位置的每个操作系统线程上打印 hello world ,某些输出将如下所示:

New to parallelism and learning the ropes to HPX with C++. I'm looking at a specific hello-word example that will print hello world on every OS-thread on every locality, some output would look like:

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

问题是,当程序输出 on locality x locality是什么意思?我理解OS线程,但我不太确定程序意味着什么地方。

My question is, when the program output on locality x, what exactly does locality mean? I understand OS-thread but I'm not quite sure what the program means by which locality.

HPX main 中的一些代码示例这不一定是我的问题所必需的,多次调用查找与主题相关的地点。

Example of some code inside HPX main this isn't necessarily required by my question, but it does include multiple calls to finding localities which relate to topic.

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();
}


推荐答案

文档 - 您可以将Locality视为执行应用程序的进程数。

允许2个服务器执行您的程序,第一个执行locality 0,第二个地点1.

这样你可以知道哪个进程执行相同的代码,让我们说服务器(locality 0),它是客户端(locality 1)。

From what I understand from their documentation - you can treat Locality as the number of processes that execute the application.
lets say 2 servers execute your program, the first one will execute locality 0, and the second locality 1.
That way you can know which process, which executes the same code, is lets say the server (locality 0) and which is the client (locality 1).

此外,每个进程可以运行多个线程,这可以作为os_threads的数量显示。

In addition, each process can run multiple threads, which is visible as the number of 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 / getting_started / commandline.html

这是对如何使用多个地点的解释:
http://stellar.cct.lsu.edu/files/hpx_0.8.1/ docs / hpx / tutorial / getting_started / unix_pbs.html

This is the explanation of how to use multiple localities: http://stellar.cct.lsu.edu/files/hpx_0.8.1/docs/hpx/tutorial/getting_started/unix_pbs.html

我认为最好的解决方法是使用--hpx:node和--hpx:threads。

I think the best way to understand it is to play with the values of --hpx:node and --hpx:threads.

此外 - 我认为openmpi文档有点更好地理解术语...

In addition - I think the openmpi documentation is a bit better for understanding the terms...

虽然不确定我是否有帮助,但我希望我能做到。

Although not sure I helped, I hope I did.

这篇关于并行性的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆