####   New Version MPI 환경 구성 
작성일 : 2008년 2월 21일 
작성자 : 서진우 
1. intel v10 compiler + mkl v10 환경 구축 하기 
– Intel CC, FC는 기존 설치 방법과 동일 함. 
– Intel MKL 설치 하기. 
설치 방법은 동일. 추가 환경 설정 방법은 다음과 같다. 
# cd /engrid/enhpc/intel/mkl/tools/environment/ 
# cp mklvarsem64t.* /etc/profile.d/ 
/engrid/enhpc/intel/mkl/benchmarks 에 Intel에 최적화된 HPL 등이 존재 한다. 
이걸 이용하면 쉽게 HPL 테스트를 할 수 있다. 
2. mpich2 + intel 환경 구축 하기 
# export FC=ifort 
# export F77=ifort 
# export F90=ifort 
# export CC=icc 
# export CXX=icpc 
# export RSHCOMMAND=/usr/bin/rsh 
# ./configure –prefix=/engrid/enhpc/mpich2/intel –enable-timing=runtime –enable-f77 –enable-f90 –enable-cxx –enable-romio –enable-threads=multiple –enable-mpe –with-thread-package=pthreads 
# make && make install 
# cd ~ 
# vi .mpd.conf 
———————————————————————– 
MPD_SECRETWORD=password 
———————————————————————– 
# chmod 600 .mpd.conf 
# ensync .mpd.conf 
# vi /etc/mpd.hosts 
———————————————————————– 
node00:8 
node01:4 
node02:4 
node03:4 
node04:4 
———————————————————————– 
# mpdboot -r /usr/bin/rsh -n 5 –ncpus=8 -f /etc/mpd.hosts 
  -r : 통신프로토콜명령 
  -n : 노드수 
  –ncpus : Master 서버  Core 수 
  -f : 노드와 core 리스트 파일 
  ;; –ncpus 와 -f 사용 시 -f 로 불려오는 노드와 core 리스트 파일에 등록된 정보를 기본으로 클러스터 작업 노드 구성을 
     하게 되는데 mpdboot를 실행하는 노드의 코어 수가 다를 경우 –ncpus를 이용하여 별도로 코어수를 다르게 지정할 수 있다. 
         즉 node00의 core수가 8이고 나머지는 4개일 경우 .. 
     node00에서 “mpdboot -r rsh -n 5 -f /etc/mpd.hosts” 라고 실행한 후 “mpiexec -n 20″을 실행하면 코어 배열이 모든 서버 
     가 동일하게 4개씩 활당이 된다. 하지만 “mpdboot -r rsh -n 5 -f /etc/mpd.hosts –ncpus=8” 이라고 실행한 후… 
     “mpiexec -n 20” 을 실행하면 node00 에서 core 8개가 활당되고, 나머지 노드에서는 core 3개씩 활당이 되어진다. 
# mpdtrace : mpdboot 로 구성된 클러스터 작업 구성을 보여 준다. 
# mpdrun -l -n 8 hostname : mpdboot 로 구성된 서버 프로세서에게 hostname 명령을 배열대로 실행 시킨다. 
# mpdallexit : mpdboot 로 구성된 클러스터 구성을 해제한다. 
3. mpich2 and mkl 제공 기본 BMT 사용하기 
– MKL 제공 HPL 사용하기 
mkl v10 에서 제공하는 benchmark를 이용하여 쉽게 HPL을 실행할 수 있다. 
# cd /engrid/enhpc/intel/mkl/benchmarks/mp_linpack 
# vi Make.em64t 
————————————————————————– 
. 
. 
  CC      = mpicc  # 해당 mpicc 경로를 적어 주면 된다. 
