24小时热门版块排行榜    

Znn3bq.jpeg
查看: 771  |  回复: 7
当前主题已经存档。

tjpm

金虫 (正式写手)

[交流] 【讨论】vasp单机并行的问题

在台式机(Centos 5.3 x86_64 ,cpu:E4400,内存:8GB)上装过一个并行版的vasp.
ivf是 11.0的吧,mkl也是inetl fortran编译器安装包里自带的(11.0后都集成在一起了,可以直接一起安装)。
mkl的lib路径写添加到mkl.conf里并移到 /etc/ld.so.conf.d 下,然后 sudo ldconfig一下保证之后运行时可用找到动态链接库。

mpich2编译的过程是:
export FC=ifort
export F77=ifort
./configure --prefix=/dir

编译vasp的 过程我也不说了。
lapack和blas都是用mkl的。
vasp.4.lib是用mpif90编译的。
直接贴makefile吧。
=================================
.SUFFIXES: .inc .f .f90 .F
SUFFIX=.f90

#-----------------------------------------------------------------------
# fortran compiler and linker
#-----------------------------------------------------------------------
#FC=/export/mpi/mpich_intel_up/bin/mpif90
# fortran linker
#FCL=$(FC)

#-----------------------------------------------------------------------
# whereis CPP ?? (I need CPP, can't use gcc with proper options)
# that's the location of gcc for SUSE 5.3
#
#  CPP_   =  /usr/lib/gcc-lib/i486-linux/2.7.2/cpp -P -C
#
# that's probably the right line for some Red Hat distribution:
#
#  CPP_   =  /usr/lib/gcc-lib/i386-redhat-linux/2.7.2.3/cpp -P -C
#
#  SUSE X.X, maybe some Red Hat distributions:

CPP_ =  ./preprocess <$*.F | /usr/bin/cpp -P -C -ansi >$*$(SUFFIX)

#-----------------------------------------------------------------------
# possible options for CPP:
# NGXhalf             charge density   reduced in X direction
# wNGXhalf            gamma point only reduced in X direction
# avoidalloc          avoid ALLOCATE if possible
# IFC                 work around some IFC bugs
# CACHE_SIZE          1000 for PII,PIII, 5000 for Athlon, 8000-12000 P4
# RPROMU_DGEMV        use DGEMV instead of DGEMM in RPRO (usually  faster)
# RACCMU_DGEMV        use DGEMV instead of DGEMM in RACC (faster on P4)
#-----------------------------------------------------------------------

#CPP     = $(CPP_) -DMPI \

#-----------------------------------------------------------------------
# general fortran flags  (there must a trailing blank on this line)
#-----------------------------------------------------------------------

FFLAGS =  -FR -lowercase

#-----------------------------------------------------------------------
# optimization
# we have tested whether higher optimisation improves performance
# -xW   SSE2 optimization
# -axW  SSE2 optimization,  but also generate code executable on all mach.
# -tpp7 P4 optimization
# -prefetch
#-----------------------------------------------------------------------

OFLAG = -O0

OFLAG_HIGH = $(OFLAG)
OBJ_HIGH =
OBJ_NOOPT =
DEBUG  = -FR -O0
INLINE = $(OFLAG)


#-----------------------------------------------------------------------
# the following lines specify the position of BLAS  and LAPACK
# on P4, VASP works fastest with Intels mkl performance library
# so that's what I recommend
#-----------------------------------------------------------------------

# Atlas based libraries
#ATLASHOME= $(HOME)/archives/BLAS_OPT/ATLAS/lib/Linux_P4SSE2/
#BLAS=   -L$(ATLASHOME)  -lf77blas -latlas

# use specific libraries (default library path points to other libraries)
BLAS=-L/opt/intel/Compiler/11.0/069/mkl/lib/em64t -lmkl -lguide -lpthread
LAPACK=-L/opt/intel/Compiler11.0/069/mkl/lib/em64t -lmkl_lapack

