2012-07-28

OpenMPI 在 debian 單機上的安裝設定 (OpenMPI On PC)


2012-07-27 - R.J' Wiki : OpenMPI 在 debian 單機上的安裝設定
  • 環境
    • debian GNU/Linux 6.0 stable
    • openmpi-bin 版本 1.4.2-4
    • CPU ( lscpu )
      Architecture:          i686
      CPU op-mode(s):        32-bit, 64-bit
      CPU(s):                2
      Thread(s) per core:    1
      Core(s) per socket:    2
      CPU socket(s):         1
      Vendor ID:             GenuineIntel
      CPU family:            6
      Model:                 23
      Stepping:              10
      
  • 安裝(install)
    sudo aptitude install libopenmpi-dev openmpi-bin openmpi-doc
    
  • 程式碼(code)
    MPI_Hello.c
    #include <stdio.h>
    #include <stdio>
    
    int main(int argc, char* argv[]) {
       int myrank, nprocs;
    
       MPI_Init(&argc, &argv);
       MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
       MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
    
       printf("Hello from processor %d of %d\n", myrank, nprocs);
    
       MPI_Finalize();
       return 0;
    }
    
  • 編譯(compiler)
    mpicc MPI_Hello.c -o MPI_Hello
    
  • 執行(run)
    mpiexec -n 4 MPI_Hello
    
    mpirun -n 4 MPI_Hello
    
  • 輸出結果(output)
    Hello from processor 2 of 4
    Hello from processor 0 of 4
    Hello from processor 1 of 4
    Hello from processor 3 of 4
    


ref - http://sealmemory.blogspot.tw/2012/05/ubuntu-1204-openmpi-cluster.html

沒有留言: