我将使用msmpi,我的意思是“只有mpi”我们不能使用套接字,我的应用程序是关于可扩展的分布式数据结构;最初,我们有一个服务器包含一个文件,该文件具有可变大小(可以通过插入增加大小并通过删除减少),当文件大小超过一定限制时,文件将被分割,一半保留在第一个服务器中并且后半部分将被移动到新的服务器等等......并且客户端需要始终通过他想要检索的数据的地址来通知,因此他应该具有文件的拆分操作的图像。最后,我希望我能说得更清楚。
,第二个是:
我尝试使用msmpi或mpich2编译简单的客户端/服务器应用程序(代码源是下面的)并且它不起作用并且给我错误消息“mpi_open_port()中的致命错误和堆栈的其他错误” ,所以我在ubunto 11.10上安装了open mpi,并尝试运行与服务器端一起使用的相同示例,它给了我一个端口名称,但在客户端它给了我错误消息:
[user-Compaq-610:03833] [[39604,1],0] ORTE_ERROR_LOG: Not found in file ../../../../../../ompi/mca/dpm/orte/dpm_orte.c at line 155
[user-Compaq-610:3833] *** An error occurred in MPI_Comm_connect
[user-Compaq-610:3833] *** on communicator MPI_COMM_WORLD
[user-Compaq-610:3833] *** MPI_ERR_INTERN: internal error
[user-Compaq-610:3833] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)
--------------------------------------------------------------------------
mpirun has exited due to process rank 0 with PID 3833 on
node toufik-Compaq-610 exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpirun (as reported here).
所以我很困惑问题是什么,我花了一些时间试图解决它, 如果有任何身体可以帮助我,我会很高兴,并提前感谢你。
源代码在这里:
/* the server side */
#include <stdio.h>
#include <mpi.h>
main(int argc, char **argv)
{
int my_id;
char port_name[MPI_MAX_PORT_NAME];
MPI_Comm newcomm;
int passed_num;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_id);
passed_num = 111;
if (my_id == 0)
{
MPI_Open_port(MPI_INFO_NULL, port_name);
printf("%s\n\n", port_name); fflush(stdout);
} /* endif */
MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &newcomm);
if (my_id == 0)
{
MPI_Send(&passed_num, 1, MPI_INT, 0, 0, newcomm);
printf("after sending passed_num %d\n", passed_num); fflush(stdout);
MPI_Close_port(port_name);
} /* endif */
MPI_Finalize();
exit(0);
} /* end main() */
并在客户端:
#include <stdio.h>
#include <mpi.h>
int main(int argc, char **argv)
{
int passed_num;
int my_id;
MPI_Comm newcomm;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_id);
MPI_Comm_connect(argv[1], MPI_INFO_NULL, 0, MPI_COMM_WORLD, &newcomm);
if (my_id == 0)
{
MPI_Status status;
MPI_Recv(&passed_num, 1, MPI_INT, 0, 0, newcomm, &status);
printf("after receiving passed_num %d\n", passed_num); fflush(stdout);
} /* endif */
MPI_Finalize();
return 0;
//exit(0);
} /* end main() */
答案 0 :(得分:0)
您是如何运行该应用程序的?似乎客户端和服务器代码是相同的。
通常,所有MPI流程的代码都是相同的,程序根据此代码段if (my_id == 0) { ... }
决定基于排名执行的内容。该应用程序使用mpiexec执行。例如,mpiexec -n 2 ./application
将在一个1
通信器中运行两个具有等级2
和MPI_COMM_WORLD
的MPI进程。确切地执行prococesses(在同一节点或不同节点上)取决于配置。
尽管如此,您应该使用MPI_Open_port
创建端口并将其传递给MPI_Comm_connect
。以下是有关如何使用这些功能的示例:MPI_Comm_connect
此外,对于MPI_Recv
,必须有相应的MPI_Send
。否则接收过程将永远等待。