#=======================================================================
# MPI section, uncomment the following lines
#
# one comment for users of mpich or lam:
# You must *not* compile mpi with g77/f77, because f77/g77            
# appends *two* underscores to symbols that contain already an        
# underscore (i.e. MPI_SEND becomes mpi_send__).  The pgf90
# compiler however appends only one underscore.
# Precompiled mpi version will also not work !!!
#
# We found that mpich.1.2.1 and lam-6.5.X are stable
# mpich.1.2.1 was configured with
#  ./configure -prefix=/usr/local/mpich_nodvdbg -fc="pgf77 -Mx,119,0x200000"  \
# -f90="pgf90 -Mx,119,0x200000" \
# --without-romio --without-mpe -opt=-O \
#
# lam was configured with the line
#  ./configure  -prefix /usr/local/lam-6.5.X --with-cflags=-O -with-fc=pgf90 \
# --with-f77flags=-O --without-romio
#
# lam was generally faster and we found an average communication
# band with of roughly 160 MBit/s (full duplex)
#
# please note that you might be able to use a lam or mpich version
# compiled with f77/g77, but then you need to add the following
# options: -Msecond_underscore (compilation) and -g77libs (linking)
#
# !!! Please do not send me any queries on how to install MPI, I will
# certainly not answer them !!!!
#=======================================================================
#-----------------------------------------------------------------------
# fortran linker for mpi: if you use LAM and compiled it with the options
# suggested above,  you can use the following line
#-----------------------------------------------------------------------

FC=mpif90
FCL=$(FC)

#-----------------------------------------------------------------------
# additional options for CPP in parallel version (see also above):
# NGZhalf               charge density   reduced in Z direction
# wNGZhalf              gamma point only reduced in Z direction
# scaLAPACK             use scaLAPACK (usually slower on 100 Mbit Net)
#-----------------------------------------------------------------------

CPP    = $(CPP_) -DMPI  -DHOST=\"LinuxIFC\" -DIFC \
     -Dkind8  -DCACHE_SIZE=4000 -DPGF90 -Davoidalloc \
     -DMPI_BLOCK=500 -DPROC_GROUP=8 \
     -DRPROMU_DGEMV  -DRACCMU_DGEMV
#      -DNGZhalf

#-----------------------------------------------------------------------
# location of SCALAPACK
# if you do not use SCALAPACK simply uncomment the line SCA
#-----------------------------------------------------------------------

#BLACS=$(HOME)/archives/SCALAPACK/BLACS/
#SCA_=$(HOME)/archives/SCALAPACK/SCALAPACK

#SCA= $(SCA_)/libscalapack.a  \
# $(BLACS)/LIB/blacsF77init_MPI-LINUX-0.a $(BLACS)/LIB/blacs_MPI-LINUX-0.a $(BLACS)/LIB/blacsF77init_MPI-LINUX-0.a

SCA=

#-----------------------------------------------------------------------
# libraries for mpi
#-----------------------------------------------------------------------

LIB     = -L../vasp.4.lib -ldmy  \
      ../vasp.4.lib/linpack_double.o $(LAPACK) \
      $(SCA) $(BLAS)

# FFT: fftmpi.o with fft3dlib of Juergen Furthmueller
FFT3D   = fftmpi.o fftmpi_map.o fft3dlib.o

# fftw.3.0 is slighly faster and should be used if available
#FFT3D   = fftmpiw.o fftmpi_map.o fft3dlib.o   /opt/libs/fftw-3.0/lib/libfftw3.a

#-----------------------------------------------------------------------
# general rules and compile lines
#-----------------------------------------------------------------------
BASIC=   symmetry.o symlib.o   lattlib.o  random.o   

SOURCE=  base.o     mpi.o      smart_allocate.o      xml.o  \
         constant.o jacobi.o   main_mpi.o  scala.o   \
         asa.o      lattice.o  poscar.o   ini.o      setex.o     radial.o  \
         pseudo.o   mgrid.o    mkpoints.o wave.o      wave_mpi.o  $(BASIC) \
         nonl.o     nonlr.o    dfast.o    choleski2.o    \
         mix.o      charge.o   xcgrad.o   xcspin.o    potex1.o   potex2.o  \
         metagga.o  constrmag.o pot.o      cl_shift.o force.o    dos.o      elf.o      \
         tet.o      hamil.o    steep.o    \
         chain.o    dyna.o     relativistic.o LDApU.o sphpro.o  paw.o   us.o \
         ebs.o      wavpre.o   wavpre_noio.o broyden.o \
         dynbr.o    rmm-diis.o reader.o   writer.o   tutor.o xml_writer.o \
         brent.o    stufak.o   fileio.o   opergrid.o stepver.o  \
         dipol.o    xclib.o    chgloc.o   subrot.o   optreal.o   davidson.o \
         edtest.o   electron.o shm.o      pardens.o  paircorrection.o \
         optics.o   constr_cell_relax.o   stm.o    finite_diff.o \
         elpol.o    setlocalpp.o