————————————————————————– 
# make arch=em64t install 
# cd bin/em64t 
# vi HPL.dat -> 환경에 맞게 수정 
# mpiexec -n 10 ./xhpl 
이 밖에 MKL에 기본적으로 컴파일이 되어 있는 xhpl 이 있다. 
/engrid/enhpc/intel/mkl/benchmarks/mp_linpack/bin_intel 밑에 서버 아키텍처별로 디렉토리가 생성되어 있다. 
이것을 이용해서 테스트 해도 된다. 성능은 직접 컴파일한 거 보다 좋게 나온다. ^^;; 
– MPICH2 제공 BMT 프로그램 사용하기 
# cd /engrid/enhpc/mpich2/intel/share/ 
밑에 다양한 BMT 툴이 있다 .해당 디렉토리에 가서 make 하고 mpiexec를 실행하면 된다. 
4. Netpipe 테스트 하기 
# tar xzvf NetPIPE.x.x.x.tar.gz 
# cd NetPIPE-x.x.x 
# vi makefile 
————————————————————————– 
CC         = cc 
CFLAGS     = -O 
SRC        = ./src 
# 해당 MPICC 의 PATH 를 적어 넣는다 
MPICC       = /engrid/enhpc/mpich2/intel/bin/mpicc 
. 
. 
MPI2CC   = /engrid/enhpc/mpich2/intel/bin/mpicc 
MPI2_LIB = /engrid/enhpc/mpich2/intel/lib 
MPI2_INC = /engrid/enhpc/mpich2/intel/include 
. 
————————————————————————- 
# make tcp 
# make mpi 
– tcp 테스트 
tcp bendwitch 테스트는 두대 서버간의 네트워크 패킷 크기별 전송 대역폭과 응답속도를 측정해 준다. 
먼저 source 서버에서 NPtcp 데몬을 실행하고, 원격 서버에서 NPtcp -h hostname 으로 실행하면 된다. 
local > ./NPtcp 
remote > ./NPtcp -h local 
—————————————————————————————— 
Now starting the main loop 
  0:       1 bytes   1602 times –>      0.12 Mbps in      62.45 usec 
  1:       2 bytes   1601 times –>      0.24 Mbps in      62.45 usec 
  2:       3 bytes   1601 times –>      0.37 Mbps in      62.45 usec 
  3:       4 bytes   1067 times –>      0.28 Mbps in     110.50 usec 
. 
. 
120: 6291459 bytes      3 times –>    895.89 Mbps in   53577.82 usec 
121: 8388605 bytes      3 times –>    896.60 Mbps in   71380.81 usec 
122: 8388608 bytes      3 times –>    896.65 Mbps in   71377.16 usec 
123: 8388611 bytes      3 times –>    896.60 Mbps in   71380.85 usec 
—————————————————————————————— 
– mpi 테스트 
mpi 테스트는 mpi를 실행할 두대 서버간의 mpi 통신 시 네트워크 대역폭을 측정하는 것이다. 
# vi mpdhosts 
—————————————————————————————— 
node00 
node01 
—————————————————————————————— 
# mpdboot -n 2 -r rsh -f mpdhosts 
# mpiexec -n 2 ./NPmpi 
——————————————————————————————- 
0: node00 
1: node01 
Now starting the main loop 
  0:       1 bytes   1602 times –>      0.12 Mbps in      62.46 usec 
  1:       2 bytes   1600 times –>      0.24 Mbps in      62.46 usec 
  2:       3 bytes   1600 times –>      0.24 Mbps in      94.28 usec 
  3:       4 bytes    707 times –>      0.49 Mbps in      62.46 usec 
