zoukankan      html  css  js  c++  java
  • MPI并行仿真基础c语言版

    之前联合上海超算中心做过一些并行的工作,大概把工作的过程讲解一下:

    代码的并行运算有三种,共享内存,MPI和两者混合,我使用的是MPI。

    要进行MPI编程,首先要下载这个软件:http://www.mpich.org/

    可自行到上述网站下载,目前windows的最新版本是2.1.4.1。

    安装好以后有以下几个目录:

    /usr/local/mpi/                 MPI software directory
    /usr/local/mpi/COPYRIGHT        Copyright notice
    /usr/local/mpi/README           various notes and instructions
    /usr/local/mpi/bin/             binaries, including mpiexec and mpicc
    /usr/local/mpi/examples         elementary MPI programs
    /usr/local/mpi/doc/             documentation
    /usr/local/mpi/include/         include files
    /usr/local/mpi/lib/             library files

    有些目录可能没有,没有关系。

    但是readme一定要读一次。里面有在vs下的详细配置方法(做1,2,3,4,6即可):

    Compiling an MPI program:

    1)  Create a project for Visual Studio 2003, or Intel Fortran 8.0

    2)  Add mpich2\include to the include path

    3)  Add mpich2\lib to the library path

    4)  For C applications add mpi.lib to your target link command.

    5)  For Fortran applications add fmpich2.lib to the link command.

    6)  Compile

    7)  Place your application and all the dlls it depends on in a shared location or copy them to all the nodes.

    8)  Run the application using mpiexec

    同样重要的还有examples下的vs工程,里面有c和c++两种版本的例子(在一个工程中)。

    例子看不懂,可以先把这篇4页纸的MPI教程看完,那就一定能懂了。

    教程链接:Hi,推荐文件给你 "MPI教程.pdf" http://vdisk.weibo.com/s/tu4-Q

    如果用到更复杂的函数编程可参考文献1。

    另外,安装mpich2以后会有个wmpiexec.exe的文件,只需要选择自己编写的编译后的MPI程序(即exe文件),并设置线程个数,MPIEXEC wrapper就会用多线程技术模拟多核运行环境执行MPI程序。

    参考文献:

    1.http://www.mcs.anl.gov/research/projects/mpi/www

    2.http://www.mcs.anl.gov/research/projects/mpi/

  • 相关阅读:
    luogu P3375 【模板】KMP字符串匹配
    leetcode[129]Sum Root to Leaf Numbers
    leetcode[130]Surrounded Regions
    leetcode[131]Palindrome Partitioning
    leetcode[132]Palindrome Partitioning II
    leetcode[133]Clone Graph
    leetcode[134]Gas Station
    leetcode[135]Candy
    leetcode[136]Single Number
    leetcode[137]Single Number II
  • 原文地址:https://www.cnblogs.com/xlw1219/p/2957285.html
Copyright © 2011-2022 走看看