加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Lammps GPU 版本安装测试

(2012-10-09 13:43:37)
标签:

cuda

gpu

gpu计算

hpc

lammps

it

1.         什么是 Lammps?

*       LAMMPS 是经典的分子动力学代码,是 Large-scale Atomic/Molecular Massively Parallel Simulator 的缩写。

*       用于软材料和硬材料。

*       核心开发者是美国能源部 Sandia National Labs

*       网站: http://lammps.sandia.gov/

2.         Lammps 编译需要的软件包

*         CUDA 5, R304 或更新的驱动

*     OpenMPI  1.4.5 :  用于集群计算

*     下载: http://www.openmpi.org

*     安装:

*     $ tar zxvf openmpi.tar.gz

*     $ cd openmpi

*     $ ./configure –prefix=/opt/openmpi #opnempi install_path

*     $ make install

*     $ export PATH=/opt/openmpi/bin:$PATH

*     $ export LD_LIBRARY_PATH=/opt/openmpi/lib:$LD_LIBRARY_PATH

*       FFTW 2.1.5

*     下载: http://www.fftw.org

*     安装:

*     $ tar zxvf fftw-2.1.5.tar.gz

*     $ cd fftw-2.1.5

*     $ ./configure –prefix=/opt/fftw #fftw install path

*     $ make install

*     $ export LD_LIBRARY_PATH=/opt/fftw/lib:$LD_LIBRARY_PATH

3.         Lammps GPU软件包

*             GPU LAMMPS: ORNL Nvidia 开发。

*   现已集成在Lammps软件包中,不需要单独下载安装。

*   称为GPU 软件包。

*             LAMMPScuda:  Christian Trott Lars Winterfeld 开发, the department of Theoretical Physics II, Technischen Universität Ilmenau.

*   现已集成在Lammps软件包中,不需要单独下载安装。

*   称为 USER-CUDA 软件包

4.         Lammps GPU 安装过程

a)         下载Lammps源文件

网站下载:http://lammps.sandia.gov/download.html;目前最新为lammps-10Oct12

$ tar –xzvf lammps.tar.gz

b)        编译GPU

$ cd lammps-10Oct12/lib/gpu

修改Makefile文件; 选择CUDA路径和GPU架构(红色部分)

$ vi Makefile.linux

#

 

CUDA_HOME = /opt/cuda/cuda5.0

NVCC = nvcc

 

# Kelper CUDA

CUDA_ARCH = -arch=sm_30

# Tesla CUDA

#CUDA_ARCH = -arch=sm_21

# newer CUDA

#CUDA_ARCH = -arch=sm_13

# older CUDA

#CUDA_ARCH = -arch=sm_10 -DCUDA_PRE_THREE

 

CUDA_PRECISION = -D_SINGLE_SINGLE

CUDA_INCLUDE = -I$(CUDA_HOME)/include

CUDA_LIB = -L$(CUDA_HOME)/lib64

CUDA_OPTS = -DUNIX -O3 -Xptxas -v --use_fast_math

 

CUDR_CPP = mpicxx -DMPI_GERYON -DUCL_NO_EXIT -DMPICH_IGNORE_CXX_SEEK

CUDR_OPTS = -O2 # -xHost -no-prec-div -ansi-alias

 

BIN_DIR = ./

OBJ_DIR = ./

LIB_DIR = ./

AR = ar

BSH = /bin/sh

 

CUDPP_OPT = -DUSE_CUDPP -Icudpp_mini

 

include Nvidia.makefile

 

$ make –f Makefile.linux

 

c)         编译USER-CUDA

$ cd lammps-10Oct12/lib/cuda

$ rm *.o

$ make CUDA_INSTALL_PATH=/opt/cuda/cuda5.0 cufft=2 precision=2 arch=30

 

d)        编译Lammps

$ cd lammps-10Oct12/src

$ make clean-all

$ make no-all

$ make yes-molecule

$ make yes-kspace

$ make yes-asphere                # Need this one for Gay-Berne test. These packages have to be included *LAST*:

$ make yes-gpu                        # Add the GPU capability.

$ make yes-user-cuda            # Add more GPU capability.

$ vi MAKE/Makefile.gpu