. 
. 
118: 6291453 bytes      3 times –>    894.53 Mbps in   53659.32 usec 
119: 6291456 bytes      3 times –>    891.74 Mbps in   53827.64 usec 
120: 6291459 bytes      3 times –>    894.61 Mbps in   53654.99 usec 
121: 8388605 bytes      3 times –>    894.83 Mbps in   71521.80 usec 
122: 8388608 bytes      3 times –>    894.85 Mbps in   71520.01 usec 
123: 8388611 bytes      3 times –>    894.82 Mbps in   71522.51 usec 
—————————————————————————————— 
5. HPL 테스트 하기 
v10대 Mkl 이용시 HPL makefile 정의 내용 중 변경 사항이 있다. 
기존의 Make.MPI-INTEL 파일 내용을 아래와 같이 변경한다. 
——————————————————————————————- 
LAdir        = /engrid/enhpc/intel/mkl/lib/em64t 
LAinc        = 
LAlib        = $(LAdir)/libmkl_intel_lp64.a $(LAdir)/libmkl_intel_thread.a \\ 
$(LAdir)/libmkl_core.a $(LAdir)/libguide.a -lpthread 
. 
CC           = $(MPP_HOME)/bin/mpicc 
CCNOOPT      = $(HPL_DEFS) -O0 -w 
CCFLAGS      = $(HPL_DEFS) -O3 -axP -w 
. 
LINKER       = $(MPP_HOME)/bin/mpicc 
LINKFLAGS    = $(CCFLAGS) -static_mpi 
—————————————————————————————— 
# make arch=MPI-INTEL install 
mkl 에서 제공하는 HPL 과 비슷한 성능을 나타낸다. 
6. IMB 테스트 하기 
IMB 는 Intel MPI Benchmark 툴로서 MPI 실행 시 프로세서의 네트워크 간의 통신 성능을 측정하는 
BMT 툴이다. 
# cd IBM_3.1/src 
# vi make_mpich 
—————————————————————————————— 
MPI_HOME= /engrid/enhpc/mpich2/intel  <- MPI 환경에 맞게 수정 
. 
. 
—————————————————————————————— 
# make -f make_mpich 
그럼 IBM_MPI1 실행파일이 생성된다. 
# mpdboot -n 5 -r rsh -f ~mpd.hosts 
# mpiexec -n 10 ./IMB-MPI1 > ~/IMB_test_result.txt 
# cat ~/IMB_test_result.txt 
—————————————————————————————– 
#————————————————— 
#    Intel (R) MPI Benchmark Suite V3.1, MPI-1 part     
#————————————————— 
# Date                  : Fri Feb 22 02:18:29 2008 
# Machine               : x86_64 
# System                : Linux 
# Release               : 2.6.9-55.ELsmp 
# Version               : #1 SMP Fri Apr 20 16:36:54 EDT 2007 
# MPI Version           : 2.0 
# MPI Thread Environment: MPI_THREAD_MULTIPLE 
# Calling sequence was: 
# ./IMB-MPI1 
# Minimum message length in bytes:   0 
# Maximum message length in bytes:   4194304 
# 
# MPI_Datatype                   :   MPI_BYTE 
# MPI_Datatype for reductions    :   MPI_FLOAT 
# MPI_Op                         :   MPI_SUM   
# 
# 
# List of Benchmarks to run: 
# PingPong 
# PingPing 
# Sendrecv 
# Exchange 
# Allreduce 
# Reduce 
# Reduce_scatter 
# Allgather 
# Allgatherv 
# Gather 
# Gatherv 
# Scatter 
# Scatterv 
# Alltoall 
# Alltoallv 
# Bcast 
# Barrier 
#————————————————— 
# Benchmarking PingPong 
# #processes = 2 
# ( 8 additional processes waiting in MPI_Barrier) 
#————————————————— 
       #bytes #repetitions      t[usec]   Mbytes/sec 
. 
      4194304           10     35973.11       111.19 
#————————————————— 
# Benchmarking PingPing 
# #processes = 2 
# ( 8 additional processes waiting in MPI_Barrier) 
#————————————————— 
       #bytes #repetitions      t[usec]   Mbytes/sec 
. 
      4194304           10     42797.59        93.46 
#—————————————————————————– 
# Benchmarking Sendrecv 
# #processes = 2 
# ( 8 additional processes waiting in MPI_Barrier) 
#—————————————————————————– 
       #bytes #repetitions  t_min[usec]  t_max[usec]  t_avg[usec]   Mbytes/sec 
. 
      4194304           10     41784.69     41796.92     41790.81       191.40 
