听闻VASP有重大更新,课题组恰好购买了版权。作为课题组服务器的(免费)维护员,特来尝试编译一下新版。
6.5.0 (December 17, 2024)主要新特性:电声耦合
https://www.vasp.at/wiki/index.php/Changelog#Changelog650
服务器软硬件概要:
- CPU:双路 Intel 第三代至强
- 节点数:3
# 登录节点CPU的型号/主频等和计算节点不同,计算节点采用了核心更多,主频稍高的Gold 6336Y CPU @ 2.40GHz
$ lscpu
Architecture: x86_64CPU op-mode(s): 32-bit, 64-bitAddress sizes: 46 bits physical, 57 bits virtualByte Order: Little Endian
CPU(s): 80On-line CPU(s) list: 0-79
Vendor ID: GenuineIntelModel name: Intel(R) Xeon(R) Silver 4316 CPU @ 2.30GHzCPU family: 6Model: 106Thread(s) per core: 2Core(s) per socket: 20Socket(s): 2......
- 操作系统:Ubuntu 22.04 LTS Server (Jammy)
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
......
0. 编译环境准备
Intel OneAPI 套件
$ module avail -t intel
/mnt/data/apps/modules/programming/compilers:
intel-oneapi/2023.2
intel-oneapi/2024.0
intel-oneapi/2024.1
笔者的服务器上安装了三个OneAPI套件版本。这里选择intel-oneapi/2023.2
。
关于OneAPI版本:
intel-oneapi/2023.2是这一系列套件中最后一个支持经典C/C++/Fortran编译器的版本, 也就是icc/icpc/ifort。
详见Intel的通告:https://www.intel.com/content/www/us/en/developer/articles/release-notes/oneapi-c-compiler-release-notes.html
“Intel® C++ Compiler Classic (icc) is deprecated and was discontinued in the oneAPI 2024.0 release.”
对于只支持经典C/C++/Fortran的VASP版本,比如VASP5.4.4,需要使用OneAPI <=2023.2,在>=2024的OneAPI的套件里,已经弃用了icc/icpx/ifort这三个编译器,而是换成了icx/icpx/ifx这几个基于LLVM的编译器。
Intel官网不能再下载到老版本的编译套件了,但是笔者发现一个可用的仓库,存放了老版的安装包(包括了已经弃用的Intel Parallel Studio):https://get.hpc.dev/vault/intel/
如果读者不喜欢Intel,VASP官网还提供了能用于编译VASP兼容工具链:https://www.vasp.at/wiki/index.php/Toolchains
可选择使用GCC+OpenMPI替代,并加配FFTW3+SCALAPACK等数学库替代MKL。
VASP开发组强烈建议添加HDF5支持来增强I/O,笔者之前也编译了多个HDF5。
$ module avail -t hdf5
/mnt/data/apps/modules/libraries/io:
hdf5/1.12.3-gcc8
hdf5/1.12.3-gcc8-mpi
hdf5/1.12.3-gcc11
hdf5/1.12.3-intel-oneapi2023.2
hdf5/1.12.3-intel-oneapi2023.2-mpi
读者可根据上述兼容工具链的网址里挑选兼容的HDF5版本。这里选择hdf5/1.12.3-intel-oneapi2023.2-mpi
。
1. 编译
1.1 加载环境
带有module的系统
$ module load intel-oneapi/2023.2
$ module load compiler mpi mkl
$ module load hdf5/1.12.3-intel-oneapi2023.2-mpi
不带module的系统
使用类似
$ source /opt/intel/oneapi/setvars.sh
$ source /opt/intel/oneapi/compiler/latest/env/vars.sh intel64
/opt/intel/具体换为读者所安装OneAPI的路径
注意事项:如果读者是自己手动安装OneAPI,例如是2023.2.4版本,intel mpi相关的编译器和LIB可能不能直接加载到PATH和LD_LIBRARY_PATH里,导致mpiifort not found读者需要自己手动定位mpi的路径进行修复。
1.2 解压VASP6.5.0源码
$ tar -xzf vasp.6.5.0.tgz
$ cd vasp.6.5.0
$ ls
arch/ src/ build/ makefile README_ELPHON.md
......
1.3 C/C++/Fortran Classic
先尝试用C/C++ Classic
$ cp arch/makefile.include.intel ./makefile.include
$ vim makefile.include
修改 makefile.include,一个参考:
# Default precompiler options
CPP_OPTIONS = -DHOST=\"Khompute\" \-DMPI -DMPI_BLOCK=8000 -Duse_collective \-DscaLAPACK \-DCACHE_SIZE=4000 \-Davoidalloc \-Dvasp6 \-Dtbdyn \-Dfock_dblbufCPP = fpp -f_com=no -free -w0 $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)FC = mpiifort
FCL = mpiifortFREE = -free -names lowercaseFFLAGS = -assume byterecl -wOFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = icc -diag-disable=10441
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)OBJECTS_LIB = linpack_double.o# For the parser library
CXX_PARS = icpc -diag-disable=10441
LLIBS = -lstdc++##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
### When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -xHOST
FFLAGS += $(VASP_TARGET_CPU)# Intel MKL (FFTW, BLAS, LAPACK, and scaLAPACK)
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL += -qmkl=sequential
MKLROOT ?= /path/to/your/mkl/installation
LLIBS += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS =-I$(MKLROOT)/include/fftw# HDF5-support (optional but strongly recommended, and mandatory for some features)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5/installation
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include# For the VASP-2-Wannier90 interface (optional)
#CPP_OPTIONS += -DVASP2WANNIER90
#WANNIER90_ROOT ?= /path/to/your/wannier90/installation
#LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier# For machine learning library vaspml (experimental)
#CPP_OPTIONS += -Dlibvaspml
#CPP_OPTIONS += -DVASPML_USE_CBLAS
#CPP_OPTIONS += -DVASPML_USE_MKL
#CPP_OPTIONS += -DVASPML_DEBUG_LEVEL=3
#CXX_ML = mpiicpc -cxx=icpx
#CXXFLAGS_ML = -O3 -std=c++17 -Wall
#INCLUDE_ML =
说明:
- 第2行,HOST笔者改为课题组服务器的名字;(可选)
- 第27和35行,笔者添加了
-diag-disable=10441
是为了不让icc和icpc编译器在编译代码时每调用一次就跳出很烦人的弃用警告。 - 第52和58行,笔者在用
module load mkl hdf5
时会分别自动设置了MKLROOT和HDF5_ROOT这两个变量。对于后者,如果echo $HDF5_ROOT
没有输出,则读者需要手动设置。
当然也可以不去掉第57-60行的注释,不打开HDF5支持。
总体来讲,不怎么需要修改makefile.include
编译
$ make DEPS=1 -j40 all
40改成读者服务器合适的CPU核心数量。注意-jN
并行编译的特性只有VASP6才支持,VASP5不支持。
编译成功后在bin/目录下生成vasp_gam vasp_std和vasp_ncl三个可执行文件。
1.4 添加到module中
$ cp -rp bin/ oneapi2023.2-hdf5
$ cd oneapi2023.2-hdf5/
$ ls
vasp_gam vasp_ncl vasp_std
$ pwd
/mnt/data/apps/vasp/vasp.6.5.0/oneapi2023.2
编写如下module file,名为6.5.0-oneapi2023.2-hdf5
#%Module1.0#####################################################################set rootdir /mnt/data/apps/vasp/vasp.6.5.0/oneapi2023.2module-whatis "Name: VASP"
module-whatis "Version: 6.5.0"
module-whatis "Category: Computational Materials Science"
module-whatis "Description: The Vienna Ab initio Simulation Package (VASP) is a computer program for atomic scale materials modelling, e.g. electronic structure calculations and quantum-mechanical molecular dynamics, from first principles. "
module-whatis "URL: http://vasp.at"proc ModulesHelp { } {global rootdirputs stderr "Name: VASP"
puts stderr "Version: 6.5.0"
puts stderr "Category: Computational Materials Science"
puts stderr "URL: http://vasp.at"
puts stderr ""
puts stderr "Package specification:"
puts stderr "Manually compiled"
puts stderr ""
puts stderr "Directory Location:"
puts stderr "$rootdir"
puts stderr ""
puts stderr "Description:"
puts stderr "The Vienna Ab initio Simulation Package (VASP) is a computer program"
puts stderr "for atomic scale materials modelling, e.g. electronic structure"
puts stderr "calculations and quantum-mechanical molecular dynamics, from first"
puts stderr "principles."
puts stderr ""
puts stderr "Additional Notes:"
puts stderr ""
puts stderr "1. VASP is a licensed software"}conflict vaspif { [ module-info mode load ] } {module load intel-oneapi/2023.2module load compiler mpi mklmodule load hdf5/1.12.3-intel-oneapi2023.2-mpi
}prepend-path PATH $rootdir
setenv OMP_NUM_THREADS 1
放到MODULEPATH
变量包含的目录下,即可。
注意:
setenv OMP_NUM_THREADS 1
会把OMP_NUM_THREADS
强制设为1,读者要注意这是否是预期的,一般来说VASP其值为1,但是读者应该小心测试,否则应该要删除这一行。
测试:
$ module avail -t vasp
/mnt/data/apps/modules/compmatsci/dft:
vasp/5.4.4-oneapi2023.2
vasp/6.3.2-oneapi2023.2-hdf5
vasp/6.5.0-oneapi2023.2-hdf5$ module help vasp/6.5.0-oneapi2023.2-hdf5
-------------------------------------------------------------------
Module Specific Help for /mnt/data/apps/modules/compmatsci/dft/vasp/6.5.0-oneapi2023.2-hdf5:Name: VASP
Version: 6.5.0
Category: Computational Materials Science
URL: http://vasp.atPackage specification:
Manually compiledDirectory Location:
/mnt/data/apps/vasp/vasp.6.5.0/oneapi2023.2Description:
The Vienna Ab initio Simulation Package (VASP) is a computer program
for atomic scale materials modelling, e.g. electronic structure
calculations and quantum-mechanical molecular dynamics, from first
principles.Additional Notes:1. VASP is a licensed software
-------------------------------------------------------------------
最后一个即刚刚添加的VASP6.5.0。
1.5 C/C++/Fortran LLVM
如法炮制,仅仅某些行不同。
复制使用于OneAPI (LLVM)套件的makefile.include
$ cp arch/makefile.include.oneapi ./makefile.include
$ make veryclean
$ rm bin/vasp_*
$ make DEPS=1 -j40 all
编译结束发现vasp_gam没有生成,另外两个是正常的,如果直接make gam
会报编译器错误。
即便先清除-j40
编译生成的文件,然后用单核单线程编译,仍然报错。错误来源于使用mpiifort -fc=ifx
编译greens_real_space.f90
。
$ make veryclean
$ make gam
mpiifort -fc=ifx -free -names lowercase -assume byterecl -w -xHOST -O2 -I/mnt/data/apps/intel/oneapi/2023.2/mkl/2023.2.0/include/fftw -I/mnt/data/apps/hdf5/1.12.3/intel-oneapi2023.2-mpi/include -c greens_real_space.f90#0 0x0000000002203192#1 0x0000000002266e47#2 0x0000000002266f70#3 0x00007f01ad517520#4 0x0000000001fa52da#5 0x0000000001fe414c#6 0x000000000200350e#7 0x0000000001fe45a2#8 0x000000000200f2fa#9 0x00000000020073e7#10 0x0000000001fe42fb#11 0x0000000001fe0db1#12 0x0000000001fe00aa#13 0x000000000206039d#14 0x000000000224c731#15 0x000000000214f026#16 0x000000000231f37e#17 0x00007f01ad4fed90#18 0x00007f01ad4fee40 __libc_start_main + 128#19 0x0000000001f8fa69greens_real_space.f90: error #5633: **Internal compiler error: segmentation violation signal raised** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error.
compilation aborted for greens_real_space.f90 (code 3)
make[2]: *** [makefile:195: greens_real_space.o] Error 3
make[2]: Leaving directory '/mnt/data/apps/vasp/vasp.6.5.0/build/gam'
cp: cannot stat 'vasp': No such file or directory
make[1]: *** [makefile:150: all] Error 1
make[1]: Leaving directory '/mnt/data/apps/vasp/vasp.6.5.0/build/gam'
make: *** [makefile:17: gam] Error 2
猜测可能是编译器的问题,随即加载了更新的OneAPI套件(这里是2024.1),并顺利编译通过。
$ module purge
$ module load intel-oneapi/2024.1
$ module load compiler mpi mkl
$ make veryclean
$ rm bin/vasp_*
$ make DEPS=1 -j40 all
2. 结束
本文到此,后面有空更新VASP6.5.0+GPU (nvhpc)和AMD CPU的编译经验。
转载请注明出处。
欢迎交流。