-------------------------------------------------------------------------- mpiexec was unable to launch the specified application as it could not access or execute an executable:
Executable: /home/xuan/a.out Node: jiemy
while attempting to start process rank 2.
测试demo
这里给一个我自己写的demo吧,创建一个test文件夹,创建一个hello_c.c
1 2 3
$ mkdir /mnt/test $ cd /mnt/test $ sudo gedit hello_c.c
intmain(int argc,char *argv[]) { int my_rank;/*进程序号*/ int p; /*进程总数*/ int source;/*发送者序号*/ int dest;/*接受者序号*/ int tag=0;/*消息标签*/ char message[100];/*消息储存*/ MPI_Status status;/*return status for*/
if(my_rank!=0) {/*创建消息*/ //得到本机的ip地址 char hostname[128]; get(hostname); sprintf(message,"Greeting from process %d,and ip is %s!",my_rank,hostname); dest=0; /*Use strlen+1 so that \0 gets transmitted*/ MPI_Send(message,strlen(message)+1,MPI_CHAR,dest,tag,MPI_COMM_WORLD); }else{/*my rank ==0*/ for(source=1;source<p;source++){ MPI_Recv(message,100,MPI_CHAR,source,tag,MPI_COMM_WORLD,&status); printf("%s\n",message); } char hostname[128]; get(hostname); printf("Greeting from process %d,and ip is %s!\n",my_rank,hostname); } /*关闭MPI*/ MPI_Finalize(); }/*主函数结束*/
$ mpicc hello.c $ mpiexec -hostfile hosts -np 4 ./a.out <--output--> Greeting from process 1,and ip is xuan-PC! Greeting from process 2,and ip is jiemy-virtual-machine! Greeting from process 3,and ip is jiemy-virtual-machine! Greeting from process 0,and ip is xuan-PC!