# openmpi = Redhat 5.x , mpic++, OpenMPI-1.4.5, FFTW2

 

SHELL = /bin/sh

 

# ---------------------------------------------------------------------

# compiler/linker settings

# specify flags and libraries needed for your compiler

 

CC =            mpic++

CCFLAGS =       -O2 \

                -funroll-loops -fstrict-aliasing -Wall -W -Wno-uninitialized

SHFLAGS =       -fPIC

DEPFLAGS =      -M

 

LINK =          mpic++

LINKFLAGS =     -O

LIB =           -lstdc++

SIZE =          size

 

ARCHIVE =       ar

ARFLAGS =       -rcsv

SHLIBFLAGS =    -shared

 

# ---------------------------------------------------------------------

# LAMMPS-specific settings

# specify settings for LAMMPS features you will use

# if you change any -D setting, do full re-compile after "make clean"

 

# LAMMPS ifdef settings, OPTIONAL

# see possible settings in doc/Section_start.html#2_2 (step 4)

 

LMP_INC =       -DLAMMPS_GZIP

 

# MPI library, REQUIRED

# see discussion in doc/Section_start.html#2_2 (step 5)

# can point to dummy MPI library in src/STUBS as in Makefile.serial

# INC = path for mpi.h, MPI compiler settings

# PATH = path for MPI library

# LIB = name of MPI library

 

MPI_INC = -I/opt/openmpi/include     

MPI_PATH =

MPI_LIB = -L/opt/openmpi/lib -lmpi

 

# FFT library, OPTIONAL

# see discussion in doc/Section_start.html#2_2 (step 6)

# can be left blank to use provided KISS FFT library

# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings

# PATH = path for FFT library

# LIB = name of FFT library

 

FFT_INC =       -DFFT_FFTW -I/opt/fftw/include

FFT_PATH =

FFT_LIB =       -L/opt/fftw/lib -lfftw

 

# JPEG library, OPTIONAL

# see discussion in doc/Section_start.html#2_2 (step 7)

# only needed if -DLAMMPS_JPEG listed with LMP_INC

# INC = path for jpeglib.h

# PATH = path for JPEG library

# LIB = name of JPEG library

 

JPG_INC =      

JPG_PATH =

JPG_LIB =

 

# ---------------------------------------------------------------------

# build rules and dependencies

# no need to edit this section

 

include Makefile.package.settings

include Makefile.package

 

EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC)

EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH)

EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB)

 

# Link target

 

$(EXE): $(OBJ)

        $(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)

        $(SIZE) $(EXE)

 

# Library targets

 

lib:    $(OBJ)

        $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)

 

shlib:  $(OBJ)

        $(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \

        $(OBJ) $(EXTRA_LIB) $(LIB)

 

# Compilation rules

 

%.o:%.cpp

        $(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $<</span>

 

%.d:%.cpp

        $(CC) $(CCFLAGS) $(EXTRA_INC) $(DEPFLAGS) $< > $@

 

# Individual dependencies

 

DEPENDS = $(OBJ:.o=.d)

sinclude $(DEPENDS)

 

# make gpu

编译结束后,在当前目录中会出现一个可执行文件 lmp_gpu; 即为LAMMPS的运行文件。

 

5.         LAMMPS 运行测试

进入lammps-10Oct12/bench/GPU;有三个测试实例。我们以lj为例。

a)         CPU的测试:

$ mpirun –np 8 ~/lammps-10Oct12/src/lmp_gpu –c off –v x 32 –v y 32 –v z32 –v t 1000 < in.lj.cpu

 

8 MPI进程数;

-c off 关闭CUDA

x, y, z 定义问题的大小;

t 为模拟步数

 

b)        GPU软件包的测试

$ mpirun –np 8 ~/lammps-10Oct12/lmp_gpu –sf gpu –c off –v x 32 –v y 32 –v z 32 –v t 1000 < in.lj.gpu

 

c)         CUDA软件包的测试

$ mpirun –np 8 ~/lammps-10Oct12/lmp_gpu –sf cuda–v x 32 –v y 32 –v z 32 –v t 1000 < in.lj.cuda

 

具体参考README文件。

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有