Tích hợp thư viện MPI trong Visual Studio

Các bước tiến hành tích hợp thư viện MPI vào Visual Studio:

1. Cài đặt chương trình Visual Studio phiên bản từ 2005 trở lên
2. Tải về gói Microsoft Cluster Compute Pack SDK (phiên bản 32 bit hoặc 64 bit) từ địa chỉ sau và cài nó: SDK cho MPI
3. Mở Visual Studio
4. Từ menu File chọn New rồi chọn Project để tạo mới một New Project
5. Chọn Visual C++ và rồi chọn Win32 từ menu bên trái. Chọn Win32 Console Application bên phải. Nhập vào nơi lưu project của bạn và tên của project. Rồi ấn OK. Bạn có thể xem hình ở phía dưới.NewProject
6. Kích nút Next ở cửa sổ tiếp theo
7. Không kích vào hộp checkbox Precompiled header và rồi ấn nút Finish. Xem hình bên dưới.wizard
8. Project được tạo, trong file .cpp, thay đổi tên _tmain thành main và thay đổi _TCHAR* argv[] thành char* argv[] để nó tương thích với lời gọi MPI_Init của thư viện MPI.
9. Bạn có thể xoá các file không cần thiết trong Solution Explorer (xem bên dưới) ở bên trái. Nếu đó là một chương trình viết bằng ngôn ngữ C thì bạn có thể xoá hai file stdafx.h và stdafx.cpp. Và bạn cũng  bỏ dòng #include trong file .cpp của chương trình chính nếu bạn bỏ hai file stdafx ở trên.

  • Để xoá file, bạn kích chuột phải trên nó và chọn Remove.
  • Để thêm một file, kích chuột phải vào đúng thư mục và chọn Add, và rồi chọn New Item… hoặc Existing Item…deleteFiles

10. Kích chuột phải trên project trong Solution Explorer, trong ví dụ này tên project là mpiProject như trong hình ở trên, chọn Properties

  • Chọn vào Configuration Properties ở bên trái. Chọn All Configurations từ danh sách đổ xuống ở phần Configuration:.
  • Chọn C/C++ ở bên trái
    • Chọn General >> Additional Include Directories, đặt đường dẫn thư mục chứa thư viện mà bạn đã cài  bước 2. Trong trường hợp mặc định, thư mục này nằm ở: C:\Program Files\Microsoft Compute Cluster Pack\Include, bao gồm cả dấu nháy kép.
    • Chọn Advanced >> Compile As, đặt Compile as C++ Code (/TC) nếu code viết bằng ngôn ngữ C++ và ngược lại bạn chọn C
  • Chọn Linker ở bên trái
    • Chọn General >> Additional Library Directoriesđặt đường dẫn thư mục chứa thư viện mà bạn đã cài  bước 2. Trong trường hợp mặc định, thư mục này nằm ở: C:\Program Files\Microsoft Compute Cluster Pack\Lib\i386, bao gồm cả dấu nháy kép.
    • Chọn Input >> Additional Dependencies, đánh thêm vào thư viện msmpi.lib, chú ý nếu có các thư viện khác thì dùng dấu “; để ngăn cách giữa các thư viện. Ví dụ như: kernel32.lib;msmpi.lib

projectProperties
11. Nhập code chương trình của bạn và chọn meu Build >> Build Solution ở cửa sổ chính của Visual Studio để biên dịch chương trình.

Bạn có thể copy đoạn code sau để test thử thư viên MPI:


#include "mpi.h"
#include "stdio.h"

int main(int argc, char* argv[])
{
  int rc = MPI_Init(&argc,&argv);
  if (rc != MPI_SUCCESS) {
     printf ("Loi khoi tao chuong trinh MPI. Ket thuc.\n");
     MPI_Abort(MPI_COMM_WORLD, rc);
  }

  int  procId;      /* rank of process */
  int  noProc;    /* number of processes */
  int  nameSize;       /* length of name */
  char compName[MPI_MAX_PROCESSOR_NAME];
 
  MPI_Comm_size(MPI_COMM_WORLD, &noProc);
  MPI_Comm_rank(MPI_COMM_WORLD, &procId);
  MPI_Get_processor_name(compName, &nameSize);
  printf("TTSS: ProcessID %d tren %s\n", procId, compName);

  /******* Dong chuong trinh *******/
  MPI_Finalize();
  return 0;
}