INC=

vasp: $(SOURCE) $(FFT3D) $(INC) main.o
        rm -f vasp
        $(FCL) -o vasp $(LINK) main.o  $(SOURCE)   $(FFT3D) $(LIB)
makeparam: $(SOURCE) $(FFT3D) makeparam.o main.F $(INC)
        $(FCL) -o makeparam  $(LINK) makeparam.o $(SOURCE) $(FFT3D) $(LIB)
zgemmtest: zgemmtest.o base.o random.o $(INC)
        $(FCL) -o zgemmtest $(LINK) zgemmtest.o random.o base.o $(LIB)
dgemmtest: dgemmtest.o base.o random.o $(INC)
        $(FCL) -o dgemmtest $(LINK) dgemmtest.o random.o base.o $(LIB)
ffttest: base.o smart_allocate.o mpi.o mgrid.o random.o ffttest.o $(FFT3D) $(INC)
        $(FCL) -o ffttest $(LINK) ffttest.o mpi.o mgrid.o random.o smart_allocate.o base.o $(FFT3D) $(LIB)
kpoints: $(SOURCE) $(FFT3D) makekpoints.o main.F $(INC)
        $(FCL) -o kpoints $(LINK) makekpoints.o $(SOURCE) $(FFT3D) $(LIB)

clean:       
        -rm -f *.f *.o *.L ; touch *.F

main.o: main$(SUFFIX)
        $(FC) $(FFLAGS)$(DEBUG)  $(INCS) -c main$(SUFFIX)
xcgrad.o: xcgrad$(SUFFIX)
        $(FC) $(FFLAGS) $(INLINE)  $(INCS) -c xcgrad$(SUFFIX)
xcspin.o: xcspin$(SUFFIX)
        $(FC) $(FFLAGS) $(INLINE)  $(INCS) -c xcspin$(SUFFIX)

makeparam.o: makeparam$(SUFFIX)
        $(FC) $(FFLAGS)$(DEBUG)  $(INCS) -c makeparam$(SUFFIX)

makeparam$(SUFFIX): makeparam.F main.F
#
# MIND: I do not have a full dependency list for the include
# and MODULES: here are only the minimal basic dependencies
# if one strucuture is changed then touch_dep must be called
# with the corresponding name of the structure
#
base.o: base.inc base.F
mgrid.o: mgrid.inc mgrid.F
constant.o: constant.inc constant.F
lattice.o: lattice.inc lattice.F
setex.o: setexm.inc setex.F
pseudo.o: pseudo.inc pseudo.F
poscar.o: poscar.inc poscar.F
mkpoints.o: mkpoints.inc mkpoints.F
wave.o: wave.inc wave.F
nonl.o: nonl.inc nonl.F
nonlr.o: nonlr.inc nonlr.F

$(OBJ_HIGH):
        $(CPP)
        $(FC) $(FFLAGS) $(OFLAG_HIGH) $(INCS) -c $*$(SUFFIX)
$(OBJ_NOOPT):
        $(CPP)
        $(FC) $(FFLAGS) $(INCS) -c $*$(SUFFIX)

fft3dlib_f77.o: fft3dlib_f77.F
        $(CPP)
        $(F77) $(FFLAGS_F77) -c $*$(SUFFIX)

.F.o:
        $(CPP)
        $(FC) $(FFLAGS) $(OFLAG) $(INCS) -c $*$(SUFFIX)
.F$(SUFFIX):
        $(CPP)
