Intel oneAPIをインストールしてIntel MPIを使う
IntelのMPIはFreeのOpenMPIなどに比べて高性能と言われてきました。しかし少し前まではIntel MPIは有償でそれなりに高額なので、OpenMPIとの性能差を気軽に確かめることはできませんでした。現在は無償でダウンローと可能なintel oneAPIの中にIntel MPIが含まれており、その性能を気軽に確かめることができます。このBlogではIntel oneAPIをインストールして、姫野ベンチのMPI版を使い、OpenMPIとの性能差を確認します。
使用するマシンは手元にある
hpc@workbench:~$ head /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
stepping : 1
microcode : 0xb000040
cpu MHz : 1900.000
cache size : 30720 KB
physical id : 0
c@workbench:~$ nproc
24
hpc@workbench:~$ free -m
total used free shared buff/cache available
Mem: 515840 1421 513318 31 1099 511716
Swap: 0 0 0
hpc@workbench:~$ uname -a
Linux workbench 5.15.0-73-generic #80~20.04.1-Ubuntu SMP Wed May 17 14:58:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
hpc@workbench:~$
になります。
Intel oneAPIをインストールするには、
# download the key to system keyring wget --no-check-certificate -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null # add signed entry to apt sources and configure the APT client to use Intel repository: echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" |\ sudo tee /etc/apt/sources.list.d/oneAPI.list
を実行して、
sudo apt update sudo apt install intel-basekit intel-hpckit
を実行するだけです。時間は結構かかります。
その後~/.bashrcの最後に
source /opt/intel/oneapi/setvars.sh
を加えてください(shellがbashの場合)。
次に理化学研究所の姫野ベンチサイトから姫野ベンチのF90 MPI版をダウンロードします。unzipするとf90_xp_mpi.lzhというファイルができますが、それをこちらの説明にあるlhaというアプリをインストールするとさらに解凍できて、himenoBMTxpr.f90 というファイルができます。下記を実行すると、姫野ベンチをダウンロードして2回解凍してhimenoBMTxpr.f90が得られます。
mkdir ~/himeno cd himeno wget --no-check-certificate https://i.riken.jp/wp-content/uploads/2015/07/f90_xp_mpi.zip unzip f90_xp_mpi.zip sudo apt install jlha-utils -y lha x f90_xp_mpi.lzh
次にこれをコンパイルして実行して性能評価するのですが、最初にOpenMPIで試してみましょう。ubuntu標準パッケージのOpenMPIがありますのでそれをダウンロードして姫野ベンチをコンパイルします。
sudo apt install openmpi-bin -y mpif90 -Ofast himenoBMTxpr.f90 -o himeno
実行するには
mpirun -np 24 ./himeno <<. xl 1 24 1 .
を入力します。姫野ベンチのMPI版を24コアで、配列のサイズは一番大きいXL、配列の分割はとりあえず1 24 1にして実行するコマンドです。実行結果は、
For example:
Grid-size=
XS (64x32x32)
S (128x64x64)
M (256x128x128)
L (512x256x256)
XL (1024x512x512)
Grid-size =
For example:
DDM pattern=
1 1 2
i-direction partitioning : 1
j-direction partitioning : 1
k-direction partitioning : 2
DDM pattern =
Sequential version array size
mimax= 1025 mjmax= 513 mkmax= 513
Parallel version array size
mimax= 1025 mjmax= 24 mkmax= 513
imax= 1024 jmax= 23 kmax= 512
I-decomp= 1 J-decomp= 24 K-decomp= 1
Start rehearsal measurement process.
Measure the performance in 3 times.
MFLOPS: 41461.028864353313 time(s): 0.65396026000000007 4.39602009E-04
Now, start the actual measurement process.
The loop will be excuted in 275 times.
This will take about one minute.
Wait for a while.
Loop executed for 275 times
Gosa : 4.02103731E-04
MFLOPS: 45088.813867705132 time(s): 55.123154317000001
Score based on Pentium III 600MHz : 544.287964
になりました。約45GFLOPSの結果です。
次にIntel MPIでっ同様に試してみます。
source /opt/intel/oneapi/setvars.sh mpif90 -Ofast himenoBMTxpr.f90 -o himeno mpirun -np 24 ./himeno <<. xl 1 24 1 .
実行結果は、
For example:
Grid-size=
XS (64x32x32)
S (128x64x64)
M (256x128x128)
L (512x256x256)
XL (1024x512x512)
Grid-size =
For example:
DDM pattern=
1 1 2
i-direction partitioning : 1
j-direction partitioning : 1
k-direction partitioning : 2
DDM pattern =
Sequential version array size
mimax= 1025 mjmax= 513 mkmax= 513
Parallel version array size
mimax= 1025 mjmax= 24 mkmax= 513
imax= 1024 jmax= 23 kmax= 512
I-decomp= 1 J-decomp= 24 K-decomp= 1
Start rehearsal measurement process.
Measure the performance in 3 times.
MFLOPS: 43863.173483990795 time(s): 0.61814645549748093 4.39602038E-04
Now, start the actual measurement process.
The loop will be excuted in 291 times.
This will take about one minute.
Wait for a while.
Loop executed for 291 times
Gosa : 4.00876364E-04
MFLOPS: 47163.663748036117 time(s): 55.764220099663362
Score based on Pentium III 600MHz : 569.334473
となり、OpenMPIの47163/45088=1.046倍の速度でした。