Chú ý: Nếu bạn biên dịch bị lỗi “error LNK1123: failure during conversion to COFF: file invalid or corrupt”
Bạn có thể sửa nó bằng cách vào: Properties của Project
-> Configuration Properties
-> Linker (General)
-> Enable Incremental Linking -> “No (/INCREMENTAL:NO)”

12. Chạy chương trình
Sau khi biên dịch không có lỗi bạn có một file đuôi .exe nằm trong thư mục tên Project/Debug
– Bạn mở chương trình Cmd trên hệ điều hành Windows
– Chuyển tới thư mục chứa file .exe, trong ví dụ này file mpiProject.exe nằm ở ổ C:\Projects\MPITest\Debug
– Gõ câu lệnh:


mpiexec -n 3 mpiProject.exe

– Nếu không gặp lỗi gì thì bạn sẽ nhìn thấy kết quả:


Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Projects\MPITest\Debug>mpiexec -n 3 mpiProject.exe
TTSS: ProcessID 0 tren WIN-V4CPH4J1RON
TTSS: ProcessID 2 tren WIN-V4CPH4J1RON
TTSS: ProcessID 1 tren WIN-V4CPH4J1RON

C:\Projects\MPITest\Debug>

situs togel
toto slot
rtp slot
situs toto
bo togel
situs toto
situs toto
situs togel
bo togel
pam4d
situs togel
toto togel
situs togel
situs togel
bento4d
situs togel
bento4d
situs togel
bo togel
situs toto
pam4d
daftar pam4d
daftar pam4d
login bento4d
cerutu4d
cerutu4d
cerutu4d
situs toto
bento4d
situs toto
situs toto
situs togel
situs toto
situs toto
situs togel
situs togel
toto togel
situs toto
situs togel
situs togel resmi
toto slot
situs toto
situs togel
situs toto
situs togel
situs toto
situs toto
situs togel
situs toto slot
cerutu4d
situs toto
cerutu4d
situs toto
gimbal4d
daftar gimbal4d
gimbal4d
toto slot
situs toto
situs toto
toto slot
situs toto
situs toto
toto togel
toto slot
situs togel
live casino
toto slot
toto togel
bandar togel
situs toto
situs toto
situs togel
situs toto
situs togel
bakautoto
situs bandar togel
bakautoto situs resmi toto togel
bakautoto situs toto togel terpercaya 2024
monperatoto
monperatoto
monperatoto
monperatoto
monperatoto
monperatoto
situs togel
situs toto
situs toto
situs toto
situs toto
bo toto pulsa
bo toto
bo toto pulsa
bo togel
bo togel
bo togel
bo togel
cerutu4d
bo togel
bo toto
situs togel
situs togel
situs toto
situs toto
situs togel
bakautoto
situs togel
bakautoto
situs togel
situs toto
situs togel
bo togel
situs togel
bandar toto macau
togel pulsa
bo togel
Daftar Situs Toto
situs toto
situs toto
situs toto
toto togel
situs toto
situs toto
situs togel
situs togel
situs toto
situs toto
situs togel
situs toto
situs lotre

situs togel

bakautoto

bandar togel
togel resmi
bakautoto
bakautoto
bakautoto
bakautoto
situs toto slot/a>

totoslot

scatter hitam

