MPICH:如何发布名称,以便客户端应用程序可以查找名称? [英] MPICH: How to publish_name such that a client application can lookup_name it?

查看:79
本文介绍了MPICH:如何发布名称,以便客户端应用程序可以查找名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows(1.4.1p1)中使用MPICH学习MPI时,我发现了一些示例代码此处.最初,当我运行服务器时,我将必须复制生成的port_name并使用它启动客户端.这样,客户端可以连接到服务器.我将其修改为在服务器中包含MPI_Publish_name().启动名称为aaaa的服务器后,我启动客户端MPI_Lookup_name()失败

Invalid service name (see MPI_Publish_name), error stack:
MPID_NS_Lookup(87): Lookup failed for service name aaaa

以下是代码的片段:

server.c

MPI_Comm client; 
MPI_Status status; 
char port_name[MPI_MAX_PORT_NAME];
char serv_name[256];
double buf[MAX_DATA]; 
int size, again; 
int res = 0;

MPI_Init( &argc, &argv ); 
MPI_Comm_size(MPI_COMM_WORLD, &size); 
MPI_Open_port(MPI_INFO_NULL, port_name);
sprintf(serv_name, "aaaa");
MPI_Publish_name(serv_name, MPI_INFO_NULL, port_name);

while (1) 
{ 
    MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &client );
    /*...snip...*/
}

client.c

MPI_Comm server; 
double buf[MAX_DATA]; 
char port_name[MPI_MAX_PORT_NAME]; 
memset(port_name,'\0',MPI_MAX_PORT_NAME);
char serv_name[256];
memset(serv_name,'\0',256);

strcpy(serv_name, argv[1] )
MPI_Lookup_name(serv_name, MPI_INFO_NULL, port_name);
MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &server ); 
MPI_Send( buf, 0, MPI_DOUBLE, 0, tag, server ); 
MPI_Comm_disconnect( &server ); 
MPI_Finalize(); 
return 0; 

我什至找不到有关更改已发布名称可见性的任何信息. MPICH似乎尚未使用MPI_INFO实施任何操作.我会尝试使用openMPI,但是在构建它时遇到了麻烦.有什么建议吗?

解决方案

相对于正常的MPI用法,这种发布名称,查找名称并连接名称的方法显得有些古怪.

标准模式是使用mpirun指定一组要在其上启动给定数量的进程的节点. mpirun实现的常见实现操作在另一个问题 <中进行了解释/p>

一旦将所有进程作为单个并行作业的一部分启动,则MPI库将读取启动器在MPI_Init期间提供的任何信息以设置MPI_COMM_WORLD,该信息是该作业中所有进程的通信者. /p>

使用该通信器,并行应用程序可以分发工作,交换信息等.它将使用常见的MPI_SendMPI_Recv例程,所有其变体,集合运算等来完成此操作.

While learning MPI using MPICH in windows (1.4.1p1) I found some sample code here. Originally, when I ran the server, I would have to copy the generated port_name and start the client with it. That way, the client can connect to the server. I modified it to include MPI_Publish_name() in the server instead. After launching the server with a name of aaaa, I launch the client which fails MPI_Lookup_name() with

Invalid service name (see MPI_Publish_name), error stack:
MPID_NS_Lookup(87): Lookup failed for service name aaaa

Here are the snipped bits of code:

server.c

MPI_Comm client; 
MPI_Status status; 
char port_name[MPI_MAX_PORT_NAME];
char serv_name[256];
double buf[MAX_DATA]; 
int size, again; 
int res = 0;

MPI_Init( &argc, &argv ); 
MPI_Comm_size(MPI_COMM_WORLD, &size); 
MPI_Open_port(MPI_INFO_NULL, port_name);
sprintf(serv_name, "aaaa");
MPI_Publish_name(serv_name, MPI_INFO_NULL, port_name);

while (1) 
{ 
    MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &client );
    /*...snip...*/
}

client.c

MPI_Comm server; 
double buf[MAX_DATA]; 
char port_name[MPI_MAX_PORT_NAME]; 
memset(port_name,'\0',MPI_MAX_PORT_NAME);
char serv_name[256];
memset(serv_name,'\0',256);

strcpy(serv_name, argv[1] )
MPI_Lookup_name(serv_name, MPI_INFO_NULL, port_name);
MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &server ); 
MPI_Send( buf, 0, MPI_DOUBLE, 0, tag, server ); 
MPI_Comm_disconnect( &server ); 
MPI_Finalize(); 
return 0; 

I cannot find any information about altering visibility of published names, if that is even the problem. MPICH seems to not have implemented anything with MPI_INFO. I would try openMPI but I am having trouble just building it. Any suggestions?

解决方案

This approach of publishing names, looking them up, and connecting to them is outlandish relative to normal MPI usage.

The standard pattern is to use mpirun to specify a set of nodes on which to launch a given number of processes. The operation of common implementations of mpirun implementations is explained in another question

Once the processes are all launched as part of a single parallel job, the MPI library reads whatever information the launcher provided during MPI_Init to set up MPI_COMM_WORLD, a communicator over the group of all processes in the job.

Using that communicator, the parallel application can distribute work, exchange information, and so forth. It would do this using the common MPI_Send and MPI_Recv routines, in all their variants, the collective operations, and so forth.

这篇关于MPICH:如何发布名称,以便客户端应用程序可以查找名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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