VS2010+intel fortran compiler+MPICH2,如何在双核单机进行MPI程序调试?

VS2010+intel fortran compiler+MPICH2,如何在双核单机进行MPI程序调试?,第1张

RCS How-To: Compile, Link, Run and Debug FORTRAN MPI Programs Using Microsoft Visual Studio

Test-system(s) used: VMware virtual machine of WinXP x64 Pro, MS Visual Studio 2008 with Intel Visual Fortran 11.0.047 running mpich2

Installation

For the 64 bit test system, care has to be taken regarding compatibility of components one wishes to use together. Given only a 32 bit Visual Studio (VS) 2008 is available for free to Univ of Manchester researchers, a 32 bit version of mpich2 is used. We downloaded the 32 bit Windows binary from the mpich2 web site. (Using 64 bit mpich2 gives link time errors.)

Following the mpich2 for MS Windows instructions (see README.winbin.rtf) we add the relevant mpich2 include and library components to a VS project's build. For VS 2008 this is as followsfor other versions the actual locations vary. We presume you're aware of how to set parameters for your chosen build/project/configuration.

add the full path of mpich2 include directory (eg C:\Program Files (x86)\MPICH2\include) to the VS include path (Configuration Properties - Fortran - General - Additional Include Directories) add the full path of mpich2 library directory (eg C:\Program Files (x86)\MPICH2\lib) to the VS library path (Configuration Properties - Linker - General - Additional Library Directories) add the name of the relevant mpich2 library file to the VS link command using the Additional Dependencies (Configuration Properties - Linker - Input - Additional Dependencies). The mpich2 library file to use for the Intel Fortran compiler is fmpich2.lib

You should now be able to compile and link, or to build, a Fortran MPI program.

Launching MPI from Visual Studio

Rather than running the newly created executable, known to VS as $(TargetPath), we wish to launch mpiexec.exe and pass that the required mpich2 parameters and the executable. This can be achieved by

setting the launch command (Configuration Properties - Debugging - Command) to the full path for mpiexec.exe (eg C:\Program Files (x86)\MPICH2\bin\mpiexec.exe)

setting the arguments (Configuration Properties - Debugging - Command Arguments) to -n 2 $(TargetPath)

Then the MPI executable can be launched from VS by Debug - Start Without Debugging (Ctrl+F5). (Debug - Start Debugging (F5) also works but VS complains there's no debugging information for the mpiexec.exe itself)

NB if you try and use breakpoints etc it appears not to honour these - see below for how to debug.

Troubleshooting

These are just some of the problems you may see. For an exhaustive list please search the Internet.

You can now run your MPI program. If you see only one MPI process then you may not have launched the MPI processes correctly. You can check whether you program behaves as expecting by opening a terminal window (eg Start - Run - cmd) and then manually launching using {fullpath/}mpiexec.exe -n {num} {fullpath/}your.exe

If prompted for a username/password this will be the username/password used to authenticate to login to Windows. You can use mpiexec to register username/passwords. From a terminal window use mpiexec.exe -help2 for the full help on mpiexec.

If you get an error regarding inablity to connect it may due to MS Windows (or other) firewall settings. You may also occasionally need to start the mpich2 process manager (smpd.exe in the mpich2 bin directory) manually. As per Windows, a restart may help.

The VS Output window may occasionally show "First-chance exception at 0x7d4e237e in mpiexec.exe: 0x000006C5: The tag is invalid." but it appears these can be ignored.

Debugging Fortran MPI Using Visual Studio

by attaching to a currently running process (one VS window for all selected MPI processes)

This is a generic method and gives you one VS debugging window but you can move between MPI processes

compile, link and start running your MPI program (you may wish to put a read statement early on to hold the program while you do the next steps) attach to one of the currently running MPI processes: Debug - Attach to Process brings up a dialogue box which lists Available Processes. You should see NUM instances (where N is from mpiexec -n NUM) of your executable. Select all of these and click on Attach. You can now debug by adding breakpoints etc. To move between MPI processes use the Process drop-down menu just above the code listing.

launching VS from mpiexec (one VS window per MPI process)

Firstly, having compiled and linked (or built) your executable (project), close all VS application windows. From a terminal window

stop any running mpich2 process manager: {mpich2/bin/}smpd.exe -stop start smpd in debug mode: {mpich2/bin/}smpd.exe -d O (or just -d if you're happy to see debugging messages (-d NUM is the level of debugging))

Open another terminal window we can now launch the VS executable on each MPI process with the following command (this is one command and shouldn't be split over lines but your browser may reformat):

"c:\Program Files (x86)\MPICH2\bin\mpiexec.exe" -n 2 "c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"  "c:\Program Files (x86)\MPICH2\examples\Debug\fpi.exe"

where you should use the path to your mpiexec.exe and to your VS executable (devenv.exe} and to the required executable (or Fortran file or project) This will give you two (or NUM if you use -n NUM) VS applications, one for each thread. You can then debug as normal - you will have to manually start each debugging thread and you may have to "Break All" to bring up the source code for adding break and watch points.

More Information

The above was compiled by trial, error and help from the mpich2 team.

For further help and discussion

      这个事网上有攻略,参见:http://www.docin.com/p-728410179.html,或者度娘搜索“win7+ivf+mpi”字样即可。但是这个攻略有不详之处,这里结合自己的经验说说要注意的地方。

首先,假设你已经在win7系统下安装好了ivf开发环境(具体参见上述链接中的攻略,这又是一个大问题,限于篇幅这里不再详述),那么按以下步骤安装和配置mpi。

1. 安装mpich2文件。pc如果显示是64位 *** 作系统,不用搭理,要看ivf的位数,选择mpi的位数,一般是32位的。

2.安装目录可以自己选。目录下会有include,bin和lib文件夹,以及example 文件夹。安装过程中出现一个behappy,在后面要用到。

3.装完mpich2才完成了一小步,接下来要运行smpd可执行文件,该文件在安装目录下的bin文件夹中(大概是bin,反正就是上面提到的三个文件夹中的一个)。a.开始-搜索,找到 cmd.exe符,鼠标右键以管理员身份运行(注意,这里必须用鼠标右键,才能以管理员身份运行),就出现一个命令流窗口,黑色背景的那种。b. 进入smpd.exe文件所在的目录,例如目录在D盘的话,cd /d D:\。。。,总之进入smpd.exe所在的路径。c.查看smpd安装状态,smpd -status,如果没有安装,键入命令smpd -install -phrase behappy,就ok了。

4. 注册,就是让win7知道有smpd在运行了,开始-所有程序-mpich2-register相关的一个,会出现输入用户名密码什么的,用户名输入机器的名字,注意,这里要输入的名字有讲究,我的电脑-右键-管理-计算机管理(本地)-系统工具-本地用户和租-用户-名称,找到自己当前登录的账户对应的名称,而不是全名(一般两者一致,不一致的话按名称输入),将对应的账户名称和密码填入后,既可以注册。

5.ivf中的mpi配置,打开一个项目,在项目-项目名称属性中设置,有三个地方必须设置,1是fortran-genreral中的additional include directories,将include文件夹目录完整copy到里面;2是link-general中的additional library directories,将bin文件夹的完整目录copy过去;3是link-input中的addtional dependencies,将fmpich.lib文件的完整目录包括文件名copy过去。上述设置需要在每个项目中都做一遍,做一遍之后,该项目会记住设置,从而不用在同一个项目中重复设置。另外,对同一个项目,release和debug模式下也要分别进行上述设置。

6.接下来就可以使用mpi编译了,编译完生成的可执行文件(.exe)要在mpi提供的一个界面中运行,开始-所有程序-mpich2-mpiexec.exe,会d出一个对话框,在里面添加编译生成的可执行文件目录,所用的线程数即可,点击execute按钮即可以并行计算了。这里面可以勾选一个run in a separate window选项,屏幕输出会在一个独立窗口中显示,背景是黑色的那种,不勾选这个,屏幕输出就在下面的白色方框内显示。另外,如果想选择mpi运行程序的位置(可执行文件,头文件,输入文件输出文件),在对话框左下角勾选more,第一行即可选择。

上述细节乃是本人亲历艰辛才得到的经验,权作开头连接中给出的攻略的补充。

西门子原装的编程电缆支持mpi 、DP的通讯协议,

只要在PG/PC中设定为“PC Adapter (PROFIBUS). 设定方法如下:打开SIMATIC管理器,选择菜单Options(选项)/Set PG/PC Interface(设定PG/PC接口),在打开的界面中“Interface Parameter Assignment”(接口参数指派)中设定为PC Adapter (PROFIBUS),。但一般既然使用MPI编程电缆都是使用MPI接口(X1端口)与CPU通信连接,因为PC Adapter 通信速率只有通过拔开关设定为19.2kbits/s 或187.5kbits/s而实际上PROFIBUS DP的默认通信速率为1.5Mbits/s,在这里,由于你组态时候,设定为DP协议,而西门子原装的编程电缆支持mpi 、DP的通讯协议,所以,可以用dp协议进行通讯,可以监控/下载程序。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11968314.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存