situs togel
situs toto
bo togel
togel pulsa
bento4d
bento4d
situs toto
jacktoto
bandar togel
bo togel
situs toto
situs toto
bo togel
bo togel
situs toto
situs toto
situs toto
bo togel
bandar togel
situs togel
jacktoto
monperatoto
monperatoto
monperatoto
monperatoto
monperatoto
data macau
slot gacor hari ini
situs toto
situs toto
situs toto
togel online
bandar togel online
bandar toto macau
bandar togel
togel pulsa
toto togel
situs toto
bo togel
toto togel
bo togel
bo togel
situs togel
situs toto
togel online
situs toto
jacktoto
bo togel
situs togel
situs togel
situs togel
situs togel
bo togel
situs toto
bo togel
rimbabola
agen toto togel
situs togel
situs togel
bo togel
situs togel
situs togel
toto togel
situs toto
toto macau
situs togel
situs togel online
situs toto
bo toto
situs toto
bandar toto macau
situs toto
situs toto macau
togel dana
situs togel
togel pulsa
situs toto
link togel
situs togel online
situs toto
cabe4d
monperatoto
monperatoto
monperatoto
monperatoto
monperatoto
data macau
monperatoto
slot gacor hari ini
situs toto
situs toto
toto togel
situs toto
bandar togel
situs togel
rimbabola
situs toto
situs togel
slot gacor
bento4d
togel pulsa
situs toto
situs toto
situs toto
situs toto
situs toto
bento4d
bo toto
cabe4d
bo toto
jacktoto
situs toto
situs deposit pulsa
togel online
situs toto macau
cerutu4d
cerutu4d
rimbabola
situs toto macau
situs toto macau
situs togel online
situs toto
situs togel terpercaya
situs toto
rtp
situs togel
situs togel
situs toto
situs togel
bandar togel
situs togel
jacktoto
situs toto
situs toto
situs toto
situs slot gacor
situs togel
situs togel
bo togel
situs togel
situs toto
situs toto
situs togel
situs toto
situs togel
bo togel
bakautoto
bo togel
bakautoto
bet togel
situs togel
situs togel online
situs toto
bo togel
situs togel resmi
togel online
situs togel
situs toto
bo togel
rimbabola
situs togel
bo togel
situs toto
togel online
situs toto
bandar togel
bo togel
bandar totomacau
bo toto pulsa
cerutu4d
toto macau
situs togel
situs togel
situs togel
situs toto
situs toto
situs toto
agen togel
bo togel
togel online
situs togel
situs togel4d
bo togel terpercaya
situs toto
situs toto
situs togel resmi
situs togel
togel resmi
situs togel
situs togel
pam4d
bakautoto
situs toto
situs toto
bo togel
gimbal4d
situs togel
bo togel
bo toto
situs toto
bo toto
situs togel
situs toto
situs bandar togel
situs togel
situs togel
bo toto
bo togel
bandar togel resmi
10 situs togel terpercaya
cerutu4d
situs toto
bo togel
situs togel
situs togel online
situs togel
situs toto togel
situs togel
situs togel
bo togel
agen togel
situs togel
situs togel
situs toto
situs toto
situs toto
bo togel
situs toto
bo togel
cabe4d
rimbatoto
situs toto
situs toto
situs togel
situs togel
togel resmi
situs togel
situs toto
situs togel
situs togel
situs toto
cabe4d
situs toto
bandar togel
situs toto
cabe4d
situs togel
situs togel
situs toto
rimbatoto
rimbatoto
situs toto
PAM4D
PAM4D
PAM4D
rimbabola
PAM4D
gimbal4d
situs toto
rimba toto
https://iaida.ac.id/bandar
https://ak.poliupg.ac.id/ngacor/
rimba toto
rimba toto
bo togel terpercaya
rimba toto
rimba toto
rimba toto
rimba toto
rimba toto
rimba toto
rimba toto
agen togel
cabe4d
cabe4d
bandar togel
cabe4d
situs toto togel
situs togel terpercaya
situs slot
pam4d
situs togel
agen toto
situs togel
situs togel
situs togel
situs togel
rimbatoto

Có thể bạn sẽ thích…

3 phản hồi

  1. Giáp viết:

    thầy hướng dẫn bằng nhiều chữ và ít hình ảnh như thế này thì bọn em khó thực hành theo lắm ak. thầy mà đầu tư làm cả 1 cái video để bọn em thực hành thì dễ dàng hơn ak, chứ như thế này bọn em mày mò mãi mới ra và cũng có 1 số cái không ra vì không hiểu và không giống với thầy miêu tả. nói chung là khó hiểu quá thầy ak

    • Hình đại diện của người dùng admin viết:

      :). Đây là các bước thầy đã làm trên máy. Bởi mỗi hệ thống (phiên bản khác nhau) nên hình ảnh sẽ khác nhau. Nhưng mình cũng sẽ cố gắng mô tả bằng nhiều hình ảnh nhất có thể.

  1. 07/03/2016

    […] Tham khảo cách tích hơp MPI trong Visual Studio và cấu hình […]

Trả lời