$(SUFFIX).o:
        $(FC) $(FFLAGS) $(OFLAG) $(INCS) -c $*$(SUFFIX)

# special rules
#-----------------------------------------------------------------------

# -tpp5|6|7 P, PII-PIII, PIV
# -xW use SIMD (does not pay of on PII, since fft3d uses double prec)
# all other options do no affect the code performance since -O1 is used

fft3dlib.o : fft3dlib.F
        $(CPP)
#        $(F77) -FR -lowercase -O1 -tpp7 -xW -prefetch- -prev_div -unroll0 -e95 -vec_report3 -c $*$(SUFFIX)
        $(F77) -FR -lowercase -O1 -tpp7 -xW -prefetch- -prev_div -unroll0 -vec_report3 -c $*$(SUFFIX)
fft3dfurth.o : fft3dfurth.F
        $(CPP)
        $(F77) -FR -lowercase -O1 -c $*$(SUFFIX)

radial.o : radial.F
        $(CPP)
        $(F77) -FR -lowercase -O1 -c $*$(SUFFIX)

symlib.o : symlib.F
        $(CPP)
        $(F77) -FR -lowercase -O1 -c $*$(SUFFIX)

symmetry.o : symmetry.F
        $(CPP)
        $(F77) -FR -lowercase -O1 -c $*$(SUFFIX)

dynbr.o : dynbr.F
        $(CPP)
        $(F77) -FR -lowercase -O1 -c $*$(SUFFIX)

us.o : us.F
        $(CPP)
        $(F77) -FR -lowercase -O1 -c $*$(SUFFIX)

wave.o : wave.F
        $(CPP)
        $(F77) -FR -lowercase -O0 -c $*$(SUFFIX)

LDApU.o : LDApU.F
        $(CPP)
        $(F77) -FR -lowercase -O2 -c $*$(SUFFIX)


=================================
现在的问题:
试了下
mpirun -np 2 vasp
和mpirun -np 1 vasp
这样单机并行的效果不怎么好。
在服务器上使用1个CPU计算的时间大概7分钟左右,2个CPU算要5分钟左右。

自己的现在想的是 是不是MPICH2安装时没有加上shm参数,以前测试过debian源里的通用版的mpich2和加了shm选项编译的mpich2效率差异比较大。不知道大家安装时是否添加过这个参数?

还有就是帮忙看看vasp的 makefile有问题没有。

[ Last edited by tjpm on 2009-5-7 at 18:36 ]
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tjpm

金虫 (正式写手)

不知道是不是RP爆发了。
刚才重新在服务器上测试了下,就是算下载的 “vasp集合.rar”中《VASP几个计算实例.doc》里 的一个H原子能量。
单个核花了4分钟40秒。
2个核2分钟30秒。
大家讨论一下mpich2编译时的参数吧。

还有就是CPP中的选项-DCACHE_SIZE的选择

CPP    = $(CPP_) -DMPI  -DHOST=\"LinuxIFC\" -DIFC \
     -Dkind8  -DCACHE_SIZE=4000 -DPGF90 -Davoidalloc \
     -DMPI_BLOCK=500 -DPROC_GROUP=8 \
     -DRPROMU_DGEMV  -DRACCMU_DGEMV
2楼2009-05-07 19:21:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

wuli8

荣誉版主 (知名作家)

…………

优秀版主优秀版主

MPI问题
…………
3楼2009-05-26 21:48:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

y1ding

铁杆木虫 (著名写手)

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
qasd(金币+1):谢谢~
OFLAG = -O0

你都没有优化VASP
4楼2009-05-27 10:30:29
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

frank178

金虫 (正式写手)


qasd(金币+1):谢谢~
-DCACHE_SIZE=4000 也要改吧,好久不编译,忘记具体该怎么改了,手册上有
5楼2009-05-27 10:52:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tjpm

金虫 (正式写手)

这个优化与否和能否并行没有任何关系的。

我们自己的代码用icf 11 x86_64的O2,O3算出来的结果都有点小问题

只有O0能得到正确的结果(目前我可以确定是优化的过程中出的问题),所以我特别设置了不优化的。
Makefile里写的优化选项很多是直接写了,不能简单的通过改FLAG来实现,我也懒得去改了。
目前还没有买vasp ,老师只是让我学一下试试目前能带计算在XXX方面有进步没有,我就自己装了个吧。

