3.本以为到此就已经安装好了,然后就赶紧写了个Hello World的程序。
- #include <mpi.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- #pragma comment (lib, "mpi.lib")
- int main(int argc, char* argv[])
- {
- int myid,numprocs;
- int namelen;
- char processor_name[MPI_MAX_PROCESSOR_NAME];
- MPI_Init(&argc, &argv);
- //用MPI_Comm_rank 获得进程的rank,该rank值为0到p-1间的整数,相当于进程的ID
- MPI_Comm_rank(MPI_COMM_WORLD, &myid);
- //用MPI_Comm_size 获得进程个数 int MPI_Comm_size(MPI_Comm comm, int *size);
- MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
- MPI_Get_processor_name(processor_name, &namelen);
- printf("Hello World! by MoreWindows\nProcess %d of %d on %s\n", myid, numprocs, processor_name);
- MPI_Finalize();
- if (myid == 1)
- {
- printf("\nPress a key and exit.\n");
- getch();
- }
- return 0;
- }
编译运行之后各种如下错误:
c:\program files\mpich2\include\mpicxx.h(1536) : error C2555: 'MPI::Intercomm::Clone' : overriding virtual function differs from 'MPI::Comm::Clone' only by return type or calling convention
c:\program files\mpich2\include\mpicxx.h(1107) : see declaration of 'Comm'
郁闷,这么个小东西都装不好,还谈什么写程序啊!
