VC语言

本类阅读TOP10

·VC++ 学习笔记(二)
·用Visual C++打造IE浏览器(1)
·每个开发人员现在应该下载的十种必备工具
·教你用VC6做QQ对对碰外挂程序
·Netmsg 局域网聊天程序
·Windows消息大全
·VC++下使用ADO编写数据库程序
·VC++学习笔记(四)
·非法探取密码的原理及其防范
·怎样在VC++中访问、修改注册表

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
windows平台mpi程序编译

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

在这里可以下载到最新的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;

}

 




相关文章

相关软件