#—————————————————————————– 
# Benchmarking Sendrecv 
# #processes = 4 
# ( 6 additional processes waiting in MPI_Barrier) 
#—————————————————————————– 
       #bytes #repetitions  t_min[usec]  t_max[usec]  t_avg[usec]   Mbytes/sec 
. 
      4194304           10     37605.91     37795.21     37721.81       211.67 
#—————————————————————————– 
# Benchmarking Sendrecv 
# #processes = 8 
# ( 2 additional processes waiting in MPI_Barrier) 
#—————————————————————————– 
       #bytes #repetitions  t_min[usec]  t_max[usec]  t_avg[usec]   Mbytes/sec 
. 
      4194304           10     37590.60     37884.59     37688.60       211.17 
#—————————————————————————– 
# Benchmarking Sendrecv 
# #processes = 10 
#—————————————————————————– 
       #bytes #repetitions  t_min[usec]  t_max[usec]  t_avg[usec]   Mbytes/sec 
. 
      4194304           10     37523.60     37732.20     37627.89       212.02 
#—————————————————————————– 
# Benchmarking Exchange 
# #processes = 2 
# ( 8 additional processes waiting in MPI_Barrier) 
#—————————————————————————– 
       #bytes #repetitions  t_min[usec]  t_max[usec]  t_avg[usec]   Mbytes/sec 
. 
      4194304           10     86003.80     86012.60     86008.20       186.02 
. 
. 
#————————————————— 
# Benchmarking Barrier 
# #processes = 2 
# ( 8 additional processes waiting in MPI_Barrier) 
#————————————————— 
#repetitions  t_min[usec]  t_max[usec]  t_avg[usec] 
         1000        62.45        62.45        62.45 
#————————————————— 
# Benchmarking Barrier 
# #processes = 4 
# ( 6 additional processes waiting in MPI_Barrier) 
#————————————————— 
#repetitions  t_min[usec]  t_max[usec]  t_avg[usec] 
         1000       166.50       166.62       166.57 
#————————————————— 
# Benchmarking Barrier 
# #processes = 8 
# ( 2 additional processes waiting in MPI_Barrier) 
#————————————————— 
#repetitions  t_min[usec]  t_max[usec]  t_avg[usec] 
         1000       285.03       285.04       285.04 
#————————————————— 
# Benchmarking Barrier 
# #processes = 10 
#————————————————— 
#repetitions  t_min[usec]  t_max[usec]  t_avg[usec] 
         1000       436.79       437.18       437.00 
—————————————————————————————– 
7. Stream 메모리 테스트 
# tar xzvf stream_memory.tgz 
# cd StreamMemory/Code/ 
# gcc -O stream.c -o stream 
# ./stream 
————————————————————- 
This system uses 8 bytes per DOUBLE PRECISION word. 
————————————————————- 
Array size = 2000000, Offset = 0 
Total memory required = 45.8 MB. 
Each test is run 10 times, but only 
the *best* time for each is used. 
————————————————————- 
Your clock granularity/precision appears to be 1 microseconds. 
Each test below will take on the order of 7914 microseconds. 
   (= 7914 clock ticks) 
Increase the size of the arrays if this shows that 
you are not getting at least 20 clock ticks per test. 
————————————————————- 
WARNING — The above is only a rough guideline. 
For best results, please be sure you know the 
precision of your system timer. 
————————————————————- 
Function      Rate (MB/s)   Avg time     Min time     Max time 
Copy:        2837.6441       0.0102       0.0113       0.0113 
Scale:       2802.5668       0.0103       0.0114       0.0114 
Add:         3150.0100       0.0137       0.0152       0.0153 
Triad:       3127.2576       0.0138       0.0153       0.0154 
————————————————————- 
Solution Validates 
————————————————————- 
– Intel 컴파일러로 최적화 컴파일 시 .. 
# icc -O3 stream.c -o stream 
# ./stream 
————————————————————- 
This system uses 8 bytes per DOUBLE PRECISION word. 
————————————————————- 
Array size = 2000000, Offset = 0 
Total memory required = 45.8 MB. 
Each test is run 10 times, but only 
the *best* time for each is used. 
————————————————————- 
Your clock granularity/precision appears to be 1 microseconds. 
Each test below will take on the order of 6740 microseconds. 
   (= 6740 clock ticks) 
