中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Visual C++ > 综合文章
windows平台mpi程序编译
作者:未知 时间:2005-07-27 21:54 出处:CSDN 责编:chinaitpower
              摘要:windows平台mpi程序编译

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

}

 


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有