1. MPI(Message Passing Interface)
- 메시지 전달 인터페이스
- 분산 메모리 장치에서 프로그래밍하는 방법, 모든 병렬 프로세스가 다른 프로세스와 독립된 상태에서 자체 메모리 공간에서 병렬처리 발생
(참고: https://stackoverflow.com/questions/32464084/what-are-the-differences-between-mpi-and-openmp) - MS-MPI 라이브러리 사용 권장
- MPICH 라이브러리를 Window에서 사용할 수 있도록 MS사에서 만듦 - 코드로 제어 불가능. 부분 병렬처리 불가능
What are the differences between MPI and OpenMP?
I would like to know (in a few words) what are the main differences between OpenMP and MPI.
stackoverflow.com
2. 환경구축
- 개발환경 : Window 10 pro, Visual studio 2013 pro
- 가이드 링크 : https://github.com/microsoft/Microsoft-MPI/blob/master/examples/helloworld/Run_MPIHelloWorld.md
Microsoft-MPI/examples/helloworld/Run_MPIHelloWorld.md at master · microsoft/Microsoft-MPI
Microsoft MPI. Contribute to microsoft/Microsoft-MPI development by creating an account on GitHub.
github.com
1) Microsoft MPI 다운로드 및 설치
- https://www.microsoft.com/en-us/download/details.aspx?id=100593
2) 환경 변수 확인 : 명령프로프트 관리자 권한으로 실행 (set MSMPI 입력)
3) Visual studio 프로젝트 생성
4) 프로젝트 설정(C/C++ → General)
- 현재 플랫폼 32/64-bit 주의.
- C/C++ → General à Additional Include Directories → $(MSMPI_INC);$(MSMPI_INC)\x64 입력 (64-bit)
- C/C++ → General à Additional Include Directories → $(MSMPI_INC);$(MSMPI_INC)\x86 입력 (32-bit)
5) 프로젝트 설정(Linker → General)
- 현재 플랫폼 32/64-bit 주의.
- Linker → General → Additional Library Directories → $(MSMPI_LIB64) 입력 (64-bit)
- Linker → General → Additional Library Directories → $(MSMPI_LIB32) 입력 (32-bit)
6) 프로젝트 설정(Linker → Input)
- Linker → Input → Additional Dependencies → msmpi.lib 입력
3. 테스트
#include <iostream>
#include <mpi.h>
using namespace std;
int main(void)
{
int my_rank;
int world_size;
MPI_Init(NULL, NULL);
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
std::cout << "Hello World from process " << my_rank << " out of " << world_size << " processes!!!" << std::endl;
MPI_Finalize();
cout << "Finished" << endl;
getchar();
return 0;
}
4. 실행
1) 관리자권한으로 명령프롬프트 실행
2) 빌드된 프로그램 폴더 경로 설정 및 실행
- $ cd 명령어로 경로 설정
- C:드라이브에서 D:드라이브로 경로 설정 시 “ d: “ 입력
- $ mpiexec –n 20 MSMPI.exe 입력
5. 문법
- 버전확인
// MPI 버전
int ver;
int subVer;
MPI_Get_version(&ver, &subVer);
// MPI 라이브러리 버전
char cVer[32];
int len;
MPI_Get_library_version(cVer, &len);
감사합니다.
잘못된 정보나 오타 및 수정사항이 있을 경우 댓글로 달아주시면 감사하겠습니다.