背景信息
LAMMPS全称Large-scale Atomic Molecular Massively Parallel Simulator,是一款经典分子动力学软件,用于模拟液态、固态或气态的粒子集合,广泛应用于材料、物理、化学等模拟场景。
准备工作
● 创建EHPC集群,具体操作,请见“创建集群”。
● 创建集群用户,具体操作,请见“创建用户”。
● 需要安装的软件:安装Intel OneAPI、准备Lammps 安装包。
操作步骤
1.编译。
# 加载Intel工具包中的环境变量
module load libpmi/4.1.2/gcc-4.8.5 compiler-rt/2022.1.0 mpi/2021.6.0 mkl/2022.1.0 icc/2022.1.0 gcc/11.4.0
# 下载LAMMPS源代码压缩包
wget -P /share https://lammps.sandia.gov/tars/lammps-2Aug2023.tar.gz
# 解压LAMMPS源代码
tar xf lammps.tar.gz -C /share
cd /share/lammps-2Aug2023/src
# 进入/mnt/lammps-2Aug2023/src/MAKE/OPTIONS目录,修改Makefile.intel_cpu_intelmpi
vi MAKE/OPTIONS/Makefile.intel_cpu_intelmpi
# 在OPTFLAGS 中增加以下内容
-O3 -g -DLAMMPS_BIGBIG -DLAMMPS_MEMALIGN=64
# 编译
make -j $(nproc) yes-most
make -j $(nproc) yes-intel
make -j $(nproc) intel_cpu_intelmpi
# 运行测试
mpirun -np 2 lmp_intel_cpu_intelmpi -sf intel -in -pk intel /share/lammps-28Mar2023/examples/melt/in.melt
2.运行测试文件。
编辑 in.lj.billion文件如下所示:
# 3d Lennard-Jones melt
variable x index 20
variable y index 20
variable z index 20
variable xx equal 20*$x
variable yy equal 20*$y
variable zz equal 20*$z
units lj
atom_style atomic
lattice fcc 0.8442
region box block 0${xx}0${yy}0${zz}
create_box 1 box
create_atoms 1 box
mass 11.0
velocity all create 1.4487287 loop geom
pair_style lj/cut 2.5
pair_coeff 111.01.02.5
neighbor 0.3 bin
neigh_modify delay 0 every 20 check no
fix 1 all nve
run 100
撰写slurm脚本:
#!/bin/bash
#SBATCH -N 2
#SBATCH --partition=debug
#SBATCH --exclusive
#SBATCH -J lammps_bench
#SBATCH -o test_lammps.%J.out
#SBATCH -e test_lammps.%J.err
#SBATCH --time=00:5:00
#module
module load gcc compiler-rt/2022.1.0 icc/2022.1.0 mpi/2021.6.0 mkl
#config openmp
exportOMP_NUM_THREADS=1
exportOMP_PROC_BIND=true
exportOMP_PLACES=cores
#config mpi
exportI_MPI_PMI_LIBRARY=libpmi2.so
exportUCX_NET_DEVICES=mlx5_0:1,mlx5_3:1
exportSLURM_MPI_TYPE=pmi2
#run application
srun --ntasks-per-node=56 --cpus-per-task=2 --cpu-bind=cores -m plane=56 /share/user01/lammps-28Mar2023/build/lmp -sf intel -in in.lj.billion
3.查看最终结果。
LAMMPS (28 Mar 2023)
using 1 OpenMP thread(s) per MPI task
Lattice spacing in x,y,z =1.67959621.67959621.6795962
Created orthogonal box =(000) to (671.83848671.83848671.83848)
4 by 4 by 7 MPI processor grid
Created 256000000 atoms
using lattice unitsin orthogonal box =(000) to (671.83848671.83848671.83848)
create_atoms CPU =0.230 seconds
----------------------------------------------------------
Using INTEL Package without Coprocessor.
Compiler: Intel Classic C++ 20.21.6 / Intel(R) C++ g++ 11.4 mode
SIMD compiler directives: Enabled
Precision: mixed
----------------------------------------------------------
Generated 0 of 0 mixed pair_coeff terms from geometric mixing rule
Neighbor list info ...
update: every =20 steps, delay =0 steps, check = no
max neighbors/atom: 2000, page size: 100000
master list distance cutoff =2.8
ghost atom cutoff =2.8
binsize =1.4, bins =480480480
1 neighbor lists, perpetual/occasional/extra =100
(1) pair lj/cut/intel, perpetual
attributes: half, newton on, intel
pair build: half/bin/newton/intel
stencil: half/bin/3d
bin: intel
Setting up Verlet run ...
Unit style : lj
Current step :0
Time step :0.005
Per MPI rank memory allocation (min/avg/max)=3295|3343|3463 Mbytes
Step Temp E_pair E_mol TotEng Press
01.44 -6.7733673 0 -4.6133673 -5.0196698
1000.7594409 -5.7614765 0 -4.6223152 0.18996685
Loop time of 67.0307 on 112 procs for100 steps with 256000000 atoms
Performance: 644.481 tau/day, 1.492 timesteps/s, 381.915 Matom-step/s
99.6% CPU use with 112 MPI tasks x 1 OpenMP threads
...