-------------------------------------------------------------------------- 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
if(my_rank!=0) { char hostname[128]; get(hostname); sprintf(message,"Greeting from process %d,and ip is %s!",my_rank,hostname); dest=0; MPI_Send(message,strlen(message)+1,MPI_CHAR,dest,tag,MPI_COMM_WORLD); }else{ 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_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!