|
初学Linux和并行编程遇到的问题: 今天参照书上写了一个非常简单的mpi测试程序,如下: #include "mpi.h" #include <stdio.h> #include <math.h> int main(int argc,int *argv[]) { int myid, numprocs; int namelen; char processor_name[MPI_MAX_PROCESSOR_NAME]; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&myid); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Get_processor_name(processor_name,&namelen); fprintf(stderr,"Hello World! Process %d of %d on %s\n", myid, numprocs, processor_name); MPI_Finalize(); return 0; } 想想应该没有任何问题,并行编译也通过了,使用mpirun 使用一个节点运行也通过了,结果如下: [root@console xiaowu]# mpirun -np 1 tt Hello world!Process 0 of 1 on console 但是当使用2个或2个以上的节点运行时却出现了问题,如下: [root@console xiaowu]# mpirun -np 2 tt bash: /home/xiaowu/tt: No such file or directory p0_9667: p4_error: Child process exited while making connection to remote process on c0101: 0 p0_9667: (2.050781) net_send: could not write to fd=4, errno = 32
这是为什么啊?不应该是系统配置的问题,因为其他的并行程序可以正常多节点运行,如下: [root@console export]# cd /export/nistest/ [root@console nistest]# mpirun -np 4 cpi Process 0 on console Process 1 on c0101 Process 2 on c0102 Process 3 on c0103 pi is approximately 3.1416009869231249, Error is 0.0000083333333318 wall clock time = 0.000000
这两个程序唯一的不同就是在不同的目录里,我把它们都放在测试程序所在的目录,结果两个都不能运行,把它们都放在别的目录里的时候就都可以运行了,如下: [root@console examples]# mpirun -np 4 tt Hello world!Process 0 of 4 on console Hello world!Process 2 of 4 on c0102 Hello world!Process 1 of 4 on c0101 Hello world!Process 3 of 4 on c0103
看来是测试程序所在的目录出了问题,两个目录的信息如下: drwx------ 4 xiaowu xiaowu 4096 Jan 3 21:14 xiaowu drwx------ 27 nistest nistest 4096 Jan 3 21:20 nistest 这两个目录有什么不同啊? 之后发现凡是在目录 /home/及其子目录下都会有问题,而其他目录下还没有法现问题。
|