MPI 在Windows10 上安裝,使用VS2013編譯產生可執行程式

來源:互聯網
上載者:User

標籤:blank   bin   tar   www   win   .lib   直接   託管   msm   

原文地址:http://www.cnblogs.com/leijin0211/p/6851789.html

參考部落格: http://www.cnblogs.com/shixiangwan/p/6626156.html

      http://www.cnblogs.com/hantan2008/p/5390375.html

系統內容:

  Windows10  (Windows7及以上均可以)

  64bit

  VS2013

1. 下載並安裝MPICH For Windows

  進入http://www.mpich.org/downloads/網站根據作業系統下載。由於我們使用的是Windows,拉到下載網頁最底部,最新的MPICH實現已經由微軟官網託管,我們直接進去下載。

  

  然後,選擇最新的V8下載,包含兩個檔案:msmpisdk.msi和MSMpiSetup.exe。

  

  下載完畢直接分別安裝這兩個程式 msmpisdk.msi 和 MSMpiSetup.exe 

  我安裝在了D盤:

    

     

2. VS配置以及demo示範

  建立一個VC++項目

  

  在項目屬性中配置修改如下:

    包含目錄裡面添加:C:\Program Files (x86)\Microsoft SDKs\MPI\Include;

    庫目錄的裡面添加:C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64;

   

 

  其他必要配置:

    組態管理員,選擇x64編譯平台;

    C/C++ -> 前置處理器,添加:MPICH_SKIP_MPICXX;

    C/C++ -> 代碼產生 -> 運行庫,選擇:多線程調試(/MTd);

    連結器 -> 輸入 -> 附加依賴項,添加:msmpi.lib;

    

  demo測試,建立一個C++檔案,命名為main.cpp

 1 #include<stdio.h> 2 #include<mpi.h> 3 #include<stdlib.h> 4 #include<time.h> 5  6 int main(int argc, char* argv[]) 7 { 8     int myid, numprocs, namelen; 9     char processor_name[MPI_MAX_PROCESSOR_NAME];10 11     MPI_Init(&argc, &argv);        // starts MPI12     MPI_Comm_rank(MPI_COMM_WORLD, &myid);  // get current process id13     MPI_Comm_size(MPI_COMM_WORLD, &numprocs);      // get number of processes14     MPI_Get_processor_name(processor_name, &namelen);15 16     if (myid == 0) printf("number of processes: %d\n...", numprocs);17     printf("%s: Hello world from process %d \n", processor_name, myid);18 19     MPI_Finalize();20 21     return 0;22 }

 

  編譯整個項目,將編譯(1.項目右鍵重建 或者 2.使用編輯器編譯得到)得到的 exe檔案(debug檔案夾下)放在安裝的MS-MPI的bin目錄(預設為:C:\Program Files\Microsoft MPI\Bin  我安裝在了D盤)下,在這個Bin目錄下按住shift鍵於空白處按右鍵,開啟命令列視窗,輸入 mpiexec -n 10 MPI-demo.exe 得到運行結果,如:

  

  

MPI 在Windows10 上安裝,使用VS2013編譯產生可執行程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.