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

西门子原装的编程电缆支持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/11860376.html

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

发表评论

登录后才能评论

评论列表(0条)

保存