VS2010:使用MS-MPI sdk和运行时编译MPI程序 [英] VS2010: Compiling MPI program with MS-MPI sdk and runtime

查看:326
本文介绍了VS2010:使用MS-MPI sdk和运行时编译MPI程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的msdn dev论坛成员,


           我试图在visual studio 2010上编译并运行一个简单的MPI程序。操作系统是Windows 10.


           我尝试按照本教程学习如何编译和运行MPI程序:         


            https://blogs.technet.microsoft.com/windowshpc/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program/


           并从这个网站安装了ms-mpi运行时和sdk:


            https://www.microsoft.com/en-us/download/details.aspx?id=57467


            代码如下:


          

 //#include< pch.h> 
#include< stdio.h>
#include< stdlib.h>

#include< mpi.h>

int main(int argc,char * argv []){
MPI_Init(& argc,& argv);

int rank;

MPI_Comm_rank(MPI_COMM_WORLD,& rank);

if(rank == 0){
char helloStr [] =" Hello World" ;;
MPI_Send(helloStr,_countof(helloStr),MPI_CHARk,1,0,MPI_COMM_WORLD);
} else if(rank == 1){
char helloStr [12];
MPI_Recv(helloStr,_countof(helloStr),MPI_CHAR,0,0,MPI_COMM_WORLD,MPI_STATUS_IGNORE);
printf(" Rank 1从Rank 0 \ n",helloStr收到字符串%s);
}

MPI_Finalize();

返回0;
}





  ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;在尝试编译一个简单的hello world MPI程序时,我得到以下错误消息:      


           

 1> ------ Build build:项目:mpi_ms,配置:发布x64 ------ 
1> Build build 05-Feb-19上午11:35:25
1> InitializeBuildStatus:
1>触摸"x64 \Release\mpi_ms.unsuccessfulbuild"。
1> ClCompile:
1> msmpi.cpp
1> C:\Program Files(x86)\ Microsoft SDKs\MPI \Include\mpi.h(4617):错误C2061:语法错误:标识符'_Out_writes_'
1> C:\Program Files(x86)\ Microsoft SDKs \ MPI \Include\mpi.h(4618):错误C2059:语法错误:')'
1> C:\程序文件(x86)\ Microsoft SDKs\MPI \Include\mpi.h(4618):错误C2143:语法错误:缺少')'之前';'
1> C:\Program Files (x86)\ MicroSoft SDKs\MPI \Include\mpi.h(4629):错误C2061:语法错误:标识符'_Out_writes_'
1> C:\Program Files(x86)\ Microsoft SDKs \ MPI \Include\mpi.h(4630):错误C2059:语法错误:')'
1> C:\Program Files(x86)\ Microsoft Developer SDK \\\\\\\\\\\\\\\ \mpi.h(4630):错误C2143:语法错误:缺少')'之前';'
1> msmpi.cpp(16):错误C2065:'MPI_CHARk':未声明的标识符
1> ;
1> Build FAILED。
1>
1>时间流逝00:00:00.46
==========构建:0成功,1失败,0最新,0跳过====== ====

    这里有人知道发生了什么吗?这是我第一次尝试在linux环境之外编译和运行MPI C程序。我知道MPI运行时正在运行,因为我已经尝试使用MPI4py的python脚本。



祝你好运,


JoséHugo



           

解决方案

朋友,


欢迎来到MSDN论坛。


根据教程,该项目支持
MPIv6
而不是我们安装的MPIv10。更重要的是,该教程是在2015年编写的,MPIv10是在2018年发布的。这将导致版本兼容性问题。


当我使用MPIv10时,我重现了同样的问题。之后,我删除MPIv10,MPI SDKv10并安装MPIv6及其SDKv6。该程序的工作原理如下:



注意:如果我们在安装MPIv6之后在构建时遇到一些错误,如下所示:



更改"


(MSMPI_INC)\ x64到


(MSMPI_INC)\x86"并更改"


Dear members of msdn dev forum,

            I am trying to compile and run a simple MPI program on visual studio 2010. The OS is Windows 10.

            I tried to follow this tutorial on how to compile and run an MPI program:         

            https://blogs.technet.microsoft.com/windowshpc/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program/

            and installed ms-mpi runtime and sdk from this website:

            https://www.microsoft.com/en-us/download/details.aspx?id=57467

            The code is the following:

          

//#include <pch.h>
#include <stdio.h>
#include <stdlib.h>

#include <mpi.h>

int main(int argc, char* argv[]){
	MPI_Init(&argc,&argv);

	int rank;

	MPI_Comm_rank(MPI_COMM_WORLD,&rank);

	if(rank==0){
		char helloStr[] = "Hello World";
		MPI_Send( helloStr, _countof( helloStr ), MPI_CHARk, 1, 0, MPI_COMM_WORLD);
	} else if(rank==1){
		char helloStr[12];
		MPI_Recv( helloStr, _countof( helloStr ), MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
		printf ( "Rank 1 received string %s from Rank 0\n", helloStr );
	}

	MPI_Finalize();

	return 0;
}


            While trying to compile a simple hello world MPI program, above, I get the following error mesage:      

           

1>------ Build started: Project: mpi_ms, Configuration: Release x64 ------
1>Build started 05-Feb-19 11:35:25 AM.
1>InitializeBuildStatus:
1>  Touching "x64\Release\mpi_ms.unsuccessfulbuild".
1>ClCompile:
1>  msmpi.cpp
1>C:\Program Files (x86)\Microsoft SDKs\MPI\Include\mpi.h(4617): error C2061: syntax error : identifier '_Out_writes_'
1>C:\Program Files (x86)\Microsoft SDKs\MPI\Include\mpi.h(4618): error C2059: syntax error : ')'
1>C:\Program Files (x86)\Microsoft SDKs\MPI\Include\mpi.h(4618): error C2143: syntax error : missing ')' before ';'
1>C:\Program Files (x86)\Microsoft SDKs\MPI\Include\mpi.h(4629): error C2061: syntax error : identifier '_Out_writes_'
1>C:\Program Files (x86)\Microsoft SDKs\MPI\Include\mpi.h(4630): error C2059: syntax error : ')'
1>C:\Program Files (x86)\Microsoft SDKs\MPI\Include\mpi.h(4630): error C2143: syntax error : missing ')' before ';'
1>msmpi.cpp(16): error C2065: 'MPI_CHARk' : undeclared identifier
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.46
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

     Do anyone here have any idea of what is going on? This is my first time trying to compile and run MPI C programs outside linux environment. I know the MPI runtime is working because I've tried with python scripts using MPI4py.

Best regards,

José Hugo

           

解决方案

Hi friend,

Welcome to MSDN forum.

According to the tutorial, this project support for MPIv6 instead of MPIv10 we installed. What's more, the tutorial was written in 2015 and MPIv10 is published in 2018. That would cause version compatibility issue.

I reproduce same issue when i use MPIv10. After that I remove the MPIv10 , MPI SDKv10 and install MPIv6 and its SDKv6. This program works well like below:

Note: If we encounter some error when building after we install MPIv6 like below:

Changing "


(MSMPI_INC)\x64 to


(MSMPI_INC)\x86" and change "


这篇关于VS2010:使用MS-MPI sdk和运行时编译MPI程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