单机上安装mpich,有些异常,想请教一下
我的台式机是4核,在ubuntu10.04 64位版本下安装了ubuntu自带的mpich,安装还算成功。但是,运行时候发现有点奇怪。进程号永远显示是1,如下,但是,printf倒是执行了4次,如果,-np 2 ,printf显示2次,内容都是Hello World!process 0 of 1 on ubuntu。
ubuntu:$ mpirun -np 4 hello
Hello World!process 0 of 1 on ubuntu
Hello World!process 0 of 1 on ubuntu
Hello World!process 0 of 1 on ubuntu
Hello World!process 0 of 1 on ubuntu
vlbi@ubuntu:$ mpirun -np 2 hello
Hello World!process 0 of 1 on ubuntu
Hello World!process 0 of 1 on ubuntu
同样的代码,在学校的集群系统上运行,结果正常,如下:
[patience]$ mpirun -np 4 hello
Hello World!process 1 of 4 on cluster
Hello World!process 0 of 4 on cluster
Hello World!process 2 of 4 on cluster
Hello World!process 3 of 4 on cluster
源代码如下:
#include <mpi.h>
#include <stdio.h>
#include <math.h>
int main(argc,argv)int argc;char *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();
}
我单机上的现象究竟正常吗?怎么进程号都是同一个呢?