其实有时间了还是想学学abinit,比较支持开源吧。
引用回帖:
Originally posted by y1ding at 2009-5-27 10:30:
OFLAG = -O0

你都没有优化VASP

6楼2009-05-27 12:09:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tjpm

金虫 (正式写手)

等考试完了再试试了,
我想重新编译一下MPI,加一下shm的那个选项。
我的这个makefile实际是联想的人给他们装vasp时用的,我拷来就改下了
mkl的路径。。。。。
引用回帖:
Originally posted by wuli8 at 2009-5-26 21:48:
MPI问题

7楼2009-05-27 12:11:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tjpm

金虫 (正式写手)

我其实是看过手册的。。。不过按照手册上编译出来的更慢。。
这些东西只有有时间的时候一个一个试试了啊
引用回帖:
Originally posted by frank178 at 2009-5-27 10:52:
-DCACHE_SIZE=4000 也要改吧,好久不编译,忘记具体该怎么改了,手册上有

8楼2009-05-27 12:25:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 tjpm 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 290调剂生物0860 +36 哇哈哈,。 2026-04-11 42/2100 2026-04-15 13:13 by 西北望—风沙
[考研] 08工学 309分求调剂 +12 Yin DY 2026-04-08 12/600 2026-04-14 17:49 by lhj2009
[考研] 279学硕食品专业求调剂院校 20+6 孤独的狼爱吃羊 2026-04-12 28/1400 2026-04-14 15:44 by zs92450
[考研] 求调剂 +20 MAX怅惘 2026-04-09 22/1100 2026-04-14 14:57 by 独醉梦孤城
[考研] 085408光电信息工程专硕355一志愿长春光机所调剂 +6 王ymaa 2026-04-13 13/650 2026-04-14 11:33 by 王ymaa
[考研] 机械工程313分找工科调剂 +4 双一流本科机械 2026-04-08 4/200 2026-04-14 07:32 by Abskk
[考研] 332求调剂 +15 蕉蕉123 2026-04-10 15/750 2026-04-13 23:12 by pies112
[考研] 一志愿双非085400电子信息344 求调剂,对材料和化学方向也感兴趣 +12 无情的小羊 2026-04-09 13/650 2026-04-13 14:17 by 张zhihao
[考研] 求调剂 +16 张番茄不炒蛋 2026-04-10 17/850 2026-04-12 13:58 by 熬夜成!
[考研] 电气工程专硕320求调剂 +5 小麻子111 2026-04-10 5/250 2026-04-12 10:47 by zhouyuwinner
[考研] 326求调剂 +6 Shansyn 2026-04-10 6/300 2026-04-12 09:46 by hammer3
[考研] 材料与化工调剂 +12 否极泰来2026 2026-04-10 13/650 2026-04-11 00:28 by wangjihu
[考研] 调剂 化学 307 +21 73372112 2026-04-09 23/1150 2026-04-10 23:53 by wj165256
[考研] 289 分105500药学专硕求调剂(找B区学校) +6 白云123456789 2026-04-09 8/400 2026-04-10 21:13 by zhouxiaoyu
[考研] 368求调剂 +3 17385968172 2026-04-10 3/150 2026-04-10 20:12 by 电子奥德彪
[考研] 吉大计算机技术331分,英语六级,求调剂 +3 峰峰021116 2026-04-09 3/150 2026-04-10 20:01 by chemisry
[考研] 中科院总分315求调剂 +8 lallalh 2026-04-09 8/400 2026-04-10 19:30 by dick_runner
[考研] 材料专硕(0856) 339分求调剂 +9 哈哈哈鹅哈哈哈 2026-04-09 10/500 2026-04-09 20:01 by Orcid
[考研] 0703化学求调剂 +21 不知名的小卅 2026-04-08 21/1050 2026-04-09 18:55 by l_paradox
[考研] 086000生物与医药调剂 +7 awwwwwooooo 2026-04-09 7/350 2026-04-09 13:31 by 北极159263
信息提示
请填处理意见