Increase the size of the arrays if this shows that 
you are not getting at least 20 clock ticks per test. 
————————————————————- 
WARNING — The above is only a rough guideline. 
For best results, please be sure you know the 
precision of your system timer. 
————————————————————- 
Function      Rate (MB/s)   Avg time     Min time     Max time 
Copy:        3935.5421       0.0073       0.0081       0.0082 
Scale:       3874.9813       0.0074       0.0083       0.0083 
Add:         4087.8496       0.0106       0.0117       0.0118 
Triad:       4088.9289       0.0106       0.0117       0.0118 
————————————————————- 
Solution Validates 
————————————————————- 
최적화 환경에서 메모리 전송률의 차이가 1GB/s 정도 향상이 된다. 
– gcc 을 이용한 표준 방식 
gcc -O stream.c -o stream 
– g77 을 이용한 표준 방식 
gcc -c mysecond.c 
g77 -O stream.f mysecond.o -o stream 
or sometimes 
gcc -c -DUNDERSCORE mysecond.c 
g77 -O stream.f mysecond.o -o stream 
– mpi 를 이용한 표준 방식 
gcc -c -DUNDERSCORE mysecond.c 
mpif77 -O stream_mpi.f mysecond.o -o stream_mpi 
– 메모리 이론치 산정 
memory clock * 8 (DDR의 경우 여기서 2를 더 곱한다.) 
메인보드 FSB 지원 부분 : 1333 = 1333 * 8 (32bit), 1333 = 1333 * 16 (64bit) 
CPU FSB 파악 
7. NPB 테스트 하기 
# tar xzvf NPB3.2.tar.gz 
# cd NPB3.2/NPB3.2-MPI/ 
# cd config/ 
# cp make.def.template make.def 
# vi make.def 
———————————————————————————- 
아래 항목을 환경에 맞게 수정함 
. 
MPIF77 = /engrid/enhpc/mpich2/intel/bin/mpif77 
. 
FMPI_LIB  = -L/engrid/enhpc/mpich2/intel/lib -lmpi 
. 
FMPI_INC = -I/engrid/enhpc/mpich2/intel/include 
. 
MPICC = /engrid/enhpc/mpich2/intel/bin/mpicc 
. 
CMPI_LIB  = -L/engrid/enhpc/mpich2/intel/lib -lmpi 
. 
——————————————————————————— 
이제 간단한 모델 하나를 컴파일 해 보자 
# cd .. 
# make LU NPROCS=2 CLASS=S 
# cd bin 
# ls 
lu.S.4 
정상적으로 컴파일을 했으면 위와 같이 lu.S.4 란 실행파일이 생성 되어 있을 것이다. 
이제 필요한 실행 파일을 일괄적으로 컴파일 해 보자 
NPB 의 주요 벤치마크 모델에 대한 설명이나 suite.def에 대한 설명은 이전에 배포한 이전 문서를 
살펴 보면 된다. 
# vi config/make.suite 
——————————————————————————– 
ft      S       8 
mg      S       8 
sp      S       4 
lu      S       8 
bt      S       4 
is      S       8 
ep      S       8 
cg      S       8 
dt      S       8 
——————————————————————————- 
# make suite 
# bin 
# ls 
bt.S.4  cg.S.8  dt.S  ep.S.8  is.S.8  lu.S.4  lu.S.8  mg.S.8  sp.S.4 
# mpiexec -n 8 ./cg.S.8 
—————————————————————————— 
NAS Parallel Benchmarks 3.2 — CG Benchmark 
Size:       1400 
Iterations:    15 
Number of active processes:     8 
Number of nonzeroes per row:        7 
Eigenvalue shift: .100E+02 
   iteration           ||r||                 zeta 
        1       0.14007433599912E-12     9.9986441579140 
        2       0.22832842650801E-14     8.5733279203222 
        3       0.20667072504918E-14     8.5954510374058 
        4       0.20147744607421E-14     8.5969972340737 
        5       0.20860579382960E-14     8.5971549151767 
        6       0.19920782216430E-14     8.5971744311608 
        7       0.19617605550665E-14     8.5971770704913 
        8       0.20837892722887E-14     8.5971774440630 
        9       0.19379127563197E-14     8.5971774983942 
       10       0.19401001173125E-14     8.5971775064409 
       11       0.18760873052386E-14     8.5971775076486 
       12       0.18533243795008E-14     8.5971775078318 
       13       0.19294692914155E-14     8.5971775078598 
       14       0.18723926834078E-14     8.5971775078641 
       15       0.18265867152505E-14     8.5971775078648 
