Wednesday, November 11, 2015

Windows visual studio 2013 install MS_MPI and run mpi program


  1. install MSMPI : msmpi.  We need install both msmpisdk.msi (to get include\ & lib\) and MSMpiSetup.exe (to get bin\mpiexec.exe) 
  2. set environment variables : 
    • MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\
    • MSMPI_INC=C:\Program Files (x86)\Microsoft SDKs\MPI\Include\
    • MSMPI_LIB32=C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x86\
    • MSMPI_LIB64=C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\
  3. create a new C++ empty project :
  4. change linker's system configuration to CONSOLE(SUBSYSTEM:CONSOLE)
  5. add linker additional lib directories (x86 or x64) this machine is x86:
  6. add linker input additional dependencies , Type msmpi.lib to the list 
  7. add location of mpi header file 
  8.  Add a C++ file to write your first MPI program and write the following codes as a test: 
    #include<iostream>
    #include<mpi.h>
    using namespace std;
    
    int main(int argc, char** argv){
    
        int mynode, totalnodes;
    
        MPI_Init(&argc, &argv); 
        MPI_Comm_size(MPI_COMM_WORLD, &totalnodes);
        MPI_Comm_rank(MPI_COMM_WORLD, &mynode);
        
        cout << "Hello world from process " << mynode;
        cout << " of " << totalnodes << endl;
    
        MPI_Finalize();
        return 0;
    }
  9. build the program and if there is no error , then test it by running mpiexec:                        "mpiexec -n 4 mpi_hello.exe"
  10. use msmpi ; use msmpi 2 : 主要参考

No comments:

Post a Comment