在这里可以下载到最新的mpich开发包
http://www-unix.mcs.anl.gov/~ashton/mpich.nt/
http://www-unix.mcs.anl.gov/mpi/mpich/download.html
1.附加包含目录里加上mpich sdk的include路径
2.附加库目录里加上mpich sdk的lib路径
3.debug: Run-time library 改为 mtd
release: Run-Time library 改为 mt
具体可以看手册,手册上配置过程是
Compiling and linking with Microsoft Developer Studio (VC++ 6.x)
1. Create a new project.
2. Add MPICHnSDKninclude to the include path.
3. Add MPICHnSDKnlib to the library path.
4. Add the /MTd compiler switch to the Debug target and /MT to the Release target.
5. Add ws2 32.lib to the library option. Add mpich.lib to the Release target and
mpichd.lib to the Debug target.
6. Add your source files.
7. Build.
8. Copy the executable and use mpirun to run the application.
//
// HelloWorld.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "mpi.h"
#include <math.h>
#include <iostream>
#define LENGTH 1024
using namespace std;
#pragma comment (lib, "mpichd.lib") //将mpichid.lib库文件加入到本工程中
int _tmain(int argc, _TCHAR* argv[])
{
int myid, numprocs;
int namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init( &argc, &argv ); //MPI程序的初始化
MPI_Comm_rank( MPI_COMM_WORLD, &myid ); //得到当前正在运行的进程的标识号
MPI_Comm_size( MPI_COMM_WORLD, &numprocs ); //得到所有参加运算的进程的个数放在numprocs中
MPI_Get_processor_name( processor_name, &namelen ); //得到运行本机器的机器名
MPI_Finalize(); //MPI程序结束
fprintf( stderr, "Hello World! Process %d of %d on %s\n", myid, numprocs, processor_name );
//--------------------------------------------------->
char wait[LENGTH];
do
cin >>wait;
while ( strncmp( wait, "exit", 4 ) );
return 0;
}