Benchmark completed 
VERIFICATION SUCCESSFUL 
Zeta is      0.859717750786E+01 
Error is     0.123972559909E-14 
CG Benchmark Completed. 
Class           =                        S 
Size            =                     1400 
Iterations      =                       15 
Time in seconds =                     0.35 
Total processes =                        8 
Compiled procs  =                        8 
Mop/s total     =                   192.35 
Mop/s/process   =                    24.04 
Operation type  =           floating point 
Verification    =               SUCCESSFUL 
Version         =                      3.2 
Compile date    =              22 Feb 2008 
Compile options: 
    MPIF77       = /engrid/enhpc/mpich2/intel/bin/mpif77 
    FLINK        = $(MPIF77) 
    FMPI_LIB     = -L/engrid/enhpc/mpich2/intel/lib -lmpi 
    FMPI_INC     = -I/engrid/enhpc/mpich2/intel/include 
    FFLAGS       = -O3 
    FLINKFLAGS   = -O3 
    RAND         = randi8 
Please send the results of this run to: 
NPB Development Team 
Internet: npb@nas.nasa.gov 
If email is not available, send this to: 
MS T27A-1 
NASA Ames Research Center 
Moffett Field, CA  94035-1000 
Fax: 650-604-3957 
——————————————————————————— 
NPB 에 대한 부가 설명 
NPB 는 모델 유형과 계산 크기, 사용되는 프로세스 수에 따라 실행 파일이 정해 짐. 아래는 모델에 대한 설명임 
* NPB 모델에 대한 설명 
BT : Navier-Stokes 라는 물리학 방정식을 푸는 문제. 큰메세지를 조금씩 주고 받으므로 CPU 성능과 큰 크기에 대한 
통신 성능을 알수 있음. 
CG : 행렬 방정식의 고유해를 구하는 계산. 불규칙적인 큰 크기의 메세지를 조금씩 주고 받음. 큰 크기의 통신 성능을 
측정할때 사용함. 
EP : 노드마다 서로 상관없는 계산을 함. 서로 통신 하지 않으므로 CPU 성능을 측정할때만 사용함. 
FT : FFT라는 방법으로 미분 방정식을 계산함. 계산량이 많기 때문에 큰 크기에서의 통신 성능과 CPU 성능 측정시 사용. 
IS : 임의의 정수 수열을 크기대로 정렬하는 계산. 다른 계산은 주로 수소점 계산이지만 이것은 정수 계산만 함. 
LU : BT 와 NS 방정식을 다른 방법을 푼다. 작은 크기의 메세지를 많이 주고 받아서 작은 크기의 문제를 테스트할때 사용. 
MG : Poisson 방정식이라는 전자기학 방정식 해를 구함. 노드 사이에 배열을 수시로 주고 받음으로 작은 크기의 통신 성능 
시험. 
SP : BT 와 성격 비슷함. 
* 계산 크기 .. 
위의 8가지 유형에 따라 계산 크기는 S, W, A, B, C, D 종류로 나누어짐. 크기는 순서대로 큰 Size의 문제라고 보면됨. 
* 프로세스의 수는 2의 승수로 정해짐 ( 1.2.4.8.16..) 
